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

Allowed arbitrary CMIP6 fx variables in special preprocessors and added a catch on project not found in config-developer (invalid project) #432

Merged
merged 16 commits into from
Jan 17, 2020

Conversation

schlunma
Copy link
Contributor

@schlunma schlunma commented Jan 15, 2020

Tasks

  • Create an issue to discuss what you are going to do, if you haven't done so already (and add the link at the bottom)
  • This pull request has a descriptive title that can be used in a changelog
  • Add unit tests
  • Public functions should have a numpy-style docstring so they appear properly in the API documentation. For all other functions a one line docstring is sufficient.
  • If writing a new/modified preprocessor function, please update the documentation
  • Circle/CI tests pass. Status can be seen below your pull request. If the tests are failing, click the link to find out why.
  • Codacy code quality checks pass. Status can be seen below your pull request. If there is an error, click the link to find out why. If you suspect Codacy may be wrong, please ask by commenting.
  • Please use yamllint to check that your YAML files do not contain mistakes
  • If you make backward incompatible changes to the recipe format, make a new pull request in the ESMValTool repository and add the link below

If you need help with any of the tasks above, please do not hesitate to ask by commenting in the issue or pull request.


Closes #431.

@schlunma schlunma added bug Something isn't working preprocessor Related to the preprocessor labels Jan 15, 2020
@schlunma schlunma self-assigned this Jan 15, 2020
Copy link
Contributor

@valeriupredoi valeriupredoi left a comment

Choose a reason for hiding this comment

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

very cool @schlunma 🍺 Note the fix for various mips here #429 -> we should merge that one first then this one

@schlunma
Copy link
Contributor Author

I think we can tackle the #429 in a more general way here. Can you test if #405 is fixed in this branch @ledm? I have to add tests for this.

@valeriupredoi
Copy link
Contributor

valeriupredoi commented Jan 16, 2020 via email

@schlunma
Copy link
Contributor Author

We only raise an error if the fx var is not in the CMOR tables, if only the files are not available no error is raised.

@valeriupredoi
Copy link
Contributor

valeriupredoi commented Jan 16, 2020 via email

@valeriupredoi
Copy link
Contributor

valeriupredoi commented Jan 16, 2020 via email

@schlunma
Copy link
Contributor Author

schlunma commented Jan 16, 2020

But why would we need/allow an fx variable name that is not in the CMOR tables? E.g. if you have a typo in your fx name, then it is really hard to figure out what is failing.

EDIT: right now, this is only done for CMIP6

@valeriupredoi
Copy link
Contributor

valeriupredoi commented Jan 16, 2020 via email

@valeriupredoi
Copy link
Contributor

valeriupredoi commented Jan 16, 2020 via email

@schlunma
Copy link
Contributor Author

Also I believe @ledm case of volcello found in Omon rather than Ofx will not work now since fx_var can not be constructed with Omon so the file search will be done with Ofx instead, and return empty

I'm pretty sure it works, this line should help:

fx_mips.append(variable['mip'])

I also added a test for it which should cover this case

@valeriupredoi

This comment has been minimized.

@schlunma
Copy link
Contributor Author

schlunma commented Jan 16, 2020

volcello is also in the table Omon, so fx_variable builds just fine 😉

@valeriupredoi

This comment has been minimized.

@valeriupredoi

This comment has been minimized.

@ledm
Copy link
Contributor

ledm commented Jan 16, 2020

Does this fix address the other problem raised in #405: Some parts of the preprocessor chain need to be applied to the fx file as well as the diagnostic variable data.

@valeriupredoi
Copy link
Contributor

valeriupredoi commented Jan 16, 2020

Nope, that's a completely different dish of curry. I'll think about that today.

Also, apologies for my previous email comments introducing my lengthy email signature 🍺

Copy link
Contributor

@valeriupredoi valeriupredoi left a comment

Choose a reason for hiding this comment

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

@schlunma I have compacted your implementation to serve irrespective of project and added a couple more tests; I am changing the Approved status (that I gave yesterday) so that you and @ledm can test 🍺

@valeriupredoi
Copy link
Contributor

BTW if I didn't say it - really nice approach @schlunma 🍺

@schlunma
Copy link
Contributor Author

schlunma commented Jan 16, 2020

BTW if I didn't say it - really nice approach @schlunma beer

Thanks 😁

I was a bit scared of expanding this to all projects, but actually this should be no problem.

One thing I mentioned: Do we check if there's a CMOR table for the project somewhere before this code? If not, then cmor_table = CMOR_TABLES[var_project] fails with a really nasty KeyError.

@valeriupredoi
Copy link
Contributor

variable (or var as in our function) is already initialized and _add_cmor_info has been run on it so CMOR_TABLES[var_project] should always return the correct cmor table, man 🍺

@valeriupredoi
Copy link
Contributor

here's a test running with a fictitious CMIP7 as variable["project"]:

esmvalcore/_recipe.py:757: in _get_single_preprocessor_task
    config_user=config_user,
esmvalcore/_data_finder.py:270: in get_output_file
    cfg = get_project_config(variable['project'])
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

project = 'CMIP7'

    def get_project_config(project):
        """Get developer-configuration for project."""
        logger.debug("Retrieving %s configuration", project)
>       return CFG[project]
E       KeyError: 'CMIP7'

esmvalcore/_config.py:171: KeyError

@schlunma
Copy link
Contributor Author

Nice, so not our business 😄

@valeriupredoi
Copy link
Contributor

of course it is, seaman Beaumont! (ref to Hunt for Red October)
Here's the catch and controlled fail 👍 🍺

@valeriupredoi
Copy link
Contributor

BTW the last test I added is a message for future us when we will run ESMValTool on CMIP7 data 🤣

@valeriupredoi valeriupredoi changed the title Allowed arbitrary CMIP6 fx variables in special preprocessors Allowed arbitrary CMIP6 fx variables in special preprocessors and added a catch on project not found in config-developer (invalid project) Jan 16, 2020
Copy link
Member

@bouweandela bouweandela left a comment

Choose a reason for hiding this comment

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

Looks good to me. @mattiarighi Could you please test?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working preprocessor Related to the preprocessor
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Use of areacella and areacello in area_statistics not supported for CMIP6
5 participants