Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Point to right directory where Hycom data is stored #206

Merged
merged 17 commits into from
Jan 10, 2022
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ coverage.xml
*.cover
.hypothesis/
.pytest_cache/
oceanspy/tests/Data
oceanspy/tests/Data/
oceanspy/tests/.ipynb_checkpoints/
oceanspy/tests/.nfs*
Expand Down
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ repos:
- id: isort

- repo: https://github.com/psf/black
rev: 21.10b0
rev: 21.12b0
hooks:
- id: black

Expand All @@ -19,7 +19,7 @@ repos:
- id: flake8

- repo: https://github.com/nbQA-dev/nbQA
rev: 1.1.1
rev: 1.2.2
hooks:
- id: nbqa-black
additional_dependencies: [black]
Expand Down
1 change: 1 addition & 0 deletions oceanspy/tests/Data
40 changes: 21 additions & 19 deletions oceanspy/tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,26 @@
# Import modules
import subprocess
import os

import pooch
from pooch import Untar

# Download data
def pytest_configure():
print("\nHello! I'm downloading test data.")

# Directory
Datadir = "./oceanspy/tests/"
# Download data if necessary
def pytest_configure():

# Download xmitgcm test
commands = [
"cd {}".format(Datadir),
"rm -fr Data",
"wget -v -O Data.tar.gz -L "
"https://livejohnshopkins-my.sharepoint.com/"
":u:/g/personal/malmans2_jh_edu/"
"EVtxjAQL13tCt7dFHNrzsrwBuqdjDe3zrvrJ625YrjrF0g"
"?download=1",
"tar xvzf Data.tar.gz",
"rm -f Data.tar.gz",
]
subprocess.call("&&".join(commands), shell=True)
fnames = pooch.retrieve(
url="https://zenodo.org/record/5825166/files/Data.tar.gz?download=1",
processor=Untar(),
known_hash="165bb4c0459a3b776efe9f94e8f7843140bc7e90b9d686af574cdb8c11006ba2",
)
symlink_args = dict(
src=f"{os.path.commonpath(fnames)}",
dst="./oceanspy/tests/Data",
target_is_directory=True,
)
try:
print(f"Linking {symlink_args['src']!r} to {symlink_args['dst']!r}")
os.symlink(**symlink_args)
except FileExistsError:
os.unlink("./oceanspy/tests/Data")
os.symlink(**symlink_args)
6 changes: 5 additions & 1 deletion oceanspy/tests/test_open_oceandataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
xmitgcm_url = "{}catalog_xmitgcm.yaml".format(Datadir)
xarray_url = "{}catalog_xarray.yaml".format(Datadir)
ECCO_url = "{}catalog_ECCO.yaml".format(Datadir)
hycom_url = "{}hycom_test.yaml".format(Datadir)


# Test SciServer
Expand All @@ -43,6 +44,7 @@ def test_find_entries(names):
("grd_rect", xarray_url),
("grd_curv", xarray_url),
("LLC", ECCO_url),
("HYCOM", hycom_url),
],
)
def test_opening_and_saving(name, catalog_url):
Expand All @@ -55,13 +57,15 @@ def test_opening_and_saving(name, catalog_url):
od1 = from_catalog(name, catalog_url)

# Check dimensions
if name != "xarray":
if name not in ["xarray", "HYCOM"]:
dimsList = ["X", "Y", "Xp1", "Yp1"]
assert set(dimsList).issubset(set(od1.dataset.dims))

# Check coordinates
if name == "LLC":
coordsList = ["XC", "YC", "XG", "YG"]
elif name == "HYCOM":
coordsList = ["XC", "YC"]
else:
coordsList = ["XC", "YC", "XG", "YG", "XU", "YU", "XV", "YV"]
assert set(coordsList).issubset(set(od1.dataset.coords))
Expand Down
37 changes: 9 additions & 28 deletions sciserver_catalogs/catalog_xarray.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1442,32 +1442,21 @@ sources:
Justin et al (2014), A new synoptic scale resolving global climate simulatoin using the Community Earth System Model. J. Adv. Model. Earth Syst., 6, 1065-1094. https:doi.org/10.1002/2014MS000363
original_output: Monthly means.


# ======================================================================
# HyCOM data test, interpolated onto lat-lon-depth coords
HYCOM_test:
description: Simulation off the Northern California Coast with HyCOM ocean mdoel
driver: netcdf
description: Simulation off the Northern California Coast with HyCOM ocean model
driver: zarr
model: HyCOM
args:
urlpath: /sciserver/oceanography/HyCOM/swot+smode/GLBy0.04_*.nc
xarray_kwargs:
engine: netcdf4
drop_variables: ['bottom_salinity','bottom_temp','bottom_u','bottom_v']
concat_dim: time
combine: by_coords
parallel: True
decode_cf: False
urlpath: /home/idies/workspace/poseidon/data10_01/HyCOM
xarray_kwargs:
engine: zarr
metadata:
rename:
water_temp: Temp
water_u: U
water_v: V
lon: X
lat: Y
depth: Z
manipulate_coords:
fillna: False
coords1Dfrom2D: False
lon: XC
lat: YC
grid_coords:
add_midp: True
grid_coords:
Expand All @@ -1484,19 +1473,11 @@ sources:
Zl: -0.5
time:
time: -0.5
parameters:
temp_offset: 20
temp_scale: 0.001
temp_fill: -30000
sal_offset: 20
sal_scale: 0.001
sal_fill: -30000
ssh_fill: 1.2676e30
name: California_Coast
description: |
High-resolution grid of the (1/25 deg) numerical simulation covering the California Coast using the HyCOM model. The original grid has 41 (isopycnal) layers but these files were interpolated to 101 vertical levels.
mates: |
Sample (test) files
projection: Mercator
original_output: snapshot.
original_output: snapshot