MTgeophysics / mtpy-v2

Tools to work with magnetotelluric transfer functions, based on MTH5 and mt-metadata. This is an update to mtpy.
https://mtpy-v2.readthedocs.io/en/latest/index.html
MIT License
30 stars 9 forks source link

Downsampling frequencies #15

Open SashaAivaz opened 7 months ago

SashaAivaz commented 7 months ago

I have a MT collection that has no survey id and to downsample frequencies, I needed to add the survey id because the keys for MT collection are survey_id.station_id and having '0' for survey id meant no string and problem. I got this error: image I have used this code to downsample and add the id:

# with MTCollection() as mc:
     mc.open_collection(r"C:\Users\aivazpourporgous\Documents\MT\CCA\Inversion\CCA_0\edi\lin0_resampled_frequency.h5")
     for filename in edifiles:
        mt_object = MT()
        mt_object.read(filename)
        #mt_object.survey = "downsampled"
        new_frequency = np.logspace(-3, 3, 20)
        new_mt_obj = mt_object.interpolate(new_frequency, f_type="frequency")
        new_mt_obj.survey = "downsampled"
        mc.add_tf(new_mt_obj)
#
#

Now I have two entities for each station one unknown survey id and one downsampled. I added the id to the original mt_object before making new_mt_obj but result is same. image

kujaku11 commented 7 months ago

@SashaAivaz Try again, I just fixed a bug in MTCollection.add_tf.

I updated the add_tf to have arguments add_tf(tf_object, new_survey='new_survey_name', tf_id_extra='interpolated'

The tf_id_extra will add this onto the end of the tf_id which is the transfer function id, usually the same as the station. If your station and tf_id are "mt01" then if you set tf_id_extra the new tf_id will be "mt01_tf_id_extra", helps organize transfer functions.

But now you should be able to set the survey for your original data and your downsampled data.

SashaAivaz commented 7 months ago

@kujaku11 I did installed the updates but it seems it doesn't like any argument for add_tf It gives same error for tf_id_extra. Untitled