Re: more questions

From: Mary Haley <haley_at_nyahnyahspammersnyahnyah>
Date: Wed, 10 Nov 2004 15:19:48 -0700 (MST)

Ray sent me this message, and gave me permission to post it back to
pyngl-talk. Does anybody have comments about Pickle? I'm new to it
myself.

--Mary

> On Nov 5, 2004, at 14:32 PM, R.T. Pierrehumbert wrote:
>
> Now that we have Python, I think there may also be an alternate
> Python-ish
> way to do such things as Ivan wants. Since resources are just Python
> objects, if you have a resource you use a lot, you can just save it
> to disk using the Pickle module, and retrieve it similarly. If you have
> a
> set of resources (say, one for contour plots, another for an
> accompanying
> line plot) you can package them up into a single object with two
> different elements and pickle that. Defining a simple plot function
> that calls the Ngl routines you want, pulling the right resources
> out of the Pickle'd file, takes care of the rest.
>
> There are also advantages of the old ncl way of doing resource files,
> but I've been pretty satisfied with the approach I've outlined above.
>
>
> On Nov 4, 2004, at 5:32 PM, Mary Haley wrote:
>
> >>
> >> Hello everyone,
> >>
> >> I also have some questions regarding plotting with PyNGL:
> >>
> >> 1. I make lots of similar plots/maps that use the same settings for
> >> several resources. Is there a way to specify a "resource file" with
> >> the common resource settings that can be used in several different
> >> Python scripts?
> >
> > Hi Ivan,
> >
> > Yes, you can use a resource file called ".hluresfile" that you put in
> > your home directory. Note that you cannot set the "ngl" resources in
> > this file.
> >
> > So, for example, if you always want a white background, black
> > foreground, helvetica font, a function code of "~" (the default is a
> > colon, which is a common character in titles), and a size of 700x700
> > whenever you send your output to an X11 window, you would create a
> > file called "~/.hluresfile", and put the following six lines in it:
> >
> > *wkForegroundColor : (/0.,0.,0./)
> > *wkBackgroundColor : (/1.,1.,1./)
> > *Font : helvetica
> > *txFuncCode : ~
> > *wkWidth : 700
> > *wkHeight : 700
> >
> > There is more information about resource files in the PyNGL document:
> >
> > http://www.pyngl.ucar.edu/selectedtopics.html#ResourceFiles
> >
> >> 2. Is there a way to change the view port size (vpWidthF or
> >> vpHeightF) but keep the X and Y axis labels the same size?
> >
> > Whenever you change the width and height of your plot, other aspects
> > of the plot (including the X/Y axis labels) will scale accordingly.
> > To fix the size of these labels, you need to set them explicitly:
> >
> > resources.tiXAxisFontHeightF = 0.025
> > resources.tiYAxisFontHeightF = 0.025
> >
> > If you want to retrieve the font heights from your current plot so you
> > know what to set them to before you change the size, add the following
> > lines after your plot is created:
> >
> > ...
> > contour = Ngl.contour(wks,data,resources)
> > ...
> > ysize = Ngl.get_float(contour.base,"tiYAxisFontHeightF")
> > xsize = Ngl.get_float(contour.base,"tiXAxisFontHeightF")
> > print xsize, ysize
> >
> > Then, use the values for xsize and ysize to set your font heights.
> >
> >> 3. How do I make the labelbar legends that are smaller than one to
> >> be in the format "0.1" instead of ".1"?
> >
> > For some of our text resources, like the tickmark labels, we have a
> > corresponding "Format" resource that allows you to format the strings
> > used. However, I don't see a similar resource for labelbar
> > labels. I'm not sure if this is an oversight, or if it just hasn't
> > been implemented. [Dave B, can you pipe in here?]
> >
> > For a work-around, you can set the labels yourself:
> >
> > resources.cnExplicitLabelBarLabelsOn = True
> > resources.lbLabelStrings = ["0.1","0.2","0.3",...,]
> >
> >> 4. Is it possible to use Ngl.panel to (for example) put one XY plot
> >> and 3 filled contour maps in one frame and specify a single
> >> labelbar for the filled contour maps? When I tried to do that I
> >> got errors saying that the panel contained plots (the XY plot) that
> >> were not consistent with a labelbar attribute.
> >
> > Ngl.panel should only be used for plots that are the same size. If you
> > want to panel different sized plots, the best thing to do is control
> > the locations and sizes yourself using the vpXF, vpYF, vpWidthF, and
> > vpHeightF resources.
> >
> > The "meteogram.py" example script shows how to create different plots
> > and put them on the same page. I believe you need the latest PyNGL
> > version in order to run it. Try:
> >
> > pyngl meteogram
> >
> > and it should copy a file called "meteogram.py" in your current working
> > directory, run it through Python, and create a PostScript file
> > called "meteogram.ps".
> >
> >> I would also like to thank Mary Haley and Fred Clare for their
> >> effort and for giving us the ability to do high quality graphics
> >> under Python.
> >>
> >> - Ivan
> >
> > Flattery will get you everywhere! Thanks for the compliment. It
> > really has been the effort of the whole NCL team to bring you these
> > high-quality graphics.
> >
> > --Mary
> >
> >> --
> >> Ivan Lima
> >> Woods Hole Oceanographic Institution, MC&G MS #25
> >> 360 Woods Hole Road, Woods Hole, MA 02543-1543 USA
> >> _______________________________________________
> >> pyngl-talk mailing list
> >> pyngl-talk_at_ucar.edu
> >> http://mailman.ucar.edu/mailman/listinfo/pyngl-talk
> >>
_______________________________________________
pyngl-talk mailing list
pyngl-talk_at_ucar.edu
http://mailman.ucar.edu/mailman/listinfo/pyngl-talk
Received on Wed Nov 10 2004 - 15:20:17 MST

This archive was generated by hypermail 2.2.0 : Thu Jan 19 2006 - 21:30:17 MST