NOTICE: This version of the NSF Unidata web site (archive.unidata.ucar.edu) is no longer being updated.
Current content can be found at unidata.ucar.edu.

To learn about what's going on, see About the Archive Site.

i need some help

Dear all:

i am having some runtime errors trying to run my program  below: i get an
error like

Exception in thread "main" visad.SetException: SampledSet.init_samples:
sample dimension 1 doesn't match expected length 2

what i am trying to do is to create a flat plane and put spikes on it by
reading the data from a file.
i will be glad if this anomaly can be corrected, i have started compiling a
list of all possible visad errors like the above and their solutions, i will
post it when it gets enough.

see code below:

thanks in advance

Isaac



 sample data
A2HS_HUMAN      39300   5.43    .16666666666666669
A2HS_HUMAN      39300   5.43    .6862056629875621

**//code

import javax.swing.*; 
import visad.*; 
import java.io.*;
import java.util.Vector;
import visad.java3d.DisplayImplJ3D; 
import visad.data.text.TextAdapter;
import java.util.StringTokenizer;

public class Gridd 
{ 
 private static FlatField vals_ff;
 private static  Set domain_set;
 private  static DataReferenceImpl data_ref;
 
  public static void main(String[] args) throws Exception 
  { 
  
  Vector nice = new Vector();
  
  BufferedReader fi = new BufferedReader(new FileReader("tryE.txt"));
        for(String p=fi.readLine();p!=null;p=fi.readLine())
        {
        StringTokenizer tokenizer = new StringTokenizer (p);
        if (tokenizer.hasMoreTokens())
        {
        String name = tokenizer.nextToken();
        float A =Float.parseFloat( tokenizer.nextToken());
        float B= Float.parseFloat(tokenizer.nextToken());
  float rat= Float.parseFloat(tokenizer.nextToken());
        nice.add(new prodat(name,A,B,rat));
                }
   }
    
       // range types for data 
    RealType ratio = RealType.getRealType("ratio"); 
    RealType mass = RealType.getRealType("mass"); 
    RealType pi = RealType.getRealType("pi"); 
    RealTupleType tuple = new RealTupleType(mass,pi); 
    

     FunctionType type = new FunctionType(
      new RealTupleType(mass, pi), ratio);
      
       nice.trimToSize();
  float[][] protein =new float[1][nice.size()*nice.size()];
 float[][] range =new float[1][nice.size()];
  for(int z=0;z<protein.length;z++)
  {
        prodat prox=(prodat)nice.get(z);
        range[0][z]=prox.getProp();
  }
   //float[][] t_x = protein.floatTofloat(((FlatF)
  Irregular2DSet set = new Irregular2DSet(tuple,protein);
  vals_ff=new FlatField(type,set); 
  vals_ff.setSamples(protein,false);
  
  // try to create a plain grid and put ratio as spikes on the grid
  
    for(int i=0;i<protein.length;i++)
    {
        for(int j=0;j<protein.length;j++)
        {
                int ndx = (int)(i* protein[0][j] + j);
                if (i % protein.length == 0 && j % protein.length == 0 ) 
                {
                        //float spike=Math.round(range[0][j]);
                        float spike=range[0][j];
                        //protein[0][ndx]= spike;
                        if(spike >0.5)
                 {
                 protein[0][ndx]= spike;
                 }
                  else protein[0][ndx] =-1*spike;
                }
        }
    }
                

    // construct data reference 
    DataReferenceImpl ref = new DataReferenceImpl("ref"); 
    ref.setData(vals_ff); 

    // construct display 
    DisplayImplJ3D display = new DisplayImplJ3D("display"); 
    display.addMap(new ScalarMap(ratio, Display.ZAxis)); 
    display.addMap(new ScalarMap(mass, Display.XAxis)); 
    display.addMap(new ScalarMap(pi, Display.YAxis)); 
     display.addMap(new ScalarMap(ratio,Display.RGB));
    //display.setBackgroundColor(3.0f,1.0f,1.0f);
    display.addReference(ref); 

    // configure display 
    GraphicsModeControl gmc = display.getGraphicsModeControl(); 
    gmc.setPointSize(5.0f); 
    gmc.setScaleEnable(true); 
    //gmc.setBackgroundColor(3.0f,1.0f,1.0f);

    // display onscreen 
    JFrame frame = new JFrame("Isaac, visad graphics"); 
    frame.getContentPane().add(display.getComponent()); 
    frame.pack(); 
    frame.show(); 
  } 

} 

  


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