Skip to content

Commit

Permalink
updates utm2geo python script routine to account for negative zone nu…
Browse files Browse the repository at this point in the history
…mbers
  • Loading branch information
danielpeter committed Dec 18, 2024
1 parent 352ab97 commit 8ccb2db
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 17 deletions.
18 changes: 9 additions & 9 deletions utils/scripts/convert_utm2geo.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,15 +104,6 @@ def utm_geo(lon,lat,zone,iway,ellipsoid=23):

#---------------------------------------------------------------

# lon/lat
if iway == IUTM2LONGLAT:
xx = lon
yy = lat
else:
dlon = lon
dlat = lat


#----- Set Zone parameters
# zone
UTM_PROJECTION_ZONE = zone
Expand All @@ -124,6 +115,15 @@ def utm_geo(lon,lat,zone,iway,ellipsoid=23):
cm = zone * 6.0 - 183.0 # set central meridian for this zone
cmr = cm * degrad

# lon/lat
if iway == IUTM2LONGLAT:
xx = lon
yy = lat
if lsouth: yy = yy - 1.e7
else:
dlon = lon
dlat = lat

#---- Lat/Lon to UTM conversion
if iway == ILONGLAT2UTM:

Expand Down
16 changes: 11 additions & 5 deletions utils/scripts/run_convert_IRIS_EMC_netCDF_2_tomo.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,18 +298,23 @@ def geo2utm(lon,lat,zone):
e6 = e2 * e4
ep2 = e2/(1.0 - e2)

#----- Set Zone parameters
# zone
lsouth = False
if UTM_PROJECTION_ZONE < 0: lsouth = True
zone = abs(UTM_PROJECTION_ZONE)

cm = zone * 6.0 - 183.0 # set central meridian for this zone
cmr = cm*degrad

if iway == IUTM2LONGLAT:
xx = rx
yy = ry
if lsouth: yy = yy - 1.e7
else:
dlon = rlon
dlat = rlat

#----- Set Zone parameters
zone = UTM_PROJECTION_ZONE
cm = zone * 6.0 - 183.0 # set central meridian for this zone
cmr = cm*degrad

#---- Lat/Lon to UTM conversion
if iway == ILONGLAT2UTM:

Expand Down Expand Up @@ -412,6 +417,7 @@ def geo2utm(lon,lat,zone):

else:
rx = xx
if lsouth: yy = yy + 1.e7
ry = yy
rlon = rlon_save
rlat = rlat_save
Expand Down
5 changes: 2 additions & 3 deletions utils/scripts/run_get_simulation_topography.py
Original file line number Diff line number Diff line change
Expand Up @@ -1079,7 +1079,6 @@ def geo2utm(lon,lat,zone):

#---------------------------------------------------------------


# save original parameters
rlon_save = rlon
rlat_save = rlat
Expand All @@ -1093,11 +1092,11 @@ def geo2utm(lon,lat,zone):
ep2 = e2/(1.0 - e2)

#----- Set Zone parameters

# zone
lsouth = False
if UTM_PROJECTION_ZONE < 0: lsouth = True

zone = abs(UTM_PROJECTION_ZONE)

cm = zone * 6.0 - 183.0 # set central meridian for this zone
cmr = cm*degrad

Expand Down

0 comments on commit 8ccb2db

Please sign in to comment.