megies / obspyck

ObsPyck is a GUI application that is intended to cover the tasks in a standard analysis workflow for seismic events in seismological observatory practice.
https://github.com/megies/obspyck/wiki
GNU General Public License v2.0
61 stars 32 forks source link

NLLOC lat/lon conversion #72

Open saeedsltm opened 6 years ago

saeedsltm commented 6 years ago

Hi, Could you please help me how to set gk2lonlat function correctly when using our own coordinate system in NLLOC?

Regards

megies commented 6 years ago

Well.. you should just replace the function such that it converts from the coordinates you use in NonLinLoc (this is assuming that in NonLinLoc you use TRANS NONE, I think) to WGS84. If you have a coordinate system that has an EPSG code you can do it pretty much the same as in the original gk2lonlat function.

saeedsltm commented 6 years ago

Thanks, OK but when we use something like this "TRANS LAMBERT WGS-84 35.50 50.50 32.0 38.0 0.0" which is already WGS, then what would be gk2lonlat? In this case our reference is WGS84!

megies commented 6 years ago

OK, so currently, I guess you should just put

def gk2lonlat(x, y):
    return x, y
saeedsltm commented 6 years ago

I did it but here is the result! please find attachement

On 1/12/18, Tobias Megies notifications@github.com wrote:

OK, so currently, I guess you should just put

def gk2lonlat(x, y):
    return x, y

-- You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub: https://github.com/megies/obspyck/issues/72#issuecomment-357200265

-- Dear

Regards


Saeed Soltani Moghadam. PhD student of Earthquake Seismology @ IIEES, Tehran, Iran. Tel: (+98) 917 709 7029

megies commented 6 years ago

Attachments to email replies are not retained by Github..

saeedsltm commented 6 years ago

sorry, by the way it did not work. i think the problem is i need to convert x/y from Cartesian coordinate system (source and station relative to map center in TRANS line of NLL control file) to lon/lat. So the output coordinate system is WGS-84 but i dont have any idea about the input coordinate system.

saeedsltm commented 6 years ago

Finally i found a solution and here is the change list: 1- write new gk2lonlat function in util.py like: def gk2lonlat(lon0,lat0,x,y): lon0*=ones_like(x) lat0*=ones_like(y) wgs84_geod = Geod(ellps='WGS84') new_lon, new_lat, _ = wgs84_geod.fwd(lon0,lat0,rad2deg(arctan2(y,x)),sqrt(x**2+y**2)*1e3) return new_lon, new_lat 2- and change the following line: data[0], data[1] = gk2lonlat(data[0], data[1]) to: data[0], data[1] = gk2lonlat(lon0, lat0, data[0], data[1]) 3- add the following lines to obspyk.py's line 2191: # read reference coordinate with open(files['summary']) as f: for l in f: if "TRANSFORM" in l: lat0 = float(l.split()[5]) lon0 = float(l.split()[7]) 4- and change the following lines: 4-1) line: lon, lat = gk2lonlat(x,y) to: lon, lat = gk2lonlat(lon0,lat0,x,y) 4-2) line: data = readNLLocScatter(PROGRAMS['nlloc']['files']['scatter'], self.widgets.qPlainTextEdit_stderr) to: data = readNLLocScatter(lon0, lat0, PROGRAMS['nlloc']['files']['scatter'], self.widgets.qPlainTextEdit_stderr) Thanks.

megies commented 6 years ago

Ah, I think I understand what the problem is now.. basically in your case we need to parse the GEOGRAPHIC line in the nonlinloc hypocenter-phase output file, instead of the HYPOCENTER line that I usually use because I have to convert coordinates manually after the nonlinloc run (all of our models are in local XYZ coordinate systems).

Compare two flavors of the hypocenter output file:

I'll try to come up with a simple switch for the configuration file, so that this can be done without hacking the source code in the future.. maybe even later today or this week

megies commented 6 years ago

Oh, just saw your python repos.. nice! Need to give PyVelest and PyGAVel a try at some point.. 🚀 :-)

saeedsltm commented 6 years ago

Yes, actually i made a change to use GEOGRAPHIC but it didn't resolve my problem because stations are also needed to change their positions. About the repos, they may need some minor changes i think ;).

megies commented 6 years ago

but it didn't resolve my problem because stations are also needed to change their positions.

Hmm.. I don't understand, can you clarify? I don't see how station coordinates are ever handled in something else than lon/lat..

saeedsltm commented 6 years ago

Yes you right. Only source and scatter points are using gk2lonlat function.

On 1/15/18, Tobias Megies notifications@github.com wrote:

but it didn't resolve my problem because stations are also needed to change their positions.

Hmm.. I don't understand, can you clarify? I don't see how station coordinates are ever handled in something else than lon/lat..

-- You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub: https://github.com/megies/obspyck/issues/72#issuecomment-357682965

-- Dear

Regards


Saeed Soltani Moghadam. PhD student of Earthquake Seismology @ IIEES, Tehran, Iran. Tel: (+98) 917 709 7029

megies commented 6 years ago

Ok, so what I would do is add a config option for nlloc that can either be..

The latter two cases would then use HYPOCENTER line and the first option the GEOGRAPHIC line.

saeedsltm commented 6 years ago

scatters are in x,y relative to geographical center in introduced in TRANS line. So they need to be converted according to reference coordinate system.