@@ -152,6 +152,8 @@ def __init__(
152
152
self ._mini_summary_columns = MINI_SUMMARY_COLUMNS
153
153
self .survey_metadata = {}
154
154
self .initialized = False
155
+ self .local_mth5_obj = None
156
+ self .remote_mth5_obj = None
155
157
156
158
def __str__ (self ):
157
159
return str (self .mini_summary .head ())
@@ -797,6 +799,20 @@ def update_survey_metadata(
797
799
if len (self .survey_metadata .keys ()) > 1 :
798
800
raise NotImplementedError
799
801
802
+ @property
803
+ def mth5_objs (self ):
804
+ """
805
+
806
+ :return: dictionary [station_id: mth5_obj]
807
+ :rtype: dict
808
+
809
+ """
810
+ mth5_obj_dict = {}
811
+ mth5_obj_dict [self .local_station_id ] = self .local_mth5_obj
812
+ if self .remote_station_id is not None :
813
+ mth5_obj_dict [self .remote_station_id ] = self .remote_mth5_obj
814
+ return mth5_obj_dict
815
+
800
816
def initialize_mth5s (self , mode = "r" ):
801
817
"""
802
818
returns a dict of open mth5 objects, keyed by station_id
@@ -811,18 +827,15 @@ def initialize_mth5s(self, mode="r"):
811
827
local station id : mth5.mth5.MTH5
812
828
remote station id: mth5.mth5.MTH5
813
829
"""
814
- mth5_obj_dict = {}
815
- mth5_obj_dict [self .local_station_id ] = initialize_mth5 (
816
- self .local_mth5_path , mode = mode
817
- )
830
+ self .local_mth5_obj = initialize_mth5 (self .local_mth5_path , mode = mode )
818
831
if self .remote_station_id :
819
- mth5_obj_dict [ self .remote_station_id ] = initialize_mth5 (
832
+ self .remote_mth5_obj = initialize_mth5 (
820
833
self .remote_mth5_path , mode = "r"
821
834
)
822
835
823
836
self .initialized = True
824
837
825
- return mth5_obj_dict
838
+ return self . mth5_objs
826
839
827
840
def initialize_dataframe_for_processing (self , mth5_objs : dict ) -> None :
828
841
"""
@@ -894,11 +907,17 @@ def add_columns_for_processing(self, mth5_objs) -> None:
894
907
Keys are station_id, values are MTH5 objects.
895
908
896
909
"""
897
- # columns_to_add = ["run_dataarray", "stft", "run_reference"]
898
- mth5_obj_column = len (self .df ) * [None ]
899
- for i , station_id in enumerate (self .df ["station" ]):
900
- mth5_obj_column [i ] = mth5_objs [station_id ]
901
- self .df ["mth5_obj" ] = mth5_obj_column
910
+ if not self .initialized :
911
+ raise ValueError ("mth5 objects have not been initialized yet." )
912
+
913
+ if self ._has_df ():
914
+ self ._df .loc [
915
+ self ._df .station == self .local_station_id , "mth5_obj"
916
+ ] = self .local_mth5_obj
917
+ if self .remote_station_id is not None :
918
+ self ._df .loc [
919
+ self ._df .station == self .remote_station_id , "mth5_obj"
920
+ ] = self .remote_mth5_obj
902
921
903
922
def close_mth5s (self ) -> None :
904
923
"""
0 commit comments