grid interpolation

From: Matt Masarik <mmasarik_at_nyahnyahspammersnyahnyah>
Date: Tue Apr 23 2013 - 15:13:10 MDT

Hello NCL Talkers,

I'm trying to do a grid interpolation using the function 'linint2' and
am having some troubles. The
dataset I am interpolating from has coordinates

                                 lat: 89.5 to -89.5
                                 lon: -179.5 to 179.5

the dataset I am interpolating to has coordinates

                                lat: -90 to 90
                                lon: 0 to 356.25

    So, the first thing I did was to invert the variable in latitude (
-89.5 to 89.5) and then 'flip'
the variable in longitude ( 0.5 to 395.5 ). I did the same operations
to the coordinate variables
themselves because it seems they weren't changed as I was under the
impression they would be.
At this point I make a call to linint2 and get the following error

            warning:linint2: xi, yi, xo, and yo must be monotonically
increasing

I am confused because I believe that my x's and y's are monotonically
increasing.

I've included the code fragment below, followed by output from
printVarSummary() statements.
(I apologize for the length of this email, but I wanted to give all
relevant information).
Any suggestions of what may be going on would be appreciated.

Thank you, Matt

;; open files
outfile = addfile("./cl18502005.nc","r")
infile = addfile("./MCD200207.nc","r")

;; get coords
outlon = outfile->lon
outlat = outfile->lat
inlon = infile->lon
inlat = infile->lat

;; get variables
invar = infile->cl_R_low(0,:,:)

invar!0 = "lat"
invar!1 = "lon"
invar&lat = inlat
invar&lon = inlon
invar&lat@units="degrees_north"
invar&lon@units="degrees_east"

printVarSummary(outlon)
printVarSummary(outlat)
printVarSummary(inlat)
printVarSummary(inlon)
printVarSummary(invar)

invar = invar(::-1,:) ; invert the latitude dimension
invar = lonFlip(invar) ; flip the longitude dimension
inlon = lonFlip(inlon)
inlat = inlat(::-1)

printVarSummary(inlat)
printVarSummary(inlon)
printVarSummary(invar)

outvar = linint2(inlon,inlat,invar,True,outlon,outlat,0)

  ====== printVarSummarys ========

Before lat/lon flips
------------------------

Variable: outlon
Type: double
Total Size: 768 bytes
             96 values
Number of Dimensions: 1
Dimensions and sizes: [lon | 96]
Coordinates:
             lon: [ 0..356.25]
Number Of Attributes: 5
   bounds : lon_bnds
   units : degrees_east
   axis : X
   long_name : longitude
   standard_name : longitude

Variable: outlat
Type: double
Total Size: 768 bytes
             96 values
Number of Dimensions: 1
Dimensions and sizes: [lat | 96]
Coordinates:
             lat: [ -90.. 90]
Number Of Attributes: 5
   bounds : lat_bnds
   units : degrees_north
   axis : Y
   long_name : latitude
   standard_name : latitude

Variable: inlat
Type: float
Total Size: 720 bytes
             180 values
Number of Dimensions: 1
Dimensions and sizes: [lat | 180]
Coordinates:
             lat: [89.5..-89.5]
Number Of Attributes: 5
   long_name : latitude
   valid_range : ( -90, 90 )
   standard_name : latitude
   axis : Y
   units : degrees_north

Variable: inlon
Type: float
Total Size: 1440 bytes
             360 values
Number of Dimensions: 1
Dimensions and sizes: [lon | 360]
Coordinates:
             lon: [-179.5..179.5]
Number Of Attributes: 5
   long_name : longitude
   valid_range : ( -180, 180 )
   standard_name : longitude
   axis : X
   units : degrees_east

Variable: invar
Type: float
Total Size: 259200 bytes
             64800 values
Number of Dimensions: 2
Dimensions and sizes: [lat | 180] x [lon | 360]
Coordinates:
             lat: [89.5..-89.5]
             lon: [-179.5..179.5]
Number Of Attributes: 8
   time : 1
   valid_range : ( 0, 1 )
   standard_name : cloud_area_fraction
   units : 1
   missing_value : -999

After lat/lon flips
------------------------
Variable: inlat
Type: float
Total Size: 720 bytes
             180 values
Number of Dimensions: 1
Dimensions and sizes: [lat | 180]
Coordinates:
             lat: [-89.5..89.5]
Number Of Attributes: 5
   long_name : latitude
   valid_range : ( -90, 90 )
   standard_name : latitude
   axis : Y
   units : degrees_north

Variable: inlon
Type: float
Total Size: 1440 bytes
             360 values
Number of Dimensions: 1
Dimensions and sizes: [lon | 360]
Coordinates:
             lon: [0.5..359.5]
Number Of Attributes: 6
   lonFlip : longitude coordinate variable has been reordered via
lonFlip
   units : degrees_east
   axis : X
   standard_name : longitude
   valid_range : ( -180, 180 )
   long_name : longitude

Variable: invar
Type: float
Total Size: 259200 bytes
             64800 values
Number of Dimensions: 2
Dimensions and sizes: [lat | 180] x [lon | 360]
Coordinates:
             lat: [-89.5..89.5]
             lon: [0.5..359.5]
Number Of Attributes: 9
   lonFlip : longitude coordinate variable has been reordered via
lonFlip
   missing_value : -999
   units : 1
   standard_name : cloud_area_fraction
   valid_range : ( 0, 1 )
   time : 1
   _FillValue : -999

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Tue Apr 23 15:14:10 2013

This archive was generated by hypermail 2.1.8 : Fri Apr 26 2013 - 17:10:26 MDT