Re: [idvusers] Jython coding a grid formula using more than one data source

  • To: Tom Whittaker <whittaker@xxxxxxxx>
  • Subject: Re: [idvusers] Jython coding a grid formula using more than one data source
  • From: Mike Umscheid - NOAA Federal <mike.umscheid@xxxxxxxx>
  • Date: Thu, 6 Aug 2015 11:28:47 -0500
Wow that worked!  Thank you very much for the prompt reply and coding
help!  Really appreciate it Tom.  -Mike

On Thu, Aug 6, 2015 at 11:03 AM, Tom Whittaker <whittaker@xxxxxxxx> wrote:

> I assume that the variable "field" is some VisAD Data Object (like a
> FlatField or FieldImpl).  You might check the type...  If that's the
> case, then I would do something like this:
>
> Inside the loop, right after "field = ... ":
>
>    if x == 4:
>       sum = field.clone();
>    else:
>       sum = sum + field;
>
> The first time through the loop, you then create a new object ("sum") that
> will be used for the summation.  It has all the same attributes as
> "field" (units, coordinate system, etc.) and its values.
>
> Then after the loop is done, just do:
>       avg = sum / 5.0;
>
> Hope that helps...if "field" is not a VisAD Data object, then you'll
> likely need a different approach..
>
> tom
>
> On Thu, Aug 6, 2015 at 10:17 AM, Mike Umscheid - NOAA Federal
> <mike.umscheid@xxxxxxxx> wrote:
> > I'm wondering if someone with some stronger IDV/Jython knowledge than me
> > help me with proper Jython coding.
> >
> > What I have already successfully Jython coded:
> >
> > "Paintball Plot" of Composite Reflectivity >= 38dbz... Load in 5
> > consecutive HRRR model runs, create a dataSelection subsetting to a user
> > input domain applied to all 5 sources, creating a field of "Composite
> > Reflectivity" of all 5 sources, creating the display, applying Display
> > Control modifications like contour info, display label, etc.  Here is the
> > code:
> >
> > def makeHRRR_PaintballPlot_CZ():
> >> runHour = raw_input('Input last model run hour for the paintball plot:
> ')
> >> subset = getPlotSubset()
> >> boundBox = subset.split(',')
> >> dataSel = DataSelection()
> >> colors = ["Red","Orange","Yellow","Green","DkGreen"]
> >> a = [0,0,0,0,0]
> >> for x in range(4,-1,-1):
> >>    a[x] = makeDataSource(getHRRR(int(runHour)-x))
> >>
> >>
> dataSel.setBounds(float(boundBox[0]),float(boundBox[1]),float(boundBox[2]),float(boundBox[3]))
> >>    field =
> a[x].getData(a[x].findDataChoice("CompRefl"),None,dataSel,None)
> >>    dc = createDisplay('planviewcontourfilled',field,"Composite
> >> Reflectivity")
> >>    pause()
> >>    cinfo =
> idv.getDisplayConventions().findDefaultContourInfo("CompRefl")
> >>    cinfo.setMin(38.0)
> >>    dc.setContourInfo(cinfo)
> >>    ctm = idv.getColorTableManager()
> >>    dc.setColorTable(ctm.getColorTable(colors[x]))
> >>    dc.setLegendLabelTemplate("%shortname%")
> >>    dc.setDisplayListTemplate("%shortname% - %timestamp%")
> >
> >
> > What I want to do:  After this is done plotting, create another display
> > that is the average of all 5 of these fields.  I have tried using things
> > like idveval() and adding all the fields together and dividing by 5, but
> > that doesn't work (or maybe I'm coding it wrong).  I can make this plot
> > manually by going into the Dashboard>Field Selector>Formulas and using
> > idveval() function, but I'd like to have this field automatically created
> > within this Jython method.  Thanks!
> >
> > Mike Umscheid
> > _______________________________________________
> > idvusers mailing list
> > idvusers@xxxxxxxxxxxxxxxx
> > For list information, to unsubscribe, visit:
> http://www.unidata.ucar.edu/mailing_lists/
>
>
>
> --
> Tom Whittaker
> Researcher-Emeritus
> Honorary Fellow
> Space Science and Engineering Center
> University of Wisconsin-Madison
> Madison, WI USA
>


  • 2015 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the idvusers archives: