Skip to main content

Package to load files saved by Cohaerentia DAS Interrogator.

Project description

ReaderDAS

Installazione

Installare attraverso PyPi:

pip install readerDAS
pip install readerDAS --upgrade

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 = 'file_di_prova.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 = '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.1.0.tar.gz (13.6 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.1.0-py3-none-any.whl (16.3 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for readerdas-1.1.0.tar.gz
Algorithm Hash digest
SHA256 f60811b2f97d48df3571f11584dcb00ce33935289ccde1eae2342b22055e6449
MD5 43ddc1f9c9515f4fcc0680d8b628c03c
BLAKE2b-256 e070e360617a14bbc285f42233003d26b2d0528595995553d89a64f319e323d7

See more details on using hashes here.

File details

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

File metadata

  • Download URL: readerdas-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 16.3 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 readerdas-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0283427ee1e9c6e084b40c0711de51a3eec025f2c2ac5975e4eb27bf4ff5f250
MD5 6ace6836ebc010c5e91231ce7bc9dcc5
BLAKE2b-256 8704038e3e88ef2e408b4df1e115f947a5ff28af87244c9baac1bf1d25c00acf

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