Skip to content
Snippets Groups Projects
Commit fb354997 authored by Erin (Josh) Rigler's avatar Erin (Josh) Rigler
Browse files

Properly map `data_type`/`location` codes in *SNCL.py:

There is an ambiguity that exists between `data_type` and `location` in *SNCL.py. Ideally, we'd clean this up, but that involves many changes, and well beyond just the *SNCL.py files. These changes at least fix issues with geomagio scripts that popped up during testing.
parent cbaaea6b
No related branches found
No related tags found
1 merge request!400Minor miscellaneous fixes
...@@ -44,7 +44,9 @@ class LegacySNCL(SNCL): ...@@ -44,7 +44,9 @@ class LegacySNCL(SNCL):
return LegacySNCL( return LegacySNCL(
station=station, station=station,
network=network, network=network,
channel=get_channel(element=element, interval=interval), channel=get_channel(
element=element, interval=interval, data_type=location or data_type
),
location=location or get_location(element=element, data_type=data_type), location=location or get_location(element=element, data_type=data_type),
) )
...@@ -68,9 +70,10 @@ class LegacySNCL(SNCL): ...@@ -68,9 +70,10 @@ class LegacySNCL(SNCL):
raise ValueError(f"Unexcepted interval code: {channel_start}") raise ValueError(f"Unexcepted interval code: {channel_start}")
def get_channel(element: str, interval: str) -> str: def get_channel(element: str, interval: str, data_type: str) -> str:
return _check_predefined_channel(element=element, interval=interval) or ( return _check_predefined_channel(element=element, interval=interval) or (
_get_channel_start(interval=interval) + _get_channel_end(element=element) _get_channel_start(interval=interval)
+ _get_channel_end(element=element, data_type=data_type)
) )
...@@ -133,7 +136,7 @@ def _check_predefined_channel(element: str, interval: str) -> Optional[str]: ...@@ -133,7 +136,7 @@ def _check_predefined_channel(element: str, interval: str) -> Optional[str]:
return None return None
def _get_channel_end(element: str) -> str: def _get_channel_end(element: str, data_type: str) -> str:
channel_middle = "V" channel_middle = "V"
if "_Volt" in element: if "_Volt" in element:
channel_middle = "E" channel_middle = "E"
...@@ -144,6 +147,16 @@ def _get_channel_end(element: str) -> str: ...@@ -144,6 +147,16 @@ def _get_channel_end(element: str) -> str:
elif element in ["F", "G"]: elif element in ["F", "G"]:
channel_middle = "S" channel_middle = "S"
channel_end = element.split("_")[0] channel_end = element.split("_")[0]
if data_type == "variation" or data_type[0] == "R":
# this may not actually be necessary since UVW were
# never used as legacy channels; it is included here
# solely for consistency with SNCL.py, but should be safe
if channel_end == "U":
channel_end = "H"
elif channel_end == "V":
channel_end = "Y"
elif channel_end == "W":
channel_end = "Z"
return channel_middle + channel_end return channel_middle + channel_end
......
...@@ -46,7 +46,7 @@ class SNCL(BaseModel): ...@@ -46,7 +46,7 @@ class SNCL(BaseModel):
station=station, station=station,
network=network, network=network,
channel=get_channel( channel=get_channel(
element=element, interval=interval, data_type=data_type element=element, interval=interval, data_type=location or data_type
), ),
location=location or get_location(element=element, data_type=data_type), location=location or get_location(element=element, data_type=data_type),
) )
...@@ -178,7 +178,7 @@ def _get_channel_end(element: str, data_type: str) -> str: ...@@ -178,7 +178,7 @@ def _get_channel_end(element: str, data_type: str) -> str:
elif "_Temp" in element: elif "_Temp" in element:
channel_middle = "K" channel_middle = "K"
channel_end = element.split("_")[0] channel_end = element.split("_")[0]
if data_type == "variation": if data_type == "variation" or data_type[0] == "R":
if channel_end == "H": if channel_end == "H":
channel_end = "U" channel_end = "U"
elif channel_end == "E": elif channel_end == "E":
......
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