[gradsusr] How to mask out areas outside Mississippi basin ?
zhaokuifeng
zhaokuifeng at gmail.com
Thu Mar 8 01:13:10 EST 2012
the best way is to use gis shape files .opengrads2
2012/3/6 bo-dong at huskers.unl.edu <bo-dong at huskers.unl.edu>
> Thanks Chuck and Hosein, this really helps, greatly appreciated :)
>
> best,
> Bo
>
> ________________________________________
> From: gradsusr-bounces at gradsusr.org [gradsusr-bounces at gradsusr.org] on
> behalf of Charles Seman [charles.seman at noaa.gov]
> Sent: Friday, March 02, 2012 12:25
> To: GrADS Users Forum
> Subject: Re: [gradsusr] How to mask out areas outside Mississippi basin ?
>
> Bo,
>
> I don't think the technique of defining the basinmask = undefined
> everywhere works as shown below. I think this way would work:
>
> 'set x 1 'nx
> 'set y 1 'ny
> 'set z 1'
> 'set t 1'
> 'define basinmask = const(somevar,-1,-a)' ;* defines all points = -1
>
> Then proceed as outlined below to update desired basinmask points to a
> value of 1. Then use the basinmask and maskout() as shown in Example 2
> at http://grads.iges.org/grads/gadoc/gradfuncmaskout.html to do
> area-average of points where basinmask = 1.
>
> Chuck
>
> On 03/01/2012 04:47 PM, Charles Seman 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
>
> _______________________________________________
> gradsusr mailing list
> gradsusr at gradsusr.org
> http://gradsusr.org/mailman/listinfo/gradsusr
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://gradsusr.org/pipermail/gradsusr/attachments/20120308/1bf44acd/attachment-0003.html
More information about the gradsusr
mailing list