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

Add ocean variable to the ACCESS Live CMORiser #2601

Open
wants to merge 103 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 101 commits
Commits
Show all changes
103 commits
Select commit Hold shift + click to select a range
e6d7253
add regular express facet
rhaegar325 Jul 23, 2024
6aff095
add ocean variables
rhaegar325 Oct 21, 2024
76f147e
add more atm variables
rhaegar325 Oct 23, 2024
c765261
update config-dev.yml and add test recipe
rhaegar325 Nov 8, 2024
2ea176e
update config-dev.yml and add test recipe
rhaegar325 Nov 8, 2024
1770e41
delete regular_expression in doc
rhaegar325 Nov 25, 2024
1f95013
fix units
rhaegar325 Nov 25, 2024
37e0ddb
fix test_access_esm1_5.py
rhaegar325 Nov 25, 2024
5a1805f
Merge pull request #1 from ACCESS-NRI/add-more-variables-live-cmoriser
rhaegar325 Nov 25, 2024
41e3529
tune format
rhaegar325 Nov 26, 2024
31ec2ca
fix documentation issue
rhaegar325 Nov 26, 2024
97eea6e
fix function doc format
rhaegar325 Nov 26, 2024
7c6db47
fix doc
rhaegar325 Nov 26, 2024
f1fd769
fix function format
rhaegar325 Nov 26, 2024
445335e
fix function format
rhaegar325 Nov 26, 2024
7525421
fix format
rhaegar325 Nov 27, 2024
48e6aa2
resolve conflict
rhaegar325 Dec 1, 2024
5e12dc5
test
rhaegar325 Dec 1, 2024
07d99c2
fix errror
rhaegar325 Dec 1, 2024
e100b89
fix doc error
rhaegar325 Dec 1, 2024
041b50f
fix link break
rhaegar325 Dec 1, 2024
f081537
fix repeat
rhaegar325 Dec 1, 2024
a1782bc
fix repeat
rhaegar325 Dec 1, 2024
771901f
fix units error
rhaegar325 Dec 1, 2024
4561d90
fix units error
rhaegar325 Dec 1, 2024
79931cb
fix assert error
rhaegar325 Dec 1, 2024
98caf58
fix assert error
rhaegar325 Dec 1, 2024
ff2e659
fix assert error
rhaegar325 Dec 1, 2024
d65df55
fix assert error
rhaegar325 Dec 1, 2024
f0123ed
fix assert error
rhaegar325 Dec 2, 2024
7a066a8
fix assert error
rhaegar325 Dec 2, 2024
f286722
fix assert error
rhaegar325 Dec 2, 2024
e76c43b
fix test script
rhaegar325 Dec 2, 2024
4a15aa5
fix test script
rhaegar325 Dec 2, 2024
10c8c92
fix test script
rhaegar325 Dec 2, 2024
3dcd50c
Fix some formatting issues
rbeucher Dec 2, 2024
d834941
Fix some issues in tests
rbeucher Dec 2, 2024
7251007
Remove extra blank lines
rbeucher Dec 2, 2024
ea1734b
Fix format
rbeucher Dec 2, 2024
1db17eb
add date check in filename for native ACCESS ocean files
flicj191 Dec 9, 2024
a28a8a9
add date check in filename for native ACCESS ocean files
flicj191 Dec 9, 2024
fc8b6d8
add date check in filename for native ACCESS ocean files. fix format
flicj191 Dec 9, 2024
c8cc31a
Merge branch 'main' into add-ocean-variable-access-live-cmoriser
rbeucher Jan 29, 2025
df85ac9
Merge branch 'main' into add-ocean-variable-access-live-cmoriser
rbeucher Feb 11, 2025
0da2aa4
fix coordinate unit
rhaegar325 Feb 18, 2025
8761d83
fix ocean grid
rhaegar325 Feb 20, 2025
65ff1f9
fix test issue while add grid
rhaegar325 Feb 21, 2025
e7c17cc
fix test
rhaegar325 Feb 21, 2025
679536a
fix test
rhaegar325 Feb 21, 2025
a960370
fix _base_fix.py
rhaegar325 Feb 21, 2025
1769308
fix format issue
rhaegar325 Feb 21, 2025
8f93e75
fix format
rhaegar325 Feb 21, 2025
8f31eb3
fix format
rhaegar325 Feb 21, 2025
77359a9
fix format
rhaegar325 Feb 21, 2025
44c3b96
fix format
rhaegar325 Feb 21, 2025
ed7297c
fix format
rhaegar325 Feb 26, 2025
ad175db
Increase version number for v.2.12.0rc1 (#2660)
sloosvel Feb 13, 2025
bea94a8
Add release notes for v2.12.0rc1 (#2662)
sloosvel Feb 13, 2025
11eb07e
Fix test that loads realistic GRIB file (#2665)
schlunma Feb 17, 2025
970da54
Fix failing test with Dask 2025.2: ours issue not theirs (#2663)
valeriupredoi Feb 17, 2025
cdb966b
Update CMIP5 EC-EARTH pr fix (#2666)
bouweandela Feb 19, 2025
9b04a99
Add a fix for differing index coord long names in NorESM2-MM and EC-E…
bouweandela Feb 19, 2025
1d0d7e5
Pin sphinx to < 8.2 (#2671)
bouweandela Feb 20, 2025
ec8406a
Add option to ignore horizontal coordinates if there are multiple whe…
bouweandela Feb 20, 2025
a81d256
Always write target coordinates to source cube after regridding (#2673)
schlunma Feb 21, 2025
cb189ab
Increase version for v2.12.0rc2 and update changelog (#2675)
sloosvel Feb 21, 2025
e3eeac6
[Condalock] Update Linux condalock file (#2674)
github-actions[bot] Feb 21, 2025
1ad3fb7
Ignore overflow errors when converting branch times (#2668)
bouweandela Feb 24, 2025
99e7c34
add regular express facet
rhaegar325 Jul 23, 2024
f70721f
add ocean variables
rhaegar325 Oct 21, 2024
8d93b03
add more atm variables
rhaegar325 Oct 23, 2024
41615d2
fix documentation issue
rhaegar325 Nov 26, 2024
ff44c07
fix doc
rhaegar325 Nov 26, 2024
3cc699f
test
rhaegar325 Dec 1, 2024
3a85d6d
fix assert error
rhaegar325 Dec 1, 2024
d3645e5
Fix some formatting issues
rbeucher Dec 2, 2024
c450bdf
Fix format
rbeucher Dec 2, 2024
19a6a13
fix coordinate unit
rhaegar325 Feb 18, 2025
3aeca77
fix ocean grid
rhaegar325 Feb 20, 2025
140de42
fix test issue while add grid
rhaegar325 Feb 21, 2025
b2f980a
fix _base_fix.py
rhaegar325 Feb 21, 2025
874ef69
fix format issue
rhaegar325 Feb 21, 2025
456540f
fix format
rhaegar325 Feb 26, 2025
f444af2
fix exttra_facets
rhaegar325 Feb 26, 2025
127fc03
fix typo
rhaegar325 Feb 26, 2025
24d92b2
fix typo
rhaegar325 Feb 26, 2025
14ccc36
fix format
rhaegar325 Feb 26, 2025
620893c
fix format
rhaegar325 Feb 26, 2025
6a88d62
fix format
rhaegar325 Feb 26, 2025
719af9b
Removed trailing whitespace
rhaegar325 Feb 26, 2025
2a48fee
fix ruff-format issue
rhaegar325 Feb 26, 2025
0989a21
fix grid_path
rhaegar325 Feb 26, 2025
619c38c
fix grid_path
rhaegar325 Feb 27, 2025
aec2d22
fix grid_path
rhaegar325 Feb 27, 2025
c5078fa
fix grid_path
rhaegar325 Feb 27, 2025
58384d4
fix grid_path
rhaegar325 Feb 27, 2025
4639bfb
fix grid_path
rhaegar325 Feb 27, 2025
4d5ea40
add explaination of ocean-grid-path in doc
rhaegar325 Feb 27, 2025
60a4ea6
Merge branch 'main' into add-ocean-variable-access-live-cmoriser
rhaegar325 Feb 27, 2025
fab92af
Merge branch 'main' into add-ocean-variable-access-live-cmoriser
rbeucher Mar 3, 2025
039403a
change numpy usage
rhaegar325 Mar 3, 2025
838e24f
change numpy usage
rhaegar325 Mar 3, 2025
06889f5
Merge branch 'main' into add-ocean-variable-access-live-cmoriser
rhaegar325 Mar 3, 2025
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
31 changes: 17 additions & 14 deletions doc/quickstart/find_data.rst
Original file line number Diff line number Diff line change
Expand Up @@ -679,21 +679,24 @@ For some variables, extra facets are necessary; otherwise ESMValCore cannot
read them properly.
Supported keys for extra facets are:

==================== ====================================== =================================
Key Description Default value if not specified
==================== ====================================== =================================
``raw_name`` Variable name of the variable in the CMOR variable name of the
raw input file corresponding variable
``modeling_realm`` Realm attribute include `atm`, `ice` No default (needs to be
and `oce` specified in extra facets or
recipe if default DRS is used)
```special_attr`` A special attribute in the filename No default
`ACCESS-ESM` raw data, it's related to
==================== ========================================== ====================================
Key Description Default value if not specified
==================== ========================================== ====================================
``raw_name`` Variable name of the variable in the CMOR variable name of the
raw input file corresponding variable
``modeling_realm`` Realm attribute includes `atm`, `ice`, No default (needs to be
and `oce` specified in extra facets or
recipe if default DRS is used)
``freq_attribute`` A special attribute in the filename No default
`ACCESS-ESM` raw data, related to the
frequency of raw data
``sub_dataset`` Part of the ACCESS-ESM raw dataset No default
root, need to specify if you want to
use the cmoriser
==================== ====================================== =================================
``sub_dataset`` Part of the ACCESS-ESM raw dataset root, No default
needs to be specified if you want to use
the cmoriser
``ocean_grid_path`` Path to load the grid data for ACCESS No default
ocean variables
==================== ========================================== ====================================


.. _data-retrieval:

Expand Down
96 changes: 96 additions & 0 deletions esmvalcore/cmor/_fixes/access/_base_fix.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
"""Fix base classes for ACCESS-ESM on-the-fly CMORizer."""

import logging
import warnings
from pathlib import Path

import iris
import numpy as np
from cf_units import Unit
from iris.cube import CubeList

from esmvalcore.cmor._fixes.native_datasets import NativeDatasetFix
Expand All @@ -26,3 +31,94 @@ def get_cubes_from_multivar(self, cubes):
for name in name_list:
data_list.append(self.get_cube(cubes, name))
return CubeList(data_list)

def fix_ocean_dim_coords(self, cube):
"""Fix dim coords of ocean variables."""
cube.dim_coords[-2].points = np.arange(300)
cube.dim_coords[-2].standard_name = None
cube.dim_coords[-2].var_name = "j"
cube.dim_coords[-2].long_name = "cell index along second dimension"
cube.dim_coords[-2].attributes = None

cube.dim_coords[-1].points = np.arange(360)
cube.dim_coords[-1].standard_name = None
cube.dim_coords[-1].var_name = "i"
cube.dim_coords[-1].long_name = "cell index along first dimension"
cube.dim_coords[-1].attributes = None
cube.dim_coords[-1].units = Unit(1)

def fix_ocean_aux_coords(self, cube):
"""Fix aux coords of ocean variables."""
lat_bounds, lon_bounds = self.load_ocean_grid_data("ocean_grid_path")
temp_points = []
for i in cube.aux_coords[-1].points:
temp_points.append([j % 360 for j in i])
cube.aux_coords[-1].points = np.array(temp_points)
cube.aux_coords[-1].standard_name = "longitude"
cube.aux_coords[-1].long_name = "longitude"
cube.aux_coords[-1].var_name = "longitude"
cube.aux_coords[-1].attributes = None
cube.aux_coords[-1].units = "degrees"
cube.aux_coords[-1].bounds = lon_bounds

cube.aux_coords[-2].points = np.array(
cube.aux_coords[-2].points, dtype=np.float64
)
cube.aux_coords[-2].standard_name = "latitude"
cube.aux_coords[-2].long_name = "latitude"
cube.aux_coords[-2].var_name = "latitude"
cube.aux_coords[-2].attributes = None
cube.aux_coords[-2].units = "degrees"
cube.aux_coords[-2].bounds = lat_bounds

def _get_path_from_facet(self, facet):
"""Try to get path from facet."""
path = Path(self.extra_facets[facet])
if not path.is_file():
raise FileNotFoundError(
f"'{path}' given by facet '{facet}' does not exist"
)
return path

def load_ocean_grid_data(self, facet):
"""Load supplementary grid data for ACCESS ocean variable."""
path_to_grid_data = self._get_path_from_facet(facet)
cubes = self._load_cubes(path_to_grid_data)

y_vert_t = [cube for cube in cubes if cube.var_name == "y_vert_T"][0]
lat_bounds = np.transpose(y_vert_t.data, (1, 2, 0))
x_vert_t = [cube for cube in cubes if cube.var_name == "x_vert_T"][0]
lon_bounds = np.transpose(x_vert_t.data, (1, 2, 0))

return lat_bounds, lon_bounds

@staticmethod
def _load_cubes(path: Path | str) -> CubeList:
"""Load cubes and ignore certain warnings."""
with warnings.catch_warnings():
warnings.filterwarnings(
"ignore",
message="Ignoring netCDF variable .* invalid units .*",
category=UserWarning,
module="iris",
) # iris < 3.8
warnings.filterwarnings(
"ignore",
message="Ignoring invalid units .* on netCDF variable .*",
category=UserWarning,
module="iris",
) # iris >= 3.8
warnings.filterwarnings(
"ignore",
message="Gracefully filling .* dimension coordinate.*",
category=UserWarning,
module="iris",
)
warnings.filterwarnings(
"ignore",
message="Failed to create .*dimension coordinate.*",
category=UserWarning,
module="iris",
)
cubes = iris.load(path)
return cubes
61 changes: 61 additions & 0 deletions esmvalcore/cmor/_fixes/access/access_esm1_5.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import logging

from cf_units import Unit
from iris.cube import CubeList

from ._base_fix import AccessFix
Expand Down Expand Up @@ -126,3 +127,63 @@ def fix_height_value(self, cube):
"""Fix height value to make it comparable to other dataset."""
if cube.coord("height").points[0] != 2:
cube.coord("height").points = [2]


class Tos(AccessFix):
"""Fixes for Tos."""

def fix_metadata(self, cubes):
"""Fix metadata.

Parameters
----------
cubes : iris.cube.CubeList
Input cubes.

Returns
-------
iris.cube.CubeList
"""
cube = self.get_cube(cubes)

self.fix_ocean_dim_coords(cube)
self.fix_ocean_aux_coords(cube)

return CubeList([cube])


class So(AccessFix):
"""FIxes for So."""

def fix_metadata(self, cubes):
"""Fix metadata.

Parameters
----------
cubes : iris.cube.CubeList
Input cubes.

Returns
-------
iris.cube.CubeList
"""
cube = self.get_cube(cubes)

self.fix_ocean_dim_coords(cube)
self.fix_ocean_aux_coords(cube)
self.fix_depth_metadata(cube)
self.fix_so_units(cube)

return CubeList([cube])

def fix_depth_metadata(self, cube):
"""Fix depth metadata."""
cube.dim_coords[1].standard_name = "depth"
cube.dim_coords[1].long_name = "ocean depth coordinate"
cube.dim_coords[1].var_name = "lev"
cube.dim_coords[1].attributes = {"positive": "down"}

def fix_so_units(self, cube):
"""Fix units of so."""
cube.attributes.pop("invalid_units")
cube.units = Unit(0.001)
6 changes: 4 additions & 2 deletions esmvalcore/config-developer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,9 @@ ACCESS:
default:
- '{dataset}/{sub_dataset}/{exp}/{modeling_realm}/netCDF'
input_file:
default: '{sub_dataset}.{special_attr}-*.nc'
output_file: '{project}_{dataset}_{mip}_{exp}_{institute}_{sub_dataset}_{special_attr}_{short_name}'
default:
- '{sub_dataset}.{freq_attribute}-*.nc'
- 'ocean_{freq_attribute}.nc-*'
output_file: '{project}_{dataset}_{mip}_{exp}_{institute}_{sub_dataset}_{freq_attribute}_{short_name}'
cmor_type: 'CMIP6'
cmor_default_table_prefix: 'CMIP6_'
107 changes: 107 additions & 0 deletions esmvalcore/config/extra_facets/access-mappings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
ACCESS-ESM1-5:

'*':
# atm

tas:
raw_name: fld_s03i236
Expand Down Expand Up @@ -65,3 +66,109 @@ ACCESS-ESM1-5:
- fld_s01i235
- fld_s01i201
modeling_realm: atm

clivi:
raw_name: fld_s30i406
modeling_realm: atm

evspsbl:
raw_name: fld_s03i223
modeling_realm: atm

hfls:
raw_name: fld_s03i234
modeling_realm: atm

hfss:
raw_name: fld_s03i217
modeling_realm: atm

hur:
raw_name: fld_s30i206
modeling_realm: atm

hurs:
raw_name: fld_s03i245
modeling_realm: atm

huss:
raw_name: fld_s03i237
modeling_realm: atm

prsn:
raw_name: fld_s05i215
modeling_realm: atm

rldscs:
raw_name: fld_s02i208
modeling_realm: atm

rsdt:
raw_name: fld_s01i207
modeling_realm: atm

rsuscs:
raw_name: fld_s01i211
modeling_realm: atm

rsut:
raw_name: fld_s01i208
modeling_realm: atm

rsutcs:
raw_name: fld_s01i209
modeling_realm: atm

sci:
raw_name: fld_s05i270
modeling_realm: atm

sfcWind:
raw_name: fld_s03i230
modeling_realm: atm

sfcWindmax:
raw_name: fld_s03i227_max
modeling_realm: atm

tauu:
raw_name: fld_s03i460
modeling_realm: atm

tauv:
raw_name: fld_s03i461
modeling_realm: atm

ts:
raw_name: fld_s00i024
modeling_realm: atm

uas:
raw_name: fld_s03i209
modeling_realm: atm

vas:
raw_name: fld_s03i210
modeling_realm: atm

wap:
raw_name: fld_s30i208
modeling_realm: atm

rls:
raw_name: fld_s02i201
modeling_realm: atm

rss:
raw_name: fld_s01i201
modeling_realm: atm

# ocean

tos:
raw_name: sst
modeling_realm: ocn

so:
raw_name: salt
modeling_realm: ocn
Loading