Skip to main content

Package to load files saved by Cohaerentia DAS Interrogator.

Project description

ReaderDAS

Installazione

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

pip install \readerDAS-0.2.8-py3-none-any.whl

modificando opportunamente la versione nel nome del file.

Caricamento dati

Caricamento in memoria dei dati. Le funzioni sotto restituiscono entrambe un oggetto di tipo Data.

Importare:

from readerDAS import h5info, from_file, DataFolder

Singolo file

Per leggere dati da un singolo file.

filename = '2024-10-07T09-18-28.331Z_traffico_5m_GL5m.h5'
h5info(filename)
data_single = from_file(filename=filename, section='full', start_s=0, count_s=20)

andando quindi ad indicare il nome della sezione (usare la funzione h5info per vedere che sezioni sono disponibili) e la sezione temporale che si vuole importare; di default la sezione caricata è full, ovvero nel caso in cui non si siano impostate sezioni nel programma di acquisizione. Di default parte da inizio file se start_s non è fornito; arriva fino a fine file se count_s non è fornito.e

Multipli files in una cartella

Per caricare dati da più files, specificando un intervallo temporale e un intervallo di posizioni contenute in una sezione.

ATTENZIONE: l'assunzione è che tutti i files contenuti nella cartella siano stati salvati con continuità e con stessi parametri.

Prima si inizializza la cartella, andando a caricare le informazioni e i parametri dell'acquisizione.

folder = 'C:/Users/marbr/Downloads/DAS_Misure'
folder_obj = DataFolder(folder=folder)
print(folder_obj)

Successivamente è possibile utilizzare l'oggetto folder_obj per caricare i dati desiderati:

start_time = datetime(2024,10,7,9,10,0,tzinfo=timezone.utc)
stop_time = datetime(2024,10,7,9,35,0,tzinfo=timezone.utc)
loaded_data,info_slice = folder_obj.get_data(type='phase',section='full',start_position_m=20, stop_position_m=370, start_time=start_time, stop_time=stop_time)
print(loaded_data)

Si può selezionare il tipo di dato da caricare, con parametro type: phase (default) o magnitude.

Se si vuole lavorare in secondi, invece che datetime, al momento si deve fare:

from datetime import datetime, timedelta

# rispetto ad inizio file:
start_time = datetime.fromtimestamp(a.first_measure_ms/1000, timezone.utc) + timedelta(seconds=10)
stop_time = start_time + timedelta(seconds=200)

Elaborazione

L'oggetto Data espone alcuni metodi per elaborare dato, che andranno eventualmente espansi.

Energia

Calcolata su finestre temporali window_s e come somma del modulo quadro, posizione per posizione lungo la fibra.

energy_window_s = 0.512
energy, axis_time_energy = loaded_data.energy(window_s=energy_window_s)

Come esempio, seguente codice per plot waterfall dell'energia utilizzando la libreria plotly:

import plotly.graph_objects as go

colormap = 'Viridis'
fig_energy = go.Figure(layout=dict(title=f"Energy of '{loaded_data.type}', window: {energy_window_s}s",xaxis_title='Position (m)',
                                   height=800,))
fig_energy.add_trace(go.Heatmap(x=loaded_data.axis_position_m,y=axis_time_energy,z=energy,
                         #zsmooth='best',
                         colorscale=colormap, showscale=False,
                         zmax=50,zmin=0,zauto=False))
fig_energy.show()

Singolo punto spaziale

Un helper method per estrarre l'andamento temporale di un solo punto lungo la fibra, espresso in metri. Sotto per esempio il metro 92, con esempio di plot in plotly.

from plotly.subplots import make_subplots

position_data, actual_position, position_index = loaded_data.filter_by_position(position_m=92)

yaxis_label = "Phase (rad)" if loaded_data.type == "phase" else "Magnitude (a.u.)"
fig = make_subplots(specs=[[{"secondary_y": True}]])
fig.add_trace(go.Scatter(x=loaded_data.axis_time_utc,y=position_data, name=yaxis_label))
fig.add_trace(go.Scatter(x=axis_time_energy, y=energy[:,position_index],name='energy'),secondary_y=True)
fig.update_yaxes(title_text=yaxis_label, secondary_y=False)
fig.update_yaxes(title='Energy (a.u.)', secondary_y=True)
fig.update_xaxes(title='UTC Time')
fig.update_layout(title=f"Position: {actual_position:.02f}m",showlegend=False)
fig.show()

Sottocampionamento temporale

E' possibile importare i dati contenuti nei files di una cartella, decimarli temporalmente e risalvari in un singolo file h5. Per farlo utilizzare la funzione sottocampionamento.decimate_folder

from readerDAS.sottocampionamento import decimate_folder

folder = "Traffico_Weekend"
last_position_index: int = 460  # 450
target_frequency_Hz = 10  # Hz
output_file = "prova.h5"

decimate_folder(
    folder=folder,
    output_file=output_file,
    target_frequency_Hz=target_frequency_Hz,
    last_position_index=last_position_index,
    section_index=0,
)

TODO

  • sottocampionamento spaziale, senza proprio caricare quei punti in memoria. Dubbia utilità dal punto di vista della velocità perché tanto il chunk viene caricato tutto in memoria e poi indicizzato...ma sicuramente la memoria complessiva viene ridotta.

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

readerdas-1.0.2.tar.gz (12.3 kB view details)

Uploaded Source

Built Distribution

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

readerdas-1.0.2-py3-none-any.whl (14.0 kB view details)

Uploaded Python 3

File details

Details for the file readerdas-1.0.2.tar.gz.

File metadata

  • Download URL: readerdas-1.0.2.tar.gz
  • Upload date:
  • Size: 12.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.1 CPython/3.12.1 Windows/11

File hashes

Hashes for readerdas-1.0.2.tar.gz
Algorithm Hash digest
SHA256 731fcde93f88b6f99574414e81080a0f340ad48597e4f7cb938a3a824c01ecda
MD5 5b04edb24ef2962136673986657cb6ff
BLAKE2b-256 3a998eb9bf412cbbfb6be5688f85616b3fbc137318c95b649503d727e4b91bae

See more details on using hashes here.

File details

Details for the file readerdas-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: readerdas-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 14.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.1 CPython/3.12.1 Windows/11

File hashes

Hashes for readerdas-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 ecc755cb295f6c3a777d36e39ba7955618cc0c6c5ef04e10d0aa9642e44c12ff
MD5 00839fa901a62e6ab74b208f97756637
BLAKE2b-256 0af102096f6368bc2cbcdda23c4a56d416e5cd52e7d0d83c3c1318578cf59632

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