<jupyter_start><jupyter_text>Build an MTH5 and Operate the Aurora Pipeline Outlines the process of making an MTH5 file, generating a processing config, and running the aurora processor<jupyter_code># Required imports for theh program. 
from pathlib import Path
import sys
import pandas as pd
from mth5.clients.make_mth5 import MakeMTH5
from mth5 import mth5, timeseries
from mt_metadata.utils.mttime import get_now_utc, MTime
from aurora.config.config_creator import ConfigCreator
from aurora.pipelines.process_mth5 import process_mth5_run<jupyter_output>2021-11-19 18:55:35,163 [line 135] mth5.setup_logger - INFO: Logging file can be found /Users/tronan/Desktop/Projects/mth5/logs/mth5_debug.log<jupyter_text>Build an MTH5 file from information extracted by IRIS<jupyter_code># Set path so MTH5 file builds to current working directory. 
default_path = Path().cwd()
# Initialize the Make MTH5 code. 
m = MakeMTH5(mth5_version='0.1.0')
m.client = "IRIS"
# Generate data frame of FDSN Network, Station, Location, Channel, Startime, Endtime codes of interest

ZUCAS04LQ1 = ['ZU', 'CAS04', '', 'LQE', '2020-06-02T19:00:00', '2020-07-13T19:00:00']
ZUCAS04LQ2 = ['ZU', 'CAS04', '', 'LQN', '2020-06-02T19:00:00', '2020-07-13T19:00:00']
ZUCAS04BF1 = ['ZU', 'CAS04', '', 'LFE', '2020-06-02T19:00:00', '2020-07-13T19:00:00']
ZUCAS04BF2 = ['ZU', 'CAS04', '', 'LFN', '2020-06-02T19:00:00', '2020-07-13T19:00:00']
ZUCAS04BF3 = ['ZU', 'CAS04', '', 'LFZ', '2020-06-02T19:00:00', '2020-07-13T19:00:00']

request_list = [ZUCAS04LQ1, ZUCAS04LQ2, ZUCAS04BF1, ZUCAS04BF2, ZUCAS04BF3]

# Turn list into dataframe
request_df =  pd.DataFrame(request_list, columns=m.column_names)\
# Inspect the dataframe
print(request_df)
# Request the inventory information from IRIS
inventory = m.get_inventory_from_df(request_df, data=False)
# Inspect the inventory
inventory<jupyter_output><empty_output><jupyter_text>Builds an MTH5 file from the user defined database. Note: Intact keeps the MTH5 open after it is done building<jupyter_code>mth5_object = m.make_mth5_from_fdsnclient(request_df, interact=True)
# mth5_object.open_mth5(h5_path, 'w')
# h5_path = str(default_path)+'/ZU_CAS04.h5'
#mth5_object.close_mth5()<jupyter_output><empty_output><jupyter_text>Extract information from the open MTH5 Object<jupyter_code>mth5_object
# Collect information from the MTh5 Object and use it in the config files. 
mth5_filename = mth5_object.filename
version = mth5_object.file_version
# Edit and update the MTH5 metadata 
s = mth5_object.get_station("CAS04")
s.metadata.location.declination.model = 'IGRF'
s.write_metadata()
# Get the available stations and runs from the MTH5 object
ch_summary = mth5_object.channel_summary
ch_summary
available_runs = ch_summary.run.unique()
sr = ch_summary.sample_rate.unique()
if len(sr) != 1:
    print('Only one sample rate per run is available')
available_stations = ch_summary.station.unique()
sr[0]
available_stations[0]
mth5_object<jupyter_output><empty_output><jupyter_text>Generate an Aurora Configuration file using MTH5 as an input<jupyter_code>station_id = available_stations[0]
run_id = available_runs[0]
sample_rate = sr[0]
config_maker = ConfigCreator()
config_path = config_maker.create_run_config(station_id, run_id, mth5_filename, sample_rate)

config_path<jupyter_output><empty_output><jupyter_text>Run the Aurora Pipeline using the input MTh5 and Confiugration File<jupyter_code>show_plot='True'
tf_cls = process_mth5_run(
        config_path,
        run_id,
        mth5_path=mth5_filename,
        units="MT",
        show_plot=False,
        z_file_path=None,
        return_collection=False,
    )

type(tf_cls)<jupyter_output><empty_output><jupyter_text>Write the transfer functions generated by the Aurora pipeline<jupyter_code>tf_cls.write_tf_file(fn="emtfxml_test.xml", file_type="emtfxml")
tf_cls.write_tf_file(fn="emtfxml_test.xml", file_type="edi")
 tf_cls.write_tf_file(fn="emtfxml_test.xml", file_type="zmm")<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.11052366565961733, 'fraction_numerical': 0.0649546827794562, 'mean_word_length': 6.553231939163498, 'pattern_counts': {'":': 0, '<': 28, '<?xml version=': 0, '>': 28, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 7}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '7', 'dir': 'jupyter-structured-clean-dedup', 'id': '13008', 'license': 'MIT', 'n_tokens_mistral': 1627, 'n_tokens_neox': 1491, 'n_words': 324, 'path': 'docs/notebooks/operate_aurora.ipynb', 'repo_name': 'simpeg/aurora', 'size': '3972'}