diff --git a/geomagio/edge/FDSNFactory.py b/geomagio/edge/FDSNFactory.py index 618395c46246defd50d2cdd301fab8c98a308922..6985f4133ce7fa146d2bb94780b716d3c30c4fd9 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