|
65 | 65 | from typing import Optional, Union
|
66 | 66 |
|
67 | 67 | import pandas as pd
|
68 |
| - |
69 | 68 | from loguru import logger
|
70 | 69 |
|
71 | 70 | import mt_metadata.timeseries
|
72 | 71 | from mt_metadata.utils.list_dict import ListDict
|
73 |
| -import mth5.timeseries.run_ts |
74 | 72 |
|
| 73 | +import mth5.timeseries.run_ts |
| 74 | +from mth5.utils.helpers import initialize_mth5 |
75 | 75 |
|
76 | 76 | from mtpy.processing.run_summary import RunSummary
|
77 | 77 | from mtpy.processing import (
|
@@ -151,6 +151,7 @@ def __init__(
|
151 | 151 | self.remote_station_id = remote_station_id
|
152 | 152 | self._mini_summary_columns = MINI_SUMMARY_COLUMNS
|
153 | 153 | self.survey_metadata = {}
|
| 154 | + self.initialized = False |
154 | 155 |
|
155 | 156 | def __str__(self):
|
156 | 157 | return str(self.mini_summary.head())
|
@@ -796,6 +797,33 @@ def update_survey_metadata(
|
796 | 797 | if len(self.survey_metadata.keys()) > 1:
|
797 | 798 | raise NotImplementedError
|
798 | 799 |
|
| 800 | + def initialize_mth5s(self, mode="r"): |
| 801 | + """ |
| 802 | + returns a dict of open mth5 objects, keyed by station_id |
| 803 | +
|
| 804 | + A future version of this for multiple station processing may need |
| 805 | + nested dict with [survey_id][station] |
| 806 | +
|
| 807 | + Returns |
| 808 | + ------- |
| 809 | + mth5_objs : dict |
| 810 | + Keyed by stations. |
| 811 | + local station id : mth5.mth5.MTH5 |
| 812 | + remote station id: mth5.mth5.MTH5 |
| 813 | + """ |
| 814 | + mth5_obj_dict = {} |
| 815 | + mth5_obj_dict[self.local_station_id] = initialize_mth5( |
| 816 | + self.local_mth5_path, mode=mode |
| 817 | + ) |
| 818 | + if self.remote_station_id: |
| 819 | + mth5_obj_dict[self.remote_station_id] = initialize_mth5( |
| 820 | + self.remote_mth5_path, mode="r" |
| 821 | + ) |
| 822 | + |
| 823 | + self.initialized = True |
| 824 | + |
| 825 | + return mth5_obj_dict |
| 826 | + |
799 | 827 | def initialize_dataframe_for_processing(self, mth5_objs: dict) -> None:
|
800 | 828 | """
|
801 | 829 | Adds extra columns needed for processing to the dataframe.
|
|
0 commit comments