Skip to content

Commit

Permalink
fix a few bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
jlmaurer committed Jul 25, 2023
1 parent 4075d18 commit 0b90036
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
2 changes: 1 addition & 1 deletion test/test_intersect.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def test_cube_intersect(wm):
path_delays = os.path.join(SCENARIO_DIR, f'{wm}_hydro_{date}T{time.replace(":", "")}_ztd.tiff')
da = xrr.open_rasterio(path_delays, band_as_variable=True)['band_1']
hyd = da.sel(x=-117.8, y=33.4, method='nearest').item()
np.testing.assert_almost_equal(hyd, gold[wm])
np.testing.assert_almost_equal(hyd, gold[WM], decimal=4)

# Clean up files
shutil.rmtree(SCENARIO_DIR)
Expand Down
16 changes: 6 additions & 10 deletions tools/RAiDER/delay.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@
models are accessed as NETCDF files and should have "wet" "hydro"
"wet_total" and "hydro_total" fields specified.
"""
import os
import pyproj
import xarray

from datetime import datetime
from pyproj import CRS, Transformer
from typing import List, Union

Expand Down Expand Up @@ -402,18 +404,12 @@ def transformPoints(lats: np.ndarray, lons: np.ndarray, hgts: np.ndarray, old_pr
if not isinstance(old_proj, CRS):
old_proj = CRS.from_epsg(old_proj.lstrip('EPSG:'))

t = Transformer.from_crs(old_proj, new_proj)
t = Transformer.from_crs(old_proj, new_proj, always_xy=True)

in_flip = old_proj.axis_info[0].direction
out_flip = new_proj.axis_info[0].direction

if in_flip == 'east':
res = t.transform(lons, lats, hgts)
else:
res = t.transform(lats, lons, hgts)

if out_flip == 'east':
return np.stack((res[1], res[0], res[2]), axis=-1).T
else:
return np.stack(res, axis=-1).T
res = t.transform(lons, lats, hgts)

# lat/lon/height
return np.stack([res[1], res[0], res[2]], axis=-1)

0 comments on commit 0b90036

Please sign in to comment.