SciTools / iris-esmf-regrid

A collection of structured and unstructured ESMF regridding schemes for Iris.
https://iris-esmf-regrid.readthedocs.io/en/latest
BSD 3-Clause "New" or "Revised" License
19 stars 17 forks source link

Allow regridding for projections in non-degree type units #178

Closed stephenworsley closed 11 months ago

stephenworsley commented 2 years ago

Addresses #222

Some projections, like OSGB, have units which cannot be converted to degrees (i.e. meters) and cause regridding to fail. This PR assumes that where a coordinate system exists, units ought to already be compatible with it.

codecov[bot] commented 2 years ago

Codecov Report

Merging #178 (432ebc2) into main (97d0257) will increase coverage by 0.01%. Report is 2 commits behind head on main. The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main     #178      +/-   ##
==========================================
+ Coverage   98.73%   98.75%   +0.01%     
==========================================
  Files          33       33              
  Lines        3646     3680      +34     
==========================================
+ Hits         3600     3634      +34     
  Misses         46       46              
Files Coverage Δ
esmf_regrid/schemes.py 95.60% <100.00%> (+0.03%) :arrow_up:
esmf_regrid/tests/unit/schemes/__init__.py 100.00% <100.00%> (ø)
...regrid/tests/unit/schemes/test_ESMFAreaWeighted.py 100.00% <100.00%> (ø)
...smf_regrid/tests/unit/schemes/test_ESMFBilinear.py 100.00% <100.00%> (ø)
esmf_regrid/tests/unit/schemes/test_ESMFNearest.py 100.00% <100.00%> (ø)
...egrid/tests/unit/schemes/test__cube_to_GridInfo.py 100.00% <ø> (ø)

:mega: We’re building smart automated test selection to slash your CI/CD build times. Learn more

trexfeathers commented 2 years ago

Using pyproj.Proj could be an easy way of converting these cases to degrees.

stephenworsley commented 2 years ago

Using pyproj.Proj could be an easy way of converting these cases to degrees.

This conversion ought to happen at this point: https://github.com/SciTools-incubator/iris-esmf-regrid/blob/eca3a2a0dc4d5a2e8a2c8ae8535127f719d5fa4c/esmf_regrid/_esmf_sdo.py#L224-L225

I would imagine that cartopy would be calling Proj here anyway. I think that in the case where units are supplied in meters, at this point cartopy describes the projection as being described in meters and is expecting data to be in meters. There is still a case that there could be more to be done to ensure that units are compatible with the coordinate system, but I'm not sure what it would mean for a coordinate to have a unit which disagreed with the coordinate system.

The approach I've gone for is to treat the coordinate system as the single source of truth for a coordinate where it exists. This seems the simplest way to do things for the time being.

lbdreyer commented 2 years ago

Do you plan to add some testing to this PR?

stephenworsley commented 2 years ago

Do you plan to add some testing to this PR?

Yes, I have been thinking about adding tests. I think I would ideally want some OSGB data (or a subset of such data) to work with, since thats where this problem showed up. The closest I can find in iris-test-data seems to be transverse mercator (which I think OSGB is an instance of). If you have any other ideas of data to test this on let me know.

github-actions[bot] commented 2 years ago

@SciTools-incubator/esmf-regrid-devs This pull-request is stale due to a lack of activity in the last 90 days. Remove stale label or comment, otherwise this pull-request will close automatically in 7 days time.

github-actions[bot] commented 2 years ago

@SciT@SciTools-incubator/esmf-regrid-devs This stale pull-request has been automatically closed due to no community activity

stephenworsley commented 1 year ago

I think this is still worth getting done

CLAassistant commented 11 months ago

CLA assistant check
All committers have signed the CLA.

trexfeathers commented 11 months ago

Thanks @stephenworsley!