[gradsusr] Masking out on the two sides of data origin

Charles Seman Charles.Seman at noaa.gov
Wed Aug 31 14:01:32 EDT 2011


Hyacinth,

I worked on this and found a technique which seems to work for a lon/lat
gridded dataset (please see attached script "region.gs").  Basically,
the idea is to first define a 2D global mask variable "varmask" which is
everywhere equal to -1 (for future use in "maskout()"), then make an
outer loop in latitude for -45 to 10, and two inner loops in longitude
to split the "defval" code into two segments: 300-360, and 0-20 to
redefine the global mask variable "varmask" to a value of "+1" only
within the desired region (for future use in "maskout()").  Then use
code like "d maskout('var',varmask)'" to display the original variable
"'var'" only within the region where it has been redefined to +1
(varmask = -1 everywhere else). Please let me know if you have any
questions or find any errors in the code.

Hope this helps,
Chuck

Hyacinth Nnamchi wrote:
> Dear grads users,
> 
> My dataset in T30 Gaussian grids is written from longitude 0 (x=1) to 
> longitude 360 (X=96). Now I want to "maskout" so that I'll have data 
> only for: lon = -60 20 and lat = -45 10 i.e. mainly for South Atlantic 
> Ocean. So the data origin splits my box into two.
> 
> y=12
>   while ( y <= 29 )
>     x=81
>     while ( x <= 102 )
>       'set y 'y
>       'set x 'x
>       'set defval pmask 'x' 'y' 1'
>       x=x+1
>     say ' Domain =  lat = 'y',   lon = 'x
>     endwhile
>     y=y+1
>   endwhile
> 
> I have tried the above, changing x again and again but it's either I get 
> only the western or the eastern segment of the box, not a full 
> continuous box. My ctl and GrADS info are included below.
> 
> Thanks in advance for any suggestions.
> 
> Hyacinth
> 
> ********************************************************************************************
> 
> ga-> q ctlinfo
> dset noaa_anom_1950_2010_mean1950_2010.t30.grd
> title Sea surface temperature on T30 gg
> undef -9.99e+08
> xdef 96 linear 0 3.75
> ydef 48 levels -87.16 -83.47 -79.78 -76.07 -72.36 -68.65 -64.94 -61.23
>  -57.52 -53.81 -50.1 -46.39 -42.68 -38.97 -35.26 -31.54 -27.83 -24.12
>  -20.41 -16.7 -12.99 -9.28 -5.57 -1.86 1.86 5.57 9.28 12.99
>  16.7 20.41 24.12 27.83 31.54 35.26 38.97 42.68 46.39 50.1
>  53.81 57.52 61.23 64.94 68.65 72.36 76.07 79.78 83.47 87.16
> zdef 1 linear 1013 1
> tdef 732 linear 00Z01JAN1950 1mo
> vars 1
> ssta  1  99  surface temperature  [degk]
> endvars
> ****************************************************************
> ga-> q config   ! 
>                                                                      
> Config: v2.0.a9 little-endian readline printim grib2 netcdf hdf4-sds 
> hdf5 opendap-grids,stn geotiff 
> shapefile                                                                                                   
> 
> Grid Analysis and Display System (GrADS) Version 
> 2.0.a9                                                
> Copyright (c) 1988-2010 by Brian Doty and 
> the                                                          
> Institute for Global Environment and Society 
> (IGES)                               &! nbsp;                    
> This program is distributed WITHOUT ANY 
> WARRANTY                                                       
> See file COPYRIGHT for more 
> information.                                                               
> 
> Built Fri Sep  3 11:29:45 MDT 2010 for i686! -pc-linux-gnu
> 
> This version of GrADS has been configured with th e following options:
>   o Built on a LITTLE ENDIAN machine
>   o Athena Widget GUI DISABLED
>   o Command line editing ENABLED
>       http://tiswww.case.edu/php/chet/readline/rltop.html
>   o printim command for image output ENABLED
>       http://www.zlib.net
>       http://www.libpng.org/pub/png/libpng.html
>       http://www.libgd.org/Main_Page
>   o GRIB2 interface ENABLED
>       http://www.ijg.org
>       http://www.ece.uvic.ca/~mdadams/jasper
>       http://www.nco.ncep.noaa.gov/pmb/codes/GRIB2
>       g2clib-1.1.8
>   o NetCDF interface ENABLED
>       http://www.unidata.ucar.edu/software/netcdf
>       netcdf 4.1.1-rc2 of Mar 26 2010 20:33:15 $
>   o OPeNDAP gridded d! ata interface ENABLED
>   o OPeNDAP station data interface ENABLED
>       http://iges.org/grads/gadoc/supplibs.html
>       libgadap 2.0
>   o HDF4 and HDF5 interfaces ENABLED
>       http://hdfgroup.org
>       HDF 4.2r3
>       HDF5 1.8.4
>   o GeoTIFF and KML/TIFF output ENABLED
>       http://www.libtiff.org
>       http://geotiff.osgeo.org
>   o KML contour output ENABLED
>   o Shapefile interface ENABLED
>       http://shapelib.maptools.org
> 
> For additional information please consult http://iges.org/grads
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> 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."
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: region.gs
Url: http://gradsusr.org/pipermail/gradsusr/attachments/20110831/ff0f6dcc/attachment-0003.pl 


More information about the gradsusr mailing list