Hi Michael,
You can do something almost as convenient. Assume that
'float new_values[length]' are the values for the k-th
component of 'field' where 'length = field.getLength()':
float[][] values = field.getFloats(false); / don't copy
// just update values for field component k
values[k] = new_values;
field.setSamples(values, false); // don't copy
You may need to initialize the values array to all
Float.NaN the first time you do this.
Good luck,
Bill
On Thu, 2 Dec 2004, Kapper Michael G Contr AFRL/PRSA wrote:
> Greetings,
>
>
>
> I am attempting real-time VisAD visualization with a plasma code and I have
> a few issues regarding RealTupleTypes and FlatField.setSamples(). I would
> like to include all possible variables that can be visualized when my code
> is initialized, but not all of them will be plotted all of the time as the
> simulation progresses. The user can turn variables on and off through a
> GUI. Therefore I would like to set only the samples for the data that I
> want to visualize at that particular iteration. So I have set up my
> RealTupleTypes as following.
>
>
>
>
>
> density = RealType.getRealType("density", SI.meter, null);
>
> densityTuple = new RealTupleType(density);
>
>
>
> temperature = RealType.getRealType("temperature", SI.meter, null);
>
> temperatureTuple = new RealTupleType(temperature);
>
>
>
> velocity = new RealType[Ndims];
>
> for(int n=0;n<Ndims;n++)
>
> { velocity[n] = RealType.getRealType("velocity"+n, SI.meter, null);
>
> }
>
> velocityField = new RealTupleType(velocity);
>
>
>
> electromagnetic = new RealType[Ndims];
>
> for(int n=0;n<Ndims;n++)
>
> { electromagnetic[n] = RealType.getRealType("electromagnetic"+n, SI.meter,
> null);
>
> }
>
> electromagneticField = new RealTupleType(electromagnetic);
>
>
>
> etc...
>
>
>
>
>
> This has worked well so far because I am able to setSamples() for each
> individual FlatField separately. Therefore when I don't want to visualize a
> variable, I just don't set its samples. But what I really want, is to do
> things like generate a 3D surface plot of the density and then map
> streamlines for the flow field on top of the density surface. This is
> easily accomplished by creating a RealTupleType with density, velocityX, and
> velocityY. Then you just set the samples for all 3 variables. But what
> happens if you don't want to map the streamlines to the density surface
> anymore? It seems as if you still have to set the samples for all 3
> variables. I don't see method in FlatField which allows you to set samples
> for individual components. If not, is there a way around this, or possibly
> should a new method be added which allows you to select which variable you
> want to set? I guess you could create a new RealTupleType, FlatField,
> DataReference, etc..., but it would be nice if one could selectively set the
> samples for a desired variable.
>
>
>
> Thanks in advance.
>
>
>From owner-visad@xxxxxxxxxxxxxxxx Fri 3 2004 Dec 15:33:59
Message-ID: <1102088039.41b087676320e@xxxxxxxxxxxxxxxxxxx>
Date: Fri, 3 Dec 2004 15:33:59 +0000
From: Adityarajsingh Santokhee <ads@xxxxxxxxxxxxxxxxxxxx>
To: visad@xxxxxxxxxxxxxxxx
Subject: Problem with animation
Received: (from majordo@localhost)
by unidata.ucar.edu (UCAR/Unidata) id iB3FYVVS015837
for visad-out; Fri, 3 Dec 2004 08:34:31 -0700 (MST)
Received: from vimg3.rdg.ac.uk (vimg3.rdg.ac.uk [134.225.1.80])
by unidata.ucar.edu (UCAR/Unidata) with ESMTP id iB3FYTlI015803
for <visad@xxxxxxxxxxxxxxxx>; Fri, 3 Dec 2004 08:34:29 -0700 (MST)
Organization: UCAR/Unidata
Keywords: 200412031534.iB3FYTlI015803
Received: from vimp1.rdg.ac.uk ([134.225.16.90])
by vimg3.rdg.ac.uk (Exim: gateway)
with esmtp id 1CaFRe-00022V-00
for visad@xxxxxxxxxxxxxxxx; Fri, 03 Dec 2004 15:34:06 +0000
Received: from vimh1.rdg.ac.uk ([134.225.16.83])
by vimp1.rdg.ac.uk (Exim: virusscanner)
with esmtp id 1CaFRY-0001Py-00
for visad@xxxxxxxxxxxxxxxx; Fri, 03 Dec 2004 15:34:00 +0000
Received: from mercury.nerc-essc.ac.uk ([192.171.166.1])
by vimh1.rdg.ac.uk (Exim: host)
with esmtp id 1CaFRX-0003Ta-00
for visad@xxxxxxxxxxxxxxxx; Fri, 03 Dec 2004 15:33:59 +0000
Received: from sweeney.nerc-essc.ac.uk (sweeney [192.171.166.116])
by mercury.nerc-essc.ac.uk (8.12.10/8.12.10) with ESMTP id
iB3FXx7o016837
for <visad@xxxxxxxxxxxxxxxx>; Fri, 3 Dec 2004 15:33:59 GMT
Received: from localhost.localdomain (sweeney [127.0.0.1])
by sweeney.nerc-essc.ac.uk (8.12.8/8.12.8) with ESMTP id iB3FXxml017250
for <visad@xxxxxxxxxxxxxxxx>; Fri, 3 Dec 2004 15:33:59 GMT
Received: (from apache@localhost)
by localhost.localdomain (8.12.8/8.12.8/Submit) id iB3FXxHY017248
for visad@xxxxxxxxxxxxxxxx; Fri, 3 Dec 2004 15:33:59 GMT
Received: from brahman.nerc-essc.ac.uk (brahman.nerc-essc.ac.uk
[192.171.166.139])
by www.nerc-essc.ac.uk (IMP) with HTTP
for <ads@xxxxxxxxxxxxxxxxxxxxxxx>; Fri, 3 Dec 2004 15:33:59 +0000
MIME-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
User-Agent: Internet Messaging Program (IMP) 3.2.2
X-Originating-IP: 192.171.166.139
X-Scanner: exiscan *1CaFRY-0001Py-00*TABOMS37YVU* (The University of Reading)
Sender: owner-visad@xxxxxxxxxxxxxxxx
Precedence: bulk
Hello,
I have recently started using the VisAD Graphics API. I have tried Ugo Taddei
examples and the tutorials and found them very useful.
My problem is as follows. I am trying to do a simple animation of a surface :
(lat,lon)->temperature. My objective is to see how temperature of the surface
changes over time. I have been testing with the "infinite loop example" calling
FlatField.setSamples(float [][] samples) to update the display.
I am getting some results. However, the problem is that the graph is moving
along the x-axis with each new frame. This is the subroutine I am using.
public void displayData(float [][] myData) throws RemoteException,
VisADException {
// Create the quantities
// Use RealType(String name);
latitude = RealType.getRealType("latitude");
longitude = RealType.getRealType("longitude");
domain_tuple = new RealTupleType(latitude, longitude);
temperature = RealType.getRealType("temperature");
// Create a FunctionType (domain_tuple -> temperature )
// Use FunctionType(MathType domain, MathType range)
func_domain_temp = new FunctionType( domain_tuple, temperature);
// func_t_range = new FunctionType(minute, func_domain_temp );
// Create the domain Set
// Use LinearDSet(MathType type, double first1, double last1, int lengthX,
// double first2, double last2, int lengthY)
int NCOLS = 89;
int NROWS = 105;
// domain_set = new Linear2DSet(domain_tuple, -Math.PI, Math.PI, NROWS,
// -Math.PI, Math.PI, NCOLS);
domain_set = new Linear2DSet(domain_tuple, 46, 59, NROWS, -7, 3, NCOLS);
int tSamples = 10;
// Get the Set samples to facilitate the calculations
float[][] set_samples = domain_set.getSamples( false );
// The actual temperature values are stored in this array
// float[1][ number_of_samples ]
float[][] flat_samples = new float[1][NCOLS * NROWS];
// We fill our 'flat' array with the generated values
// by looping over NCOLS and NROWS
// Create the FlatFields
// Use FlatField(FunctionType type, Set domain_set)
// For the colored image
int pos=0, temp=0, count=0;
for(int c = 0; c < NCOLS; c++)
{
for(int r = 0; r < NROWS; r++)
{
pos = (NCOLS * r) + c ;
flat_samples[0][count] = myData[0][pos];
count++;
}
}
// ...and put the values above into it
// Note the argument false, meaning that the array won't be copied
vals_ff = new FlatField( func_domain_temp, domain_set);
vals_ff.setSamples( flat_samples );
// Get the values from the temperature FlatField
// create flat_isoVals array for clarity's sake
// "false" argument means "don't copy"
// Create Display and its maps
// A 2D display
display = new DisplayImplJ2D("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
// temperature to RGB and
// isoTemperature to IsoContour
// Use ScalarMap(ScalarType scalar, DisplayRealType display_scalar)
latMap = new ScalarMap( latitude, Display.YAxis );
lonMap = new ScalarMap( longitude, Display.XAxis );
tempRGBMap = new ScalarMap( temperature, Display.RGB );
// Add maps to display
display.addMap( latMap );
display.addMap( lonMap );
display.addMap( tempRGBMap );
// Create data references and set the FlatField as our data
data_ref = new DataReferenceImpl("data_ref");
data_ref.setData( vals_ff );
display.addReference( data_ref );
// Create application window and add display to window
JFrame jframe = new JFrame("Example");
jframe.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
jframe.getContentPane().add(display.getComponent());
// Set window size and make it visible
jframe.setSize(300, 300);
jframe.setVisible(true);
// index to count time step
int index=0;
count = 0;
// Loop forever, changing the samples array every time
while(true){
try{
for (int t=0; t<tSamples; t++)
{
for(int c = 0; c < NCOLS; c++)
{
for(int r = 0; r < NROWS; r++)
{
pos = (NCOLS * r) + c + temp;
flat_samples[0][count] = myData[0][pos];
count++;
}
}
count = 0;
temp = pos;
// ...and put the values above into it
// Note the argument false, meaning that the array won't be
copied
vals_ff.setSamples( flat_samples);
//index++;
Thread.sleep(500);
}
count = 0;
temp = 0;
}
catch (InterruptedException ie){
ie.printStackTrace();
}
}
}
}
Any ideas ?
Thanks in advance.
Adit.
-----------------------------------------------------------------------
Adityarajsingh Santokhee Tel: +44 118 378 5213 (direct line)
eScience Data Manager Tel: +44 118 378 8741 (ESSC)
Reading e-Science Centre Fax: +44 118 378 6413
ESSC Email: ads@xxxxxxxxxxxxxxxxxxxx
University of Reading
3 Earley Gate
Reading RG6 6AL, UK
-----------------------------------------------------------------------
----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.
>From owner-visad@xxxxxxxxxxxxxxxx Fri 3 2004 Dec 15:36:19
Message-ID: <1102088179.41b087f3c168e@xxxxxxxxxxxxxxxxxxx>
Date: Fri, 3 Dec 2004 15:36:19 +0000
From: Adityarajsingh Santokhee <ads@xxxxxxxxxxxxxxxxxxxx>
To: visad-list@xxxxxxxxxxxxx
Subject: Problem with animation
Received: (from majordo@localhost)
by unidata.ucar.edu (UCAR/Unidata) id iB3FaciA016220
for visad-out; Fri, 3 Dec 2004 08:36:38 -0700 (MST)
Received: from ssec.wisc.edu (mahogany.ssec.wisc.edu [128.104.110.2])
by unidata.ucar.edu (UCAR/Unidata) with ESMTP id iB3FaalI016206
for <visad-list@xxxxxxxxxxxxxxxx>; Fri, 3 Dec 2004 08:36:36 -0700 (MST)
Organization: UCAR/Unidata
Keywords: 200412031536.iB3FaalI016206
Received: from vimg3.rdg.ac.uk ([134.225.1.80] verified)
by ssec.wisc.edu (CommuniGate Pro SMTP 4.1.8)
with ESMTP id 3327777 for visad-list@xxxxxxxxxxxxx; Fri, 03 Dec 2004 09:36:31
-0600
Received: from vimp1.rdg.ac.uk ([134.225.16.90])
by vimg3.rdg.ac.uk (Exim: gateway)
with esmtp id 1CaFTy-000244-00
for visad-list@xxxxxxxxxxxxx; Fri, 03 Dec 2004 15:36:30 +0000
Received: from vimh1.rdg.ac.uk ([134.225.16.83])
by vimp1.rdg.ac.uk (Exim: virusscanner)
with esmtp id 1CaFTs-0001Tr-00
for visad-list@xxxxxxxxxxxxx; Fri, 03 Dec 2004 15:36:24 +0000
Received: from mercury.nerc-essc.ac.uk ([192.171.166.1])
by vimh1.rdg.ac.uk (Exim: host)
with esmtp id 1CaFTr-0003Xg-00
for visad-list@xxxxxxxxxxxxx; Fri, 03 Dec 2004 15:36:23 +0000
Received: from sweeney.nerc-essc.ac.uk (sweeney [192.171.166.116])
by mercury.nerc-essc.ac.uk (8.12.10/8.12.10) with ESMTP id
iB3FaN7o016946
for <visad-list@xxxxxxxxxxxxx>; Fri, 3 Dec 2004 15:36:23 GMT
Received: from localhost.localdomain (sweeney [127.0.0.1])
by sweeney.nerc-essc.ac.uk (8.12.8/8.12.8) with ESMTP id iB3FaNml017260
for <visad-list@xxxxxxxxxxxxx>; Fri, 3 Dec 2004 15:36:23 GMT
Received: (from apache@localhost)
by localhost.localdomain (8.12.8/8.12.8/Submit) id iB3FaJBw017258
for visad-list@xxxxxxxxxxxxx; Fri, 3 Dec 2004 15:36:19 GMT
Received: from brahman.nerc-essc.ac.uk (brahman.nerc-essc.ac.uk
[192.171.166.139])
by www.nerc-essc.ac.uk (IMP) with HTTP
for <ads@xxxxxxxxxxxxxxxxxxxxxxx>; Fri, 3 Dec 2004 15:36:19 +0000
MIME-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
User-Agent: Internet Messaging Program (IMP) 3.2.2
X-Originating-IP: 192.171.166.139
X-Scanner: exiscan *1CaFTs-0001Tr-00*X6g6wcx6gwo* (The University of Reading)
Sender: owner-visad@xxxxxxxxxxxxxxxx
Precedence: bulk
Hello,
I have recently started using the VisAD Graphics API. I have tried Ugo Taddei
examples and the tutorials and found them very useful.
My problem is as follows. I am trying to do a simple animation of a surface :
(lat,lon)->temperature. My objective is to see how temperature of the surface
changes over time. I have been testing with the "infinite loop example" calling
FlatField.setSamples(float [][] samples) to update the display.
I am getting some results. However, the problem is that the graph is moving
along the x-axis with each new frame. This is the subroutine I am using.
public void displayData(float [][] myData) throws RemoteException,
VisADException {
// Create the quantities
// Use RealType(String name);
latitude = RealType.getRealType("latitude");
longitude = RealType.getRealType("longitude");
domain_tuple = new RealTupleType(latitude, longitude);
temperature = RealType.getRealType("temperature");
// Create a FunctionType (domain_tuple -> temperature )
// Use FunctionType(MathType domain, MathType range)
func_domain_temp = new FunctionType( domain_tuple, temperature);
// func_t_range = new FunctionType(minute, func_domain_temp );
// Create the domain Set
// Use LinearDSet(MathType type, double first1, double last1, int lengthX,
// double first2, double last2, int lengthY)
int NCOLS = 89;
int NROWS = 105;
// domain_set = new Linear2DSet(domain_tuple, -Math.PI, Math.PI, NROWS,
// -Math.PI, Math.PI, NCOLS);
domain_set = new Linear2DSet(domain_tuple, 46, 59, NROWS, -7, 3, NCOLS);
int tSamples = 10;
// Get the Set samples to facilitate the calculations
float[][] set_samples = domain_set.getSamples( false );
// The actual temperature values are stored in this array
// float[1][ number_of_samples ]
float[][] flat_samples = new float[1][NCOLS * NROWS];
// We fill our 'flat' array with the generated values
// by looping over NCOLS and NROWS
// Create the FlatFields
// Use FlatField(FunctionType type, Set domain_set)
// For the colored image
int pos=0, temp=0, count=0;
for(int c = 0; c < NCOLS; c++)
{
for(int r = 0; r < NROWS; r++)
{
pos = (NCOLS * r) + c ;
flat_samples[0][count] = myData[0][pos];
count++;
}
}
// ...and put the values above into it
// Note the argument false, meaning that the array won't be copied
vals_ff = new FlatField( func_domain_temp, domain_set);
vals_ff.setSamples( flat_samples );
// Get the values from the temperature FlatField
// create flat_isoVals array for clarity's sake
// "false" argument means "don't copy"
// Create Display and its maps
// A 2D display
display = new DisplayImplJ2D("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
// temperature to RGB and
// isoTemperature to IsoContour
// Use ScalarMap(ScalarType scalar, DisplayRealType display_scalar)
latMap = new ScalarMap( latitude, Display.YAxis );
lonMap = new ScalarMap( longitude, Display.XAxis );
tempRGBMap = new ScalarMap( temperature, Display.RGB );
// Add maps to display
display.addMap( latMap );
display.addMap( lonMap );
display.addMap( tempRGBMap );
// Create data references and set the FlatField as our data
data_ref = new DataReferenceImpl("data_ref");
data_ref.setData( vals_ff );
display.addReference( data_ref );
// Create application window and add display to window
JFrame jframe = new JFrame("Example");
jframe.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
jframe.getContentPane().add(display.getComponent());
// Set window size and make it visible
jframe.setSize(300, 300);
jframe.setVisible(true);
// index to count time step
int index=0;
count = 0;
// Loop forever, changing the samples array every time
while(true){
try{
for (int t=0; t<tSamples; t++)
{
for(int c = 0; c < NCOLS; c++)
{
for(int r = 0; r < NROWS; r++)
{
pos = (NCOLS * r) + c + temp;
flat_samples[0][count] = myData[0][pos];
count++;
}
}
count = 0;
temp = pos;
// ...and put the values above into it
// Note the argument false, meaning that the array won't be
copied
vals_ff.setSamples( flat_samples);
//index++;
Thread.sleep(500);
}
count = 0;
temp = 0;
}
catch (InterruptedException ie){
ie.printStackTrace();
}
}
}
}
Any ideas ?
Thanks in advance.
Adit.
-----------------------------------------------------------------------
Adityarajsingh Santokhee Tel: +44 118 378 5213 (direct line)
eScience Data Manager Tel: +44 118 378 8741 (ESSC)
Reading e-Science Centre Fax: +44 118 378 6413
ESSC Email: ads@xxxxxxxxxxxxxxxxxxxx
University of Reading
3 Earley Gate
Reading RG6 6AL, UK
-----------------------------------------------------------------------
----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.
----- End forwarded message -----
-----------------------------------------------------------------------
Adityarajsingh Santokhee Tel: +44 118 378 5213 (direct line)
eScience Data Manager Tel: +44 118 378 8741 (ESSC)
Reading e-Science Centre Fax: +44 118 378 6413
ESSC Email: ads@xxxxxxxxxxxxxxxxxxxx
University of Reading
3 Earley Gate
Reading RG6 6AL, UK
-----------------------------------------------------------------------
----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.