Skip to content

Commit

Permalink
Merge pull request #1 from ACCESS-NRI/add-more-variables-live-cmoriser
Browse files Browse the repository at this point in the history
Add Ocean variables to the ACCESS-Live CMORiser
  • Loading branch information
rhaegar325 authored Nov 25, 2024
2 parents 546937f + 37e0ddb commit 5a1805f
Show file tree
Hide file tree
Showing 7 changed files with 586 additions and 5 deletions.
4 changes: 2 additions & 2 deletions doc/quickstart/find_data.rst
Original file line number Diff line number Diff line change
Expand Up @@ -615,12 +615,12 @@ 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
``frequency_attribute`` A special attribute in the filename No default
`ACCESS-ESM` raw data, it's related to
frquency 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
use the cmoriser
==================== ====================================== =================================

.. _data-retrieval:
Expand Down
36 changes: 36 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,8 @@

import logging

import numpy as np

from iris.cube import CubeList

from esmvalcore.cmor._fixes.native_datasets import NativeDatasetFix
Expand All @@ -27,3 +29,37 @@ 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

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
64 changes: 64 additions & 0 deletions esmvalcore/cmor/_fixes/access/access_esm1_5.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

from ._base_fix import AccessFix

from cf_units import Unit

logger = logging.getLogger(__name__)


Expand Down Expand Up @@ -125,3 +127,65 @@ 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)

5 changes: 4 additions & 1 deletion 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'
default:
- '{sub_dataset}.{frequency_attribute}-2000*.nc'
- 'ocean_{frequency_attribute}.nc-2000*'
output_file: '{project}_{dataset}_{mip}_{exp}_{institute}_{sub_dataset}_{special_attr}_{short_name}'
cmor_type: 'CMIP6'
cmor_default_table_prefix: 'CMIP6_'
119 changes: 119 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 @@ -66,3 +67,121 @@ ACCESS-ESM1-5:
- 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

ua:
raw_name: fld_s30i201
modeling_realm: atm

uas:
raw_name: fld_s03i209
modeling_realm: atm

va:
raw_name: fld_s30i202
modeling_realm: atm

vas:
raw_name: fld_s03i210
modeling_realm: atm

wap:
raw_name: fld_s30i208
modeling_realm: atm

zg:
raw_name: fld_s30i207
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

0 comments on commit 5a1805f

Please sign in to comment.