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

Area statistics won't work on data with lambert Conformal projection #1156

Open
thomascrocker opened this issue Jun 7, 2021 · 13 comments
Open
Assignees
Labels
bug Something isn't working data issue EUCP www.eucp-project.eu

Comments

@thomascrocker
Copy link
Contributor

For RCM data on a Lambert Conformal projection (see for example http://esg1.umr-cnrm.fr/thredds/fileServer/CORDEX_CNRM/output/EUR-11/CNRM/CNRM-CERFACS-CNRM-CM5/rcp85/r1i1p1/CNRM-ALADIN63/v2/3hr/tas/v20190419/tas_EUR-11_CNRM-CERFACS-CNRM-CM5_rcp85_r1i1p1_CNRM-ALADIN63_v2_3hr_200601010300-200701010000.nc ) the names of the x and y dim coordinates are projection_x_coordinate and projection_y_coordinate. I think this is a standard naming.

However, when dealing with irregular grids the code to calculate area statistics assumes that the names of these coordinates are grid_latitude and grid_longitude.

if 'grid_latitude' in coord_names and 'grid_longitude' in coord_names:

So the calculation of area weights fails.

This can probably be fairly easily fixed by modifying the logic on that line slightly. Creating this issue so it's on my TODO list of things to sort out re CORDEX. If I get around to creating a branch that fixes this I'll update this issue.

@thomascrocker thomascrocker added bug Something isn't working data issue EUCP www.eucp-project.eu labels Jun 7, 2021
@thomascrocker thomascrocker self-assigned this Jun 7, 2021
@zklaus zklaus added this to the v2.4.0 milestone Jun 8, 2021
@zklaus
Copy link

zklaus commented Jun 8, 2021

@thomascrocker, I am afraid the issue is more subtle. The names grid_latitude and grid_longitude are reserved for only rotated regular grids. That is the only kind of grid for which we have the ability to calculate the areas, so merely changing the names doesn't help, we would need to add calculation of areas. That would be a great addition, preferably to iris, but it substantial effort.

@thomascrocker
Copy link
Contributor Author

Ah yes, I see that the area_weights method only supports spherical co-ordinate systems.. In which case this makes it even more important that #865 and #184 are finished. This would at least allow me to regrid the data onto a regular grid as a workaround (and to be honest is needed for other purposes anyway).
What needs to be done to move them forward?

@zklaus
Copy link

zklaus commented Jun 10, 2021

I think #865 is essentially ready, we just got a bit side-tracked in the comments. #184 needs more work, I think. Either way, these will have to wait until after the 2.3.0 release.

@zklaus
Copy link

zklaus commented Oct 15, 2021

#865 is done, but #184 won't make it into this release, so I'll bump this issue to 2.5.0 as well. Sorry.

@zklaus zklaus modified the milestones: v2.4.0, v2.5.0 Oct 15, 2021
@thomascrocker
Copy link
Contributor Author

#865 is done, but #184 won't make it into this release, so I'll bump this issue to 2.5.0 as well. Sorry.

No problem, #184 doesn't conflict with anything I need to do so I'm able still able to produce the analysis I need to.

@schlunma
Copy link
Contributor

schlunma commented Feb 4, 2022

Moving this to v2.6 since there is not open PR yet.

@schlunma schlunma modified the milestones: v2.5.0, v2.6.0 Feb 4, 2022
@sloosvel sloosvel removed this from the v2.6.0 milestone Jun 7, 2022
@nhsavage
Copy link

nhsavage commented Jun 17, 2022

a summary of where I think we are with this issue

  1. we can't currently calculate area weights for data on lambert conformal grids because iris doesn't support this
  2. we can't regrid to a regular lat/lon to allow us to bypass this issue until#184 is merged

So either:

  1. we extend Iris to be able to calculate area weights (better, see iris:4812) or
  2. we complete Add general CORDEX coordinate boundary fix #184 and work around the problem using regridding

Is that a good summary?

@zklaus
Copy link

zklaus commented Jun 17, 2022

@nhsavage, if we can get the areacella "fx" file, we should be able to read the area and make things work that way. Could you try an example with added cell area? The preprocessor section should look something like

preprocessors:
  my_preprocessor:
    area_statistics:
      operator: mean
      fx_variables:
        areacella:

@nhsavage
Copy link

we can give that a go, but in general that approach is sub optimal until #1082 is merged

@nhsavage
Copy link

also - the areacella files do not appear to be uploaded for the RegCM4 family of models. This is one of the CORDEX core models and as such is a key target here (we can ask for this to be uploaded of course)

@nhsavage
Copy link

Hmm. I have been drilling down into the source code where this fails. It seems that #999 actually added the support for using cell area files already. That suggests strongly that using the fx files is a good way forward. We should try this for the original file with a more recent release of ESMValCore.

That does add extra importance to #1082 though.

For the models which are misisng areacella files, we can use a twin track approach, asking the modellers to upload these files to ESGF and in the short term making our own files

@stephenworsley
Copy link

I've had a chat with @nhsavage, I believe that iris.analysis.cartography.area_weights can be approximated by using the back end of iris-esmf regrid using the following code:

import esmf_regrid

field = esmf_regrid.schemes._cube_to_GridInfo(cube).make_esmf_field()
field.get_area()
area_weights = field.data

Note: that this is probably going to be an approximation since ESMF assumes all straight lines are great circle arcs. If this turns out to be a workable solution, I could look into making this a pubic utility function in iris-esmf-regrid. Also, this seems to involve iris guessing the bounds since they were not present on the file I was experimenting with.

@bouweandela
Copy link
Member

That does add extra importance to #1082 though.

@nhsavage An alternative approach has been implemented in the end, and has been available for a while now. See here for documentation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working data issue EUCP www.eucp-project.eu
Projects
None yet
Development

No branches or pull requests

7 participants