Animation missing steps

Hello,

I've noticed some odd behaviour with animation, where it can seemingly
miss some time steps.

Attached is a sample program that demonstrates this.  It creates a
couple of FlatFields with FunctionTypes (Time->something), adds them to
a DisplayImplJ3D, then turns on the animation.

Looking at the times in the data, there should be 16 time steps, but
VisAD only steps through 14 of them.  Two are missing, the times at
"2003-07-21 18:25 +0000" and "2003-07-21 23:25 +0000".

If the program is modified so that it has only one FlatField with all
the times merged and in order, it will step through all the times.

I'm guessing that this may be to do with the way visad decides which
elements are close enough to be displayed at the same time step.

So, is this the expected behaviour?  How can I get animation over two
FlatFields with times similar to this using all the discrete time steps?

Thanks
Russell



-- 
Russell Steicke

-- Fortune says:
I never deny, I never contradict.  I sometimes forget.
                -- Benjamin Disraeli, British PM, on dealing with the
                   Royal Family
import visad.*;
import visad.java3d.*;
import javax.swing.*;
import java.text.ParsePosition;
import java.text.SimpleDateFormat;
import java.util.TimeZone;

public class t5
{

    static String[] dates1 = new String[] {
        "2003-07-21 18:00 +0000",
        "2003-07-22 00:00 +0000",
        "2003-07-22 06:00 +0000",
        "2003-07-22 12:00 +0000",
        "2003-07-22 18:00 +0000",
    };

    static String[] dates2 = new String[] {
        "2003-07-21 13:25 +0000",
        "2003-07-21 14:25 +0000",
        "2003-07-21 15:25 +0000",
        "2003-07-21 16:13 +0000",
        "2003-07-21 17:25 +0000",
        "2003-07-21 18:25 +0000",
        "2003-07-21 19:25 +0000",
        "2003-07-21 20:25 +0000",
        "2003-07-21 21:25 +0000",
        "2003-07-21 22:13 +0000",
        "2003-07-21 23:25 +0000",
    };

    static SimpleDateFormat dateFormat;

    static double date2double(String datestr)
    {
        java.util.Date date = dateFormat.parse(datestr, new ParsePosition(0));
        System.out.println("date "+dateFormat.format(date));
        return date.getTime() / 1000.0;
    }

    public static void main(String[] args)
    {
        try {
            dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm ZZZ");
            dateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));

            // Set up the first FlatField
            RealType rt1 = RealType.getRealType("rt1");
            FunctionType functionType1 = new FunctionType(RealType.Time, rt1);
            double[][] doubles1 = new double[1][dates1.length];
            for (int i=0; i<dates1.length; i++) {
                doubles1[0][i] = date2double(dates1[i]);
            }
            Gridded1DDoubleSet domain1 = new Gridded1DDoubleSet(RealType.Time,
                                                                doubles1,
                                                                dates1.length);
            FlatField flatField1 = new FlatField(functionType1, domain1);
            for (int i=0; i<dates1.length; i++) {
                flatField1.setSample(i, new Real(rt1, i));
            }

            // Set up the second FlatField
            RealType rt2 = RealType.getRealType("rt2");
            FunctionType functionType2 = new FunctionType(RealType.Time, rt2);
            double[][] doubles2 = new double[1][dates2.length];
            for (int i=0; i<dates2.length; i++) {
                doubles2[0][i] = date2double(dates2[i]);
            }
            Gridded1DDoubleSet domain2 = new Gridded1DDoubleSet(RealType.Time,
                                                                doubles2,
                                                                dates2.length);
            FlatField flatField2 = new FlatField(functionType2, domain2);
            for (int i=0; i<dates2.length; i++) {
                flatField2.setSample(i, new Real(rt2, i));
            }

            // Display stuff
            JFrame jframe = new JFrame("t5");
            DisplayImpl display = new DisplayImplJ3D("display");
            display.addMap(new ScalarMap(RealType.Time, display.Animation));
            display.addMap(new ScalarMap(rt1, display.RGB));
            display.addMap(new ScalarMap(rt2, display.RGB));

            jframe.getContentPane().add(display.getComponent());

            DataReference dr1 = new DataReferenceImpl("dr1");
            dr1.setData(flatField1);
            display.addReference(dr1, null);

            DataReference dr2 = new DataReferenceImpl("dr2");
            dr2.setData(flatField2);
            display.addReference(dr2, null);

            // Start the animation
            AnimationControl animationControl
                = (AnimationControl)display.getControl(AnimationControl.class);
            animationControl.setStep(3000);
            animationControl.setOn(true);

            jframe.setSize(400, 400);
            jframe.show();

        } catch (Exception e) {
            System.err.println("Exception: "+e);
            e.printStackTrace();
            System.exit(1);
        }
    }


}

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