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

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



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