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

Regridding to reference dataset fails sometimes #56

Closed
schlunma opened this issue Oct 31, 2018 · 5 comments · Fixed by #1609
Closed

Regridding to reference dataset fails sometimes #56

schlunma opened this issue Oct 31, 2018 · 5 comments · Fixed by #1609
Assignees
Labels
bug Something isn't working preprocessor Related to the preprocessor

Comments

@schlunma
Copy link
Contributor

Not an urgent issue, but something I noticed:

Regridding to a reference dataset, e.g.

regrid_to_ref:
  regrid:
    target_grid: GFDL-CM3
    scheme: linear

invokes a simple iris.load_cube

https://github.com/ESMValGroup/ESMValTool/blob/43598ee48a327fc3ef2a6e53768324d02ad61863/esmvaltool/preprocessor/_regrid.py#L169

on the raw nc file, which may fail in rare cases if the file contains multiple variables (e.g rsdt of GFDL-CM3), which leads to errors like this:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "~/anaconda3/envs/esmvaltool/lib/python3.6/site-packages/iris/__init__.py", line 376, in load_cube
    raise iris.exceptions.ConstraintMismatchError(str(e))
iris.exceptions.ConstraintMismatchError: failed to merge into a single cube.
  cube.long_name differs: 'Length of average period' != 'End time for average period'
  cube.var_name differs: 'average_DT' != 'average_T2'
  cube.units differs: Unit('days') != Unit('days since 1860-01-01 00:00:00', calendar='gregorian')

I think we need an advanced loading function here.

@schlunma schlunma changed the title Regridding to reference dataset Regridding to reference dataset fails sometimes Oct 31, 2018
@bouweandela
Copy link
Member

Yes, if the dataset needs cmorization before the grid can be read it doesn't work. This should probably be fixed similar to how it is done for vertical levels in the function esmvaltool.preprocessor._regrid.get_reference_levels.

@valeriupredoi
Copy link
Contributor

this needs just the MxN grid dimensionality so a single iris.load(file, constraints=constraint) where constraint is on the var_name:

    constraint = iris.Constraint(
        cube_func=(lambda c: c.var_name == VARIABLE))

should do fine, no need to CMORize twice the same file

@bouweandela
Copy link
Member

That would work for this particular case but not in general.

@valeriupredoi
Copy link
Contributor

what sort of general case you thinking about @bouweandela

@bouweandela
Copy link
Member

Where the cmorization error is different from containing multiple variables in a single file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment