uafgeotools / rtm

A Python package for locating infrasound sources using reverse time migration
https://uaf-rtm.readthedocs.io/
MIT License
38 stars 13 forks source link

UTM zone issue in prepare_fdtd_run #68

Closed leighton-watson closed 1 year ago

leighton-watson commented 2 years ago

There is a bug with prepare_fdtd_run (in travel_time.py at line 87). If stations are in different UTM zones then at least one station will be written in an incorrect position. I imagine this can be fixed by fixing the forcing the UTM zone, as noted in the comment at this line.

leighton-watson commented 2 years ago

There could also be an issue with line 239 travel_times.assign_attrs(UTM=grid.UTM). I haven't got to fdtd_travel_timeyet to see if this is an issue or not.

liamtoney commented 2 years ago

There could also be an issue with line 239 travel_times.assign_attrs(UTM=grid.UTM). I haven't got to fdtd_travel_timeyet to see if this is an issue or not.

Thanks Leighton. The line you mention here shouldn't be a problem; grid.UTM is just a dictionary storing the UTM projection parameters, not actual coordinates.

liamtoney commented 2 years ago

Okay, without creating a new branch and implementing the change, here's my suggestion. Grab the UTM zone number from the dem (this should be defined) like so:

zone_number = dem.UTM['zone']

This defines a single UTM zone which can be used for all UTM conversions. Then, in the utm.from_latlon() call, add the kwarg force_zone_number=zone_number.

@leighton-watson can you give this a shot and let me know if it works? Or let me know if you already tried this. My other concern is that the code in https://github.com/uafgeotools/rtm/blob/0d100ea142fa4200579a21da8169eaeec42b7b20/rtm/travel_time.py#L89 is collapsing coordinates outside the DEM region to the DEM edge, but I haven't thought that through enough yet.

liamtoney commented 2 years ago

My other concern is that the code in

https://github.com/uafgeotools/rtm/blob/0d100ea142fa4200579a21da8169eaeec42b7b20/rtm/travel_time.py#L89

is collapsing coordinates outside the DEM region to the DEM edge, but I haven't thought that through enough yet.

In thinking about this more, if the dem and the stations are all sharing the same UTM zone, the above line should not be an issue... but I'm not able to try this out myself, so I'll let you update me.

leighton-watson commented 2 years ago

Fantastic! That works and the station is now plotted at the correct location.

download

Okay, without creating a new branch and implementing the change, here's my suggestion. Grab the UTM zone number from the dem (this should be defined) like so:

zone_number = dem.UTM['zone']

This defines a single UTM zone which can be used for all UTM conversions. Then, in the utm.from_latlon() call, add the kwarg force_zone_number=zone_number.

@leighton-watson can you give this a shot and let me know if it works?