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.4.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.4-py3-none-any.whl (8.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: readerluna-1.7.4.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.4.tar.gz
Algorithm Hash digest
SHA256 5da764061ed1a19326d654bfc3a8b369b83447f21e1a93edd443e803f3946003
MD5 ca7e2d6e33edde22286541319c4722f2
BLAKE2b-256 9887a5058631888926c0dbcd1ca408cf98cc1d5731d5d63b9cfb644f71a1295c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: readerluna-1.7.4-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.4-py3-none-any.whl
Algorithm Hash digest
SHA256 f8e03c39449d2bc60665b16c1479f817a333dba06af48b03a32679f0687346a1
MD5 1c03a1d0b0952daf17454d91fba32c86
BLAKE2b-256 8f6e0d35bddfa98f2637b5e86cf55f46484fb2be361acc2b5cca8bf3397cb6a6

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