From 8ccb2db9baef96968779d80b936b303305cdef9f Mon Sep 17 00:00:00 2001 From: Daniel Peter Date: Wed, 18 Dec 2024 21:17:47 +0100 Subject: [PATCH] updates utm2geo python script routine to account for negative zone numbers --- utils/scripts/convert_utm2geo.py | 18 +++++++++--------- .../run_convert_IRIS_EMC_netCDF_2_tomo.py | 16 +++++++++++----- utils/scripts/run_get_simulation_topography.py | 5 ++--- 3 files changed, 22 insertions(+), 17 deletions(-) diff --git a/utils/scripts/convert_utm2geo.py b/utils/scripts/convert_utm2geo.py index fbc28cf74..f958f01a2 100755 --- a/utils/scripts/convert_utm2geo.py +++ b/utils/scripts/convert_utm2geo.py @@ -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 @@ -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: diff --git a/utils/scripts/run_convert_IRIS_EMC_netCDF_2_tomo.py b/utils/scripts/run_convert_IRIS_EMC_netCDF_2_tomo.py index 8808ceabe..cb415c26d 100755 --- a/utils/scripts/run_convert_IRIS_EMC_netCDF_2_tomo.py +++ b/utils/scripts/run_convert_IRIS_EMC_netCDF_2_tomo.py @@ -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: @@ -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 diff --git a/utils/scripts/run_get_simulation_topography.py b/utils/scripts/run_get_simulation_topography.py index 340f98e7f..da9d9508e 100755 --- a/utils/scripts/run_get_simulation_topography.py +++ b/utils/scripts/run_get_simulation_topography.py @@ -1079,7 +1079,6 @@ def geo2utm(lon,lat,zone): #--------------------------------------------------------------- - # save original parameters rlon_save = rlon rlat_save = rlat @@ -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