# [gradsusr] Help on calculating Area Maximum from NetCDF file using Grads

Anil Kumar anilku at oceanmanager.com
Fri Jun 27 03:25:08 EDT 2014

Hi Jennifer and All,

Am seeking help on calculating area maximum with linear interpolation using Grads. Earlier I was using below methodology to calculate area average over small areas defined. It was working good but now I need to calculate amax using lterp in grads but in documentation I cannot find that ltrep uses amax as argument <http://www.iges.org/grads/gadoc/gradfunclterp.html>  ; neither it is giving correct result nor giving error.

My Requirement :  I have a larger dataset (.NC file) 1440*720 points. I want a new destination grid with linear interpolation having all the all area maximum values using amax() of small-small regions. And ultimately, need to query the destination grid for output.

What Am doing so far :

I have a NetCDF file having  below CTL Info.

*****************************************************************

dset D:\WeatherGribFiles\2014\06\22\rtofs_glo_2ds_f024_daily_prog.nc

title 2D Sfc Daily Prognostic 00Z22jun2014: Forecast, downloaded Jun 22 15:20 UTC

undef 1.26765e+30

dtype netcdf

xdef 1440 linear 74.16 0.24999

ydef 720 linear -90 0.24999

zdef 1 linear 1 1

tdef 1 linear 00Z23JUN2014 1mn

vars 2

u_velocity=>u_velocity  1  t,z,y,x  eastward_sea_water_velocity (m/s)

v_velocity=>v_velocity  1  t,z,y,x  northward_sea_water_velocity (m/s)

endvars

*****************************************************************

I want a new destination grid ; which would contain the area maximum values as points. Destination grid should contain maximum value from every 8 points in x-axis and y axis. For this, I have created below, CTL file named as  rtofs_glo_2ds_f024_daily_prog.ctl:

*****************************************************************

dset D:\WeatherGribFiles\2014\06\22\rtofs_glo_2ds_f024_daily_prog.nc

index  D:\WeatherGribFiles\2014\06\22\rtofs_glo_2ds_f024_daily_prog_DUMMY.nc

title 2D Sfc Daily Prognostic 00Z22jun2014: Forecast, downloaded Jun 22 15:20 UTC

undef 1.26765e+30

dtype netcdf

xdef 180 linear 74.16 2.0

ydef 90 linear -90 2.0

zdef 1 linear 1 1

tdef 1 linear 00Z23JUN2014 1mn

options template

vars 2

u_velocity=>u_velocity  1  t,z,y,x  eastward_sea_water_velocity (m/s)

v_velocity=>v_velocity  1  t,z,y,x  northward_sea_water_velocity (m/s)

endvars

*****************************************************************

Below is the command I use to display the data from destination grid rtofs_glo_2ds_f024_daily_prog_DUMMY.nc defined in above CTL file. Below is the command set using.

*****************************************************************

reinit

sdfopen D:/WeatherGribFiles/2014/06/22/rtofs_glo_2ds_f024_daily_prog.nc

open D:/WeatherGribFiles/2014/06/22/rtofs_glo_2ds_f024_daily_prog2.ctl

set parea 0 11 0 8.5

set vpage 0 11 0 8.5

set lon -74.16 434

set lat -90 90

set cthick 6

set arrscl 0.10

define val = mag(lterp(u_velocity.1*1.95,lat.2,amax),lterp(v_velocity.1*1.95,lat.2,amax))

d lterp(u_velocity.1*1.95,lat.2,amax);lterp(v_velocity.1*1.95,lat.2,amax);val

*****************************************************************

When I change the destination grid dimensions slightly  in rtofs_glo_2ds_f024_daily_prog.ctl file

xdef 135 linear 74.16 2.5

ydef 68 linear -90 2.5

and checks for the output, It varies at the same point i.e. if I look at certain point before changing and after changing grid dimensions, the result comes of different magnitude.

What I want is, When I increase or decrease the destination grid points in “rtofs_glo_2ds_f024_daily_prog.ctl”, and the maximum value should be at its place.

How can I achieve this ?????

Thanks for any guidance.

Thanks & Regards

Anil Kumar

-------------- next part --------------
An HTML attachment was scrubbed...