GTable1D : Différence entre versions
(Page créée avec « TBW ... Return to the introduction ↑ Go to the next page → ») |
|||
Ligne 1 : | Ligne 1 : | ||
− | + | <font color=#556B2F>'''GENIUS'''</font> allows to display (and read/write !) one dimension tables (abscissa et ordinate). The idea is to be able to manage one or several tabulated functions y<sub>i</sub> = f(x<sub>i</sub>) as, for example C<sub>x</sub> et C<sub>z</sub> depending on the Angle of Attack … | |
+ | |||
+ | To do it, we must use [{{PathCurrentJavaDoc}}/fr/cnes/genius/highLevel/GEntryRealVector.html GEntryRealVector] class (or [{{PathCurrentJavaDoc}}/fr/cnes/genius/highLevel/GEntryIntVector.html GEntryIntVector], [{{PathCurrentJavaDoc}}/fr/cnes/genius/highLevel/GEntryDateVector.html GEntryDateVector]) to store data by columns. | ||
+ | |||
+ | <syntaxhighlight lang="java"> | ||
+ | GUnit[] unitAng = {new GMetricUnit("deg"), new GMetricUnit("rad")}; | ||
+ | |||
+ | double[] incVal = {Math.toRadians(10.), Math.toRadians(15.), Math.toRadians(20.), | ||
+ | Math.toRadians(25.), Math.toRadians(30.), Math.toRadians(35.), | ||
+ | Math.toRadians(40.)}; | ||
+ | double[] cxVal = {0.100, 0.150, 0.200, 0.250, 0.350, 0.450, 0.600}; | ||
+ | double[] czVal = {0.250, 0.300, 0.350, 0.400, 0.500, 0.550, 0.600}; | ||
+ | |||
+ | incTabIhm = new GEntryRealVector("Angle Of Attack", incVal, unitAng); | ||
+ | incTabIhm.setNameInConfigFile("AOA"); | ||
+ | CxTabIhm = new GEntryRealVector("Cx", cxVal); | ||
+ | CzTabIhm = new GEntryRealVector("Cz", czVal); | ||
+ | CzTabIhm.addGInterval(errInterval); | ||
+ | </syntaxhighlight> | ||
+ | |||
+ | Then we will use [{{PathCurrentJavaDoc}}/fr/cnes/genius/highLevel/GTable1D.html GTable1D] class to assembly them: | ||
+ | |||
+ | <syntaxhighlight lang="java"> | ||
+ | aeroTabIhm=new GTable1D("Cx/Cz = f(Mach)", TableOrientation.VERTICAL,incTabIhm, CxTabIhm, CzTabIhm); | ||
+ | aeroTabIhm.setConstraint(new GConstraint(GConstraint.newline())); | ||
+ | </syntaxhighlight> | ||
+ | |||
+ | [[File:GTable1d.jpg]] | ||
+ | |||
+ | At last, if we want to get the content of this table, we will have to use the <font color=#4169E1>getGVector()</font> method then <font color=#4169E1>getValue()</font> or <font color=#4169E1>getValueArray()</font> methods. The following example gives us a method to recover a double table: | ||
+ | |||
+ | <syntaxhighlight lang="java"> | ||
+ | public double[] getData ( int rank ) { | ||
+ | double[] tmp = new double[aeroTabIhm.getGVector(rank).size()]; | ||
+ | for (int i = 0; i < tmp.length; i++) { | ||
+ | tmp[i] = (Double)aeroTabIhm.getGVector(rank).getValue(i); | ||
+ | } | ||
+ | return tmp; | ||
+ | } | ||
+ | </syntaxhighlight> | ||
+ | |||
+ | Note that, it is mandatory to cast the data as, since the V1.2 version, it is possible to get objects as [{{PathCurrentJavaDoc}}/fr/cnes/genius/highLevel/GEntryDateVector.html GEntryDateVector] in [{{PathCurrentJavaDoc}}/fr/cnes/genius/highLevel/GTable1D.html GTable1D], so the <font color=#4169E1>getGVector()</font> will return a table of Objects rather than a table of Number as previously. | ||
+ | |||
[[WELCOME_TO_THE_GENIUS_WIKI|Return to the introduction ↑]] | [[WELCOME_TO_THE_GENIUS_WIKI|Return to the introduction ↑]] | ||
[[GTable2D|Go to the next page →]] | [[GTable2D|Go to the next page →]] |
Version du 5 mai 2017 à 13:40
GENIUS allows to display (and read/write !) one dimension tables (abscissa et ordinate). The idea is to be able to manage one or several tabulated functions yi = f(xi) as, for example Cx et Cz depending on the Angle of Attack …
To do it, we must use GEntryRealVector class (or GEntryIntVector, GEntryDateVector) to store data by columns.
GUnit[] unitAng = {new GMetricUnit("deg"), new GMetricUnit("rad")}; double[] incVal = {Math.toRadians(10.), Math.toRadians(15.), Math.toRadians(20.), Math.toRadians(25.), Math.toRadians(30.), Math.toRadians(35.), Math.toRadians(40.)}; double[] cxVal = {0.100, 0.150, 0.200, 0.250, 0.350, 0.450, 0.600}; double[] czVal = {0.250, 0.300, 0.350, 0.400, 0.500, 0.550, 0.600}; incTabIhm = new GEntryRealVector("Angle Of Attack", incVal, unitAng); incTabIhm.setNameInConfigFile("AOA"); CxTabIhm = new GEntryRealVector("Cx", cxVal); CzTabIhm = new GEntryRealVector("Cz", czVal); CzTabIhm.addGInterval(errInterval);
Then we will use GTable1D class to assembly them:
aeroTabIhm=new GTable1D("Cx/Cz = f(Mach)", TableOrientation.VERTICAL,incTabIhm, CxTabIhm, CzTabIhm); aeroTabIhm.setConstraint(new GConstraint(GConstraint.newline()));
At last, if we want to get the content of this table, we will have to use the getGVector() method then getValue() or getValueArray() methods. The following example gives us a method to recover a double table:
public double[] getData ( int rank ) { double[] tmp = new double[aeroTabIhm.getGVector(rank).size()]; for (int i = 0; i < tmp.length; i++) { tmp[i] = (Double)aeroTabIhm.getGVector(rank).getValue(i); } return tmp; }
Note that, it is mandatory to cast the data as, since the V1.2 version, it is possible to get objects as GEntryDateVector in GTable1D, so the getGVector() will return a table of Objects rather than a table of Number as previously.