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 42 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 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
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
2 changes: 1 addition & 1 deletion doc/quickstart/find_data.rst
Original file line number Diff line number Diff line change
Expand Up @@ -593,7 +593,7 @@ Key Description Default value if not
``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
``freq_attribute`` A special attribute in the filename No default
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As we are changing special_attr to freq_attribute we need to edit above as well in lines 576 and 562. Maybe also add for ocean directories and and files like line 561 and 562
'{dataset}/{sub_dataset}/{exp}/{modeling_realm}'
'ocean_{freq_attribute}.nc-*'
and also add to the list of supported variables for ocean (ln 556/557)

`ACCESS-ESM` raw data, it's related to
frequency of raw data
``sub_dataset`` Part of the ACCESS-ESM raw dataset No default
Expand Down
39 changes: 39 additions & 0 deletions esmvalcore/cmor/_fixes/access/_base_fix.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import logging

import numpy as np
from iris.cube import CubeList

from esmvalcore.cmor._fixes.native_datasets import NativeDatasetFix
Expand All @@ -26,3 +27,41 @@ 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.array([int(i) for i in range(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.array([int(i) for i in range(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

def fix_ocean_aux_coords(self, cube):
"""Fix aux coords of ocean variables."""
temp_points = []
for i in cube.aux_coords[-1].points:
temp_points.append(
[j + 360 for j in i if j < 0] + [j for j in i if j >= 0]
)
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"

temp_points = []
for i in cube.aux_coords[-2].points:
temp_points.append([j.astype(np.float64) for j in i])
cube.aux_coords[-2].points = np.array(temp_points)
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"
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)
7 changes: 5 additions & 2 deletions esmvalcore/config-developer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,11 @@ ACCESS:
input_dir:
default:
- '{dataset}/{sub_dataset}/{exp}/{modeling_realm}/netCDF'
- '{dataset}/{sub_dataset}/{exp}/{modeling_realm}/'
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
7 changes: 7 additions & 0 deletions esmvalcore/local.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,13 @@ def _get_start_end_date(
datetime_pattern, date_range_pattern, stem, "datetime"
)

# ACCESS native ocean file names eg 'ocean_month.nc-18521231'
if start_date is None or end_date is None:
stem = Path(file).name
dates = re.findall(datetime_pattern, stem)
if len(dates) == 1:
start_date = end_date = dates[0][0]

# As final resort, try to get the dates from the file contents
if (
(start_date is None or end_date is None)
Expand Down
Loading