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

Addressed Josh's Comments

parent d76d6285
No related branches found
No related tags found
1 merge request!390Added NEIC client parameters to FDSNFactory.py
......@@ -69,15 +69,14 @@ class FDSNFactory(TimeseriesFactory):
Notes
-----
This is designed to read from the FDSN Client and EDGE if data is less than 1 day old, but it
currently only writes to an edge.
This is designed to read from the FDSN Client and EDGE if data is less than 1 day old
"""
def __init__(
self,
base_url: str = "http://service.iris.edu",
host: Optional[str] = None,
port: Optional[int] = None,
fdsn_url: str = "http://service.iris.edu",
host: Optional[str] = "edgecwb.usgs.gov",
port: Optional[int] = 2061,
tag: str = "GeomagAlg",
observatory: Optional[str] = None,
network: str = "NT",
......@@ -92,7 +91,7 @@ class FDSNFactory(TimeseriesFactory):
] = None, # Accepts "remove_sensitivity" or "remove_response"
):
TimeseriesFactory.__init__(self, observatory, channels, type, interval)
self.Client = FDSNClient(base_url)
self.Client = FDSNClient(fdsn_url)
self.port = port # Need to add this paramter for later logic
self.host = host
self.remove_sensitivity = remove_sensitivity
......@@ -254,11 +253,11 @@ class FDSNFactory(TimeseriesFactory):
)
# Determine whether to use FDSN Client or request data from EDGE
if endtime >= (UTCDateTime.now() - 86400):
print("The endtime is less than a day later!", endtime)
oldest_neic_utc = UTCDateTime.now() - (
86_400 * 60
) # `date` ensures a midnight boundary
if starttime >= oldest_neic_utc:
self.host = "137.227.252.145"
self.port = 2061
# use NEIC Client instead
neic_client = neic.Client(self.host, self.port)
......@@ -275,8 +274,6 @@ class FDSNFactory(TimeseriesFactory):
endtime=endtime + half_delta,
)
data.attach_response(inv)
else:
data = self.Client.get_waveforms(
......@@ -286,9 +283,11 @@ class FDSNFactory(TimeseriesFactory):
channel=sncl.channel,
starttime=starttime,
endtime=endtime + half_delta,
attach_response=True,
)
# Attach the channel response. This must be done before the _calibarate_sensitivity_and_response function is called
data.attach_response(inv)
# Perfrom calibrations to properly remove response/sensitivity
data = self._calibrate_sensitivty_and_response(data)
......@@ -415,23 +414,6 @@ class FDSNFactory(TimeseriesFactory):
Channels are mapped as follows: 'X' -> '*F2', 'Y' -> '*F1', 'Z' -> '*FZ'.
"""
# Initialize FDSN client and get the necessary data
# FDSN = self.Client
# Determine if the requested channel is X, Y, or
# inv = FDSN.get_stations(
# network=sncl.network,
# station=sncl.station,
# location=sncl.location, # Use location if necessary
# channel=sncl.channel, # Request *F1, *F2, and *FZ
# starttime=starttime,
# endtime=endtime,
# level="response",
# )
print(
"The SNCL Channel being requested for teh inventory object in rotations: ",
sncl.channel,
)
# Rotate the stream to ZNE
data.rotate(method="->ZNE", inventory=inv)
......@@ -486,6 +468,4 @@ class FDSNFactory(TimeseriesFactory):
# Geomag Program observatories use 2nd order instrument_polynomial
# to capture both offset and scale, but no frequency response
data.remove_response()
else:
print("NO RESPONSE ATTIBUTE WAS DEALT WITH")
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