os.path.join(station_save_dir, "{0}.edi".format(station)), ) if not os.path.isfile( os.path.join(station_save_dir, "{0}.png".format(station))): shutil.copy( os.path.join(png_path, "{0}.png".format(station)), os.path.join(station_save_dir, "{0}.png".format(station)), ) ### Make MTH5 File m = mth5.MTH5() mth5_fn = os.path.join(station_save_dir, "{0}.mth5".format(station)) m.open_mth5(mth5_fn) if not m.h5_is_write: raise mth5.MTH5Error("Something is wrong") ### update metadata from csv and cfg files m.update_metadata_from_cfg(cfg_fn) if csv_fn is not None: try: station_df = archive.get_station_info_from_csv( csv_fn, station) m.update_metadata_from_series(station_df) except archive.ArchiveError as err: print("{0} {1} {0}".format("*" * 4, err)) m.write_metadata() ### loop over schedule blocks for ii, fn_block in enumerate(fn_list, 1): sch_obj = zc.merge_z3d(fn_block)
with archive.Capturing() as output: station_st = datetime.datetime.now() ### copy edi and png into archive director # if not os.path.isfile(os.path.join(station_save_dir, '{0}.edi'.format(station))): # shutil.copy(os.path.join(edi_path, '{0}.edi'.format(station)), # os.path.join(station_save_dir, '{0}.edi'.format(station))) # if not os.path.isfile(os.path.join(station_save_dir, '{0}.png'.format(station))): # shutil.copy(os.path.join(png_path, '{0}.png'.format(station)), # os.path.join(station_save_dir, '{0}.png'.format(station))) ### Make MTH5 File m = mth5.MTH5() mth5_fn = os.path.join(station_save_dir, '{0}.mth5'.format(station)) m.open_mth5(mth5_fn) if not m.h5_is_write: raise mth5.MTH5Error('Something is wrong') ### update metadata from csv and cfg files m.update_metadata_from_cfg(cfg_fn) if csv_fn is not None: try: station_df = archive.get_station_info_from_csv(csv_fn, station) m.update_metadata_from_series(station_df) except archive.ArchiveError as err: print('{0} {1} {0}'.format('*'*4, err)) m.write_metadata() ### loop over schedule blocks for ii, fn_block in enumerate(fn_list, 1): sch_obj = zc.merge_z3d(fn_block)
cfg_fn = r"C:\Users\jpeacock\Documents\GitHub\MTarchive\examples\example_mth5_cfg.txt" # ============================================================================= # File # ============================================================================= # need to over write existing files ### get the file names for each block of z3d files zc = archive.Z3DCollection() fn_list = zc.get_time_blocks(z3d_dir) st = datetime.datetime.now() ### Use with so that it will close if something goes amiss m = mth5.MTH5() m.open_mth5(r"c:\Users\jpeacock\Documents\imush\mshH020_test.mth5") if not m.h5_is_write: raise mth5.MTH5Error('Something is f****d') m.update_metadata_from_cfg(cfg_fn) m.update_metadata_from_series(archive.get_station_info_from_csv(csv_fn, 'mshH020')) m.write_metadata() for ii, fn_block in enumerate(fn_list, 1): sch_obj = zc.merge_z3d(fn_block) sch_obj.name = 'schedule_{0:02}'.format(ii) ### create group for schedule action m.add_schedule(sch_obj) ### add calibrations for hh in ['hx', 'hy', 'hz']: