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

Added necessary check within FDSNSNCL.py to assign the sncl.channel as...

Added necessary check within FDSNSNCL.py to assign the sncl.channel as LF1,LF2,LFZ when X,Y,Z are requested by the user.
parent 8d7291a1
No related branches found
No related tags found
1 merge request!335FDSN 3D Rotation
...@@ -228,7 +228,7 @@ class FDSNFactory(TimeseriesFactory): ...@@ -228,7 +228,7 @@ class FDSNFactory(TimeseriesFactory):
network=self.network, network=self.network,
location=self.locationCode, location=self.locationCode,
) )
print("the channel reported to SCNL is ", channel)
# geomag-algorithms *should* treat starttime/endtime as inclusive everywhere; # geomag-algorithms *should* treat starttime/endtime as inclusive everywhere;
# according to its author, EdgeCWB is inclusive of starttime, but exclusive of # according to its author, EdgeCWB is inclusive of starttime, but exclusive of
# endtime, to satisfy seismic standards/requirements, to precision delta/2; # endtime, to satisfy seismic standards/requirements, to precision delta/2;
...@@ -376,15 +376,26 @@ class FDSNFactory(TimeseriesFactory): ...@@ -376,15 +376,26 @@ class FDSNFactory(TimeseriesFactory):
) )
# Rotate the stream to ZNE # Rotate the stream to ZNE
print(f"Before rotation: {[tr.stats.channel for tr in data]}")
data.rotate(method="->ZNE", inventory=inv) data.rotate(method="->ZNE", inventory=inv)
print(data) print(f"After rotation: {[tr.stats.channel for tr in data]}")
# After rotation, extract the correct channel based on requested_channel
if requested_channel == "X":
selected_channel = "*FN"
elif requested_channel == "Y":
selected_channel = "*FE"
elif requested_channel == "Z":
selected_channel = "*FZ"
else:
raise ValueError(f"Invalid channel {requested_channel}")
# # Now return only the requested channel (mapped to Z, N, or E) # Filter the rotated stream to return only the trace for the selected channel
# if requested_channel == "X": filtered_stream = data.select(channel=selected_channel)
# return data.select(channel="?FN") # N after rotation
# elif requested_channel == "Y":
# return data.select(channel="?FE") # E after rotation
# elif requested_channel == "Z":
# return data.select(channel="?FZ") # Z remains Z
return data # If no data found for the selected channel, return an empty stream
if len(filtered_stream) == 0:
print(f"No data found for channel: {requested_channel}")
return Stream()
return filtered_stream
...@@ -66,19 +66,27 @@ def get_FDSN_channel( ...@@ -66,19 +66,27 @@ def get_FDSN_channel(
network: Optional[str] = None, network: Optional[str] = None,
location: Optional[str] = None, location: Optional[str] = None,
) -> str: ) -> str:
channel_start = _get_channel_start(interval=interval, data_type=data_type)
# Check if element is X, Y, or Z and return the concatenated string with the start prepended
if element in ["X", "Y", "Z"]:
# Return *F1,*F2,*FZ with the start applied to each
return ",".join([f"{channel_start}{suffix}" for suffix in ["F1", "F2", "FZ"]])
# Handle the case when location is "40" and network is "IU"
if location == "40" and network == "IU": if location == "40" and network == "IU":
return _get_channel_start( return channel_start + _get_channel_end(element=element)
interval=interval, data_type=data_type
) + _get_channel_end(element=element) # Default case
return get_channel(element=element, interval=interval, data_type=data_type) return get_channel(element=element, interval=interval, data_type=data_type)
def _get_channel_end(element: str) -> str: def _get_channel_end(element: str) -> str:
if element in ["H", "U", "X"]: if element in ["H", "U"]:
return "F2" return "F2"
elif element in ["E", "V", "Y"]: elif element in ["E", "V"]:
return "F1" return "F1"
elif element in ["Z", "W"]: elif element in ["W"]:
return "FZ" return "FZ"
elif element[0:2] == "LF": # predefined element elif element[0:2] == "LF": # predefined element
return element[1:] return element[1:]
......
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