[gradsusr] How to highlight multiple model domains in one figure

Jennifer M Adams jadams21 at gmu.edu
Fri Oct 21 15:39:57 EDT 2016


Yes, if PDEF is in play it is trickier, but writing the code to check for undefs at the ends of each row/column is a bit of a nuisance. How about extracting the projected grid lat/lon values from the file outside of GrADS? If it’s netcdf, it’s easy (use ncdump or put the coordinate variables in the vars list in a descriptor without PDEF). If it’s grib, there’s probably a way to get that info out of the file with wgrib/wgrib2.
—Jennifer


On Oct 21, 2016, at 2:29 PM, Jeff Duda <jeffduda319 at gmail.com<mailto:jeffduda319 at gmail.com>> wrote:

All,
As an FYI, the second method in Jennifer's email, to draw an outline around the model domain, does not work for irregularly shaped or pre-projected domains (e.g., lambert conformal projected grid using 'set mproj latlon'). If you use a control file with an XDEF and YDEF line, then the grid point 1,1 starts where your XDEF and YDEF lines start, which may not match your domain's actual (1,1) location. Even if it does, then your other corner points will be chopped off the display domain. The only other thing I can think of would be to cross your display domain and draw a mark when you cross from the UNDEF value to a defined value, indicating you have crossed the domain boundary. You could probably then use some clever and painstaking coding to obtain a list of page coordinate points and then draw lines between them to outline the domain.

Jeff Duda

On Fri, Oct 21, 2016 at 8:45 AM, Jennifer M Adams <jadams21 at gmu.edu<mailto:jadams21 at gmu.edu>> wrote:
Hi, Mano —
If you want to fill the area of the grid domain with a color of your choice, then you can do this:
‘set rgb 20 100 100 100 100’  ;* a transparent grey
‘set ccolor 20’
‘d const(var,0)’

If you want to draw an outline, then here is an algorithm to try:
1. Draw a blank plot covering the largest domain to set up the scaling environment
2. Construct a ‘draw line’ command by looping over the grid coordinates at the boundaries (e.g. x=1,y=1:YDEF, y=1,x=1:XDEF, etc.) and using the 'q this2that’ commands (either 'q gr2xy’ or ‘q w2xy’) to get the location in X,Y space of each grid point.

cmd=‘draw line ‘
loop over edges
   cmd=cmd%xpos’ ‘ypos’ '
endloop
cmd

—Jennifer

On Oct 15, 2016, at 10:41 AM, Jeff Duda <jeffduda319 at gmail.com<mailto:jeffduda319 at gmail.com>> wrote:

There's no simple or easy way to do it. Here are two methods I have used in the past:

1) Generate a netcdf grid using whatever library you're familiar with (if any). Make the grid the same size as your model domain. You can make the values inside the grid essentially whatever you want so long as you can bound the outer edge of the domain in a single contour. I suggest making all values in the domain either 0.0 or 1.0. Then write a control file to display that grid and make sure the value of UNDEF is set to something other than the value on the grid. Then just display the field using gxout contour and with contour labeling set to off.

2) Use gxout fwrite and define any field on that domain using const like 'define field = const(tmp,1,-a)' which essentially does the same thing as in option 1, except it will write the field to a binary file instead of a netcdf file. Then you can just modify the control file you used for the original data set (assuming you used one), just changing the DSET, DTYPE, and VARS entries to suit your new data. Whatever the name of the field you wrote (in this example, it was defined using the name 'field'), the VARS entry will become
VARS 1
field 0 99 field
ENDVARS

Also make sure to set UNDEF to some value other than the constant value (1 in this example). Then, as in the first suggestion, display the field using gxout contour and with contour labeling off.

Once you have the general idea here, you can manipulate the steps to make small alterations to improve the output image.

Jeff Duda

On Fri, Oct 14, 2016 at 7:59 PM, lpasmanoranjan <lpasmanoranjan at gmail.com<mailto:lpasmanoranjan at gmail.com>> wrote:
Dear GrADS users,
I would like to ask you a favour.

I would like to highlight the following three model domains in one figure around my study region (India as center). But I can't able to draw the closed polygons as in the attachment.

I have three model domains in Lambert conformal conic projection:
MODEL 1: (8S,50E), (8S,90E), (45N,95E), (45N,45E).
MODEL 2: (7S,42E), (7S,92E), (47N,97E), (47N,41E).
MODEL 3:

Would you please suggest how to do it in grads!!

Thank you very much for any kind of help or suggestion.


--
Kind Regards,
Mano


_______________________________________________
gradsusr mailing list
gradsusr at gradsusr.org<mailto:gradsusr at gradsusr.org>
http://gradsusr.org/mailman/listinfo/gradsusr




--
Jeff Duda
Post-doctoral research associate
University of Oklahoma School of Meteorology
_______________________________________________
gradsusr mailing list
gradsusr at gradsusr.org<mailto:gradsusr at gradsusr.org>
http://gradsusr.org/mailman/listinfo/gradsusr

--
Jennifer Miletta Adams
Center for Ocean-Land-Atmosphere Studies (COLA)
George Mason University




_______________________________________________
gradsusr mailing list
gradsusr at gradsusr.org<mailto:gradsusr at gradsusr.org>
http://gradsusr.org/mailman/listinfo/gradsusr




--
Jeff Duda
Post-doctoral research associate
University of Oklahoma School of Meteorology
_______________________________________________
gradsusr mailing list
gradsusr at gradsusr.org<mailto:gradsusr at gradsusr.org>
http://gradsusr.org/mailman/listinfo/gradsusr

--
Jennifer Miletta Adams
Center for Ocean-Land-Atmosphere Studies (COLA)
George Mason University



-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://gradsusr.org/pipermail/gradsusr/attachments/20161021/889e3938/attachment-0001.html 


More information about the gradsusr mailing list