-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
180 degree difference between SAzim and RAz #5
Comments
Hi Tom The SAzim is measured for a line from the epicenter to the station, and the RAz is measured for a ray leaving the hypocenter towards the station. So, as you note, they should be the same for a 1D, laterally homogeneous model,
I checked some NLL (NLLoc:v7.00.10(30Aug2020)) output I am running today for a 1D model and these two values are the same (though printed to different decimal precision). Can you check or send examples of your event *.hyp output to see if this is the case? (I suppose you already checked this, but I wanted to confirm...) Best regards, Anthony |
Hi Anthony, Thanks for your quick response - I'm glad that I understood correctly. Yes of course - please find an example attached. I have found this consistently for a few 1D velocity models in different regions, though admittedly the scripts for generating the LUT's and running NLLoc itself are all closely related. I have also attached the angle and time LUT files for one station to see if you can re-create the issue from those. Tom |
Did you run Grid2Time and NLLoc on the same machine, with the same byte-order? I suppose so, otherwise there might be all sorts of other problems. And was Grid2Time run on the same version of NLL as NLLoc? I cannot see a reason for the 180 deg flip, other than your rays are leaving the hypocenter away from the station, which seems unlikely. A way to check this is to plot the angles grid in Grid2GMT. You can check this, or I would need your control file to run Grid2GMT. |
Yes, I re-made the grids with both v6 and v7, and ran then ran each with both NLLoc v6 and v7 to check it wasn't some sort of inter-compatibility issue. What I sent you here previously were grids created by Grid2Time v7 and the hyp file from running NLLoc v7 using those grids. All were made on the same machine. I have attached my control file here (the reason I didn't before is due to the clutter.. sorry about that! but I have left it as-used in case there's something there that's causing the problem) and will have a go at plotting up the angles grids as soon as I get a moment. |
I guess I need all the files (obs etc.) so I can run from scratch here (tomorrow...) and see if I get the same, and then debug... |
Will do. Thanks again for your help. |
Well, when I run from scratch here (Vel2Grid, Grid2Time, NLLoc) I get the same angles for SAzim and RAz! PHASE ID Ins Cmp On Pha FM Date HrMn Sec Err ErrMag Coda Amp Per > TTpred Res Weight StaLoc(X Y Z) SDist SAzim RAz RDip RQual Tcorr What CPU and OS are you using? Which compiler? Perhaps try the version here: https://github.com/alomax/NonLinLoc Thanks, |
How intriguing... I am compiling / running on Ubuntu 16.04 with gcc 5.4.0:
CPU is:
I have cloned this repository. Which Makefile should I use to compile it? When I downloaded the source code for 7.0.0 from your website there was just a single Makefile, but here there are 3 - it looks like I should use either Makefile-NLLoc or Makefile.ORIG to compile with gcc. |
There are instructions using cmake on the home github page. |
I updated to cmake 3.18.2:
And followed the build instructions, but unfortunately |
Looks like it only failed for Loc2ddct, which is not needed for the main NLL tools. Are the other executables fully built? |
Yes, Vel2Grid, Grid2Time and NLLoc were all there, so I have run through again from scratch. It still gives me the 180 degree difference: v7.0.1_loc.20140829.201636.grid0.loc.hyp.zip For completeness, the list of binaries available was as follows (though I imagine it is not relevant here):
|
OK. I am stumped. Could it be a subtle machine architecture or compiler issue? |
I made the following change:
i.e. reversing the test for I'm afraid I don't have any bright ideas, other than perhaps compiling using a more up-to-date version of gcc, which I will try now. Did you use exactly the same control file when you ran it on your machine? And did you compare the angles grids I sent to those generated when you re-ran it? I had a brief look into the Grid2GMT docs - am I correct in thinking that they require a 3D time grid to work? Either way I am not 100% sure I understand how I would plot the angles grid. |
Aha - good news - updating gcc --> v7.3 seems to have fixed the issue! I reverted the source code before re-compiling. Full info on compilers used:
I also checked that running the newly compiled NLLoc using the old (vanilla v7.0.1 compiled with gcc 5.4) LUT still does have the 180 issue, so it seems to be in the generation of the angles grids. I have attached the new, correct hyp file here. |
Good, and thanks for all the info. Bizarre - maybe related to the way NLL compresses azimuth, dip and ray-angle quality into an integer that gives problems, otherwise I do not think there is anything that should cause hiccups at the compiler/machine level... Just give an update that all is fine, after you have done more work... Thanks, Anthony |
I did a little more digging, and things took a turn for the slightly more bizarre: I returned to the NLL v7.0.0 source-code and compiled that with gcc v7.3 and in this case it did not fix the issue. So I un-commented the line:
Whereas for all the configurations (combinations of compiler, version etc.) where it doesn't work, it returns
This of course explains why me reversing the test to:
didn't make a difference, as the case that *pazim == 0.0 slips through with both So the question is, should this inequality really be "greater than or equal to", as opposed to "greater than"? For the very short term I have switched this to "greater than or equal to" and all versions compiled with all compiler versions now seem to work (including inter-compatibility between NLL v6.0.0 LUT's and NLL 7.0.0 / 7.0.1 NLLoc). But I would like to hear your thoughts on:
As a final note, I had a look at the test script included in this repository to see if it caught this bug: it does, but as currently written the script does not run. I had to make some fixes (adding lines to make directories for the time and model files, etc.), and I think the files it said to diff between were not quite correct. If it would be useful, I can create a separate issue to explain these problems in full, or just submit a PR with the fixes - whichever you would prefer. Overall this episode has highlighted to me the importance of tests to catch this kind of subtle (but important!) bug!! |
Hi Tom I took a good look today, and the basic problem is deeper, there are 2 bugs that cancel each other, but with your compiler, one of the bugs changes an (invalid) unsigned short value and thus the results of the "if (*pazim" test we were looking at above. So I have made changes in several places to fix both bugs, but would like to do more tests here to confirm. The problem would affect the case where the ray leaves the hypocenter away from the station with any compiler, and also in the normal case where the ray leaves the hypocenter towards the station with your problem compiler/version. The bugs only affect 2D time grids (1D velocity models), not 3D models/time grids. And the 1D model would need to be very weird velocity model, so the rays leave the hypocenter away from the station (not really possible with a 1D, flat layered model). I think you can most simply make a work around by changing:
as long as you do not have a weird velocity model . Tell me if this works (provisionally). Anthony |
My understanding of the documentation is that SAzim and RAz should be identical when using travel-time grids constructed from 1D velocity models. Instead (in both NLLoc 6.0.0 and 7.0.0 - I haven't cloned this latest version) I find that RAz is 180 degrees different (i.e. opposite). This is the case irrespective of RDip.
Is this somehow intentional? It seems to me that the station azimuth calculation is correct, and the ray azimuth is wrong by 180 degrees.
I noticed this when parsing hyp files into MTfit - it turns out one of my predecessors in our research group had written a patch for NLLoc v6 to "correct" this, but when I switched to the vanilla version of NLLoc v7 the problem re-appeared (and all my moment tensors were upside down). I have attached the patched version of GridLib.c here, but to my (admittedly untrained) eye it looks quite clunky, so I'm not sure it will be of much use.
The Vel2Grid / Grid2Time parameters I have used are as follows:
The text was updated successfully, but these errors were encountered: