Skip to content

Commit

Permalink
Merge pull request #152 from ACCESS-NRI/issue-151-om3-builder
Browse files Browse the repository at this point in the history
Add ACCESS-OM3 builder
  • Loading branch information
dougiesquire committed Mar 1, 2024
2 parents c6c4449 + 1f613a7 commit 66941d7
Show file tree
Hide file tree
Showing 130 changed files with 476 additions and 5 deletions.
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
# autoapi directives
autoapi_dirs = ["../src/access_nri_intake"]
autoapi_add_toctree_entry = False
autoapi_ignore = ["*/.ipynb_checkpoints", "*/_version.py", "*/__init__.py"]
autoapi_ignore = ["*/.ipynb_checkpoints", "*/_version.py"]
autoapi_python_class_content = "both"
autoapi_options = [
"members",
Expand Down
11 changes: 9 additions & 2 deletions docs/datastores/builders.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ The access-nri-intake package is installed in the :code:`hh5` and :code:`xp65` a
users can install it into their own environment (see :ref:`installation` for details). The Builders can be
imported from the :code:`access_nri_intake.source.builders` submodule.

There are currently three Builders available. Their core public APIs are given below (their full APIs can be
There are currently four Builders available. Their core public APIs are given below (their full APIs can be
found in :ref:`source_api`).

.. note::
Expand All @@ -39,8 +39,15 @@ ACCESS-CM2 output: :code:`AccessCm2Builder`
:special-members: __init__, build, save
:noindex:

ACCESS-OM3 output: :code:`AccessOm3Builder`
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

.. autoclass:: access_nri_intake.source.builders.AccessOm3Builder
:special-members: __init__, build, save
:noindex:

.. note::

If you have ACCESS model output that isn't compatible with the existing set of Builders, check out the
:ref:`builder_create` section or open an issue
`here <https://github.com/ACCESS-NRI/access-nri-intake-catalog/issues/new/choose>`_.
`here <https://github.com/ACCESS-NRI/access-nri-intake-catalog/issues/new/choose>`_.
85 changes: 85 additions & 0 deletions src/access_nri_intake/source/builders.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,91 @@ def parser(file):
return {INVALID_ASSET: file, TRACEBACK: traceback.format_exc()}


class AccessOm3Builder(BaseBuilder):
"""Intake-ESM datastore builder for ACCESS-OM3 COSIMA datasets"""

def __init__(self, path):
"""
Initialise a AccessOm3Builder
Parameters
----------
path : str or list of str
Path or list of paths to crawl for assets/files.
"""

kwargs = dict(
path=path,
depth=2,
exclude_patterns=[
"*restart*",
"*MOM_IC.nc",
"*ocean_geometry.nc",
"*ocean.stats.nc",
"*Vertical_coordinate.nc",
],
include_patterns=["*.nc"],
data_format="netcdf",
groupby_attrs=["file_id", "frequency"],
aggregations=[
{
"type": "join_existing",
"attribute_name": "start_date",
"options": {
"dim": "time",
"combine": "by_coords",
},
},
],
)

super().__init__(**kwargs)

@staticmethod
def parser(file):
try:
(
filename,
file_id,
_,
frequency,
start_date,
end_date,
variable_list,
variable_long_name_list,
variable_standard_name_list,
variable_cell_methods_list,
variable_units_list,
) = parse_access_ncfile(file)

if ("mom6" in filename) or ("ww3" in filename):
realm = "ocean"
elif "cice" in filename:
realm = "seaIce"
else:
raise ParserError(f"Cannot determine realm for file {file}")

info = {
"path": str(file),
"realm": realm,
"variable": variable_list,
"frequency": frequency,
"start_date": start_date,
"end_date": end_date,
"variable_long_name": variable_long_name_list,
"variable_standard_name": variable_standard_name_list,
"variable_cell_methods": variable_cell_methods_list,
"variable_units": variable_units_list,
"filename": filename,
"file_id": file_id,
}

return info

except Exception:
return {INVALID_ASSET: file, TRACEBACK: traceback.format_exc()}


class AccessEsm15Builder(BaseBuilder):
"""Intake-ESM datastore builder for ACCESS-ESM1.5 datasets"""

Expand Down
16 changes: 14 additions & 2 deletions src/access_nri_intake/source/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ def _todate(t):
return cftime.num2date(t, time_var.units, calendar=time_var.calendar)

time_format = "%Y-%m-%d, %H:%M:%S"
start_date = "none"
end_date = "none"
ts = None
te = None
frequency = "fx"
has_time = time_dim in ds

Expand Down Expand Up @@ -137,7 +137,15 @@ def _todate(t):
if has_time & (frequency != "fx"):
if not has_bounds:
ts, te = _guess_start_end_dates(ts, te, frequency)

if ts is None:
start_date = "none"
else:
start_date = ts.strftime(time_format)

if te is None:
end_date = "none"
else:
end_date = te.strftime(time_format)

if frequency[0]:
Expand Down Expand Up @@ -169,7 +177,10 @@ def parse_access_filename(filename):
"""

# ACCESS output file patterns
# TODO: these should be defined per driver to prevent new patterns from breaking old drivers
not_multi_digit = "(?:\\d(?!\\d)|[^\\d](?=\\d)|[^\\d](?!\\d))"
om3_components = "(?:cice|mom6|ww3)"
ymds = "\\d{4}[_,-]\\d{2}[_,-]\\d{2}[_,-]\\d{5}"
ymd = "\\d{4}[_,-]\\d{2}[_,-]\\d{2}"
ym = "\\d{4}[_,-]\\d{2}"
y = "\\d{4}"
Expand All @@ -181,6 +192,7 @@ def parse_access_filename(filename):
r"^ocean.*[^\d]_(\d{2})$", # A few wierd files in ACCESS-OM2 01deg_jra55v13_ryf9091
r"^.*\.p.(\d{6})_.*", # ACCESS-CM2 atmosphere
r"^.*\.p.-(\d{6})_.*", # ACCESS-ESM1.5 atmosphere
rf"[^\.]*\.{om3_components}\..*({ymds}|{ymd}|{ym})$", # ACCESS-OM3
]
# Frequency translations
frequencies = {
Expand Down
1 change: 1 addition & 0 deletions tests/data/access-om3/README
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
These files were copied from a test run using an early version of ACCESS-OM3 and subsequently stripped to a test dataset that includes only single variables/grid points
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
7 changes: 7 additions & 0 deletions tests/data/access-om3/metadata.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
experiment_uuid: 4cf0c4ee-09c9-4675-ae1f-ce46f0d848ed
created: '2024-02-27'
name: MOM6-CICE6-WW3-1deg_jra55do_ryf-4cf0c4ee
model: ACCESS-OM3
url: [email protected]:COSIMA/MOM6-CICE6-WW3.git
contact: dougiesquire
email: [email protected]
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
7 changes: 7 additions & 0 deletions tests/data/access-om3/pbs_logs/1deg_jra55do_ry.e109393186
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Loading parallelio/2.5.10
Loading requirement: hdf5/1.14.1-2 netcdf-c/4.9.2 netcdf-fortran/4.6.0
Currently Loaded Modulefiles:
1) openmpi/4.1.4(default) 4) hdf5/1.14.1-2 7) parallelio/2.5.10
2) pbs 5) netcdf-c/4.9.2
3) intel-compiler/2021.6.0 6) netcdf-fortran/4.6.0
payu: Model exited with error code 233; aborting.
7 changes: 7 additions & 0 deletions tests/data/access-om3/pbs_logs/1deg_jra55do_ry.e109393326
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Loading parallelio/2.5.10
Loading requirement: hdf5/1.14.1-2 netcdf-c/4.9.2 netcdf-fortran/4.6.0
Currently Loaded Modulefiles:
1) openmpi/4.1.4(default) 4) hdf5/1.14.1-2 7) parallelio/2.5.10
2) pbs 5) netcdf-c/4.9.2
3) intel-compiler/2021.6.0 6) netcdf-fortran/4.6.0
payu: Model exited with error code 14; aborting.
6 changes: 6 additions & 0 deletions tests/data/access-om3/pbs_logs/1deg_jra55do_ry.e109493795
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Loading parallelio/2.5.10
Loading requirement: hdf5/1.14.1-2 netcdf-c/4.9.2 netcdf-fortran/4.6.0
Currently Loaded Modulefiles:
1) openmpi/4.1.4(default) 4) hdf5/1.14.1-2 7) parallelio/2.5.10
2) pbs 5) netcdf-c/4.9.2
3) intel-compiler/2021.6.0 6) netcdf-fortran/4.6.0
6 changes: 6 additions & 0 deletions tests/data/access-om3/pbs_logs/1deg_jra55do_ry.e109494482
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Loading parallelio/2.5.10
Loading requirement: hdf5/1.14.1-2 netcdf-c/4.9.2 netcdf-fortran/4.6.0
Currently Loaded Modulefiles:
1) pbs 4) hdf5/1.14.1-2 7) parallelio/2.5.10
2) openmpi/4.1.4(default) 5) netcdf-c/4.9.2
3) intel-compiler/2021.6.0 6) netcdf-fortran/4.6.0
35 changes: 35 additions & 0 deletions tests/data/access-om3/pbs_logs/1deg_jra55do_ry.o109393186
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
laboratory path: /scratch/tm70/ds0092/access-om3
binary path: /scratch/tm70/ds0092/access-om3/bin
input path: /scratch/tm70/ds0092/access-om3/input
work path: /scratch/tm70/ds0092/access-om3/work
archive path: /scratch/tm70/ds0092/access-om3/archive
Pre-existing archive found at: /scratch/tm70/ds0092/access-om3/archive/MOM6-CICE6-WW3. Experiment name will remain: MOM6-CICE6-WW3
nruns: 1 nruns_per_submit: 1 subrun: 1
Loading input manifest: manifests/input.yaml
Loading restart manifest: manifests/restart.yaml
Loading exe manifest: manifests/exe.yaml
Setting up access-om3
Checking exe and input manifests
Updating full hashes for 1 files in manifests/exe.yaml
Creating restart manifest
Writing manifests/restart.yaml
Writing manifests/exe.yaml
payu: Found modules in /opt/Modules/v4.3.0
mpirun -wdir /scratch/tm70/ds0092/access-om3/work/MOM6-CICE6-WW3 -np 48 /scratch/tm70/ds0092/access-om3/work/MOM6-CICE6-WW3/access-om3-MOM6-CICE6-WW3-3965e25
/g/data/tm70/ds0092/model/payu/MOM6-CICE6-WW3/access-om3.err /scratch/tm70/ds0092/access-om3/archive/MOM6-CICE6-WW3/error_logs/access-om3.109393186.gadi-pbs.err
/g/data/tm70/ds0092/model/payu/MOM6-CICE6-WW3/access-om3.out /scratch/tm70/ds0092/access-om3/archive/MOM6-CICE6-WW3/error_logs/access-om3.109393186.gadi-pbs.out
/g/data/tm70/ds0092/model/payu/MOM6-CICE6-WW3/job.yaml /scratch/tm70/ds0092/access-om3/archive/MOM6-CICE6-WW3/error_logs/job.109393186.gadi-pbs.yaml
/g/data/tm70/ds0092/model/payu/MOM6-CICE6-WW3/env.yaml /scratch/tm70/ds0092/access-om3/archive/MOM6-CICE6-WW3/error_logs/env.109393186.gadi-pbs.yaml

======================================================================================
Resource Usage on 2024-02-27 13:57:27:
Job Id: 109393186.gadi-pbs
Project: tm70
Exit Status: 1
Service Units: 1.01
NCPUs Requested: 48 NCPUs Used: 48
CPU Time Used: 00:04:23
Memory Requested: 192.0GB Memory Used: 20.95GB
Walltime requested: 01:00:00 Walltime Used: 00:00:38
JobFS requested: 10.0GB JobFS used: 0B
======================================================================================
34 changes: 34 additions & 0 deletions tests/data/access-om3/pbs_logs/1deg_jra55do_ry.o109393326
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
laboratory path: /scratch/tm70/ds0092/access-om3
binary path: /scratch/tm70/ds0092/access-om3/bin
input path: /scratch/tm70/ds0092/access-om3/input
work path: /scratch/tm70/ds0092/access-om3/work
archive path: /scratch/tm70/ds0092/access-om3/archive
nruns: 1 nruns_per_submit: 1 subrun: 1
Loading input manifest: manifests/input.yaml
Loading restart manifest: manifests/restart.yaml
Loading exe manifest: manifests/exe.yaml
Setting up access-om3
Checking exe and input manifests
Updating full hashes for 1 files in manifests/exe.yaml
Creating restart manifest
Writing manifests/restart.yaml
Writing manifests/exe.yaml
payu: Found modules in /opt/Modules/v4.3.0
mpirun -wdir /scratch/tm70/ds0092/access-om3/work/MOM6-CICE6-WW3 -np 48 /scratch/tm70/ds0092/access-om3/work/MOM6-CICE6-WW3/access-om3-MOM6-CICE6-WW3-3965e25
/g/data/tm70/ds0092/model/payu/MOM6-CICE6-WW3/access-om3.err /scratch/tm70/ds0092/access-om3/archive/MOM6-CICE6-WW3/error_logs/access-om3.109393326.gadi-pbs.err
/g/data/tm70/ds0092/model/payu/MOM6-CICE6-WW3/access-om3.out /scratch/tm70/ds0092/access-om3/archive/MOM6-CICE6-WW3/error_logs/access-om3.109393326.gadi-pbs.out
/g/data/tm70/ds0092/model/payu/MOM6-CICE6-WW3/job.yaml /scratch/tm70/ds0092/access-om3/archive/MOM6-CICE6-WW3/error_logs/job.109393326.gadi-pbs.yaml
/g/data/tm70/ds0092/model/payu/MOM6-CICE6-WW3/env.yaml /scratch/tm70/ds0092/access-om3/archive/MOM6-CICE6-WW3/error_logs/env.109393326.gadi-pbs.yaml

======================================================================================
Resource Usage on 2024-02-27 14:02:41:
Job Id: 109393326.gadi-pbs
Project: tm70
Exit Status: 1
Service Units: 0.88
NCPUs Requested: 48 NCPUs Used: 48
CPU Time Used: 00:11:19
Memory Requested: 192.0GB Memory Used: 34.53GB
Walltime requested: 01:00:00 Walltime Used: 00:00:33
JobFS requested: 10.0GB JobFS used: 0B
======================================================================================
26 changes: 26 additions & 0 deletions tests/data/access-om3/pbs_logs/1deg_jra55do_ry.o109493795
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
laboratory path: /scratch/tm70/ds0092/access-om3
binary path: /scratch/tm70/ds0092/access-om3/bin
input path: /scratch/tm70/ds0092/access-om3/input
work path: /scratch/tm70/ds0092/access-om3/work
archive path: /scratch/tm70/ds0092/access-om3/archive
nruns: 1 nruns_per_submit: 1 subrun: 1
Loading input manifest: manifests/input.yaml
Loading restart manifest: manifests/restart.yaml
Loading exe manifest: manifests/exe.yaml
Setting up access-om3
Checking exe and input manifests
Updating full hashes for 1 files in manifests/exe.yaml
Creating restart manifest

======================================================================================
Resource Usage on 2024-02-28 12:33:28:
Job Id: 109493795.gadi-pbs
Project: tm70
Exit Status: 271 (Linux Signal 15 SIGTERM Termination)
Service Units: 9.84
NCPUs Requested: 48 NCPUs Used: 48
CPU Time Used: 04:38:57
Memory Requested: 192.0GB Memory Used: 47.51GB
Walltime requested: 01:00:00 Walltime Used: 00:06:09
JobFS requested: 10.0GB JobFS used: 8.16MB
======================================================================================
30 changes: 30 additions & 0 deletions tests/data/access-om3/pbs_logs/1deg_jra55do_ry.o109494482
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
laboratory path: /scratch/tm70/ds0092/access-om3
binary path: /scratch/tm70/ds0092/access-om3/bin
input path: /scratch/tm70/ds0092/access-om3/input
work path: /scratch/tm70/ds0092/access-om3/work
archive path: /scratch/tm70/ds0092/access-om3/archive
nruns: 1 nruns_per_submit: 1 subrun: 1
Loading input manifest: manifests/input.yaml
Loading restart manifest: manifests/restart.yaml
Loading exe manifest: manifests/exe.yaml
Setting up access-om3
Checking exe and input manifests
Updating full hashes for 1 files in manifests/exe.yaml
Creating restart manifest
Writing manifests/restart.yaml
Writing manifests/exe.yaml
payu: Found modules in /opt/Modules/v4.3.0
mpirun -wdir /scratch/tm70/ds0092/access-om3/work/MOM6-CICE6-WW3 -np 48 /scratch/tm70/ds0092/access-om3/work/MOM6-CICE6-WW3/access-om3-MOM6-CICE6-WW3

======================================================================================
Resource Usage on 2024-02-28 12:37:35:
Job Id: 109494482.gadi-pbs
Project: tm70
Exit Status: 0
Service Units: 4.13
NCPUs Requested: 48 NCPUs Used: 48
CPU Time Used: 01:51:24
Memory Requested: 192.0GB Memory Used: 46.95GB
Walltime requested: 01:00:00 Walltime Used: 00:02:35
JobFS requested: 10.0GB JobFS used: 8.16MB
======================================================================================
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
1 change: 1 addition & 0 deletions tests/data/access-om3/restart000/rpointer.atm
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
GMOM_JRA_WD.datm.r.1900-01-02-00000.nc
1 change: 1 addition & 0 deletions tests/data/access-om3/restart000/rpointer.cpl
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
GMOM_JRA_WD.cpl.r.1900-01-02-00000.nc
1 change: 1 addition & 0 deletions tests/data/access-om3/restart000/rpointer.ice
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
./GMOM_JRA_WD.cice.r.1900-01-02-00000.nc
1 change: 1 addition & 0 deletions tests/data/access-om3/restart000/rpointer.ocn
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
GMOM_JRA_WD.mom6.r.1900-01-02-00000.nc
1 change: 1 addition & 0 deletions tests/data/access-om3/restart000/rpointer.rof
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
GMOM_JRA_WD.drof.r.1900-01-02-00000.nc
1 change: 1 addition & 0 deletions tests/data/access-om3/restart000/rpointer.wav
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
GMOM_JRA_WD.ww3.r.1900-01-02-00000
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
1 change: 1 addition & 0 deletions tests/data/access-om3/restart001/rpointer.atm
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
GMOM_JRA_WD.datm.r.1900-01-03-00000.nc
1 change: 1 addition & 0 deletions tests/data/access-om3/restart001/rpointer.cpl
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
GMOM_JRA_WD.cpl.r.1900-01-03-00000.nc
1 change: 1 addition & 0 deletions tests/data/access-om3/restart001/rpointer.ice
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
./GMOM_JRA_WD.cice.r.1900-01-03-00000.nc
1 change: 1 addition & 0 deletions tests/data/access-om3/restart001/rpointer.ocn
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
GMOM_JRA_WD.mom6.r.1900-01-03-00000.nc
1 change: 1 addition & 0 deletions tests/data/access-om3/restart001/rpointer.rof
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
GMOM_JRA_WD.drof.r.1900-01-03-00000.nc
1 change: 1 addition & 0 deletions tests/data/access-om3/restart001/rpointer.wav
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
GMOM_JRA_WD.ww3.r.1900-01-03-00000
1 change: 1 addition & 0 deletions tests/test_builders.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
7,
),
(["access-esm1-5"], "AccessEsm15Builder", {"ensemble": False}, 11, 11, 11),
(["access-om3"], "AccessOm3Builder", {}, 12, 12, 6),
],
)
def test_builder_build(
Expand Down
2 changes: 2 additions & 0 deletions tests/test_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
AccessCm2Builder,
AccessEsm15Builder,
AccessOm2Builder,
AccessOm3Builder,
)


Expand All @@ -35,6 +36,7 @@ def test_CatalogManager_init(tmp_path):
(AccessOm2Builder, "access-om2", {}),
(AccessCm2Builder, "access-cm2/by578", {"ensemble": False}),
(AccessEsm15Builder, "access-esm1-5", {"ensemble": False}),
(AccessOm3Builder, "access-om3", {}),
],
)
def test_CatalogManager_build_esm(tmp_path, test_data, builder, basedir, kwargs):
Expand Down
Loading

0 comments on commit 66941d7

Please sign in to comment.