NCPP / ocgis

OpenClimateGIS is a set of geoprocessing and calculation tools for CF-compliant climate datasets.
Other
70 stars 21 forks source link

Option to wrap lat/lon grids #419

Closed bekozi closed 8 years ago

bekozi commented 8 years ago

Provide a request dataset parameter to wrap grids before subsetting. This is relevant to: https://github.com/bird-house/flyingpigeon/issues/17#issuecomment-210621463. It is important that masked values are removed during a subset across the meridian.

@nilshempelmann

bekozi commented 8 years ago

@nilshempelmann do you want to test the wrapping option before merging? I think it would be a good idea. You can find the code in the https://github.com/NCPP/ocgis/tree/i419-wrap-option branch. The documentation for the new spatial_wrapping operations parameter is here: https://github.com/NCPP/ocgis/blob/i419-wrap-option/doc/api.rst#spatial_wrapping.

Let me know if you have any questions!

nilshempelmann commented 8 years ago

latitude looks fine, but seems there is still a problem with the longitude:

bbox = [-20,-20,20,20]

Also the the longitude output is:

[ 0. 1.875 3.75 5.625 7.5 9.375 11.25 13.125

  1. 16.875 18.75 20.625 22.5 24.375 26.25 28.125
  2. 31.875 33.75 35.625 37.5 39.375 41.25 43.125
  3. 46.875 48.75 50.625 52.5 54.375 56.25 58.125
  4. 61.875 63.75 65.625 67.5 69.375 71.25 73.125
  5. 76.875 78.75 80.625 82.5 84.375 86.25 88.125
  6. 91.875 93.75 95.625 97.5 99.375 101.25 103.125
    1. 106.875 108.75 110.625 112.5 114.375 116.25 118.125
    2. 121.875 123.75 125.625 127.5 129.375 131.25 133.125
    3. 136.875 138.75 140.625 142.5 144.375 146.25 148.125
    4. 151.875 153.75 155.625 157.5 159.375 161.25 163.125
    5. 166.875 168.75 170.625 172.5 174.375 176.25 178.125
    6. -178.125 -176.25 -174.375 -172.5 -170.625 -168.75 -166.875 -165. -163.125 -161.25 -159.375 -157.5 -155.625 -153.75 -151.875 -150. -148.125 -146.25 -144.375 -142.5 -140.625 -138.75 -136.875 -135. -133.125 -131.25 -129.375 -127.5 -125.625 -123.75 -121.875 -120. -118.125 -116.25 -114.375 -112.5 -110.625 -108.75 -106.875 -105. -103.125 -101.25 -99.375 -97.5 -95.625 -93.75 -91.875 -90. -88.125 -86.25 -84.375 -82.5 -80.625 -78.75 -76.875 -75. -73.125 -71.25 -69.375 -67.5 -65.625 -63.75 -61.875 -60. -58.125 -56.25 -54.375 -52.5 -50.625 -48.75 -46.875 -45. -43.125 -41.25 -39.375 -37.5 -35.625 -33.75 -31.875 -30. -28.125 -26.25 -24.375 -22.5 -20.625 -18.75 -16.875 -15. -13.125 -11.25 -9.375 -7.5 -5.625 -3.75 -1.875]

while cdo stores only the required values as well in a other (preferable?) order:

[-78.75 -76.875 -75. -73.125 -71.25 -69.375 -67.5 -65.625 -63.75 -61.875 -60. -58.125 -56.25 -54.375 -52.5 -50.625 -48.75 -46.875 -45. -43.125 -41.25 -39.375 -37.5 -35.625 -33.75 -31.875 -30. -28.125 -26.25 -24.375 -22.5 -20.625 -18.75 -16.875 -15. -13.125 -11.25 -9.375 -7.5 -5.625 -3.75 -1.875 0. 1.875 3.75 5.625 7.5 9.375 11.25 13.125 15. 16.875 18.75 20.625 22.5 24.375 26.25 28.125 30. 31.875 33.75 35.625 37.5 39.375 41.25 43.125 45. 46.875 48.75 ]

here is an example: https://github.com/bird-house/flyingpigeon/blob/master/notebooks/ocgis_wrap.ipynb

Le 03/06/2016 à 00:28, Ben Koziol a écrit :

@nilshempelmann https://github.com/nilshempelmann do you want to test the wrapping option before merging? I think it would be a good idea. You can find the code in the https://github.com/NCPP/ocgis/tree/i419-wrap-option branch. The documentation for the new |spatial_wrapping| operations parameter is here: https://github.com/NCPP/ocgis/blob/i419-wrap-option/doc/api.rst#spatial_wrapping.

Let me know if you have any questions!

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/NCPP/ocgis/issues/419#issuecomment-223441562, or mute the thread https://github.com/notifications/unsubscribe/AIPUql7od9kBCaxRDRguVAVMd9QP_hiNks5qH1kQgaJpZM4ILwTW.

bekozi commented 8 years ago

Thanks for testing. I was forgetting the piece about the ordering. Seemed to simple. :smile: The longitude array needs to be reordered such that: [-180, ..., 0, ..., 180]. I'll test with that bounding box too before the next push.

bekozi commented 8 years ago

@nilshempelmann This is again ready for testing. There are still elements that are a work-in-progress (i.e. mask handling and documentation). A new argument to OcgOperations was added called spatial_reorder. Setting this to True, will reorder the coordinates and associated data arrays such that longitude is in ascending order. It is False by default. I think there are edge cases I am not handling, so I will be interested in your mileage!

Branch: https://github.com/NCPP/ocgis/tree/i419-wrap-option.

Sorry for the delay in getting this in...

nilshempelmann commented 8 years ago

Great work! First tests looks very good: https://github.com/bird-house/flyingpigeon/blob/master/notebooks/cdo_ocgis.ipynb

nilshempelmann commented 8 years ago

Tests with rotated poles and chunking are fine as well: https://github.com/bird-house/flyingpigeon/blob/develop/notebooks/cdo_ocgis.ipynb

bekozi commented 8 years ago

Excellent :+1:. Did you have more testing you wanted to do before I commit this?

nilshempelmann commented 8 years ago

You can commit this. Good work

On 27/06/2016 17:18, Ben Koziol wrote:

Excellent 👍. Did you have more testing you wanted to do before I commit this?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/NCPP/ocgis/issues/419#issuecomment-228777734, or mute the thread https://github.com/notifications/unsubscribe/AIPUqoZ1F-S-mx509-SRZdc4x3tCG-Y5ks5qP-nOgaJpZM4ILwTW.

bekozi commented 8 years ago

Pushed to https://github.com/NCPP/ocgis/tree/next.