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

Development fx restructured #21

Closed
wants to merge 23 commits into from

Conversation

valeriupredoi
Copy link
Contributor

@valeriupredoi valeriupredoi commented Jun 10, 2019

Related issue #109
porting ESMValGroup/ESMValTool#1065 to ESMValCore/version2_development

@valeriupredoi valeriupredoi added preprocessor Related to the preprocessor paper labels Jun 10, 2019
@bouweandela
Copy link
Member

Can you please merge the development branch into this branch, so we can see what's new?

@valeriupredoi
Copy link
Contributor Author

Can you please merge the development branch into this branch, so we can see what's new?

le done 🍺

files = find_files(input_dirs, filenames_glob)

return files


def get_input_filelist(variable, rootpath, drs):
"""Return the full path to input files."""
# change ensemble to fixed r0i0p0 for fx variables
if variable['project'] == 'CMIP5'and variable['frequency'] == 'fx':
variable['ensemble'] = 'r0i0p0'
Copy link
Member

Choose a reason for hiding this comment

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

You're already setting the ensemble in _recipe.py, so I think there is no need to do it again here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ermm, I don't think that gets picked up for all the cases, lemme test

Copy link
Member

Choose a reason for hiding this comment

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

Have you had a chance to do this yet?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

not yet 😢

@bouweandela
Copy link
Member

bouweandela commented Jun 14, 2019

I think we should also get rid of the funky syntax for specifying fx variables. So instead of this (example from recipe_ocean_Landschuetzer2016.yml):

diagnostics:
  diag_timeseries_surface_average_vs_OBS:
    variables:
      dpco2:
        mip: Omon
        fx_files: [areacello, ]
      spco2:
        mip: Omon
        fx_files: [areacello, ]
      fgco2:
        mip: Omon
        fx_files: [areacello, ]

we should have

diagnostics:
  diag_timeseries_surface_average_vs_OBS:
    variables:
      dpco2:
        mip: Omon
      spco2:
        mip: Omon
      fgco2:
        mip: Omon
      areacello:
        mip: Omon

If we do it like this, it has the advantage that fixes and cmor checks are applied automatically to fx variables in the same way as they are applied to normal variables. The only remaining issue is then how to apply fixes to fx variables that are used as input to preprocessor functions, but that is something we can solve later.

Does this make sense?

@valeriupredoi
Copy link
Contributor Author

yes, I like that and I initially wanted to do it this way but the problem is that the preprocessor masking with fx is way more frequent in a lot of recipes than just using the fx files/variables in the diagnostics only so we need that functionality more stringently - I think we should probably leave it as is now for now, since this way (this PR) mirrors the previous functionality (with the added funky syntax yes) and set this up for a change for v2.1. What say you @mattiarighi @bouweandela @ledm

@valeriupredoi
Copy link
Contributor Author

#22 is actually doing more so might wanna look at this instead

@bouweandela
Copy link
Member

Hi V., I though that the simplification of the variable definition as described in in #21 (comment) was the whole point of this pull request. If not, what problem is this actually solving? Is there an associated issue?

@valeriupredoi
Copy link
Contributor Author

@bouweandela (sorry man, I was travelling yesterday, am fully back in work now) - this PR does a few things:

  • simplifies the code base by removing the need for dedicated fx file finding functions in _data_finder.py and dedicated structures in config-developer.yml
  • implements the usage for CMIP6 fx files that now have mips that are not just fx
  • allows for using the fx variable as a stand-alone standard variable
  • carries over the functionality for CMIP5 fx files finding and usage

Note that to have the usage of fx variables and files in the preprocessor via mask_landsea etc without explicitly declaring the fx dictionary fx_files: {'short_name': 'bla', 'mip': 'blabla'} is not trivial to implement since _recipe.py treats variables on an independent base. #22 is stepping towards that

Alas, there is no issue for this PR but there is one for both this PR and #22 in #46

@valeriupredoi
Copy link
Contributor Author

#109

files = find_files(input_dirs, filenames_glob)

return files


