Re: [visad] Gridded2DSet Error

Okay, I have tried all constructors of GriddedSet, but same error is coming.

And now I am using Irregular2DSet :
But the display is BLANK, nothing appears.
So,kindly help me to find where I am wrong.
And what should be the size in Linear2Dset.

  Irregular2DSet gset = new Irregular2DSet(xy, samples, null, null, null,
null, true);
 FunctionType ftype = new FunctionType(xy, value);
        FlatField field = new FlatField(ftype, gset);
        float[][] values = new float[1][count];
        for ( i=0; i<count; i++)
        {
            values[0][i] = (float) rh1array[i];
        }
        field.setSamples(values, false);
        System.out.println("3.........resample field to regular grid");
    // resample field to regular grid
int size=182;                         //4230,10,2,769860;
   Linear2DSet set = new Linear2DSet(xy,0, 3600, size, -40, 400, size);
    field = (FlatField) field.resampleDouble(set, Data.WEIGHTED_AVERAGE,
Data.NO_ERRORS);


      System.out.println("4........  create display");
    // create display
      DisplayImpl display=new DisplayImplJ2D("display");
         GraphicsModeControl dispGMC = (GraphicsModeControl)
display.getGraphicsModeControl();
    dispGMC.setScaleEnable(true);

   // display.getGraphicsModeControl().setPointSize(5.0f);
    display.addMap(new ScalarMap(x, Display.XAxis));
    display.addMap(new ScalarMap(y, Display.YAxis));
    ScalarMap color = new ScalarMap(value, Display.RGBA);
    display.addMap(color);

      System.out.println("5........ add data to display");
    // add data to display
    DataReferenceImpl ref = new DataReferenceImpl("ref");
    ref.setData(field);
    display.addReference(ref);
 System.out.println("6..............show display onscreen");
    // show display onscreen
    JFrame frame = new JFrame("Irregular rendering test");
   frame.getContentPane().add(display.getComponent());
    frame.setBounds(200, 200, 400, 400);
    frame.show();
      System.out.println("7....END MAIN");




On Sat, Apr 19, 2014 at 7:52 PM, Tom Rink <rink@xxxxxxxxxxxxx> wrote:

>  Hi Devanshi,
>
> If the domain samples points are irregular you need to use the
> IrregularSet.  If the
> points are close to gridded, but with some localized irregularity you can
> try turning
> off the samples consistency check using the appropriate GriddedSet
> constructor.
>
> Tom
>
>
> On 4/18/14 2:23 PM, Devanshi Prajapati wrote:
>
> Hello all,
>
>  I am using gridded 2D set but,
> I got an error : " *Gridded2DSet: samples do not form a valid grid*"
> on the line of constructor of *Gridded2DSet.*
>
>  *I have tried changing lengthX and lengthY passed as parameter but I
> dont know why error is coming.*
>
>         RealType x = RealType.getRealType("x");
>         RealType y = RealType.getRealType("y");
>
>          RealTupleType xy = new RealTupleType(x,y);
>         RealType value = RealType.getRealType("rh1");
>
>          int yCoordinates= 182;
>         int xCoordinates= 4230;
>         int count = xCoordinates*yCoordinates; // (182*4230)= 769860
>
>
>         double latarray[]=new double[count];
>         double lonarray[]=new double[count];
>         double rh1array[]=new double[count];
>
>  //FILL ALL THE ARRAYS ABOVE.
>
>         float[][] samples = new float[2][count];
>        int i,j,k=0;
>        for ( j=0; j<yCoordinates; j++)
>        {
>             for ( i=0; i<xCoordinates; i++)
>             {
>                     samples[0][k] = (float) ((latarray[i]/100)-40);
>                     samples[1][k] = (float)((lonarray[i]/100));
>                      k++;
>             }
>        }
>        System.out.println("COUNT ::: "+k); //769860
>        System.out.println("1.1...........");
>    // Irregular2DSet iset = new
> Irregular2DSet(xy,samples,null,null,null,null);
>
>  *Gridded2DSet gset= new
> Gridded2DSet(xy,samples,xCoordinates,yCoordinates);*
>  ...
>
>  Anyone please, guide me how to set grid coordinates to make it work.
> My samples are irregular  and I want 2D image type result.
>
>
> --
>  Thank you.
> Devanshi U. Prajapati
> LJIET(MCA)
>
>
> _______________________________________________
> visad mailing listvisad@xxxxxxxxxxxxxxxx
> For list information, to unsubscribe, visit: 
> http://www.unidata.ucar.edu/mailing_lists/
>
>
>


-- 
Devanshi U. Prajapati
LJIET(MCA)
  • 2014 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the visad archives: