Skip to main content

Reader LUNA

Installazione

Per installare il pacchetto, da terminale nella cartella che contiene il file wheel:

pip install \readerluna-0.1.0-py3-none-any.whl

modificando opportunamente la versione nel nome del file.

Utilizzo

Per caricare un file testuale:

from readerLUNA import Luna
file = 'desrf/ytgy-2024-11-21T15;47;18.425138.txt'
misura = Luna(file=file)

Oppure un file h5 precedentemente esportato (vedere sotto):

misura = Luna(file='prova.h5')

E' possibile effettuare smooth lungo entrambe le direzioni:

misura.smooth(samples_time=10,samples_position=5)

Plot

Esistono metodi per plottare la heatmap oppure le linee con andamento nel tempo di alcuni punti indicati, in cm, o ancora andamento delle posizioni per alcuni momenti temporali indicati (come variabili datetime con timezone utc indicata).

misura.plot_heatmap().show()
misura.plot_heatmap(zmin=-10,zmax=500).show()
misura.plot_positions_vs_time(positions_cm=[5,20,27.8]).show()

from datetime import datetime, timezone, timedelta 
start_time = datetime( 2024,11,25,16,46,42,tzinfo=timezone.utc )
misura.plot_times_vs_position(times_utc=[start_time + timedelta( minutes=i*10 ) for i in range(5)]).show()

E' possibile utilizzare matplotlib invece che plotly.

misura.plot_heatmap(library='matplotlib')
misura.plot_positions_vs_time(positions_cm=[5,20,27.8],library='matplotlib')

Post-processing

Sostituzione NaN

Gli eventuali NaN nell'array 2d vengono sostituiti con valor medio dei due non NaN adiacienti, lungo l'asse dei tempi o delle posizioni, in base a parametro axis.

misura.clean_nan()
misura.clean_nan(axis='position')

Non molto veloce, andrebbe cercato qualche metodo meno iterativo.

Sostituzione outliers

Outliers vengono individuati e poi sostituiti con valore interpolato tra i vicini.

number_of_outliers = misura.clean_outliers()

Andrebbero provati hampel o altri metodi per trovare outliers; mentre la decisione di usare media di finestra rettangolare è una mia idea con zero fondamenti scientifici a supporto. Provato ed implementato interquantile range threshold (IQR) ma sembra funzionare peggio.

Concatenare nel tempo

Possibile concatenare due o più misure usando l'operatore +. La concatenazione avviene lungo la direzione temporale e deve avere stessa dimensione lungo l'asse spaziale. Nell'esempio sotto, avendo un solo file di dati, introduco un delta fittizio di un'ora.

misura2 = Luna(file=file)
misura2.time_utc = [time + timedelta(hours=1) for time in misura2.time_utc]

misura_sum = misura + misura2
misura_sum.plot_heatmap()

Per esempio, per leggere tutti i files in una cartella con una parte comune nel nome:

from glob import glob
from pandas.errors import EmptyDataError

folder = 'C:/Users/marbr/OneDrive/Cohaerentia/01 - Progetti/Autostrade - Valdera/Misure/Trave1_8m_Ciclo/Strain'
first = True
for file in glob(f"{folder}/Processed_1Hz_*.txt"):
    try:
        if first:
            misura = Luna(file=file)
            first = False
        else:
            misura = misura + Luna(file=file)
    except EmptyDataError:
        print(file)

Stare attenti che i nomi files siano ordinati per nome correttamente, ovvero in ordine temporale. Non c'è nessun controllo e riordinamento via codice.

Esportare in file h5

misura.export(filename='prova.h5`)

Metadata

Release files for readerLUNA 1.7.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for readerLUNA 1.7.5
File Size Uploaded Provenance Actions
readerluna-1.7.5.tar.gz 7.1 kB Without provenance Details for readerluna-1.7.5.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for readerLUNA 1.7.5
File Interpreter ABI Platform Actions
readerluna-1.7.5-py3-none-any.whl Python 3 none any Details for readerluna-1.7.5-py3-none-any.whl

Total release size: 15.2 kB

Release files / readerluna-1.7.5.tar.gz

Download URL readerluna-1.7.5.tar.gz
Size 7.1 kB
Tags Source
SHA-256 checksum
How to use checksums
6aaf3d0492ec66fc52d776e77a2a71582113ec07e875135931a7d5ae1ec62a2f
BLAKE2b-256 checksum
How to use checksums
6198f07037d57c3ad8ee64ec0a0fd52bd89951f5a8b61cb920738ca1ea7a176c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.1.2 CPython/3.12.9 Windows/11

Release files / readerluna-1.7.5-py3-none-any.whl

Download URL readerluna-1.7.5-py3-none-any.whl
Size 8.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fe55a385ced4484ff89e19d24af30ada8fd6f0f0588fe4912de12711cbbf421b
BLAKE2b-256 checksum
How to use checksums
043e78f47ef670362835392719da0e9df1da10b39399d81b6e0b71609808fd36
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.1.2 CPython/3.12.9 Windows/11

Security for readerLUNA 1.7.5

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page