From 9eb3e7c4fd1028080b3aeee1fbd618ef82b5eb68 Mon Sep 17 00:00:00 2001 From: spencer <swilbur@usgs.gov> Date: Wed, 11 Sep 2024 08:49:03 -0600 Subject: [PATCH] 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. --- geomagio/edge/FDSNFactory.py | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/geomagio/edge/FDSNFactory.py b/geomagio/edge/FDSNFactory.py index 618395c4..6985f413 100644 --- a/geomagio/edge/FDSNFactory.py +++ b/geomagio/edge/FDSNFactory.py @@ -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 -- GitLab