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.7.5.tar.gz (7.1 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.7.5-py3-none-any.whl (8.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: readerluna-1.7.5.tar.gz
  • Upload date:
  • Size: 7.1 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.7.5.tar.gz
Algorithm Hash digest
SHA256 6aaf3d0492ec66fc52d776e77a2a71582113ec07e875135931a7d5ae1ec62a2f
MD5 8dd01cd1e04a239a1b616ece98e11f6a
BLAKE2b-256 6198f07037d57c3ad8ee64ec0a0fd52bd89951f5a8b61cb920738ca1ea7a176c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: readerluna-1.7.5-py3-none-any.whl
  • Upload date:
  • Size: 8.1 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.7.5-py3-none-any.whl
Algorithm Hash digest
SHA256 fe55a385ced4484ff89e19d24af30ada8fd6f0f0588fe4912de12711cbbf421b
MD5 69669633e2e37c3c457eafbea52c715e
BLAKE2b-256 043e78f47ef670362835392719da0e9df1da10b39399d81b6e0b71609808fd36

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