Re: [idvusers] Jython method for generating a change map sequence from a netCDF file

Patrick,

There is a new function (in the latest nightly build) that might do what you wish. Look under Formulas --> Grids --> Time Steps --> Time Step Difference.

Bill

Patrick Koethur wrote:
Hi everyone,

I've tried to write a Jython method which calculates the changes in the numeric values of a variable in a netCDF file over time and returns a time sequence. The method I've written looks like this:

def computeSimpleChangeMap(twoDTimeSeries):
   # get the number of time steps
   timeStepCount = twoDTimeSeries.getDomainSet().getLength()
   changeMapSequence = []
   for t in range(timeStepCount):
       if t < (timeStepCount-1):
change = twoDTimeSeries.getSample(t+1) - twoDTimeSeries.getSample(t)
           changeMapSequence.append(change)
   fld = makeTimeSequence(changeMapSequence)
   return fld

However, when I run this method, I get the following error message:
" Traceback (innermost last):
File "<string>", line 1, in ?
File "<string>", line 121, in computeSimpleChangeMap
File "<string>", line 230, in makeTimeSequence
at visad.Set.<init>(Set.java:148)
at visad.SimpleSet.<init>(SimpleSet.java:58)
at visad.SampledSet.<init>(SampledSet.java:47)
at visad.GriddedSet.<init>(GriddedSet.java:72)
at visad.Gridded1DSet.<init>(Gridded1DSet.java:130)
at visad.Gridded1DDoubleSet.<init>(Gridded1DDoubleSet.java:107)
at visad.Gridded1DDoubleSet.create(Gridded1DDoubleSet.java:174)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)

visad.UnitException: visad.UnitException: Set: units dimension 1 does not match Domain dimension 2"


The dumpType() method returns the following information:

dumpType(twoDTimeSeries.getSample(0))
FunctionType:
Domain has 2 components:
0. RealType: Longitude
0. Name = Longitude
0. Unit: deg
1. RealType: Latitude
1. Name = Latitude
1. Unit: deg
Range:
RealType: zo[unit:m]
Name = zo[unit:m]
Unit: m

dumpType(twoDTimeSeries)
FunctionType:
Domain has 1 components:
0. RealType: Time
0. Name = Time
0. Unit: s since 1970-01-01 00:00:00.000 UTC
Range:
FunctionType:
Domain has 2 components:
0. RealType: Longitude
0. Name = Longitude
0. Unit: deg
1. RealType: Latitude
1. Name = Latitude
1. Unit: deg
Range:
RealType: zo[unit:m]
Name = zo[unit:m]
Unit: m

dumpType(changeMapSequence[0])
VisAD MathType analysis
FunctionType:
Domain has 2 components:
0. RealType: Longitude
0. Name = Longitude
0. Unit: deg
1. RealType: Latitude
1. Name = Latitude
1. Unit: deg
Range:
RealType: zo[unit:m]
Name = zo[unit:m]
Unit: m

dumpType(changeMapSequence)
Error: Traceback (innermost last): File "", line 1, in ? TypeError: dumpType(): 1st arg can't be coerced to visad.Data


I am able to generate the change map sequence manually by using the "Make a time sequence from single time grids/images" formula in combination with multiple "Simple difference a-b"formulas. Therefore, there must be a problem with the changeMapSequence variable. A simple Python list doesn't seem to be appropriate here. Does anyone know what kind of data type to use and how to construct it? Any help is much appreciated.

Best regards,
Patrick Koethur

_______________________________________________
idvusers mailing list
idvusers@xxxxxxxxxxxxxxxx
For list information, to unsubscribe, visit: http://www.unidata.ucar.edu/mailing_lists/


--
The Fingerhuts
Saint Johnsbury, Vt, 05819

email: fingerhuts3@xxxxxxxxx