Skip to content

Conversation

@schlunma
Copy link
Contributor

@schlunma schlunma commented Apr 20, 2023

Description

This PR refactors the extract_shape preprocessor and makes it more flexible, by

  • allowing a dict for the ids parameter to extract regions based on a non-default attribute name (e.g., Acronym for the IPCC AR6 regions). Default names are id and name (with different capitalization options).
  • adding the shape file that describes the IPCC AR6 regions to the repository and allowing easy access to that by using shapefile: ar6.

Example:

extract_shape:
  shapefile: ar6
  method: contains
  ids:
    Acronym:
    - NEU
    - WCE
    - MED

Closes #1648
Closes #758
Related to #2007

Link to documentation:


Before you get started

Checklist

It is the responsibility of the author to make sure the pull request is ready to review. The icons indicate whether the item will be subject to the 🛠 Technical or 🧪 Scientific review.


To help with the number pull requests:

@schlunma schlunma added the enhancement New feature or request label Apr 20, 2023
@schlunma schlunma added this to the v2.9.0 milestone Apr 20, 2023
@schlunma schlunma self-assigned this Apr 20, 2023
@codecov
Copy link

codecov bot commented Apr 20, 2023

Codecov Report

Merging #2008 (f50a1ee) into main (291ce38) will increase coverage by 0.03%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main    #2008      +/-   ##
==========================================
+ Coverage   93.02%   93.06%   +0.03%     
==========================================
  Files         237      237              
  Lines       12706    12743      +37     
==========================================
+ Hits        11820    11859      +39     
+ Misses        886      884       -2     
Impacted Files Coverage Δ
esmvalcore/_recipe/recipe.py 99.01% <100.00%> (ø)
esmvalcore/preprocessor/_area.py 93.22% <100.00%> (+1.65%) ⬆️

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.

quick comment through which I am signing myself up as a reviewer for this (cheers, Manu, very good idea!) but I got a meeting in 5min so I'll be back here after that 🍺

@valeriupredoi
Copy link
Contributor

I'll review this in a jiffy, today

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.

this is very cool and very useful too - heard a few times about the need of AR6 regions in ESMValTool at the TerraFIRMA GA two weeks ago, very much cheers, Manu! I am approving because I don't want to be the ned stopping progress but I have a couple more serious questions (other than typos and minor code suggestions):

  • how big are those shapefiles?
  • I'd stay away from decalring types that may change in the future even if the external API may stay the same (eg fiona.collection.Collection)

Cheers, bud 🍺

@schlunma
Copy link
Contributor Author

schlunma commented Jun 1, 2023

Thanks V, I addressed all your comments in 8847b95!

Regarding your questions:

  • The total size of all AR6-related files is 380 K.
  • Agreed about fiona type hints; I removed them 👍

Thanks 🍻

@valeriupredoi
Copy link
Contributor

brilliant, you're a star, Manu! Ready to be merged then 🥳

@bouweandela bouweandela added preprocessor Related to the preprocessor and removed enhancement New feature or request labels Jun 2, 2023
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.

Thanks @schlunma, great addition!

@valeriupredoi
Copy link
Contributor

then @bouweandela can merge, we found us a merger too 👍

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.

Adding the "Acronym" field to Shape ID keys in order to read IPCC AR6 regions Add support for named scientific regions in extract_shape

4 participants