Visualisation of 2D data using VisAd
Source code name: "plots2d_visad1.py"
Programming language: Python
Topic: Plots/2D
DMelt Version 1.9. Last modified: 06/28/1971. License: Pro
https://datamelt.org/code/cache/plots2d_visad1_6685.py
To run this script using the DMelt IDE, copy the above URL link to the menu [File]→[Read script from URL] of the DMelt IDE.


from visad import SI,Integer1DSet,RealType
from visad import FunctionType, FieldImpl, ScalarMap, Display
from visad import Display,FlatField,DataReferenceImpl
from visad.java2d import DisplayImplJ2D

time = RealType("time",SI.second)
height = RealType("height",SI.meter)

# Create a FunctionType, that is the class which represents our function
#  This is the MathType ( time -> height )
# Use FunctionType(MathType domain, MathType range)
func_time_height = FunctionType(time, height)


# Those are our actual height values
# Note the dimensions of the array:
# float[ number_of_range_components ][ number_of_range_samples]
h_vals =[[0.0, 33.75, 45.0, 33.75, 0.0]] 


# Create the time_set, with 5 integer values, ranging from 0 to 4.
# That means, that there should be 5 values for height.
# Use Integer1DSet(MathType type, int length)
time_set = Integer1DSet(time, 5);

vals_ff = FlatField( func_time_height, time_set);

# and put the height values above in it
vals_ff.setSamples( h_vals );

# create canvas
display = DisplayImplJ2D("display1");

# Create the ScalarMaps: quantity time is to be displayed along x-axis
# and height along y-axis
# Use ScalarMap(ScalarType scalar, DisplayRealType display_scalar)
timeMap = ScalarMap( time, Display.XAxis );
heightMap = ScalarMap( height, Display.YAxis );


# Add maps to display
display.addMap( timeMap );
display.addMap( heightMap );


#  Create a data reference and set the FlatField as our data
data_ref = DataReferenceImpl("data_ref");
data_ref.setData( vals_ff );


# Add reference to display
display.addReference( data_ref );

from javax.swing import JFrame
# Create application window, put display into it
jf=JFrame("VisAD application");
jf.getContentPane().add(display.getComponent())

# Set window size and make it visible
jf.setSize(600, 400);
jf.setVisible(True);



You see the box below because you did not login.