uafgeotools / mtuq

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

SPECFEM3D_SAC client support depth gridsearch #237

Closed SeismoFelix closed 8 months ago

SeismoFelix commented 8 months ago

SPECFEM3D_SAC.py client script was changed to support depth grid searches. In the MTUQ current version, when SPECFEM3D format is used, the path to the Green Functions (GFs) leads directly to the SAC files. Therefore, it is not possible to implement a moment tensor estimation, allowing a depth grid search. For instance, when using FK GFs, the path does not lead immediately to the SAC files but a manifold of directories named after the GFs database depth. To be consistent with the FK client, if this pull request is approved, the SPECFEM3D (SAC and SGT) GFs have to be saved in a directory named after the earthquake depth (e.g., /User/SpecfemGFs/6/*.sac if the depth of the earthquake is 6km).

The SPECMFEM3D examples data tgz files were modified (SAC and SGT) to include the earthquake depth in the directory name. For instance: SPECFEM3D_SAC/20090407201255351 would be now SPECFEM3D_SAC/20090407201255351/33

The test_greens_SPECFEM3D_SAC.py and test_greens_SPECFEM3D_SGT.py scripts were modified for setting earthquake depths rounded to the nearest integer. This is for making the creation of the corresponding GFs directory easier (e.g., for a depth of 33033.599853515625, the GFs directory had to end in 33.0335... So, for simplicity, the depth was rounded to 33000)

The setup/code_generator.py script remains unmodified since (so far) it does not write test_greens_SPECFEM3D_SAC.py and test_greens_SPECFEM3D_SGT.py.

With these modifications, the implementation of GridSearch.DoubleCouple+Magnitude+Depth.py for SPECFEM3D GFs is straightforward and was already tested.

rmodrak commented 8 months ago

Felix,

Very useful, I think this is a big improvement.

I was thinking of trying the following--

Is it alright if I make changes to your fork?

thanks, Ryan

SeismoFelix commented 8 months ago

Sure! Be my guest. Is enough Clicking in the box 'Allow edits by maintainers' to allow you to work my fork? If so, go ahead, and thanks for the help.

I would like to add that to allow shallow searches, the naming of the subdirectories also had to be adjusted in the FK client that is in km so far.

rmodrak commented 8 months ago

Sounds good, I will go ahead.

rmodrak commented 8 months ago

Agreed, shallow searches can be helpful for underground explosions, implosions, etc. I was thinking choosing between m or km via an optional keyword argument. I believe the newly modified tgz files should continue to work fine.

rmodrak commented 8 months ago

I've tried revising SPECFEM3D_SAC.py. Could you glance at it?

rmodrak commented 8 months ago

I don't understand the proposed changes to SPECFEM3D_SGT.py.

Doesn't the existing name convention already include depth? (see line 118)

SeismoFelix commented 8 months ago

I don't understand the propsed changes to SPECFEM3D_SGT.py.

Doesn't the existing name convention already include depth? (see line 118)

You are right Ryan, sorry. The SGT modifications are unnecessary since the name convention already includes the depth. I put the SGT codes (SPECFEM3D_SGT.py, test_greens_SPECFEM3D_SGT.py, and the SGT GFs directory) in their original form.

rmodrak commented 8 months ago

Sounds great, thanks Felix. Please feel free to merge whenever ready.

SeismoFelix commented 8 months ago

Great, Ryan, thanks. I already checked the moment tensor estimations with Specfem3D GFs, allowing depth search, and everything looks fine after your commit. However, I do not see the merge option below the message that there are no conflicts with the base branch. It seems I have no permission for merging.

Screenshot 2023-11-09 at 1 44 17 PM