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

Added previous changes Josh made regarding the removal of the instruments...

Added previous changes Josh made regarding the removal of the instruments response/sensitivity. I also added some default innit function incase the user wants to override this logic as requested in the original issue.
parent 27fda05a
No related branches found
No related tags found
1 merge request!337Remove Instrument Sensitivity/Response
......@@ -280,24 +280,31 @@ class FDSNFactory(TimeseriesFactory):
trace=data[0], starttime=starttime, endtime=endtime
)
if self.remove_sensitivity is not None:
if self.remove_sensitivity_flag == "remove_sensitivity":
data[0].remove_sensitivity()
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":
data[0].remove_response(output="DEF", zero_mean=False, taper=False)
else:
# If the instrument_sensitivity exists, remove the sensitivity
if hasattr(data[0].stats.response, "instrument_sensitivity"):
data[0].remove_sensitivity()
elif self.remove_sensitivity_flag == "remove_response":
trace.remove_response()
else:
data[0].remove_response(output="DEF", zero_mean=False, taper=False)
if data[0].stats.response.instrument_sensitivity.input_units == "T":
# convert to nT (nanoteslas) if units are "T" (Teslas)
data[0].data *= 1e9
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