Skip to content
Snippets Groups Projects
Commit f97d0eda authored by Wilbur, Spencer Franklin's avatar Wilbur, Spencer Franklin
Browse files

Merge branch 'Except_204_Error_FDSN' into 'master'

204 Error Exception Handling

See merge request !339
parents 84a6f967 30cc1734
No related branches found
No related tags found
1 merge request!339204 Error Exception Handling
Pipeline #489717 passed
......@@ -256,14 +256,12 @@ class FDSNFactory(TimeseriesFactory):
endtime=endtime + half_delta,
attach_response=True,
)
except FDSNNoDataException:
data = Stream()
data.merge()
if channel in channel_rotations:
data = self._rotate_and_return_requested_channel(
data, sncl, starttime, endtime, channel
)
if data.count() == 0 and add_empty_channels:
data += self._get_empty_trace(
starttime=starttime,
......@@ -275,39 +273,49 @@ class FDSNFactory(TimeseriesFactory):
network=sncl.network,
location=sncl.location,
)
# Skip further processing if the data is still empty
if data.count() == 0:
return data
if data.count() != 0:
TimeseriesUtility.pad_and_trim_trace(
trace=data[0], starttime=starttime, endtime=endtime
)
if channel in channel_rotations:
data = self._rotate_and_return_requested_channel(
data, sncl, starttime, endtime, channel
)
for trace in data:
response = trace.stats.response
if self.remove_sensitivity is not None:
if self.remove_sensitivity_flag == "remove_sensitivity":
trace.remove_sensitivity()
elif self.remove_sensitivity_flag == "remove_response":
trace.remove_response()
else:
raise ValueError(
f"Warning: Unrecognized remove_sensitivity value '{self.remove_sensitivity}'. No sensitivity or response removal applied."
)
else:
if response.instrument_sensitivity:
if response.instrument_sensitivity.input_units == "T":
# some ASL stations produce data in Teslas, not nanoteslas
response.instrument_sensitivity.value /= 1e9
response.instrument_sensitivity.input_units = "nT"
# apply total gain/sensitivity, ignore any frequency response
trace.remove_sensitivity()
if hasattr(trace.stats, "response") and trace.stats.response is not None:
response = trace.stats.response
if self.remove_sensitivity is not None:
if self.remove_sensitivity_flag == "remove_sensitivity":
trace.remove_sensitivity()
elif self.remove_sensitivity_flag == "remove_response":
trace.remove_response()
else:
raise ValueError(
f"Warning: Unrecognized remove_sensitivity value '{self.remove_sensitivity}'. No sensitivity or response removal applied."
)
else:
# according to fdsn docs, if no instrument_sensitivity,
# the response must be an instrument_polynomial
# https://docs.fdsn.org/projects/stationxml/en/latest/reference.html#instrumentsensitivity
# Geomag Program observatories use 2nd order instrument_polynomial
# to capture both offset and scale, but no frequency response
data.remove_response()
if response.instrument_sensitivity:
if response.instrument_sensitivity.input_units == "T":
# some ASL stations produce data in Teslas, not nanoteslas
response.instrument_sensitivity.value /= 1e9
response.instrument_sensitivity.input_units = "nT"
# apply total gain/sensitivity, ignore any frequency response
trace.remove_sensitivity()
else:
# according to fdsn docs, if no instrument_sensitivity,
# the response must be an instrument_polynomial
# https://docs.fdsn.org/projects/stationxml/en/latest/reference.html#instrumentsensitivity
# Geomag Program observatories use 2nd order instrument_polynomial
# to capture both offset and scale, but no frequency response
data.remove_response()
else:
self._set_metadata(data, observatory, channel, type, interval)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment