forked from ESMValGroup/ESMValCore
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
on-the-fly cmoriser for ACCESS native data (ESMValGroup#2430)
Co-authored-by: Yousong Zeng <Yousong> Co-authored-by: Romain Beucher <[email protected]> Co-authored-by: Manuel Schlund <[email protected]>
- Loading branch information
1 parent
f74d5c2
commit 116b83e
Showing
11 changed files
with
715 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
"""Fix base classes for ACCESS-ESM on-the-fly CMORizer.""" | ||
|
||
import logging | ||
|
||
from iris.cube import CubeList | ||
|
||
from esmvalcore.cmor._fixes.native_datasets import NativeDatasetFix | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
class AccessFix(NativeDatasetFix): | ||
"""Fixes functions.""" | ||
|
||
def fix_coord_system(self, cube): | ||
"""Delete coord_system to make CubeList able to merge.""" | ||
for dim in cube.dim_coords: | ||
if dim.coord_system is not None: | ||
cube.coord(dim.standard_name).coord_system = None | ||
|
||
def get_cubes_from_multivar(self, cubes): | ||
"""Get cube before calculate from multiple variables.""" | ||
name_list = self.extra_facets.get('raw_name', | ||
self.vardef.short_name) | ||
|
||
data_list = [] | ||
for name in name_list: | ||
data_list.append(self.get_cube(cubes, name)) | ||
return CubeList(data_list) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
"""On-the-fly CMORizer for ACCESS-ESM.""" | ||
import logging | ||
|
||
from iris.cube import CubeList | ||
|
||
from ._base_fix import AccessFix | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
class AllVars(AccessFix): | ||
"""Fixes for all variables.""" | ||
|
||
def fix_metadata(self, cubes): | ||
"""Fix metadata. | ||
Parameters | ||
---------- | ||
cubes : iris.cube.CubeList | ||
Input cubes. | ||
Returns | ||
------- | ||
iris.cube.CubeList | ||
""" | ||
if len(cubes) == 1: | ||
cube = cubes[0] | ||
else: | ||
cube = self.get_cube(cubes) | ||
|
||
# Fix coordinates | ||
self.fix_scalar_coords(cube) | ||
self.fix_var_metadata(cube) | ||
self.fix_lon_metadata(cube) | ||
self.fix_lat_metadata(cube) | ||
|
||
# Fix coordinate 'height' | ||
if 'height_0' in [var.var_name for var in cube.coords()]: | ||
self.fix_height_metadata(cube) | ||
# Fix coordinate 'pressure' | ||
if 'pressure' in [var.var_name for var in cube.coords()]: | ||
self.fix_plev_metadata(cube, coord='pressure') | ||
|
||
# Fix coord system | ||
self.fix_coord_system(cube) | ||
|
||
return CubeList([cube]) | ||
|
||
|
||
class Rlus(AccessFix): | ||
"""Fixes for Rlus.""" | ||
|
||
def fix_rlus_data(self, cubes): | ||
"""Fix rlus data.""" | ||
return cubes[0] - cubes[1] + cubes[2] - cubes[3] | ||
|
||
def fix_metadata(self, cubes): | ||
"""Fix metadata. | ||
Parameters | ||
---------- | ||
cubes : iris.cube.CubeList | ||
Input cubes. | ||
Returns | ||
------- | ||
iris.cube.CubeList | ||
""" | ||
cubes = self.get_cubes_from_multivar(cubes) | ||
|
||
cube = self.fix_rlus_data(cubes) | ||
|
||
return CubeList([cube]) | ||
|
||
|
||
class Rsus(AccessFix): | ||
"""Fixes for Rsus.""" | ||
|
||
def fix_rsus_data(self, cubes): | ||
"""Fix rsus data.""" | ||
return cubes[0] - cubes[1] | ||
|
||
def fix_metadata(self, cubes): | ||
"""Fix metadata. | ||
Parameters | ||
---------- | ||
cubes : iris.cube.CubeList | ||
Input cubes. | ||
Returns | ||
------- | ||
iris.cube.CubeList | ||
""" | ||
cubes = self.get_cubes_from_multivar(cubes) | ||
|
||
cube = self.fix_rsus_data(cubes) | ||
|
||
return CubeList([cube]) | ||
|
||
|
||
class Tas(AccessFix): | ||
"""Fixes for Rsus.""" | ||
|
||
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_height_metadata(cube) | ||
self.fix_height_value(cube) | ||
|
||
return CubeList([cube]) | ||
|
||
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] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
# Extra facets for native ACCESS model output | ||
|
||
# A complete list of supported keys is given in the documentation (see | ||
# ESMValCore/doc/quickstart/find_data.rst). | ||
--- | ||
|
||
ACCESS_ESM: | ||
|
||
'*': | ||
|
||
tas: | ||
raw_name: fld_s03i236 | ||
modeling_realm: atm | ||
|
||
pr: | ||
raw_name: fld_s05i216 | ||
modeling_realm: atm | ||
|
||
ps: | ||
raw_name: fld_s00i409 | ||
modeling_realm: atm | ||
|
||
clt: | ||
raw_name: fld_s02i204 | ||
modeling_realm: atm | ||
|
||
psl: | ||
raw_name: fld_s16i222 | ||
modeling_realm: atm | ||
|
||
hus: | ||
raw_name: fld_s30i205 | ||
modeling_realm: atm | ||
|
||
zg: | ||
raw_name: fld_s30i207 | ||
modeling_realm: atm | ||
|
||
va: | ||
raw_name: fld_s30i202 | ||
modeling_realm: atm | ||
|
||
ua: | ||
raw_name: fld_s30i201 | ||
modeling_realm: atm | ||
|
||
ta: | ||
raw_name: fld_s30i204 | ||
modeling_realm: atm | ||
|
||
rlus: | ||
raw_name: | ||
- fld_s02i207 | ||
- fld_s02i201 | ||
- fld_s03i332 | ||
- fld_s02i205 | ||
modeling_realm: atm | ||
|
||
rlds: | ||
raw_name: fld_s02i207 | ||
modeling_realm: atm | ||
|
||
rsus: | ||
raw_name: | ||
- fld_s01i235 | ||
- fld_s01i201 | ||
modeling_realm: atm | ||
|
Empty file.
Oops, something went wrong.