def remove_static_shift( df_fn, nf=22, save_dir=Path( r"c:\Users\jpeacock\OneDrive - DOI\Geysers\CEC\EDI_files_birrp_processed\Geographic\Edited\SS" ), ): df = pd.read_csv(df_fn) for row in df.itertuples(): m1 = MT(row.original) m2 = MT(row.phase_01) m1.Z, m1.Tipper = m1.interpolate(m2.frequencies, bounds_error=False) sx = np.median(m1.Z.res_xy[:nf] / m2.Z.res_xy[:nf]) sy = np.median(m1.Z.res_yx[:nf] / m2.Z.res_yx[:nf]) print(f"station: {m1.station} - {m2.station}: sx={sx}, sy={sy}") m2.Z = m2.remove_static_shift(1.0 / sx, 1.0 / sy) m2.write_mt_file(save_dir=save_dir)
from mtpy.core.mt import MT from mtpy.utils.calculator import get_period_list # directory format for windows users edi_path = r'C:\mtpywin\mtpy\examples\data\edi_files_2' savepath = r'C:\tmp' edi_file = os.path.join(edi_path,'Synth00.edi') mtObj = MT(edi_file) #new_freq_list = mtObj.Z.freq # takes every second frequency new_freq_list = 1./get_period_list(1e-4,1e3,5) # 5 periods per decade from 0.0001 to 100000 s # create new Z and Tipper objects containing interpolated data new_Z_obj, new_Tipper_obj = mtObj.interpolate(new_freq_list) # write a new edi file using the new data mtObj.write_mt_file(save_dir=savepath, fn_basename='Synth00_new', file_type='edi', # edi or xml format new_Z_obj=new_Z_obj, # provide a z object to update the data new_Tipper_obj=new_Tipper_obj, # provide a tipper object to update the data longitude_format='LONG', # write longitudes as 'LON' or 'LONG' latlon_format='dd' # write as decimal degrees (any other input # will write as degrees minutes seconds )