DEFAULT_INTERVAL_SPECIFIC = { "day": { "data_interval_type": "1-day (00:00-23:59)", "filter_comments": [ "Scalar and Vector 1-day values are computed from average of 1-minute values in the day (00:00-23:59)", ], }, "hour": { "data_interval_type": "1-hour (00-59)", "filter_comments": [ "Scalar and Vector 1-hour values are computed from average of 1-minute values in the hour (00-59)", ], }, "minute": { "data_interval_type": "1-minute", "filter_comments": [ "Scalar and Vector 1-minute values are computed from 1 Hz values using an INTERMAGNET gaussian filter centered on the start of the minute (00:15-01:45))." ], }, "second": { "data_interval_type": "1-second", "filter_comments": [ "Vector 1-second values are computed from 10 Hz values using a Blackman filter (123 taps, cutoff 0.25Hz) centered on the start of the second." ], }, } DEFAULT_ASL_METADATA = { "ANMO": { "metadata": { "elevation": 1820, "geodetic_latitude": 34.946, "geodetic_longitude": -106.457, "station_name": "Albuquerque", "agency_name": "United States Geological Survey (USGS)", "declination_base": None, }, "interval_specific": DEFAULT_INTERVAL_SPECIFIC, }, "CASY": { "metadata": { "elevation": 10, "geodetic_latitude": -66.279, "geodetic_longitude": 110.535, "station_name": "Casey", "agency_name": "United States Geological Survey (USGS)", "declination_base": None, }, "interval_specific": DEFAULT_INTERVAL_SPECIFIC, }, "COLA": { "metadata": { "elevation": 200, "geodetic_latitude": 64.874, "geodetic_longitude": -147.862, "station_name": "College Outpost", "agency_name": "United States Geological Survey (USGS)", "declination_base": None, }, "interval_specific": DEFAULT_INTERVAL_SPECIFIC, }, "COR": { "metadata": { "elevation": 110, "geodetic_latitude": 44.586, "geodetic_longitude": -123.305, "station_name": "Corvallis", "agency_name": "United States Geological Survey (USGS)", "declination_base": None, }, "interval_specific": DEFAULT_INTERVAL_SPECIFIC, }, "QSPA": { "metadata": { "elevation": 2850, "geodetic_latitude": -89.929, "geodetic_longitude": 144.438, "station_name": "South Pole Remote Earth Science Observatory", "agency_name": "United States Geological Survey (USGS)", "declination_base": None, }, "interval_specific": DEFAULT_INTERVAL_SPECIFIC, }, "RSSD": { "metadata": { "elevation": 2090, "geodetic_latitude": 44.121, "geodetic_longitude": -104.036, "station_name": "Black Hills", "agency_name": "United States Geological Survey (USGS)", "declination_base": None, }, "interval_specific": DEFAULT_INTERVAL_SPECIFIC, }, "SBA": { "metadata": { "elevation": 50, "geodetic_latitude": -77.849, "geodetic_longitude": 166.757, "station_name": "Scott Base", "agency_name": "United States Geological Survey (USGS)", "declination_base": None, }, "interval_specific": DEFAULT_INTERVAL_SPECIFIC, }, "SFJD": { "metadata": { "elevation": 330, "geodetic_latitude": 66.996, "geodetic_longitude": -50.621, "station_name": "Sondre Stromfjord", "agency_name": "United States Geological Survey (USGS)", "declination_base": None, }, "interval_specific": DEFAULT_INTERVAL_SPECIFIC, }, "SPA": { "metadata": { "elevation": 2927, "geodetic_latitude": -90.0, "geodetic_longitude": 0.0, "station_name": "South Pole", "agency_name": "United States Geological Survey (USGS)", "declination_base": None, }, "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: print(f"Observatory '{observatory}' not found in metadata.") print("Available Observatories:", self.metadata.keys()) 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]