Hi Tom,
Thanks for your help. I figured out a method after some experimentation
and realised I could not use the visad logic. My algorithm works
point-wise, which requires having to step through each point individually.
Essentially, I modified existing code for substitution, found in IDV's
Jython library:
def wetbulb(temp,dewpt):
from java.lang import Math
tempData = temp.clone();
dewptData = dewpt.clone();
presData = extractPressureFromNWPGrid(tempData);
wetbulbData = temp.clone();
if (GridUtil.isTimeSequence(tempData)):
for t in range(tempData.getDomainSet().getLength()):
tempValues = tempData[t]
dewptValues = dewptData[t]
presValues = presData[t]
wetbulbRangeObj = wetbulbData.getSample(t)
newValues = wetbulbRangeObj.getFloats(0)
print "Processing wetbulb temperature for time ", t
for i in range(len(tempValues)):
if(str(float(tempValues[i].getValue()))!='nan'):
newValues[0][i] =
findwetbulb(kelvinToCelcius(tempValues[i].getValue()),kelvinToCelcius(dewptValues[i].getValue()),presData[i].getValue())
wetbulbRangeObj.setSamples(newValues,1)
wetbulbData = newUnit(noUnit(wetbulbData),'Wetbulb temperature in
celcius','C')
return wetbulbData
Paul
On 10 December 2013 01:12, Tom Whittaker <whittaker@xxxxxxxx> wrote:
> Hi Paul --
>
> If your function has no logic that needs to be applied to each point,
> then if the data were read in via the IDV they would be "VisAD Data
> objects" and you should just be able to do something like:
>
> a = b + c - d
>
> where "b", "c" and "d" are 3D Data objects (or maybe 4D if they
> include "time") and it will do the computation on every point. and put
> the result in "a" (creating a new Data object with characteristics
> like that of "b" (the first object in the computation).
>
> If you have logic, then you might have to iterate over every point...I
> say "might" because sometimes some of the built-in methods like "mask"
> can be used to simulate logic.
>
> Hope that helps.
>
> tom
>
>
>
> On Sun, Dec 8, 2013 at 9:39 PM, Paul Graham <meteorpaul@xxxxxxxxx> wrote:
> > Hi IDV'ers,
> >
> > I have written a Jython function which takes temperature, dewpoint and
> > pressure as arguments and evaluated at each point in a 3d domain to
> > calculate the wet bulb temperature. What is the best way using Jython to
> > iterate over my domain so I can set the wetbulb result for each point?
> > Eg. wetbulbresult[i][j][k] =
> > findwetbulb(temperature[i][j][k],dewpoint[i][j][k],pressure[i][j][k]),
> > where i,j are subscripts for the latitude and longitude and k for the
> > height.
> >
> > Thanks in advance,
> >
> > Paul
> > _______________________________________________
> > idvusers mailing list
> > idvusers@xxxxxxxxxxxxxxxx
> > For list information, to unsubscribe, visit:
> http://www.unidata.ucar.edu/mailing_lists/
>
>
>
> --
> Tom Whittaker
> University of Wisconsin-Madison
> Space Science & Engineering Center (SSEC)
> Cooperative Institute for Meteorological Satellite Studies (CIMSS)
> 1225 W. Dayton Street
> Madison, WI 53706 USA
> ph: +1 608 262 2759
>