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

Added logic to determine when to use the remove_sensitivity or...

 Added logic to determine when to use the remove_sensitivity or remove_response function on trace objects. I alsoadded a remove_sensitivity flag to the __init__ function so that a user can override the default value of None fo instances where they want to use a specifc function and ignore the default logic.
parent db3a8499
No related branches found
No related tags found
1 merge request!337Remove Instrument Sensitivity/Response
......@@ -61,6 +61,9 @@ class FDSNFactory(TimeseriesFactory):
in get_timeseries/put_timeseries
cwbhost: str
a string represeting the IP number of the cwb host to connect to.
remove_sensitivity: str
either remove_sensitivity or remove_response to explicitly use the obspy function
represented by the string
See Also
--------
......@@ -87,10 +90,13 @@ class FDSNFactory(TimeseriesFactory):
variometerMetadata: Optional[VariometerMetadata] = None,
locationCode: Optional[str] = None,
snclMapper: str = "geomag",
remove_sensitivity: Optional[
str
] = None, # Accepts "remove_sensitivity" or "remove_response"
):
TimeseriesFactory.__init__(self, observatory, channels, type, interval)
self.Client = FDSNClient(base_url)
self.remove_sensitivity = remove_sensitivity
self.tag = tag
self.forceout = forceout
self.interval = interval
......@@ -274,7 +280,27 @@ class FDSNFactory(TimeseriesFactory):
trace=data[0], starttime=starttime, endtime=endtime
)
self._set_metadata(data, observatory, channel, type, interval)
if self.remove_sensitivity is not None:
if self.remove_sensitivity_flag == "remove_sensitivity":
data[0].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()
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
else:
self._set_metadata(data, observatory, channel, type, interval)
return data
......
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