[gradsusr] Diagnostics in Ctl File?
Jeff Duda
jeffduda319 at gmail.com
Mon Nov 14 17:28:37 EST 2011
Wow, I must've been tired when I typed that in. Yes, I made a typo there,
too. Thanks for catching that, Eric. I'm sure I haven't been helping
Mason with all of these typos!
Jeff
On Mon, Nov 14, 2011 at 4:24 PM, Eric Altshuler <ela at cola.iges.org> wrote:
> Mason,
>
> I'm looking at the example in the cdiff documentation, and it clearly uses
> lon as the first argument to cdiff in the expression for dx.
>
> One thing I missed before is that Jeff's formula for dy uses lon when it
> should be lat. If the grid defined by XDEF and YDEF is uniform in both
> latitude and longitude and the grid spacing is the same, it won't matter
> whether lon or lat are used in cdiff, but if this is not true, then using
> lon in the definition of dy will give incorrect results.
>
> Eric
>
> ----- Original Message -----
> From: "Mason D. Rowell" <Mason.D.Rowell-1 at ou.edu>
> To: "GrADS Users Forum" <gradsusr at gradsusr.org>
> Sent: Monday, November 14, 2011 5:14:14 PM
> Subject: Re: [gradsusr] Diagnostics in Ctl File?
>
>
>
> All,
>
>
> So everyone is doubling down on dx using lon in the first argument of
> cdiff, whereas it is lat in the example code provided with the cdiff
> documentation?
>
>
> Mason
>
>
>
> From: gradsusr-bounces at gradsusr.org [gradsusr-bounces at gradsusr.org] on
> behalf of Arlindo da Silva [dasilva at alum.mit.edu]
> Sent: Monday, November 14, 2011 3:50 PM
> To: GrADS Users Forum
> Subject: Re: [gradsusr] Diagnostics in Ctl File?
>
>
>
>
>
>
> On Mon, Nov 14, 2011 at 4:28 PM, Jeff Duda < jeffduda319 at gmail.com >
> wrote:
>
>
> Mason,
> I see an error in what I typed, but it is only syntactic. The Grads
> commands should be
>
> 'define dx = 're'*cos(lat*(3.1419/180))*cdiff(lon*(3.14159/180),x)'
> 'define dy = 're'*cdiff(lon*(3.14159/180),y)'
>
> Note that I forgot to include the second argument in the cdiff function
> call.
>
>
>
>
> If would like to double check the formulas, compare it to the opengrads
> advection functions, e.g.,
>
>
> tadv = muadv(ugrdprs,tmpprs) + mvadv(vgrdprs,tmpprs)
>
>
> (all the metric terms are computed internally, no need to mess with dx,
> dy). The computation uses a formula described in:
>
>
> Bott, A., 1989a: A positive definite advection scheme obtained by
> nonlinear renormalization of the advection flux. Mon. Wea. Rev. , 117 ,
> 1006-1015.
>
> Bott, A., 1989b: Notes and correspondance. Mon. Wea. Rev. , 117 ,
> 2633-2636.
> This is usually a more accurate algorithm than using cdiff, particularly
> for tracers.
>
>
> Arlindo
>
>
>
>
> Jeff
>
>
>
>
>
> On Mon, Nov 14, 2011 at 3:17 PM, Rowell, Mason D. <
> Mason.D.Rowell-1 at ou.edu > wrote:
>
>
>
>
> All,
>
>
> Okay, but I see one other disparity, surely just a small typo. The
> definition of dy provided by Jeff calls lon for first argument of cdiff,
> but in the cdiff documentation it calls lat. Geometrically, lat seems to be
> correct to me. Also, each usage of cdiff in dx and dy only has one argument.
>
>
> Mason
>
>
>
> From: gradsusr-bounces at gradsusr.org [ gradsusr-bounces at gradsusr.org ] on
> behalf of Jeff Duda [ jeffduda319 at gmail.com ]
> Sent: Monday, November 14, 2011 3:05 PM
> To: GrADS Users Forum
> Subject: Re: [gradsusr] Diagnostics in Ctl File?
>
>
>
> Eric is correct. I forgot that cdiff includes points surrounding a given
> grid point, and thus the "2dx" part is already included in the cdiff
> function.
>
> Jeff
>
>
> On Mon, Nov 14, 2011 at 3:00 PM, Eric Altshuler < ela at cola.iges.org >
> wrote:
>
>
> Mason,
>
> Yes, the expressions for dx and dy are correct.
>
> Eric
>
> ----- Original Message -----
> From: "Mason D. Rowell" < Mason.D.Rowell-1 at ou.edu >
> To: "GrADS Users Forum" < gradsusr at gradsusr.org >
> Sent: Sunday, November 13, 2011 11:07:24 AM
> Subject: Re: [gradsusr] Diagnostics in Ctl File?
>
> Eric,
>
> You agree that dx and dy are defined right though?
>
> Mason
> ________________________________________
> From: gradsusr-bounces at gradsusr.org [ gradsusr-bounces at gradsusr.org ] on
> behalf of Eric Altshuler [ ela at cola.iges.org ]
> Sent: Sunday, November 13, 2011 1:33 AM
> To: GrADS Users Forum
> Subject: Re: [gradsusr] Diagnostics in Ctl File?
>
> I believe the factor of 2 in the denominator of Jeff's expression for
> temperature advection should not be there. The expression should be:
>
> 'define tadv = -ugrdprs*cdiff(tmpprs,x)/dx - vgrdprs*cdiff(tmpprs,y)/dy'
>
> because the cdiff function, when evaluated at a grid point (i,j), gives
> the difference of its argument between the grid points at (i+1) and (i-1)
> or (j+1) and (j-1), i.e. the distance the difference is taken across is two
> grid points. This is also true of dx and dy because they are themselves the
> results of using cdiff. Thus, if there is a factor of 2 in the denominator,
> then there must also be one in the numerator, and they would cancel.
>
> Eric
>
> ----- Original Message -----
> From: "Mason D. Rowell" < Mason.D.Rowell-1 at ou.edu >
> To: "GrADS Users Forum" < gradsusr at gradsusr.org >
> Sent: Saturday, November 12, 2011 8:57:32 PM
> Subject: Re: [gradsusr] Diagnostics in Ctl File?
>
>
>
> Disregard. I am getting the script to use it now. Though I am curious
> about the discrepancy between Jeff's definition of temp. advection and that
> suggested by the cdiff documenation....
>
> Mason
>
>
>
> From: gradsusr-bounces at gradsusr.org [ gradsusr-bounces at gradsusr.org ] on
> behalf of Rowell, Mason D. [ Mason.D.Rowell-1 at ou.edu ]
> Sent: Saturday, November 12, 2011 7:03 PM
> To: GrADS Users Forum
> Subject: Re: [gradsusr] Diagnostics in Ctl File?
>
>
>
>
> All,
>
> Interesting, I get a display when used at the command line, but when run
> within the script, I get,
> 'Function not found: cdiff
> Error occurred on line 15'
>
> Why could this be? It is not syntax related..it just doesn't recognize it
> within the script...the only difference is that it is used in a definition
> (for defining dx) and not with a display command like when used at the
> command prompt...
>
> Mason
>
>
>
> From: gradsusr-bounces at gradsusr.org [ gradsusr-bounces at gradsusr.org ] on
> behalf of Jeff Duda [ jeffduda319 at gmail.com ]
> Sent: Friday, November 11, 2011 11:07 PM
> To: GrADS Users Forum
> Subject: Re: [gradsusr] Diagnostics in Ctl File?
>
>
>
> Mason,
> What happens when you enter the command
> 'd cdiff(tmpprs,x)' ?
>
> Does it display something that looks like the meridional gradient in
> temperature?
>
> Jeff
>
>
> On Fri, Nov 11, 2011 at 11:00 PM, Rowell, Mason D. <
> Mason.D.Rowell-1 at ou.edu > wrote:
>
>
>
>
> Jeff,
>
> My problem comes in using cdiff. Everything else should be fine (it is
> practically verbatim from the webpage). I have a suspicion it is because it
> uses x and y as arguments on two different lines but I don't really have
> much of a way to know without more Grads experience. Could this be causing
> the problem?
>
> Mason
>
>
>
>
> From: gradsusr-bounces at gradsusr.org [ gradsusr-bounces at gradsusr.org ] on
> behalf of Jeff Duda [ jeffduda319 at gmail.com ]
> Sent: Friday, November 11, 2011 3:17 PM
>
>
>
> To: GrADS Users Forum
> Subject: Re: [gradsusr] Diagnostics in Ctl File?
>
>
>
>
>
>
> Mason,
> I preferred to derive the formulas for spacings myself. Simple
> trigonometry reveals the following that you should use for dx and dy (i.e.,
> meridional and zonal grid spacing):
> dx = Re*cos(phi)*d(theta)
> dy = Re*d(phi)
>
> where Re is the radius of the Earth (6371 to 6374 km), phi is latitude,
> theta is longitude, and the d operator means "change in". To convert this
> to Grads scripting code, you use the cdiff command. Also note that all
> angle measures need to be in radians, so you'll have to convert them as you
> do the operation. Here are the literal Grads command lines I use for this:
>
> re = 6.371e3
> 'define dx = 're'*cos(lat*(3.1419/180))*cdiff(lon*(3.14159/180))'
> 'define dy = 're'*cdiff(lon*(3.14159/180))'
>
> Obviously you can assign the conversion factor pi/180 to a script variable
> to simplify the symbolism there:
>
> conv_factor = 3.14159/180
> e.g., 'define dy = 're'*cdiff(lon*'conv_factor')'
>
> If you try to display dx or dy, you should get a nice little image that
> contours or colors dx and dy (dx should decrease towards the poles and not
> change along a line of constant latitude, and dy should only be a function
> of latitude as well). Now use this to define temperature advection
> (assuming the temperature variable is tmpprs and wind is ugrdprs/vgrdprs):
>
> 'define tadv = -ugrdprs*cdiff(tmpprs,x)/(2*dx) -
> vgrdprs*cdiff(tmpprs,y)/(2*dy)'
>
> The 98cbar.gs is indeed just a script that defines color levels and sets
> a color scheme for when you plot temperature advection. Changing the color
> tables is rather easy in Grads. You only need to define a color using 'set
> rgb # R G B', where # is anything between 16 and 255 (just a reference
> number) and R, G, and B are between 0 and 255. Then you set the contour
> intervals manually using 'set clevs , , , , , ...' where you insert
> literally the levels you want to use (separated by SPACES, not COMMAS).
> Then set the colors for those levels using 'set ccols , , , , , , ,+1'
> again using the reference numbers for each color and separating by SPACES.
> The "+1" is for the fact that you need one additional color for the number
> of levls you put. You can consult the controlling colors page for full info
> on what I just said. Also, I have a number of very simple color bar scripts
> that I've used in the past. I can provide them to all if anyone is
> interested.
>
> You can also create a simple color bar using the cbar.gs script which is
> provided in the script library .
>
> Let me know if you need any more help.
>
> Jeff
>
>
> On Fri, Nov 11, 2011 at 2:50 PM, Rowell, Mason D. <
> Mason.D.Rowell-1 at ou.edu > wrote:
>
>
>
>
> Jeff and others,
>
> Strange. This is exactly what was suggested in the ctl file near the
> comments at the bottom (that which I pulled from nomads). The only
> difference is that they have also the inclusion of a 98cbar.gs script
> right after the other expressions like that in this link you gave me, whose
> utility is a mystery since it is not necessary, at least suggested as so by
> the cdiff documenation given that it is not included. Perhaps it is just
> some coloring scheme. At any rate, the script fails at the first line
> (which attempts to define dtx), with each line coded exactly as it is shown
> (with the appropriate NARR temp as TMPprs and wind as UGRDprs and VGRDprs
> of course). I assume it will do so again at dty, and so forth. I originally
> didn't include define with these since I thought they weren't necessary but
> adding that in didn't solve the problem anyways. I suspect it is because
> cdiff calls x, and since I define my domain with lat long, it doesn't have
> a x variable to use? There definitely !
>
> isn't a spacing issue this time...
>
> Mason
>
>
>
> From: gradsusr-bounces at gradsusr.org [ gradsusr-bounces at gradsusr.org ] on
> behalf of Jeff Duda [ jeffduda319 at gmail.com ]
> Sent: Thursday, November 10, 2011 11:11 AM
> To: GrADS Users Forum
> Subject: Re: [gradsusr] Diagnostics in Ctl File?
>
>
>
> Mason,
> There is a good example of how to code temperature advection in the page
> for the cdiff command: http://www.iges.org/grads/gadoc/gradfunccdiff.html
> The reason for all of the crazy manipulations is because the data points
> on your grid are not uniformly spaced on the globe. Thus corrections have
> to be made to get the correct distance between individual grid points.
>
> Jeff
>
>
> On Thu, Nov 10, 2011 at 11:00 AM, Wesley Ebisuzaki <
> Wesley.Ebisuzaki at noaa.gov > wrote:
>
>
> Mason,
>
> I think that you've discovered the "private" commands used by nomads
> plot software for defining new variables
> and custom plots. The nomads plot package is a wrapper for GrADS. It
> has the ability to run grads .gs files that
> are embedded within the ctl files.
>
>
>
> http://www.cpc.ncep.noaa.gov/products/wesley/ncep_data/plot_doc.htmlhttp://www.cpc.ncep.noaa.gov/products/wesley/ncep_data/plot_doc.html
>
> Ask NCDC for a copy of the .gs files.
>
>
> > Has anyone done this before with grads?
> How do you expect the developers to debug the scripts?
>
> Wesley
>
>
>
>
>
>
> Rowell, Mason D. wrote:
> > All,
> >
> > I noticed ample comments toward the end of the ctl files available on
> the nomads servers from the NARR page, with a description of how to
> implement these in grads scripting. I tried to take this to plot
> temperature advection but it didn't work, b/c the last line of the comments
> calls for some function never provided. Has anyone done this before with
> grads?
> >
> > Mason
> > _______________________________________________
> > 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
>
>
>
> --
> Jeff Duda
> Grad student - PhD, Meteorology
> University of Oklahoma School of Meteorology - Center for Analysis and
> Prediction of Storms
>
>
> _______________________________________________
> gradsusr mailing list
> gradsusr at gradsusr.org
> http://gradsusr.org/mailman/listinfo/gradsusr
>
>
>
>
> --
> Jeff Duda
> Grad student - PhD, Meteorology
> University of Oklahoma School of Meteorology - Center for Analysis and
> Prediction of Storms
>
>
> _______________________________________________
> gradsusr mailing list
> gradsusr at gradsusr.org
> http://gradsusr.org/mailman/listinfo/gradsusr
>
>
>
>
> --
> Jeff Duda
> Grad student - PhD, Meteorology
> University of Oklahoma School of Meteorology - Center for Analysis and
> Prediction of Storms
>
>
> _______________________________________________
> 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
>
> _______________________________________________
> 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
>
>
>
> --
> Jeff Duda
> Grad student - PhD, Meteorology
> University of Oklahoma School of Meteorology - Center for Analysis and
> Prediction of Storms
>
>
> _______________________________________________
> gradsusr mailing list
> gradsusr at gradsusr.org
> http://gradsusr.org/mailman/listinfo/gradsusr
>
>
>
>
> --
> Jeff Duda
> Grad student - PhD, Meteorology
> University of Oklahoma School of Meteorology - Center for Analysis and
> Prediction of Storms
>
>
> _______________________________________________
> gradsusr mailing list
> gradsusr at gradsusr.org
> http://gradsusr.org/mailman/listinfo/gradsusr
>
>
>
>
>
> --
> Arlindo da Silva
> dasilva at alum.mit.edu
>
> _______________________________________________
> 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
>
--
Jeff Duda
Grad student - PhD, Meteorology
University of Oklahoma School of Meteorology - Center for Analysis and
Prediction of Storms
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://gradsusr.org/pipermail/gradsusr/attachments/20111114/8ea4d07e/attachment-0003.html
More information about the gradsusr
mailing list