def get_input_filelist(variable, rootpath, drs):
"""Return the full path to input files."""
# change ensemble to fixed r0i0p0 for fx variables
if variable['project'] == 'CMIP5'and variable['frequency'] == 'fx':
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
if variable['project'] == 'CMIP5'and variable['frequency'] == 'fx':
if variable['project'] == 'CMIP5' and variable['frequency'] == 'fx':

Copy link
Contributor Author

Choose a reason for hiding this comment

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

whoops

@@ -361,6 +362,45 @@ def _get_default_settings(variable, config_user, derive=False):
return settings


def get_input_fx_filelist(variable, rootpath, drs):
Copy link
Member

Choose a reason for hiding this comment

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

I think this function should be removed altogether, it looks like it migrated here from _data_finder.py

Copy link
Contributor Author

Choose a reason for hiding this comment

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

reply below in the main body of the issue

@bouweandela
Copy link
Member

yes, I like that and I initially wanted to do it this way but the problem is that the preprocessor masking with fx is way more frequent in a lot of recipes than just using the fx files/variables in the diagnostics only so we need that functionality more stringently - I think we should probably leave it as is now for now, since this way (this PR) mirrors the previous functionality (with the added funky syntax yes) and set this up for a change for v2.1. What say you

I would prefer to have this done in this pull request. Because now it looks like a cleanup operation that is only half done, you remove the get_input_fx_filelist function from _data_finder.py, only to re-introduce it in _recipe.py.

@valeriupredoi
Copy link
Contributor Author

the problem is that we are still keeping the fx_files dictionary attached to any variable that needs it or created by the request of fx masking in the preprocessor - you can not remove this function if the fx_files is still needed. This function merely creates that dictionary and populates it with key (fx variable) and values (fx files). What you are proposing is, as I said before, nice and straightforward but a nightmare to implement in real life. Have a look at #109 and tell me if you have a good and easy way to couple VAR with FXVAR 🍺

@bouweandela
Copy link
Member

bouweandela commented Jun 26, 2019

Which preprocessor function requires a dictionary with fx files? The ones in esmvalcore/preprocessor/_mask.py only require a list of files, which can simply be returned by get_input_filelist

@bouweandela
Copy link
Member

Have a look at #109 and tell me if you have a good and easy way to couple VAR with FXVAR

That's another discussion. I've written an answer in the issue.

@valeriupredoi
Copy link
Contributor Author

Which preprocessor function requires a dictionary with fx files? The ones in esmvalcore/preprocessor/_mask.py only require a list of files, which can simply be returned by get_input_filelist

mask_landsea and mask_lanseaice need specific fx variables (sftlf, sftof, sftgif) and yes, they can be lists of files but they need to be attached to the variable that needs masking which brings us back to the issue in #109

@valeriupredoi
Copy link
Contributor Author

Have a look at #109 and tell me if you have a good and easy way to couple VAR with FXVAR

That's another discussion. I've written an answer in the issue.

yes, I saw it and makes sense but that's not gonna be easy-peasy. Would you rather soend time on that or allow a kludge like this one here. For a nice functional way we should get the independent fx variables as regular variables implementation but note that now, as things stand in the trunk, CMIP6 fx variables dont work at all so we need something in the meantime. I am buried under documentation at the moment and I can restart this only next week. Also, have you seen #22 - that fixes all the problems bar removing the fx_files dict, which can probably be done quickly

@bouweandela
Copy link
Member

removing the fx_files dict, which can probably be done quickly

If you could do that in this pull request would be great.

Also, have you seen #22

I believe that pull request includes the changes in this pull request plus extra stuff, right? If so, I think this pull request should be finished before we start on the other one.

@valeriupredoi
Copy link
Contributor Author

valeriupredoi commented Jun 26, 2019

removing the fx_files dict, which can probably be done quickly

If you could do that in this pull request would be great.

🐫 🍺

ie I'll try next week, I am knocking down the dox now, see #113 😁

@valeriupredoi
Copy link
Contributor Author

superseded for now by #170

@valeriupredoi valeriupredoi deleted the development_fx_RESTRUCTURED branch November 7, 2019 13:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
preprocessor Related to the preprocessor
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants