[gradsusr] How to mask out areas outside Mississippi basin ?
H.L
biometeorology at gmail.com
Fri Mar 2 07:04:11 EST 2012
Hi
also you can save Mississippi river basin grid points lat/lon as a txt
file, then you can write an script to read each lat/lon from txt file
then;
.
.
...
'set gxout fwrite'
'set fwrite M.B.river.bin'
'set lat 'lat
'set lon 'lon
'd var'
...
to write values as a binary file
then you can read this binary file in grads
good luck
Hosein Lotfi
On 3/2/12, Charles Seman <charles.seman at noaa.gov> wrote:
> Bo,
>
> One thing to try would be to define a 2D mask field as initially
> undefined everywhere using const(somevar,undef_value,-a), then replace
> the values in the mask that you want to use with a value of "1" using
> "set defval"...
>
> Some script code (NOT tested!):
>
> 'sdfopen your_file.nc'
>
> 'q ctlinfo'
> rec3 = sublin(result,3)
> undef_value = subwrd(rec3,2)
>
> 'q file'
> rec5 = sublin(result,5)
> nx = subwrd(rec5,3) ; ny = subwrd(rec5,6)
>
> 'set x 1 'nx
> 'set y 1 'ny
> 'set z 1'
> 'set t 1'
> 'define basinmask = const(somevar,'undef_value',-a)'
>
> * next, adapt the code from defval_demo.gs within a loop to
> * interactively select points to change from undefined to a value of
> * "1"... this would be somewhat tedious, but after defining the
> * basinmask variable you could also write it out for future use to a
> * GrADS binary file using "fwrite" (or if you are running a version of
> * GrADS which has "sdfwrite", to a netCDF file)...
>
> continue = yes
> while ( continue = yes )
> say 'Enter "yes" to continue updating points...'
> pull continue
> if ( continue == yes )
> * ...use code from "defval_demo.gs" to update a point
> else
> break
> endif
> endwhile
>
> some reference links:
> http://grads.iges.org/grads/gadoc/gradfuncconst.html
> http://grads.iges.org/grads/gadoc/gradcomdsetdefval.html
> ftp://grads.iges.org/grads/scripts/defval_demo.gs
> http://grads.iges.org/grads/gadoc/script.html#standardio
> http://grads.iges.org/grads/gadoc/script.html#while
>
> Hope this helps,
> Chuck
>
> On 03/01/2012 01:01 PM, bo-dong at huskers.unl.edu wrote:
>> Dear All,
>>
>> I have a netcdffile with data covered the U.S., but I only want to
>> display the area of Mississippi River basin. Any idea about how to mask
>> out areas outside Mississippi River basin? Also, I need to do a basin
>> average (i.e. average all the data within Mississippi river basin), the
>> aave() function seems to average all the areas in U.S., not only in the
>> river basin.
>>
>> Your assistance is greatly appreciated.
>>
>> Thanks,
>>
>> Bo
>>
>>
>>
>> _______________________________________________
>> gradsusr mailing list
>> gradsusr at gradsusr.org
>> http://gradsusr.org/mailman/listinfo/gradsusr
>
> --
>
> Please note that Charles.Seman at noaa.gov should be considered my NOAA
> email address, not cjs at gfdl.noaa.gov.
>
> ********************************************************************
> Charles Seman Charles.Seman at noaa.gov
> U.S. Department of Commerce / NOAA / OAR
> Geophysical Fluid Dynamics Laboratory voice: (609) 452-6547
> 201 Forrestal Road fax: (609) 987-5063
> Princeton, NJ 08540-6649 http://www.gfdl.noaa.gov/~cjs/
> ********************************************************************
>
> "The contents of this message are mine personally and do not reflect any
> official or unofficial position of the United States Federal Government,
> the United States Department of Commerce, or NOAA."
> _______________________________________________
> gradsusr mailing list
> gradsusr at gradsusr.org
> http://gradsusr.org/mailman/listinfo/gradsusr
>
More information about the gradsusr
mailing list