Skip to content

Commit

Permalink
Fixed test data, fixed filename regexp
Browse files Browse the repository at this point in the history
  • Loading branch information
marc-white committed Aug 22, 2024
1 parent 2428c2d commit a13de8b
Show file tree
Hide file tree
Showing 26 changed files with 51 additions and 7 deletions.
19 changes: 12 additions & 7 deletions src/access_nri_intake/source/builders.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,10 +162,15 @@ def validate_parser(self):
"asset list provided is None. Please run `.get_assets()` first"
)

i = 0
j = 0
for asset in self.assets:
# import pdb; pdb.set_trace()
info = self.parser(asset)
i += 1
if INVALID_ASSET not in info:
validate_against_schema(info, ESM_JSONSCHEMA)
j += 1
return self

raise ParserError(
Expand Down Expand Up @@ -519,12 +524,12 @@ class AccessOm4Builder(BaseBuilder):
"""Intake-ESM datastore builder for ACCESS-OM4 COSIMA datasets"""

PATTERNS = [
rf"[^\.]*\.{PATTERNS_HELPERS['ymd-ns']}\..*({PATTERNS_HELPERS['om4_components']}).*$", # ACCESS-OM3
rf"[^\.]*({PATTERNS_HELPERS['ymd-ns']})\.{PATTERNS_HELPERS['om4_components']}.*$", # ACCESS-OM4
]

def __init__(self, path):
"""
Initialise a AccessOm3Builder
Initialise a AccessOm4Builder
Parameters
----------
Expand All @@ -534,7 +539,7 @@ def __init__(self, path):

kwargs = dict(
path=path,
depth=2,
depth=1,
exclude_patterns=[
"*restart*",
"*MOM_IC.nc",
Expand Down Expand Up @@ -577,11 +582,11 @@ def parser(cls, file):
variable_units_list,
) = cls.parse_access_ncfile(file)

if "mom6" in filename:
if "ocean" in filename:
realm = "ocean"
elif "ww3" in filename:
realm = "wave"
elif "cice" in filename:
# elif "ww3" in filename:
# realm = "wave"
elif "ice" in filename:
realm = "seaIce"
else:
raise ParserError(f"Cannot determine realm for file {file}")
Expand Down
39 changes: 39 additions & 0 deletions tests/data/access-om4/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
Generated using the following Python on NCI ARE:

```
import netCDF4
import glob
import os

srcdir = "/g/data/ik11/outputs/mom6-om4-025/OM4_025.JRA_RYF/"
destdir = "/home/120/mcw120/scratch/"

targets = ["output000", "output001"]
target_glob = "190*.nc"

for target in targets:
srcglob = os.path.join(srcdir, target, target_glob)
srcfns = [os.path.basename(_) for _ in glob.glob(srcglob)]
for srcfn in srcfns:
with netCDF4.Dataset(os.path.join(srcdir, target, srcfn), "r") as old, netCDF4.Dataset(os.path.join(destdir, target, srcfn), "w") as new:
print(old.filepath())
print(new.filepath())
new.setncattr("file_format", old.file_format)
new.setncatts(old.__dict__)
# new.set_fill_off()
for name, dimension in old.dimensions.items():
if name == "nv":
dimn = 2
elif not dimension.isunlimited():
dimn = 1
else:
dimn = dimension.size
new.createDimension(name, dimn)
for name, variable in old.variables.items():
x = new.createVariable(name, variable.datatype, variable.dimensions)
new[name].setncatts(old[name].__dict__)
if name == "time" or name == "nv": # Need time-related data only
new[name][:] = old[name][:]
print(">> Complete!")
print("--")
```
Binary file modified tests/data/access-om4/output000/19000101.ice_daily.nc
Binary file not shown.
Binary file modified tests/data/access-om4/output000/19000101.ice_month.nc
Binary file not shown.
Binary file modified tests/data/access-om4/output000/19000101.ocean_annual.nc
Binary file not shown.
Binary file modified tests/data/access-om4/output000/19000101.ocean_annual_rho2.nc
Binary file not shown.
Binary file modified tests/data/access-om4/output000/19000101.ocean_annual_z.nc
Binary file not shown.
Binary file modified tests/data/access-om4/output000/19000101.ocean_daily.nc
Binary file not shown.
Binary file modified tests/data/access-om4/output000/19000101.ocean_month.nc
Binary file not shown.
Binary file modified tests/data/access-om4/output000/19000101.ocean_month_rho2.nc
Binary file not shown.
Binary file modified tests/data/access-om4/output000/19000101.ocean_month_z.nc
Binary file not shown.
Binary file modified tests/data/access-om4/output000/19000101.ocean_scalar_annual.nc
Binary file not shown.
Binary file modified tests/data/access-om4/output000/19000101.ocean_scalar_month.nc
Binary file not shown.
Binary file modified tests/data/access-om4/output000/19000101.ocean_static.nc
Binary file not shown.
Binary file modified tests/data/access-om4/output001/19010101.ice_daily.nc
Binary file not shown.
Binary file modified tests/data/access-om4/output001/19010101.ice_month.nc
Binary file not shown.
Binary file modified tests/data/access-om4/output001/19010101.ocean_annual.nc
Binary file not shown.
Binary file modified tests/data/access-om4/output001/19010101.ocean_annual_rho2.nc
Binary file not shown.
Binary file modified tests/data/access-om4/output001/19010101.ocean_annual_z.nc
Binary file not shown.
Binary file modified tests/data/access-om4/output001/19010101.ocean_daily.nc
Binary file not shown.
Binary file modified tests/data/access-om4/output001/19010101.ocean_month.nc
Binary file not shown.
Binary file modified tests/data/access-om4/output001/19010101.ocean_month_rho2.nc
Binary file not shown.
Binary file modified tests/data/access-om4/output001/19010101.ocean_month_z.nc
Binary file not shown.
Binary file modified tests/data/access-om4/output001/19010101.ocean_scalar_annual.nc
Binary file not shown.
Binary file modified tests/data/access-om4/output001/19010101.ocean_scalar_month.nc
Binary file not shown.
Binary file modified tests/data/access-om4/output001/19010101.ocean_static.nc
Binary file not shown.

0 comments on commit a13de8b

Please sign in to comment.