Re: Using lat/lons from a low-resolution dataset to subsample a high-resolution dataset

From: Kyle Griffin <ksgriffin2_at_nyahnyahspammersnyahnyah>
Date: Tue Mar 18 2014 - 08:01:25 MDT

Hi Bronwen,

In general, if both datasets are rectilinear, you can use linint2 (or
linint2_Wrap, to keep the metadata) for this purpose.

https://www.ncl.ucar.edu/Document/Functions/Contributed/linint2_Wrap.shtml

Provided the data coordinates of the old 'in' array (defined by xi and yi
in the documentation), the function can then output a bilinearly
interpolated grid on the new 'out' array (defined by xo and yo). This works
for both downscaling and upscaling grids. You can also try linint1 if you
would prefer a quicker calculation with simple linear interpolation. Be
sure to peek at the 'See Also' section in the link above for other
interpolation functions.

For completeness, the error in your technique is likely coming from
data1lon going all the way to -180, while your Data2 longitudes does not.
As a result, it tries to read the data at -180, which of course is "out of
bounds" in Data2. While you could adjust for this, you would lose the
global nature of the data. I'd just suggest going with the interpolation
method, as you can further specify that your data is cyclic in nature and
it will handle interpolation around the ends of the longitude array.

Kyle

----------------------------------------
Kyle S. Griffin
Department of Atmospheric and Oceanic Sciences
University of Wisconsin - Madison
Room 1421
1225 W Dayton St, Madison, WI 53706
Email: ksgriffin2@wisc.edu

On Mon, Mar 17, 2014 at 4:37 PM, Bronwen Konecky <bkonecky@eas.gatech.edu>wrote:

> Hello NCL folks,
>
> I am comparing two satellite datasets with different resolutions. Data1 is
> a 5x5 global grid. Data2 is .25x.25 degree between 50S and 50N. I am trying
> to use the lat/lons of Data1 (the lower resolution dataset) to select the
> nearest gridpoint in Data2 (the hi-res dataset).* I keep getting the
> following error:
>
> fatal:NclOneDValGetClosestIndex: finish coordinate index out of range,
> can't continue
>
> I tried to reduce the latitudinal extent of Data1 to be similar to or even
> smaller than that of Data2, but I continue to get the error.
>
> What am I doing wrong? Code snippet and variable info below.
>
> --
>
>
> Variable: Data1
> Type: float
> Total Size: 653184 bytes
> 163296 values
> Number of Dimensions: 3
> Dimensions and sizes: [time | 63] x [lat | 36] x [lon | 72]
> Coordinates:
> time: [4291..6268]
> lat: [-87.5..87.5]
> lon: [-180..175]
> Number Of Attributes: 2
> average_op_ncl : dim_avg_n over dimension(s): lev
> _FillValue : -999
>
>
> Variable: Data2
> Type: float
> Total Size: 145152000 bytes
> 36288000 values
> Number of Dimensions: 3
> Dimensions and sizes: [time | 63] x [lat | 400] x [lon | 1440]
> Coordinates:
> time: [2004.666666666667..2009.916666666667]
> lat: [-49.875..49.875]
> lon: [-179.875..179.875]
> Number Of Attributes: 5
> _FillValue : -9999.9
> missing_value : -9999.9
> time_statistic : instantaneous
> units : mm/hr
> long_name : precipitation
>
>
> Code snippet:
>
> ; ---- Use Data1 (5x5degree) lat/lons to select nearest gridpoints in
> Data2 (.25x.25degree) ----
>
> latsub1 = -55. ; <-- Still get the error if I choose a smaller number
> like -49
> latsub2 = 55. ; <-- Still get the error if I choose a smaller number
> like 49
>
> Data1latsub = Data1(:,{latsub1:latsub2},:)
>
> data1lat = Data1latsub&lat
> data1lon = Data1latsub&lon
>
> printVarSummary(data1lat)
> printVarSummary(data1lon)
> printMinMax(data1lat,True)
> printMinMax(data1lon,True)
>
> printVarSummary(Data2&lat)
> printVarSummary(Data2&lon)
> printMinMax(Data2&lat,True)
> printMinMax(Data2&lon,True)
>
> Data2sub = Data2(:,{data1lat},{data1lon})
>
> printVarSummary(Data2sub)
> exit
>
>
> Output:
>
> Variable: data1lat
> Type: float
> Total Size: 88 bytes
> 22 values
> Number of Dimensions: 1
> Dimensions and sizes: [lat | 22]
> Coordinates:
> Number Of Attributes: 2
> long_name : Latitude
> units : degrees_north
>
> Variable: data1lon
> Type: float
> Total Size: 288 bytes
> 72 values
> Number of Dimensions: 1
> Dimensions and sizes: [lon | 72]
> Coordinates:
> Number Of Attributes: 2
> units : degrees_east
> long_name : Longitude
> (0)
> (0) Latitude: min=-52.5 max=52.5
> (0)
> (0) Longitude: min=-180 max=175
>
> Variable: lat (coordinate)
> Type: double
> Total Size: 3200 bytes
> 400 values
> Number of Dimensions: 1
> Dimensions and sizes: [lat | 400]
> Coordinates:
> Number Of Attributes: 2
> long_name : Latitude
> units : degrees_north
>
> Variable: lon (coordinate)
> Type: double
> Total Size: 11520 bytes
> 1440 values
> Number of Dimensions: 1
> Dimensions and sizes: [lon | 1440]
> Coordinates:
> Number Of Attributes: 2
> long_name : Longitude
> units : degrees_east
> (0)
> (0) Latitude: min=-49.875 max=49.875
> (0)
> (0) Longitude: min=-179.875 max=179.875
> fatal:NclOneDValGetClosestIndex: finish coordinate index out of range,
> can't continue
> fatal:["Execute.c":8128]:Execute: Error occurred at or near line 160 in
> file data_corr.ncl
>
> --
>
> Many thanks,
> Bronwen
>
>
> *P.S. A better approach would be to interpolate the hi-res Data2 dataset
> to match the lat/lons of the low-res Data1 dataset. I looked through the
> various regridding examples and none seemed appropriate. If anyone has
> suggestions on the best way to do this, I'd appreciate it!
>
>
>
> --
> Bronwen Konecky, Ph.D.
> Postdoctoral Fellow
> School of Earth & Atmospheric Sciences
> Georgia Institute of Technology
> 311 Ferst Dr., Atlanta, GA, 30332-0340
> (303) 492-5176
> http://blkonecky.wordpress.com/
>
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
>

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Tue Mar 18 08:01:57 2014

This archive was generated by hypermail 2.1.8 : Fri Mar 21 2014 - 15:49:21 MDT