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

Updated the IRISFactory to support the new VariometerMetadata class. Also...

Updated the IRISFactory to support the new VariometerMetadata class. Also removed unnecessary lines of code in VariometerMetadata.py and ObservatoryMetadata.py.
parent fb435bfd
No related branches found
No related tags found
1 merge request!259Updated the ObservatoryMetadata and Observatory.py files to point to the...
...@@ -282,6 +282,24 @@ DEFAULT_METADATA = { ...@@ -282,6 +282,24 @@ DEFAULT_METADATA = {
}, },
"interval_specific": DEFAULT_INTERVAL_SPECIFIC, "interval_specific": DEFAULT_INTERVAL_SPECIFIC,
}, },
"GUT": {
"metadata": {
"station_name": "Guatamala Test",
"agency_name": "United States Geological Survey (USGS)",
"geodetic_latitude": "13.588",
"geodetic_longitude": "144.867",
"elevation": "140",
"sensor_orientation": "HDZF",
"sensor_sampling_rate": 100.0,
"declination_base": 764,
"is_gin": False,
"is_intermagnet": False,
"conditions_of_use": "The Conditions of Use for data provided"
+ " through INTERMAGNET and acknowledgement templates"
+ " can be found at www.intermagnet.org",
},
"interval_specific": DEFAULT_INTERVAL_SPECIFIC,
},
"HON": { "HON": {
"metadata": { "metadata": {
"station_name": "Honolulu", "station_name": "Honolulu",
...@@ -300,6 +318,24 @@ DEFAULT_METADATA = { ...@@ -300,6 +318,24 @@ DEFAULT_METADATA = {
}, },
"interval_specific": DEFAULT_INTERVAL_SPECIFIC, "interval_specific": DEFAULT_INTERVAL_SPECIFIC,
}, },
"HOT": {
"metadata": {
"station_name": "Hot Test",
"agency_name": "United States Geological Survey (USGS)",
"geodetic_latitude": "21.316",
"geodetic_longitude": "202.000",
"elevation": "4",
"sensor_orientation": "HDZF",
"sensor_sampling_rate": 100.0,
"declination_base": 5982,
"is_gin": False,
"is_intermagnet": False,
"conditions_of_use": "The Conditions of Use for data provided"
+ " through INTERMAGNET and acknowledgement templates"
+ " can be found at www.intermagnet.org",
},
"interval_specific": DEFAULT_INTERVAL_SPECIFIC,
},
"KAK": { "KAK": {
"metadata": { "metadata": {
"station_name": "Kakioka", "station_name": "Kakioka",
...@@ -391,6 +427,24 @@ DEFAULT_METADATA = { ...@@ -391,6 +427,24 @@ DEFAULT_METADATA = {
}, },
"interval_specific": DEFAULT_INTERVAL_SPECIFIC, "interval_specific": DEFAULT_INTERVAL_SPECIFIC,
}, },
"SJT": {
"metadata": {
"station_name": "SJT Test",
"agency_name": "United States Geological Survey (USGS)",
"geodetic_latitude": "18.113",
"geodetic_longitude": "293.849",
"elevation": "424",
"sensor_orientation": "HDZF",
"sensor_sampling_rate": 100.0,
"declination_base": 208439,
"is_gin": False,
"is_intermagnet": False,
"conditions_of_use": "The Conditions of Use for data provided"
+ " through INTERMAGNET and acknowledgement templates"
+ " can be found at www.intermagnet.org",
},
"interval_specific": DEFAULT_INTERVAL_SPECIFIC,
},
"TUC": { "TUC": {
"metadata": { "metadata": {
"station_name": "Tucson", "station_name": "Tucson",
......
from pydantic import BaseModel
from typing import Dict
DEFAULT_INTERVAL_SPECIFIC = { DEFAULT_INTERVAL_SPECIFIC = {
"day": { "day": {
"data_interval_type": "1-day (00:00-23:59)", "data_interval_type": "1-day (00:00-23:59)",
...@@ -131,3 +127,57 @@ DEFAULT_ASL_METADATA = { ...@@ -131,3 +127,57 @@ DEFAULT_ASL_METADATA = {
"interval_specific": DEFAULT_INTERVAL_SPECIFIC, "interval_specific": DEFAULT_INTERVAL_SPECIFIC,
}, },
} }
class VariometerMetadata(object):
"""Helper class for providing all the metadata needed for a geomag
timeseries.
Notes
-----
Currently the only method is set_metadata. Eventually this will probably
pull from a database, or maybe a config file.
"""
def __init__(self, metadata=None, interval_specific=None):
self.metadata = metadata or DEFAULT_ASL_METADATA
self.interval_specific = interval_specific or DEFAULT_INTERVAL_SPECIFIC
def set_metadata(self, stats, observatory, channel, type, interval):
"""Set timeseries metadata (aka a traces stats)
Parameters
----------
stats : obspy.core.trace.stats
the class associated with a given obspy trace, which contains
it's metadata
observatory : string
the observatory code to look up.
channel : str
single character channel {H, E, D, Z, F}
type : {'variation', 'quasi-definitive'}
data type.
interval : {'minute', 'second'}
data interval.
Returns
-------
obspy.core.trace.stats
the combined stats and the default metadata.
"""
stats["channel"] = channel
stats["data_interval"] = interval
stats["data_type"] = type
if observatory not in self.metadata:
return
# copy in standard metadata
metadata = self.metadata[observatory]["metadata"]
for key in metadata:
stats[key] = metadata[key]
# copy in interval specific metadata
interval_specific = self.interval_specific
if "interval_specific" in self.metadata[observatory]:
interval_specific = self.metadata[observatory]["interval_specific"]
# stats['data_interval_type'] = data_interval_type[interval]
if interval in interval_specific:
for key in interval_specific[interval]:
stats[key] = interval_specific[interval][key]
from pydantic import BaseModel, validator from pydantic import BaseModel, validator
from geomagio.ObservatoryMetadata import DEFAULT_METADATA, DEFAULT_INTERVAL_SPECIFIC from geomagio.ObservatoryMetadata import (
DEFAULT_METADATA,
DEFAULT_INTERVAL_SPECIFIC,
) # remove data_int here as well
from geomagio.VariometerMetaData import DEFAULT_ASL_METADATA from geomagio.VariometerMetaData import DEFAULT_ASL_METADATA
from typing import Dict from typing import Dict
......
...@@ -5,6 +5,7 @@ from obspy.clients.iris.client import Client ...@@ -5,6 +5,7 @@ from obspy.clients.iris.client import Client
from ..geomag_types import DataInterval, DataType from ..geomag_types import DataInterval, DataType
from ..ObservatoryMetadata import ObservatoryMetadata from ..ObservatoryMetadata import ObservatoryMetadata
from geomagio.VariometerMetaData import VariometerMetadata
from .. import TimeseriesUtility from .. import TimeseriesUtility
from .IRISSNCL import IRISSNCL from .IRISSNCL import IRISSNCL
from .MiniSeedFactory import MiniSeedFactory from .MiniSeedFactory import MiniSeedFactory
...@@ -72,7 +73,7 @@ class IRISFactory(MiniSeedFactory): ...@@ -72,7 +73,7 @@ class IRISFactory(MiniSeedFactory):
channels=channels, channels=channels,
type=type, type=type,
interval=interval, interval=interval,
observatoryMetadata=observatoryMetadata or ObservatoryMetadata(), observatoryMetadata=observatoryMetadata or VariometerMetadata(),
locationCode=locationCode, locationCode=locationCode,
convert_channels=convert_channels, convert_channels=convert_channels,
) )
......
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