Skip to main content

Reader dati processati da interrogatore LUNA

Project description

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`)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

readerluna-1.6.3.tar.gz (6.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

readerluna-1.6.3-py3-none-any.whl (7.8 kB view details)

Uploaded Python 3

File details

Details for the file readerluna-1.6.3.tar.gz.

File metadata

  • Download URL: readerluna-1.6.3.tar.gz
  • Upload date:
  • Size: 6.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.2 CPython/3.12.9 Windows/11

File hashes

Hashes for readerluna-1.6.3.tar.gz
Algorithm Hash digest
SHA256 bb13946671b792e8b883e3f74d6140e6e52d74821c36209ff552f456c257d6af
MD5 092e5cc37168f71a7c2f8cf95bd433ce
BLAKE2b-256 3e0311ccfad3cfd63960b8735e54ca7d4692c5acc991f36b301f4e64eb36eebc

See more details on using hashes here.

File details

Details for the file readerluna-1.6.3-py3-none-any.whl.

File metadata

  • Download URL: readerluna-1.6.3-py3-none-any.whl
  • Upload date:
  • Size: 7.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.2 CPython/3.12.9 Windows/11

File hashes

Hashes for readerluna-1.6.3-py3-none-any.whl
Algorithm Hash digest
SHA256 c0fb5f4b63cab0fd07de0183d4c867487e2e0847ddded2a3aba7f30b04b9e6f6
MD5 a2a0ebeaae528b196bd7fbaaa1cccefc
BLAKE2b-256 e951adbcf0db6c043451800dbba8c28eeb09e526a79e81582053f83c0e36aa91

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page