Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 15 additions & 8 deletions gwsumm/archive.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,8 @@ def read_data_archive(sourcefile, rm_source_on_fail=True):
# down the whole workflow, requiring manual intervention. Here, we attempt
# to automatically catch a common failure
try:
h5file = File(sourcefile, 'r')
with File(sourcefile, 'r'):
pass
except FileNotFoundError:
raise
except OSError as exc: # file is corrupt, so we remove it to start fresh
Expand Down Expand Up @@ -250,7 +251,8 @@ def read_data_archive(sourcefile, rm_source_on_fail=True):

# -- timeseries -------------------------

for dataset in h5file.get('timeseries', {}).values():
for name in h5file.get('timeseries', {}):
dataset = h5file['timeseries'][name]
ts = TimeSeries.read(dataset, format='hdf5')
if (re.search(r'\.(rms|min|mean|max|n)\Z', ts.channel.name) and
ts.sample_rate.value == 1.0):
Expand All @@ -271,32 +273,37 @@ def read_data_archive(sourcefile, rm_source_on_fail=True):

# -- statevector -- ---------------------

for dataset in h5file.get('statevector', {}).values():
for name in h5file.get('statevector', {}):
dataset = h5file['statevector'][name]
sv = StateVector.read(dataset, format='hdf5')
sv.channel = get_channel(sv.channel)
add_timeseries(sv, key=sv.channel.ndsname)

# -- spectrogram ------------------------

for tag, add_ in zip(
['spectrogram', 'coherence-components'],
[add_spectrogram, add_coherence_component_spectrogram]):
for key, dataset in h5file.get(tag, {}).items():
['spectrogram', 'coherence-components'],
[add_spectrogram, add_coherence_component_spectrogram],
):
for key in h5file.get(tag, {}):
dataset = h5file[tag][key]
key = key.rsplit(',', 1)[0]
spec = Spectrogram.read(dataset, format='hdf5')
spec.channel = get_channel(spec.channel)
add_(spec, key=key)

# -- segments ---------------------------

for name, dataset in h5file.get('segments', {}).items():
for name in h5file.get('segments', {}):
dataset = h5file['segments'][name]
dqflag = DataQualityFlag.read(h5file, path=dataset.name,
format='hdf5')
globalv.SEGMENTS += {name: dqflag}

# -- triggers ---------------------------

for dataset in h5file.get('triggers', {}).values():
for name in h5file.get('triggers', {}):
dataset = h5file['triggers'][name]
load_table(dataset)


Expand Down
11 changes: 8 additions & 3 deletions gwsumm/data/timeseries.py
Original file line number Diff line number Diff line change
Expand Up @@ -393,10 +393,12 @@ def all_adc(cache):
"""
for path in cache:
try:
tag = os.path.basename(path).split('-')[1]
path = os.path.basename(path)
except (AttributeError, TypeError): # CacheEntry
tag = path.description
path = path.path
else:
tag = path.split('-')[1]
if not path.endswith('.gwf') or tag not in ADC_TYPES:
return False
return True
Expand Down Expand Up @@ -711,8 +713,11 @@ def _get_timeseries_dict(channels, segments, config=None,
data.override_unit(channel.unit)

# update channel type for trends
if data.channel.type is None and (
data.channel.trend is not None):
if (
data.channel is not None
and data.channel.type is None
and data.channel.trend is not None
):
if data.dt.to('s').value == 1:
data.channel.type = 's-trend'
elif data.dt.to('s').value == 60:
Expand Down
2 changes: 1 addition & 1 deletion gwsumm/tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ def new(cls):
TEST_CONFIG.seek(0)
return cp

@pytest.fixture
@classmethod
@pytest.fixture()
def cnfg(cls):
return cls.new()

Expand Down
2 changes: 1 addition & 1 deletion gwsumm/tests/test_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ def create(cls, *args, **kwargs):
return cls.PLOT(*args, **kwargs)
return cls.PLOT(*cls.DEFAULT_ARGS, **cls.DEFAULT_KWARGS)

@pytest.fixture
@classmethod
@pytest.fixture()
def plot(cls):
return cls.create()

Expand Down
Loading