DASDAE / dascore

A python library for distributed fiber optic sensing
Other
66 stars 15 forks source link

Can't get gauge length from attributes - PRODML v. 2.0 format #194

Closed ahmadtourei closed 11 months ago

ahmadtourei commented 1 year ago

Description

I can see "GaugeLength" in the attributes list using HDFView software. However, I can't get the value using: patch_0.attrs['gauge_length'] Please note that I can get some other attributes such as sampling interval or channel spacing.

Data format: ONYX - PRODML v. 2.0

Example

import dascore as dc
sp = dc.spool(data_path)
patch_0 = sp[0]
gauge_length = patch_0.attrs['gauge_length']

Error:

AttributeError                            Traceback (most recent call last)
Cell In[3], line 12
      8 print(patch_0.attrs)
     11 # get sampling rate, channel spacing, and gauge length
---> 12 gauge_length = patch_0.attrs['gauge_length']
     13 print("Gauge length = ", gauge_length)
     14 channel_spacing = patch_0.attrs['d_distance']

File [~/anaconda3/envs/py10/lib/python3.10/site-packages/dascore/core/schema.py:94](https://vscode-remote+wsl-002bubuntu.vscode-resource.vscode-cdn.net/home/ahmadtourei/coding/fervo/iDAS_stimulation_stage8/LF_DAS/~/anaconda3/envs/py10/lib/python3.10/site-packages/dascore/core/schema.py:94), in PatchAttrs.__getitem__(self, item)
     93 def __getitem__(self, item):
---> 94     return getattr(self, item)

AttributeError: 'PatchAttrs' object has no attribute 'gauge_length'

Expected behavior

Versions

d-chambers commented 1 year ago

Looks like we just need to add gauge length to the prodml attributes here. I am refactoring some of the IO stuff so I will add that in the io_refactor branch. We might consider making gauge_length a default patch attribute?

ahmadtourei commented 1 year ago

Thanks for your comment! Where do we define default patch attributes?

d-chambers commented 1 year ago

Where do we define default patch attributes?

Its in dascore/core/schema