Tuesday, May 6, 2014

Projections and Gridding

Today I have been thinking about projections

CMIP5 is netCDF the projection is provided in the Metadata, resolution 0.5° x 0.5°

I want to perform polygon regions analysis.

I need the 'masking' of the CMIP5 to be efficient. Visualisation is not a concern.

What file format for storing polygons should I use ?

  • projection 
  • resolution
I have been looking at different programming languages, particularly R and NCL.

NCL is built to handle  netCDF data efficiently.
But I am having trouble grasping how I can use my polygons efficiently. The polygons are initially shapefiles. The example polygon code focuses on using polygons in visualisation. The example shapefile masking code seems very inefficient. 

Focusing on NCL

If I know CMIP5 resolution and projection I should be able to create netCDF file with a layer / a variable / or slot in array -  per region , with binary values.

Max and Min Latitude of the region could be used to reduce data extract from the netCDF

; read only desired area & times
x     = in->SST(tStrt:tLast,{latS:latN},{lonL:lonR})

Merge / AND / if / where
@FillValue is kind of like null for this variable, ignored by many functions.
  if(.not.isatt(data,"_FillValue")) then
    data@_FillValue = default_fillvalue(typeof(data))          ;-- make sure "data" has a missing value
  end if

x is CMIP5 netCDF data
regions is all my polygons

 x and regions should have the same dimensions
 xr = where(regions.eq.17, x, x@_FillValue)
Or once I have a single binary object per region
 x = in->SST(tStrt:tLast,{r17.latS:r17.latN},{r17.lonL:r17.lonR})
 xr = where(r17, x, x@_FillValue)
There is memory concern here. 
I am going with the concept by region. that is 
For each region
  • For each netCDF file
    • Open netCDF file
    • Populate variable (X) with netCDF data by region and time period
    • Close netCDF file
    • Perform any calculation which will optimise memory footprint
      • x <- X
    • Delete X, keep derived data.
Still got the region shape file. Regrid to standard CMIP5

Ahhh there is no standard grid ding CMIP5
Initially going for bi-linearly interpolation  to 1x1 rectilinear grid 
Why Bilinear

Mora, C., et al. (2013). "Biotic and human vulnerability to projected changes in ocean biogeochemistry over the 21st century." PLoS biology 11(10): e1001682.

Why Rectilinear grid
  • Simple
  • Too many people think in rectangles
  • I don't like how the areas are so different
  • Consider variation at later stage
Why 1 x 1
  • Because resolution should be reasonable with all the CMIP5 0.5 degree data

No comments:

Post a Comment