Пример #1
0
 /**
  * Constructs well header data from the specified file. The file is in Excel CSV
  * (comma-delimited) format.
  *
  * @param fileName file containing well header data.
  */
 public Data(String fileName) {
   try {
     FileInputStream fis = new FileInputStream(fileName);
     Scanner s = new Scanner(fis);
     while (s.hasNextLine()) {
       String line = s.nextLine();
       String[] fields = line.split(",");
       if (fields.length < 10) continue;
       long id = WellLog.idFromString(fields[0]);
       if (id < 0) continue;
       WellHeader wh = new WellHeader();
       wh.id = id;
       try {
         wh.xe = Double.parseDouble(fields[5]);
         wh.yn = Double.parseDouble(fields[4]);
         wh.ze = Double.parseDouble(fields[9]);
         add(wh);
       } catch (NumberFormatException e) {
         // do nothing if well header is missing something
       }
     }
     s.close();
   } catch (IOException e) {
     throw new RuntimeException(e);
   }
 }
Пример #2
0
 /**
  * Constructs directional survey data from the specified file. The file is in Excel CSV
  * (comma-delimited) format.
  *
  * @param fileName file containing directional survey data.
  */
 public Data(String fileName) {
   try {
     FileInputStream fis = new FileInputStream(fileName);
     Scanner s = new Scanner(fis);
     long id = -1;
     DoubleList zl = new DoubleList();
     DoubleList tl = new DoubleList();
     DoubleList pl = new DoubleList();
     while (s.hasNextLine()) {
       String line = s.nextLine();
       String[] fields = line.split(",");
       if (fields.length < 4) continue;
       long idline = WellLog.idFromString(fields[0]);
       if (idline < 0) continue;
       if (id < 0) {
         id = idline;
       } else if (id != idline || !s.hasNextLine()) {
         DirectionalSurvey ds = new DirectionalSurvey();
         ds.id = id;
         ds.z = zl.trim();
         ds.t = tl.trim();
         ds.p = pl.trim();
         if (id == 490252304800L) { // Swap theta,phi for this survey!
           double[] temp = ds.t;
           ds.t = ds.p;
           ds.p = temp;
         }
         ds.n = ds.z.length;
         _data.put(id, ds);
         id = idline;
         zl = new DoubleList();
         tl = new DoubleList();
         pl = new DoubleList();
       }
       zl.add(Double.parseDouble(fields[1]));
       tl.add(Double.parseDouble(fields[2]));
       pl.add(Double.parseDouble(fields[3]));
     }
     s.close();
   } catch (IOException e) {
     throw new RuntimeException(e);
   }
 }