示例#1
0
  public static void writeTimeSeriesData(Config config, CsvData csv, HecDss dssFile, String file)
      throws Exception {
    TimeSeriesContainer ts = new TimeSeriesContainer();

    ts.fullName = config.path;
    ts.fileName = file;

    ts.times = new int[csv.data.size()];
    for (int i = 0; i < csv.data.size(); i++) {
      ts.times[i] = calcTime(csv.data.get(i).name, i == 0 ? true : false);
    }
    ts.startTime = ts.times[0];
    ts.endTime = ts.times[ts.times.length - 1];

    ts.values = csv.columns[0];
    ts.numberValues = ts.values.length;

    if (config.getParameter() != null) {
      ts.parameter = config.getParameter(); // partE;
    }
    if (config.getLocation() != null) {
      ts.location = config.getLocation(); // partE;
    }

    ts.type = config.getXtype();
    ts.units = config.getUnits();

    dssFile.put(ts);
  }
示例#2
0
  public static void writePairedData(Config config, CsvData data, HecDss dssFile) throws Exception {

    PairedDataContainer pdc = new PairedDataContainer();

    if (config.label != null) {
      pdc.labels = new String[] {"", config.label};
    }
    if (config.date != null) {
      pdc.date = config.date;
    }

    if (config.location != null) {
      pdc.location = config.location;
    }

    if (config.xunits != null) {
      pdc.xunits = config.xunits;
    }

    if (config.xtype != null) {
      pdc.xtype = pdc.xtype;
    }

    if (config.xparameter != null) {
      pdc.xparameter = pdc.xparameter;
    }

    pdc.xOrdinate = config.xOrdinate;

    if (config.yunits != null) {
      pdc.yunits = config.yunits;
    }

    if (config.ytype != null) {
      pdc.ytype = config.ytype;
    }

    if (config.yparameter != null) {
      pdc.yparameter = config.yparameter;
    }

    pdc.yOrdinate = config.yOrdinate;

    pdc.fullName = config.path;

    pdc.xOrdinates = data.firstColumn;
    pdc.yOrdinates = data.columns;

    pdc.numberCurves = config.numberCurves;
    pdc.numberOrdinates = pdc.xOrdinates.length;

    dssFile.put(pdc);
  }
示例#3
0
 public static HecDss open(String file) throws Exception {
   HecDSSUtilities.setMessageLevel(0);
   return HecDss.open(file);
 }
示例#4
0
  public static void exportJson(HecDss dssFile, String directory, String regex) throws Exception {
    int count = 0;

    HashMap<String, HashMap<String, Integer>> map = new HashMap<String, HashMap<String, Integer>>();
    Vector<CondensedReference> v = dssFile.getCondensedCatalog();
    ObjectMapper mapper = new ObjectMapper();

    cleanDirectory(new File(directory));
    new File(directory).mkdir();

    for (CondensedReference path : v) {

      CwsContainer ts = new CwsContainer();
      DataContainer dc;
      String name;
      String parameter;

      try {
        String hecpath = path.getNominalPathname();

        if (!regex.contentEquals("") && regex != null) {
          if (!hecpath.matches(regex)) continue;
        }

        dc = dssFile.get(hecpath, true);

        if (dc instanceof TimeSeriesContainer) {
          ts.timeSeriesContainer = (TimeSeriesContainer) dc;
          name = ts.timeSeriesContainer.getLocationName();
          parameter = ts.timeSeriesContainer.getParameterName();

          if (ts.timeSeriesContainer.times == null) {
            System.out.println("Ignoring: " + path.getNominalPathname());
            continue;
          }

          for (int i = 0; i < ts.timeSeriesContainer.times.length; i++) {
            ts.dates.add(Dss.calcDate(ts.timeSeriesContainer.times[i]));
          }
        } else {
          ts.pairedDataContainer = (PairedDataContainer) dc;
          parameter = "pairedData";
          name = ts.pairedDataContainer.location;
        }

      } catch (Exception e2) {
        continue;
      }

      mapper.writeValue(new File(directory + File.separatorChar + count + ".json"), ts);

      if (!map.containsKey(name)) {
        map.put(name, new HashMap<String, Integer>());
      }
      map.get(name).put(parameter, count);

      count += 1;
    }

    mapper.writeValue(new File(directory + File.separatorChar + "index.json"), map);
  }