Example #1
0
 /**
  * @param pcat
  * @param array
  * @param coordTab
  * @param flagIgnore
  */
 private static void fillXMatchArray(
     Pcat pcat, double[][] array, int[] coordTab, boolean[] flagIgnore) {
   Source o;
   String content;
   Iterator<Obj> it = pcat.iterator();
   for (int i = 0; it.hasNext(); i++) {
     o = (Source) it.next();
     // not needed
     //            flagIgnore[i] = false;
     try {
       // ra
       content = o.getValue(coordTab[0]);
       if (isSexa(content)) content = sexa2Deg(content, true);
       // array[i][0] = Double.parseDouble(content);
       array[i][0] = Double.valueOf(content).doubleValue();
       // dec
       content = o.getValue(coordTab[1]);
       if (isSexa(content)) content = sexa2Deg(content, false);
       // array[i][1] = Double.parseDouble(content);
       array[i][1] = Double.valueOf(content).doubleValue();
     } catch (NumberFormatException e) {
       e.printStackTrace();
       // ignore this source
       flagIgnore[i] = true;
       //                array[i][0] = array[i][1] = 0.0;
     } catch (NullPointerException npe) {
       npe.printStackTrace();
       // ignore this source
       flagIgnore[i] = true;
     }
   }
 }
Example #2
0
 private void fillXIDArray(Pcat pcat, String[] array, int index) {
   Source o;
   Iterator<Obj> it = pcat.iterator();
   for (int i = 0; it.hasNext(); i++) {
     o = (Source) it.next();
     array[i] = o.getValue(index);
   }
 }
Example #3
0
  private static void fillEllipsesParamArray(
      Pcat pcat,
      double[] maj,
      double[] min,
      double[] pa,
      int[] ellipsesParamIdx,
      boolean[] flagIgnore) {
    Source o;
    String content;

    // approche utilisée pour la conversion des unités :
    // on essaye de convertir les 3 param. en degrés
    // si c'est impossible, on considère que la valeur brute est en degrés ...
    Source s = (Source) pcat.iterator().next();
    double multFactMaj, multFactMin, multFactPa; // facteur multiplicatif pour maj, min et pa
    Unit uDeg, uArcSec, uMaj, uMin, uPa;
    Unit uDegTemplate = null;
    Unit uArcSecTemplate = null;
    uMaj = uDeg = null;
    try {
      uDegTemplate = new Unit("1 deg");
      uArcSecTemplate = new Unit("1 arcsec");

    } catch (ParseException e) {
    } // l'exception ne devrait jamais etre levée !

    //        A PRENDRE EN COMPTE !!
    // par défaut, grand axe en arcsec
    try {
      uArcSec = new Unit(uArcSecTemplate);
      uMaj = new Unit("1 " + s.getUnit(ellipsesParamIdx[0]));
      uArcSec.convertFrom(uMaj);
      multFactMaj = uArcSec.getValue();
    } catch (java.text.ParseException e) {
      multFactMaj = 1.0;
    } catch (ArithmeticException e2) {
      multFactMaj = 1.0;
    }
    System.out.println("facteur pour MAJ : " + multFactMaj);

    // par défaut, petit axe en arcsec
    try {
      uArcSec = new Unit(uArcSecTemplate);
      uMin = new Unit("1 " + s.getUnit(ellipsesParamIdx[1]));
      uArcSec.convertFrom(uMin);
      multFactMin = uArcSec.getValue();
    } catch (java.text.ParseException e) {
      multFactMin = 1.0;
    } catch (ArithmeticException e2) {
      multFactMin = 1.0;
    }
    System.out.println("facteur pour MIN : " + multFactMin);

    try {
      uDeg = new Unit(uDegTemplate);
      uPa = new Unit("1 " + s.getUnit(ellipsesParamIdx[2]));
      uDeg.convertFrom(uPa);
      multFactPa = uDeg.getValue();
    } catch (java.text.ParseException e) {
      multFactPa = 1.0;
    } catch (ArithmeticException e2) {
      multFactPa = 1.0;
    }
    System.out.println("facteur pour PA : " + multFactPa);

    //        System.out.println("nb_o "+pcat.nb_o);
    Iterator<Obj> it = pcat.iterator();
    for (int i = 0; it.hasNext(); i++) {
      o = (Source) it.next();
      // not needed
      //            flagIgnore[i] = false;
      try {
        // TODO : conversion d'unités pour avoir tout en degrés !!
        // major axis (en tenant compte du facteur multiplicatif)
        content = o.getValue(ellipsesParamIdx[0]);
        //                System.out.println(ellipsesParamIdx[0]);
        maj[i] = multFactMaj * Double.valueOf(content).doubleValue();
        // minor axis (en tenant compte du facteur multiplicatif)
        try {
          content = o.getValue(ellipsesParamIdx[1]);
          min[i] = multFactMin * Double.valueOf(content).doubleValue();
        }
        // if this happens, we take the same value as the major axis !
        catch (NumberFormatException e) {
          min[i] = maj[i];
        }
        // position angle (en tenant compte du facteur multiplicatif)
        try {
          content = o.getValue(ellipsesParamIdx[2]);
          pa[i] = multFactPa * Double.valueOf(content).doubleValue();
        } catch (NumberFormatException e) {
          pa[i] = 0.0;
        }
      } catch (NumberFormatException e) {
        // on flague cette source comme étant à ignorer
        flagIgnore[i] = true;
        maj[i] = min[i] = pa[i] = 0.0;
      }
    }
    //        System.out.println("nb_o "+pcat.nb_o);
  }