diff --git a/geomagio/ObservatoryMetadata_test.py b/geomagio/ObservatoryMetadata_test.py new file mode 100644 index 0000000000000000000000000000000000000000..fe0ffa6e3dbb8db92412f34ecc869baa84f61672 --- /dev/null +++ b/geomagio/ObservatoryMetadata_test.py @@ -0,0 +1,71 @@ +"""Tests for ObservatoryMetadata.py""" + +from ObservatoryMetadata import ObservatoryMetadata +from nose.tools import assert_equals +import obspy.core + + +METADATA = { + 'BOU': { + 'metadata': { + 'station_name': 'Boulder', + 'agency_name': 'United States Geological Survey (USGS)', + 'geodetic_latitude': '-90', + 'geodetic_longitude': '-180', + 'elevation': '-1000', + 'sensor_orientation': 'HDZF', + 'sensor_sampling_rate': '0.01 second', + 'declination_base': 20000, + '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': { + 'minute': { + 'data_interval_type': 'filtered 1-minute (00:15-01:45) ', + 'filter_comments': ['Vector 1-minute values are computed' + + ' from 1-second values using the INTERMAGNET gaussian' + + ' filter centered on the minute. Scalar 1-minute values' + + ' are computed from 1-second values using the' + + ' INTERMAGNET gaussian filter centered on the minute. '] + }, + 'second': { + 'data_interval_type': 'Average 1-Second' + } + } + } +} + + +DATA_INTERVAL_TYPE = { + 'minute': {'data_interval_type': 'filtered 1-minute (00:29-01:30) '}, + 'second': {'data_interval_type': 'filtered 1-Second'} +} + + +def test_set_metadata(): + """geomagio.edge.ObservatoryMetadata_test.test_set_metadata() + """ + # Test set_metadata by passing in a stats class, and looking + # for parameters that are both passed in, and aquired from the default + # metadata. + observatorymetadata = ObservatoryMetadata() + stats = obspy.core.Stats() + stats.channel = 'MVH' + stats.location = 'R0' + stats.data_interval = 'second' + stats.data_type = 'quasi-definitive' + observatorymetadata.set_metadata(stats, 'BOU', 'MVH', + 'quasi-definitive', 'second') + assert_equals(stats['declination_base'], 5527) + + # Test custom metadata + stats = obspy.core.Stats() + observatorymetadata = ObservatoryMetadata(METADATA, DATA_INTERVAL_TYPE) + observatorymetadata.set_metadata(stats, 'BOU', 'MVH', + 'quasi-definitive', 'second') + assert_equals(stats['declination_base'], 20000) + print stats + assert_equals(stats['data_interval_type'], 'Average 1-Second')