diff --git a/pysep/configs/alvizuri_tape_2018/2006-10-09T013528_NORTH_KOREA.yaml b/pysep/configs/alvizuri_tape_2018/2006-10-09T013528_NORTH_KOREA.yaml index e9077fc..674884d 100644 --- a/pysep/configs/alvizuri_tape_2018/2006-10-09T013528_NORTH_KOREA.yaml +++ b/pysep/configs/alvizuri_tape_2018/2006-10-09T013528_NORTH_KOREA.yaml @@ -47,4 +47,3 @@ remove_insufficient_length: true remove_masked_data: true fill_data_gaps: false gap_fraction: 1.0 -log_level: DEBUG diff --git a/pysep/configs/misc_events/1988-02-15T181000_KERNVILLE_EXPLOSION.yaml b/pysep/configs/misc_events/1988-02-15T181000_KERNVILLE_EXPLOSION.yaml index cf3dd0a..fc84e12 100644 --- a/pysep/configs/misc_events/1988-02-15T181000_KERNVILLE_EXPLOSION.yaml +++ b/pysep/configs/misc_events/1988-02-15T181000_KERNVILLE_EXPLOSION.yaml @@ -46,4 +46,3 @@ remove_insufficient_length: true remove_masked_data: true fill_data_gaps: false gap_fraction: 1.0 -log_level: DEBUG diff --git a/pysep/configs/misc_events/2015-10-18T051831_TAAN_FJORD_LANDSLIDE.yaml b/pysep/configs/misc_events/2015-10-18T051831_TAAN_FJORD_LANDSLIDE.yaml index e97ed44..3033452 100644 --- a/pysep/configs/misc_events/2015-10-18T051831_TAAN_FJORD_LANDSLIDE.yaml +++ b/pysep/configs/misc_events/2015-10-18T051831_TAAN_FJORD_LANDSLIDE.yaml @@ -50,4 +50,3 @@ remove_insufficient_length: true remove_masked_data: true fill_data_gaps: false gap_fraction: 1.0 -log_level: DEBUG diff --git a/pysep/configs/misc_events/2016-01-24T103037_INISKIN.yaml b/pysep/configs/misc_events/2016-01-24T103037_INISKIN.yaml index 7323e91..1ac8a41 100644 --- a/pysep/configs/misc_events/2016-01-24T103037_INISKIN.yaml +++ b/pysep/configs/misc_events/2016-01-24T103037_INISKIN.yaml @@ -47,4 +47,3 @@ remove_insufficient_length: true remove_masked_data: true fill_data_gaps: false gap_fraction: 1.0 -log_level: DEBUG diff --git a/pysep/configs/template_config.yaml b/pysep/configs/template_config.yaml index ff8974d..99eba73 100644 --- a/pysep/configs/template_config.yaml +++ b/pysep/configs/template_config.yaml @@ -1,48 +1,48 @@ -# PYSEP Config file - Template v0.1.0 +# PySEP Template config v0.5.0 +event_tag: null config_file: null client: IRIS client_debug: false timeout: 600 +taup_model: ak135 +use_mass_download: false event_selection: default -origin_time: 2009-04-07T20:12:55.351 +origin_time: null seconds_before_event: 20 seconds_after_event: 20 -event_latitude: 61.45420 -event_longitude: -149.7428 -event_depth_km: 33.033 -event_magnitude: 4.6 -networks: 'AK,YV,AV,AT,XZ,PN' +event_latitude: null +event_longitude: null +event_depth_km: null +event_magnitude: null +networks: '*' stations: '*' -channels: 'BH?' +channels: '*' locations: '*' reference_time: null seconds_before_ref: 100 seconds_after_ref: 300 -phase_list: null -llnl_db_path: /store/raw/LLNL/UCRL-MI-222502/westernus.wfdisc -min_dist: 0 -max_dist: 300.0 -min_az: 0 -max_az: 360 -min_lat: null -max_lat: null -min_lon: null -max_lon: null +phase_list: +- ttall +mindistance_km: 0 +maxdistance_km: 20000.0 +minazimuth: 0 +maxazimuth: 360 +minlatitude: null +maxlatitude: null +minlongitude: null +maxlongitude: null demean: true detrend: true -taper_percentage: 0 +taper_percentage: 0.0 rotate: null remove_response: true output_unit: VEL water_level: 60 pre_filt: default -scale_factor: 100.0 -resample_freq: 50 -remove_clipped: false -output_dir: ./ -write_files: !!set - all: null -plot_files: !!set - all: null -log_level: DEBUG -event_tag: null +scale_factor: 1 +resample_freq: null +remove_clipped: true +remove_insufficient_length: true +remove_masked_data: true +fill_data_gaps: false +gap_fraction: 1.0 diff --git a/pysep/pysep.py b/pysep/pysep.py index e9a7026..496bae6 100644 --- a/pysep/pysep.py +++ b/pysep/pysep.py @@ -762,7 +762,6 @@ def load(self, config_file=None, overwrite_event=True): logger.debug(f"{key}: {old_val} -> {val}") setattr(self, key, val) else: - import pdb;pdb.set_trace() logger.warning(f"config parameter '{key}' not explicitely " f"used by PySEP. adding to kwargs") self.kwargs[key] = val @@ -1681,10 +1680,9 @@ def write_config(self, fid=None, overwrite=False): if not key.startswith("_")} # Internal attributes that don't need to go into the written config attr_remove_list = ["st", "st_raw", "event", "inv", "c", "write_files", - "plot_files", "output_dir", "station_ids", "kwargs"] + "plot_files", "output_dir", "station_ids", "kwargs", + "llnl_db_path", "log_level", "legacy_naming"] - if self.client.upper() != "LLNL": - attr_remove_list.append("llnl_db_path") # not important unless LLNL for key in attr_remove_list: del(dict_out[key]) # Write times in as strings not UTCDateTime diff --git a/pysep/tests/test_pysep.py b/pysep/tests/test_pysep.py index 3108e0d..33e2f08 100644 --- a/pysep/tests/test_pysep.py +++ b/pysep/tests/test_pysep.py @@ -1,7 +1,11 @@ """ Test the general functionality of Pysep """ +from re import L import pytest +import os +import yaml +from glob import glob from pysep import Pysep, logger @@ -75,3 +79,28 @@ def test_curtail_stations(test_pysep): assert(nsta_pre_curtail - nsta_post_curtail == 6) + +def test_config_files_have_correct_parameters(tmpdir, test_pysep): + """ + Check that all the config files have the correct parameters based on what + PySEP writes to ensure that the config files are up to date with codebase + """ + # Write a config file from the Pysep instance and read in the yaml file + fid = os.path.join(tmpdir, "test_config.yaml") + test_pysep.write_config(fid=fid) + config = set(yaml.safe_load(open(fid)).keys()) + + # Get the directory containing the example config files + config_dir = "../configs/" + + # Iterate over all the yaml files in the directory + for dir_ in glob(os.path.join(config_dir, "*")): + if not os.path.isdir(dir_): + continue + for fid in glob(os.path.join(dir_, "*")): + if not fid.endswith(".yaml"): + continue + with open(fid, "r") as f: + config_check = set(yaml.safe_load(f).keys()) + assert(config.issubset(config_check)), \ + f"Config file {fid} does not have the correct parameters" \ No newline at end of file