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

Fix for FGOALS-f3-L sftlf #667

Merged
merged 8 commits into from
Jan 7, 2021
Merged
26 changes: 24 additions & 2 deletions esmvalcore/cmor/_fixes/cmip6/fgoals_f3_l.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
"""Fixes for CMIP6 FGOALS-f3-L."""
"""Fixes for CMIP6 FGOALS-f3-L model."""
import cftime
import dask.array as da
import numpy as np

from ..fix import Fix
mwjury marked this conversation as resolved.
Show resolved Hide resolved


class AllVars(Fix):
"""Fixes for all vars."""

def fix_metadata(self, cubes):
"""Fix parent time units.

Expand Down Expand Up @@ -39,3 +39,25 @@ def fix_metadata(self, cubes):
time.bounds = time.units.date2num(
np.stack([starts, ends], -1))
return cubes


class Sftlf(Fix):
"""Fixes for sftlf."""
def fix_data(self, cube):
"""Fix data.

Unit is %, values are <= 1.

Parameters
----------
cube: iris.cube.Cube
Cube to fix

Returns
-------
iris.cube.Cube
Fixed cube. It can be a difference instance.
"""
if cube.units == "%" and da.max(cube.core_data()).compute() <= 1.:
cube.data = cube.core_data() * 100.
return cube