Beginner question

Carsten Friedrich carsten at dtecht.com.au
Sun Jul 9 22:45:53 MDT 2006


Hi,

I'm trying to display a field of data samples (x,y)->z in 3D, pretty much
like the tutorial section 4. My field is a bit bigger, not unrealistically
big though: 365 x 100 samples.

When I try to render this, some of the peaks are missing. It seems to me
like the renderer constructs the surface using only every n-th data point
from my field and interpolates the rest (although actual values would
exist). This assumption is supported by the program below which fills the
field with random data: If every peak was drawn correctly no peak would have
several colour patches in it.

How can I get every peak drawn? (Btw iso-contour map achieves this, but
limits me in other respects).

Thanks for your help

Carsten

Sample program (contains some unnecessary code, please ignore that):

/*
 VisAD Tutorial
 Copyright (C) 2000 Ugo Taddei
 */

package tutorial.s4;

// Import needed classes

import java.awt.*;
import java.rmi.*;
import java.sql.*;

import javax.swing.*;

import com.dtecht.server.database.*;

import visad.*;
import visad.java3d.*;
import visad.util.*;

/**
 * VisAD Tutorial example 4_01 Like example 4_02 but using a ContourWidget
We
 * have the functions altitude = h(latitude, longitude) temperature
 * f(latitude, longitude)
 * 
 * represented by the MathType ( (latitude, longitude) -> (altitude,
temperature ) )
 * Map the altitude to ZAxis and temperature to RGB Run program with "java
 * P4_02"
 */

public class P4_02_1 {


	// The ContourWidget
	public P4_02_1(String[] args) throws RemoteException,
VisADException,
			SQLException {

		RealType day = //RealType.getRealType("day");// 
			RealType.getRealType("day",SI.meter,null);

		RealType age = RealType.getRealType("age",SI.meter,null);

		RealTupleType domain_tuple = new RealTupleType(day, age);

		RealType stddev
RealType.getRealType("stddev",SI.meter,null);
		RealType avg = RealType.getRealType("avg",SI.meter,null);

		RealTupleType range_tuple = new RealTupleType(avg, stddev);

		// Create a FunctionType (domain_tuple -> range_tuple )
		// Use FunctionType(MathType domain, MathType range)

		FunctionType func_domain_range = new
FunctionType(domain_tuple, range_tuple);

		int NCOLS = 100;
		int NROWS = 365;

		float[][] flat_samples = new float[2][NCOLS * NROWS];

		for(int i=0; i< NCOLS*NROWS;i++) {
			flat_samples[0][i]= (float) Math.random();  
			flat_samples[1][i]= flat_samples[0][i];
		}
		
		// Create Display and its maps

		// A 2D display

		DisplayImplJ3D display = new DisplayImplJ3D("display1");

		// Get display's graphics mode control and draw scales

		GraphicsModeControl dispGMC = (GraphicsModeControl) display
				.getGraphicsModeControl();
		dispGMC.setScaleEnable(true);

		// Create the ScalarMaps: latitude to YAxis, longitude to
XAxis and
		// altitude to ZAxis and temperature to RGB
		// Use ScalarMap(ScalarType scalar, DisplayRealType
display_scalar)

		ScalarMap latMap = new ScalarMap(day, Display.YAxis);
		ScalarMap lonMap = new ScalarMap(age, Display.XAxis);

		// Add maps to display

		display.addMap(latMap);
		display.addMap(lonMap);

		// altitude to z-axis and temperature to color

		ScalarMap altZMap = new ScalarMap(avg, Display.ZAxis);
		display.addMap(altZMap);

		ScalarMap tempRGBMap = new ScalarMap(stddev, Display.RGB);
		display.addMap(tempRGBMap);



		Set domain_set = new Integer2DSet(domain_tuple, NROWS,
NCOLS);
	//	Set domain_set = new Linear2DSet(domain_tuple, 0, 364,
NROWS, 0, 99, NCOLS);
		FlatField vals_ff = new FlatField(func_domain_range,
domain_set);

		// ...and put the values above into it

		// Note the argument false, meaning that the array won't be
copied

		vals_ff.setSamples(flat_samples, false);		
		
		// Create a data reference and set the FlatField as our data
		
		DataReferenceImpl data_ref = new
DataReferenceImpl("data_ref");

		data_ref.setData(vals_ff);

		// Add reference to display

		display.addReference(data_ref);

		// Create application window and add display to window

		JFrame jframe = new JFrame("VisAD Tutorial example 4_02");
		jframe.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		jframe.getContentPane().setLayout(new BorderLayout());
		jframe.getContentPane().add(display.getComponent(),
BorderLayout.CENTER);

		jframe.setSize(1200, 800);
		jframe.setVisible(true);

	}

	public static void main(String[] args) throws RemoteException,
VisADException {
		try {
			new P4_02_1(args);
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

} // end of Visad Tutorial Program 4_01

-- 
Carsten Friedrich
Dtecht Pty Limited
Suite 1303, 33 Bligh Street, Sydney NSW 2000
Tel: +61 2 9220 8204   
Fax: +61 2 9238 0044   http://www.dtecht.com

Dtecht Pty Ltd - Confidential Communication The information contained in
this e-mail is confidential.  It is intended solely for the addressee. If
you receive this e-mail by mistake please promptly inform us by reply e-mail
and then delete the e-mail and destroy any printed copy. You must not
disclose or use in any way the information in the e-mail. There is no
warranty that this e-mail is error or virus free. It may be a private
communication, and if so, does not represent the views of Dtecht and its
associates. 




==============================================================================
To unsubscribe visad, visit:
http://www.unidata.ucar.edu/mailing-list-delete-form.html
==============================================================================



More information about the visad mailing list