Skip to content

Commit 7d4777c

Browse files
authored
Merge pull request #21 from kthyng/main
Get up to date
2 parents 011d89e + 826c8bf commit 7d4777c

File tree

5 files changed

+416
-362
lines changed

5 files changed

+416
-362
lines changed

.github/workflows/pre-commit.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ jobs:
1111
steps:
1212
- uses: actions/checkout@v1
1313
- uses: actions/setup-python@v1
14-
- name: set PY
15-
run: echo "::set-env name=PY::$(python --version --version | sha256sum | cut -d' ' -f1)"
1614
- uses: actions/cache@v1
1715
with:
1816
path: ~/.cache/pre-commit

xroms/interp.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
Interpolation functions.
33
"""
44

5+
import sys
56
import warnings
67

78
import numpy as np
@@ -13,8 +14,8 @@
1314

1415
try:
1516
import xesmf as xe
16-
except ImportError:
17-
warnings.warn("xESMF is not installed, so `interpll` will not run.", ImportWarning)
17+
except ModuleNotFoundError:
18+
warnings.warn("xESMF is not installed, so `interpll` will not run.")
1819

1920

2021
def interpll(var, lons, lats, which="pairs"):
@@ -59,6 +60,13 @@ def interpll(var, lons, lats, which="pairs"):
5960
>>> xroms.interpll(var, [-96, -97, -96.5], [26.5, 27, 26.5], which='grid')
6061
"""
6162

63+
# make sure that xesmf was read in for this function to run
64+
try:
65+
xe
66+
except NameError:
67+
print("xESMF is not installed, so `interpll` will not run.")
68+
return
69+
6270
# rename coords for use with xESMF
6371
lonkey = [coord for coord in var.coords if "lon_" in coord][0]
6472
latkey = [coord for coord in var.coords if "lat_" in coord][0]

xroms/roms_seawater.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,9 @@ def density(temp, salt, z=None):
143143
var.attrs["long_name"] = "density"
144144
var.attrs["units"] = "kg/m^3" # inherits grid from temp
145145
var.name = var.attrs["name"]
146-
var.coords["lon_rho"].attrs["standard_name"] = "longitude"
147-
var.coords["lat_rho"].attrs["standard_name"] = "latitude"
146+
if "lon_rho" in var:
147+
var.coords["lon_rho"].attrs["standard_name"] = "longitude"
148+
var.coords["lat_rho"].attrs["standard_name"] = "latitude"
148149

149150
return var
150151

xroms/tests/test_accessor.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -531,7 +531,7 @@ def test_to_grid():
531531

532532
def test_sel2d():
533533
lon0, lat0 = -94.8, 28.0
534-
testvars = ["salt", "u", "v", "z_w"]
534+
testvars = ["salt", "u", "v"]
535535
for testvar in testvars:
536536
acc = ds[testvar].xroms.sel2d(lon0, lat0)
537537
out = xroms.sel2d(
@@ -556,7 +556,7 @@ def test_sel2d():
556556

557557
def test_argsel2d():
558558
lon0, lat0 = -94.8, 28.0
559-
testvars = ["salt", "u", "v", "z_w"]
559+
testvars = ["salt", "u", "v"]
560560
for testvar in testvars:
561561
inds = ds[testvar].xroms.argsel2d(lon0, lat0)
562562
outinds = xroms.argsel2d(
@@ -566,7 +566,7 @@ def test_argsel2d():
566566

567567

568568
def test_gridmean():
569-
testvars = ["salt", "u", "v", "z_w"]
569+
testvars = ["salt", "u", "v"]
570570
for testvar in testvars:
571571
for axis in ["Z", "Y", "X"]:
572572
var1 = ds[testvar].xroms.gridmean(axis)
@@ -575,7 +575,7 @@ def test_gridmean():
575575

576576

577577
def test_gridsum():
578-
testvars = ["salt", "u", "v", "z_w"]
578+
testvars = ["salt", "u", "v"]
579579
for testvar in testvars:
580580
for axis in ["Z", "Y", "X"]:
581581
var1 = ds[testvar].xroms.gridsum(axis)
@@ -586,7 +586,7 @@ def test_gridsum():
586586
def test_interpll():
587587
ie, ix = 2, 3
588588
indexer = {"eta_rho": [ie], "xi_rho": [ix]}
589-
testvars = ["salt", "u", "v", "z_w"]
589+
testvars = ["salt", "u", "v"]
590590
for testvar in testvars:
591591
var1 = xroms.interpll(
592592
ds[testvar], ds.lon_rho.isel(indexer), ds.lat_rho.isel(indexer)
@@ -598,7 +598,7 @@ def test_interpll():
598598

599599

600600
def test_zslice():
601-
testvars = ["salt", "u", "v", "z_w"]
601+
testvars = ["salt", "u", "v"]
602602
for testvar in testvars:
603603
varin = ds[testvar]
604604
depths = np.asarray(ds[testvar].cf["vertical"][0, :, 0, 0].values)

0 commit comments

Comments
 (0)