uafgeotools / mtuq

moment tensor uncertainty quantification
BSD 2-Clause "Simplified" License
68 stars 22 forks source link

Issues getting synthetics from FK database #277

Open ammcpherson opened 4 hours ago

ammcpherson commented 4 hours ago

Good afternoon,

I am trying to save synthetics from MTUQ to visualize against real data. I have done this with SPECFEM-generated Green's functions, but when I attempt to do the same thing using an FK database, no synthetics are generated. I cannot share the FK database of course, but these are the basic commands of what I am doing:

fk_path = '/store/wf/FK_synthetics/'+model
db = open_db(fk_path,format='FK')

origin = Origin({
        'time': '2022-09-24T15:18:54.694000Z',
        'latitude': 61.4915,
        'longitude': -145.5887,
        'depth_in_m': 41000.0,
        'id': str(eid)
})

data = read(path_data, format='sac', 
            event_id=event_id,
            station_id_list=station_id_list,
            tags=['units:m', 'type:velocity']) 

data.sort_by_azimuth()
stations = data.get_stations()

greens = db.get_greens_tensors(stations, origin)

synthetics = greens.get_synthetics(MomentTensor([269000000000000,-15643000000000000,15374000000000000,5999000000000000,7576000000000000,4205000000000000]),components=['Z','R','T'])

os.makedirs(eid+'_synthetics',exist_ok=True)
synthetics.write(eid+'_synthetics/%s/' % model,format='sac') 

As I said, this works when I am using SPECFEM-generated GFs, and the only thing that changes is how I open the GF database:

SF_path = './GFs/%s/%s' % (eid,model)
db = open_db(SF_path,format='SPECFEM3D')

Is there something that needs to change about my approach to get synthetics from an FK database?

Thanks, Amanda

rmodrak commented 2 hours ago

Hi Amanda, Thanks for the report. Maybe add some print() or type() statements to try to get to the bottom of it? I will take a look as well.

On Wed, Oct 23, 2024 at 5:26 PM Amanda McPherson @.***> wrote:

Good afternoon,

I am trying to save synthetics from MTUQ to visualize against real data. I have done this with SPECFEM-generated Green's functions, but when I attempt to do the same thing using an FK database, no synthetics are generated. I cannot share the FK database of course, but these are the basic commands of what I am doing:

fk_path = '/store/wf/FK_synthetics/'+model db = open_db(fk_path,format='FK')

origin = Origin({ 'time': '2022-09-24T15:18:54.694000Z', 'latitude': 61.4915, 'longitude': -145.5887, 'depth_in_m': 41000.0, 'id': str(eid) })

data = read(path_data, format='sac', event_id=event_id, station_id_list=station_id_list, tags=['units:m', 'type:velocity'])

data.sort_by_azimuth() stations = data.get_stations()

greens = db.get_greens_tensors(stations, origin)

synthetics = greens.get_synthetics(MomentTensor([269000000000000,-15643000000000000,15374000000000000,5999000000000000,7576000000000000,4205000000000000]),components=['Z','R','T'])

os.makedirs(eid+'_synthetics',exist_ok=True) synthetics.write(eid+'_synthetics/%s/' % model,format='sac')

As I said, this works when I am using SPECFEM-generated GFs, and the only thing that changes is how I open the GF database:

SF_path = './GFs/%s/%s' % (eid,model) db = open_db(SF_path,format='SPECFEM3D')

Is there something that needs to change about my approach to get synthetics from an FK database?

Thanks, Amanda

— Reply to this email directly, view it on GitHub https://github.com/uafgeotools/mtuq/issues/277, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABCGSSRYDZE7QDXFJQ3SRL3Z5AWD5AVCNFSM6AAAAABQP3QQNOVHI2DSMVQWIX3LMV43ASLTON2WKOZSGYYTAMBTGUZTQMI . You are receiving this because you are subscribed to this thread.Message ID: @.***>

rmodrak commented 1 hour ago

It looks like the network, station, and location codes are not getting copied to the synthetics. The result is the following output file names. ...R.sac ...T.sac ...Z.sac

rmodrak commented 1 hour ago

One way to get the correct filenames is to manually pass a list of ObsPy stats objects via the stats keyword argument when calling get_synthetics().

The syntax would be something like

synthetics = greens.get_synthetics(mt, stats=stations, components=components, mode='map')

This gets complicated though, I would have to look closely in order to recall the exact correct syntax.

Of course, we want these station codes to get passed seamlessly... trying to figure out a larger fix