[gradsusr] Maxloc Function
Mark Sponsler
msponsler at comcast.net
Sun Apr 26 14:39:30 EDT 2015
Hello everyone,
I'm struggling with maxloc. For whatever reason - I cannot get valid results out of it
I'm using a simple 0.5 X 0.5 deg grid.
I can find the max value just fine. It's the location of that value that is the issue.
Specifically selecting the correct record to read to obtain the x value (nxp3 in this example):
'd maxloc(max(htsgw,lat='lat1',lat='lat2'),lon='lon1',lon='lon2')' rec=sublin(result,nxp3)
The last valid line of data from maxloc looks like this (the next line is undefined values):
rec = MAXing. dim = 1, start = 146, end = 286Where is the actual grib point or longitude where the max value is located?
The results I'm getting are the same for every time step in the grib file.... dim = 1
Or should I be looking somewhere else?
Thanks for your help.
Here's the whole script:
********************************* Define number of grid points to scan********************************
lon1 = 120lon2 = 255lat1 = -5lat2 = 65
nxp = (lon2-lon1)* say ' nxp = 'nxpnyp = (lat2-lat1)* say ' nyp = 'nyp* Grid dimensions are 0.5 x 0.5nxp1 = nxp/0.5* say 'nxp1 = 'nxp1nyp1 = nyp/0.5* say 'nyp1 = 'nyp1nxp2 = math_int(nxp1)nyp2 = math_int(nyp1)* say 'nxp2 nyp2 = 'nxp2' 'nyp2********************************* Find Max Longitude (x dim)********************************* There are 'nxp1' number of data points over the longitude range plus 1 for MAXLOCing* and 1 for the result value line. So add 2. ******************************** nxp3 = (nxp2 + 2) say 'nxp3 = 'nxp3'set gxout print''d maxloc(max(htsgw,lat='lat1',lat='lat2'),lon='lon1',lon='lon2')' rec=sublin(result,nxp3) say 'rec = 'rec xc=subwrd(rec,4) say 'Max height lon = 'xc********************************* Find max Latitude (y dim)********************************* There are 'nyp1' number of data points over the long range plus 1 for MAXLOCing * and 1 for the result value line. So add 2. ******************************** nyp3 = (nyp2 + 2) say 'nyp3 = 'nyp3'd maxloc(max(htsgw,lon='lon1',lon='lon2'),lat='lat1',lat='lat2')' rec=sublin(result,nyp3) say 'rec = 'rec yc=subwrd(rec,4) say 'Max height lat = 'yc say 'location of max seas = 'xc' 'yc*************** Draw Max Location**************'q gr2xy 'xc' 'yc rec2=sublin(result,1) say 'rec2 = 'rec2 xc2 = subwrd(result,3) yc2 = subwrd(result,6) say 'Max Height coords = 'xc2' 'yc2
Thanks,Mark
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://gradsusr.org/pipermail/gradsusr/attachments/20150426/6dc5f94a/attachment.html
More information about the gradsusr
mailing list