Skip to content

Commit

Permalink
Merge pull request #356 from simpeg/patches
Browse files Browse the repository at this point in the history
Patches
  • Loading branch information
kkappler authored Sep 4, 2024
2 parents 9dee8d3 + 41648f5 commit ec6d6ca
Show file tree
Hide file tree
Showing 7 changed files with 6,225 additions and 6,090 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,10 @@ jobs:
run: |
jupyter nbconvert --to notebook --execute docs/examples/dataset_definition.ipynb
jupyter nbconvert --to notebook --execute docs/examples/operate_aurora.ipynb
jupyter nbconvert --to notebook --execute docs/tutorials/pkd_units_check.ipynb
jupyter nbconvert --to notebook --execute docs/tutorials/pole_zero_fitting/lemi_pole_zero_fitting_example.ipynb
jupyter nbconvert --to notebook --execute docs/tutorials/processing_configuration.ipynb
jupyter nbconvert --to notebook --execute docs/tutorials/process_cas04_multiple_station.ipynb
jupyter nbconvert --to notebook --execute docs/tutorials/process_cas04_single_station.ipynb
jupyter nbconvert --to notebook --execute docs/tutorials/synthetic_data_processing.ipynb
jupyter nbconvert --to notebook --execute tests/test_run_on_commit.ipynb
Expand Down
30 changes: 23 additions & 7 deletions aurora/test_utils/parkfield/make_parkfield_mth5.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,21 @@
from aurora.test_utils.dataset_definitions import TEST_DATA_SET_CONFIGS
from mth5.utils.helpers import read_back_data
from mth5.helpers import close_open_files
from aurora.sandbox.io_helpers.fdsn_dataset import FDSNDataset
from aurora.sandbox.io_helpers.make_mth5_helpers import create_from_server_multistation
from aurora.test_utils.parkfield.path_helpers import PARKFIELD_PATHS
from loguru import logger
from typing import Union


DATA_SOURCES = ["NCEDC", "https://service.ncedc.org/"]
DATASET_ID = "pkd_sao_test_00"
FDSN_DATASET = TEST_DATA_SET_CONFIGS[DATASET_ID]

#

def select_data_source():

def select_data_source() -> None:
"""
Identifies appropriate web client to use for NCEDC data requests.
Expand Down Expand Up @@ -47,7 +51,10 @@ def select_data_source():
return data_source


def make_pkdsao_mth5(fdsn_dataset):
def make_pkdsao_mth5(
fdsn_dataset: FDSN_DATASET,
target_folder: Union[str, pathlib.Path, None] = PARKFIELD_PATHS["data"],
) -> pathlib.Path:
"""
Makes MTH5 file with data from Parkfield and Hollister stations to use for testing.
"""
Expand All @@ -56,7 +63,7 @@ def make_pkdsao_mth5(fdsn_dataset):
fdsn_dataset.initialize_client()
h5_path = create_from_server_multistation(
fdsn_dataset,
target_folder=PARKFIELD_PATHS["data"],
target_folder=target_folder,
triage_units=["V/m to mV/km", "T to nT"],
)

Expand All @@ -66,22 +73,31 @@ def make_pkdsao_mth5(fdsn_dataset):
return h5_path


def ensure_h5_exists() -> pathlib.Path:
def ensure_h5_exists(
target_folder: Union[str, pathlib.Path, None] = PARKFIELD_PATHS["data"],
) -> pathlib.Path:
"""
Make sure that the PKD SAO MTH5 file exists. If it does not, build it.
Parameters
----------
h5_path: Union[pathlib.Path, None]
Returns
-------
h5_path: pathlib.Path
The path to the PKD SAO mth5 file to be used for testing.
"""

h5_path = PARKFIELD_PATHS["data"].joinpath(FDSN_DATASET.h5_filebase)
h5_path = target_folder.joinpath(FDSN_DATASET.h5_filebase)
if h5_path.exists():
msg = f"h5 file {h5_path} already exists -- skipping make"
logger.info(msg)
return h5_path

try:
h5_path = make_pkdsao_mth5(FDSN_DATASET)
h5_path = make_pkdsao_mth5(FDSN_DATASET, target_folder=target_folder)
return h5_path
except Exception as e:
logger.error(f"Encountered {e} Exception - make_pkdsao_mth5 failed")
Expand Down
2 changes: 1 addition & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Welcome to Aurora Documentation
tutorials/processing_configuration.ipynb
tutorials/earthscope_magnetic_data_tutorial.ipynb
tutorials/process_cas04_single_station.ipynb
tutorials/process_cas04_mulitple_station.ipynb
tutorials/process_cas04_multiple_station.ipynb
tutorials/synthetic_data_processing.ipynb

.. toctree::
Expand Down
Loading

0 comments on commit ec6d6ca

Please sign in to comment.