RE: determining if field is "index"

Hi Curtis,

In my VisadAPI class, I can iterate through my array of ScalarMaps and
call getScalar().getName() as you suggested, but I was actually
wondering if it was possible to determine what the input field "index"
is mapped to earlier in another class. 

I have the following 2 lines as the header in my .csv data file:

(index) -> (Time, x, y, z, q1, q2, q3, q4)
Time[fmt=HH:mm:ss], x, y, z, q1, q2, q3, q4

But I can't simply check what is at index 0 in my scalarmaps to find out
if "index" is mapped to "iso-contour" because in another .csv file with
the following header:
 
(index) ->
(torque,RI_X,RI_Z,DRY_Mass,Prop_mass,RW_Index,RW_Choice,Pay_power,Pay_Ma
ss,MinFreqMode)
torque,RI_X,RI_Z,DRY_Mass,Prop_mass,RW_Index,RW_Choice,Pay_power,Pay_Mas
s,MinFreqMode

"index" does not appear as the first input field in the leftmost "map
from" column in 
the mapping dialog box since the fields are alphabetically ordered.
 
I setup an array of mappings of input fields like q1, q2, x, to a
corresponding integer value for a Visad parameter like flow1azimuth,
xoffset, etc. Do you know of a way to determine which array index in my
array of mappings the "index" field would be? This may not be possible,
but is there a way to extract the MathType of the input field "index" in
VisadAPI before my other method in a different class is called? If I can
somehow determine that integer number, I can then index into that spot
in my array of mappings and check if the value there matches the integer
value for "iso-contour".

Thanks,
Michelle


Michelle Kam           (408) 742-2881
Lockheed Martin Space Systems Co. SSM/ATC/MSIS
B/153 O/L922 
1111 Lockheed Martin Way, Sunnyvale, CA 94089




-----Original Message-----
From: Curtis Rueden [mailto:curtis@xxxxxxxxxxxxx]
Sent: Wednesday, July 23, 2003 11:06 AM
To: Kam, Michelle C
Subject: Re: ShadowFunctionOrSetType


Hi Michelle,

If you have a ScalarMap object, you can find out what is being mapped
with ScalarMap.getScalar().getName(). You can find out what it is being
mapped to with ScalarMap.getDisplayScalar.getName(). Since you have an
array of ScalarMap objects, it should be simple to iterate through them
and check each one to see if it matches your conditions.

If for some reason the above is insufficient, I must ask, if you are
generating these mappings elsewhere in your *own code*, why can't you
add functionality to detect such mappings at the point of generation,
instead of trying to determine it from VisAD later?  That is, if I name
my dog Rover, does it make sense to ask my dog what his name is later?
It makes more sense for me to remember his name myself.

-Curtis

>Kam, Michelle C wrote:
>>Hi Tom,
>>Attached is an example of a file I am working with. When you load it
>>into a spreadsheet cell and then open up the mapping dialog box, you
see
>>"index" listed at the top of the "map from" column along with other
>>input fields like q1, q2,..etc. I'm prespecifying what the input
fields
>>get mapped to such as latitude, longitude, flow1 x. But as Tom pointed
>>out, when "index" is mapped to "Iso-contour", a "terminal legal"
>>exception is thrown. Therefore, I'm trying to find out when the
mappings
>>that I generate produce that specific mapping so that I can then treat
>>this scenario as a special case.
>>That is why I was wondering if there was a way to extract the
>>corresponding VisAD "mapTo" value for input field "index" after my
>>mappings are setup. This is where I set up my mappings that I randomly
>>generated in another class:
>>                public void setCellMapping(int width, int height)
throws
>>VisADException, RemoteException {
>>                        
>>                        //System.out.println("In setCellMapping() and
>>width = " + width + "height = " + height);
>>                        int fields = theJgapAPI.field_count;  //limit
on
>>for loop
>>                        int cellsAcross = mySS.NumVisX;   //3 for now
>>                        int cell_number = (width + (cellsAcross *
>>height));   //used as arg to getMappingForCell()
>>                        
>>                        //ScalarMap[] theMaps = new ScalarMap[fields];
>>//array that will be passed into setMaps()      
>>                        
>>                        Data[] myData
>>mySS.DisplayCells[width][height].getData();  
>>                        Vector myVector = new Vector(fields);
//capacity
>>= 10 because there are 10 input fields in small.v5d
>>                        int useless
DataUtility.getScalarTypes(myData,
>>myVector, false, true);  //will setup the myVector structure holding
>>input fields scalar types               
>>                        
>>                        Vector nonNullMappings = new Vector();
>>                        for (int i = 0; i < fields; i++) {
>>                                //System.out.println("in
>>setCellMapping() and i = " + i);
>>                                
>>                                int assignment
>>theJgapAPI.getMappingForCell(cell_number, i);
>>                                DisplayRealType mapTo
>>mappings[assignment];
>>                                RealType mapFrom = (RealType)
>>myVector.get(i);        
>>                                
>>                                if (mapTo != null) {
>>                                        nonNullMappings.add(new
>>ScalarMap(mapFrom, mapTo));
>>                                }
>>                        }                       
>>                        
>>                        ScalarMap[] theMaps = new
>>ScalarMap[nonNullMappings.size()];      
>>                        nonNullMappings.copyInto(theMaps);
>>                                                
>>                                //theMaps[i] = new ScalarMap(mapFrom,
>>mapTo);
>>                                //System.out.println("mapFrom = " +
>>mapFrom);
>>                                //System.out.println("mapTo
"+mapTo);
>>                                //String name = mapsFrom[i]; //string
>>name of input field i for this file, small.v5d for now
>>                                //RealType mapFrom
>>RealType.getRealType(name);  //constructs a RealType object from a
given
>>String name             
>>                                //theMaps[i] = new ScalarMap(mapFrom,
>>mapTo);
>>                        
>>        
>>mySS.DisplayCells[width][height].setMaps(theMaps);              
>>                }
>>Thanks,
>>Michelle
>>
>>Michelle Kam           (408) 742-2881
>>Lockheed Martin Space Systems Co. SSM/ATC/MSIS
>>B/153 O/L922 1111 Lockheed Martin Way, Sunnyvale, CA 94089