Mark Payne
2012-11-26
Hi,
Could anyone please point me in the right direction for the following problem please? I have bathymetry data on a 1 minute grid, and would like to "downscale" this to a one degree grid (!!). However, in doing so, I would like to calculate some statistics within each of the 1 degree pixels e.g. max depth, min depth, mean depth, depth sd etc etc. This is a for loop in e.g. MATLAB, R etc. How would you approach it with NCO though? ncap2 is one approach, but setting up the output file (ie one the 1 degree grid) could be a bit tedious. Does anyone have any suggestions?
Mark
henry Butowsky
2012-11-26
HI mark,
There is a bilinear interpolation function in ncap2 which you could use to "downsize" to a 1 deg grid.
The z for each spot on the 1 deg grid will be based on the 4 nearest 1 min points.
( I have recently add code to the function so it handles missing values)
There are two functions:
bilinear_interp()
bilinear_interp_wrap() - ( can hadle wrapped co-ordinates)
See the documentation:
http://nco.sourceforge.net/nco.html#Bilinear-interpolation
To calculate your grid stats you'll have to set up some loops and call the avg/min/max functions on hyperslabs from your original 1 min grid
…hmb
Charlie Zender
2012-11-26
The best NCO approach is ncap2. I would avoid bilinear interpolation for this problem.
Define your grid manually and then loop through lat and lon on the coarser grid and use the where() function to compute the average, min, max, etc. statistics for all the input point contained in that rectangle. Use RAM variables inside the loops (See manual).
Good luck,
cz
Mark Payne
2012-11-27
Thanks for the replies both of you. I'll look into it and see how I get on…
Cheers,
Mark