the best way is to use gis shape files .opengrads2<br><br><div class="gmail_quote">2012/3/6 <a href="mailto:bo-dong@huskers.unl.edu">bo-dong@huskers.unl.edu</a> <span dir="ltr"><<a href="mailto:bo-dong@huskers.unl.edu">bo-dong@huskers.unl.edu</a>></span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Thanks Chuck and Hosein, this really helps, greatly appreciated :)<br>
<br>
best,<br>
Bo<br>
<br>
________________________________________<br>
From: <a href="mailto:gradsusr-bounces@gradsusr.org">gradsusr-bounces@gradsusr.org</a> [<a href="mailto:gradsusr-bounces@gradsusr.org">gradsusr-bounces@gradsusr.org</a>] on behalf of Charles Seman [<a href="mailto:charles.seman@noaa.gov">charles.seman@noaa.gov</a>]<br>
Sent: Friday, March 02, 2012 12:25<br>
To: GrADS Users Forum<br>
Subject: Re: [gradsusr] How to mask out areas outside Mississippi basin ?<br>
<div class="HOEnZb"><div class="h5"><br>
Bo,<br>
<br>
I don't think the technique of defining the basinmask = undefined<br>
everywhere works as shown below. I think this way would work:<br>
<br>
'set x 1 'nx<br>
'set y 1 'ny<br>
'set z 1'<br>
'set t 1'<br>
'define basinmask = const(somevar,-1,-a)' ;* defines all points = -1<br>
<br>
Then proceed as outlined below to update desired basinmask points to a<br>
value of 1. Then use the basinmask and maskout() as shown in Example 2<br>
at <a href="http://grads.iges.org/grads/gadoc/gradfuncmaskout.html" target="_blank">http://grads.iges.org/grads/gadoc/gradfuncmaskout.html</a> to do<br>
area-average of points where basinmask = 1.<br>
<br>
Chuck<br>
<br>
On 03/01/2012 04:47 PM, Charles Seman wrote:<br>
> Bo,<br>
><br>
> One thing to try would be to define a 2D mask field as initially<br>
> undefined everywhere using const(somevar,undef_value,-a), then replace<br>
> the values in the mask that you want to use with a value of "1" using<br>
> "set defval"...<br>
><br>
> Some script code (NOT tested!):<br>
><br>
> 'sdfopen <a href="http://your_file.nc" target="_blank">your_file.nc</a>'<br>
><br>
> 'q ctlinfo'<br>
> rec3 = sublin(result,3)<br>
> undef_value = subwrd(rec3,2)<br>
><br>
> 'q file'<br>
> rec5 = sublin(result,5)<br>
> nx = subwrd(rec5,3) ; ny = subwrd(rec5,6)<br>
><br>
> 'set x 1 'nx<br>
> 'set y 1 'ny<br>
> 'set z 1'<br>
> 'set t 1'<br>
> 'define basinmask = const(somevar,'undef_value',-a)'<br>
><br>
> * next, adapt the code from <a href="http://defval_demo.gs" target="_blank">defval_demo.gs</a> within a loop to<br>
> * interactively select points to change from undefined to a value of<br>
> * "1"... this would be somewhat tedious, but after defining the<br>
> * basinmask variable you could also write it out for future use to a<br>
> * GrADS binary file using "fwrite" (or if you are running a version of<br>
> * GrADS which has "sdfwrite", to a netCDF file)...<br>
><br>
> continue = yes<br>
> while ( continue = yes )<br>
> say 'Enter "yes" to continue updating points...'<br>
> pull continue<br>
> if ( continue == yes )<br>
> * ...use code from "<a href="http://defval_demo.gs" target="_blank">defval_demo.gs</a>" to update a point<br>
> else<br>
> break<br>
> endif<br>
> endwhile<br>
><br>
> some reference links:<br>
> <a href="http://grads.iges.org/grads/gadoc/gradfuncconst.html" target="_blank">http://grads.iges.org/grads/gadoc/gradfuncconst.html</a><br>
> <a href="http://grads.iges.org/grads/gadoc/gradcomdsetdefval.html" target="_blank">http://grads.iges.org/grads/gadoc/gradcomdsetdefval.html</a><br>
> <a href="ftp://grads.iges.org/grads/scripts/defval_demo.gs" target="_blank">ftp://grads.iges.org/grads/scripts/defval_demo.gs</a><br>
> <a href="http://grads.iges.org/grads/gadoc/script.html#standardio" target="_blank">http://grads.iges.org/grads/gadoc/script.html#standardio</a><br>
> <a href="http://grads.iges.org/grads/gadoc/script.html#while" target="_blank">http://grads.iges.org/grads/gadoc/script.html#while</a><br>
><br>
> Hope this helps,<br>
> Chuck<br>
><br>
> On 03/01/2012 01:01 PM, <a href="mailto:bo-dong@huskers.unl.edu">bo-dong@huskers.unl.edu</a> wrote:<br>
>> Dear All,<br>
>><br>
>> I have a netcdffile with data covered the U.S., but I only want to<br>
>> display the area of Mississippi River basin. Any idea about how to mask<br>
>> out areas outside Mississippi River basin? Also, I need to do a basin<br>
>> average (i.e. average all the data within Mississippi river basin), the<br>
>> aave() function seems to average all the areas in U.S., not only in the<br>
>> river basin.<br>
>><br>
>> Your assistance is greatly appreciated.<br>
>><br>
>> Thanks,<br>
>><br>
>> Bo<br>
>><br>
>><br>
>><br>
>> _______________________________________________<br>
>> gradsusr mailing list<br>
>> <a href="mailto:gradsusr@gradsusr.org">gradsusr@gradsusr.org</a><br>
>> <a href="http://gradsusr.org/mailman/listinfo/gradsusr" target="_blank">http://gradsusr.org/mailman/listinfo/gradsusr</a><br>
><br>
<br>
--<br>
<br>
Please note that <a href="mailto:Charles.Seman@noaa.gov">Charles.Seman@noaa.gov</a> should be considered my NOAA<br>
email address, not <a href="mailto:cjs@gfdl.noaa.gov">cjs@gfdl.noaa.gov</a>.<br>
<br>
********************************************************************<br>
Charles Seman <a href="mailto:Charles.Seman@noaa.gov">Charles.Seman@noaa.gov</a><br>
U.S. Department of Commerce / NOAA / OAR<br>
Geophysical Fluid Dynamics Laboratory voice: (609) 452-6547<br>
201 Forrestal Road fax: (609) 987-5063<br>
Princeton, NJ 08540-6649 <a href="http://www.gfdl.noaa.gov/%7Ecjs/" target="_blank">http://www.gfdl.noaa.gov/~cjs/</a><br>
********************************************************************<br>
<br>
"The contents of this message are mine personally and do not reflect any<br>
official or unofficial position of the United States Federal Government,<br>
the United States Department of Commerce, or NOAA."<br>
_______________________________________________<br>
gradsusr mailing list<br>
<a href="mailto:gradsusr@gradsusr.org">gradsusr@gradsusr.org</a><br>
<a href="http://gradsusr.org/mailman/listinfo/gradsusr" target="_blank">http://gradsusr.org/mailman/listinfo/gradsusr</a><br>
<br>
_______________________________________________<br>
gradsusr mailing list<br>
<a href="mailto:gradsusr@gradsusr.org">gradsusr@gradsusr.org</a><br>
<a href="http://gradsusr.org/mailman/listinfo/gradsusr" target="_blank">http://gradsusr.org/mailman/listinfo/gradsusr</a><br>
</div></div></blockquote></div><br>