/** * Save the normalization data. * * @param out The output file. */ private void saveNormalize(final EncogWriteHelper out) { saveSubSection(out, "NORMALIZE", "CONFIG"); out.addSubSection("RANGE"); out.addColumn("name"); out.addColumn("io"); out.addColumn("timeSlice"); out.addColumn("action"); out.addColumn("high"); out.addColumn("low"); out.writeLine(); for (final AnalystField field : this.script.getNormalize().getNormalizedFields()) { out.addColumn(field.getName()); if (field.isInput()) { out.addColumn("input"); } else { out.addColumn("output"); } out.addColumn(field.getTimeSlice()); switch (field.getAction()) { case Ignore: out.addColumn("ignore"); break; case Normalize: out.addColumn("range"); break; case PassThrough: out.addColumn("pass"); break; case OneOf: out.addColumn("oneof"); break; case Equilateral: out.addColumn("equilateral"); break; case SingleField: out.addColumn("single"); break; default: throw new AnalystError("Unknown action: " + field.getAction()); } out.addColumn(field.getNormalizedHigh()); out.addColumn(field.getNormalizedLow()); out.writeLine(); } }
/** * Determine the input fields. * * @param headerList The headers. * @return The indexes of the input fields. */ private int[] determineInputFields(final CSVHeaders headerList) { final List<Integer> fields = new ArrayList<Integer>(); for (int currentIndex = 0; currentIndex < headerList.size(); currentIndex++) { final String baseName = headerList.getBaseHeader(currentIndex); final int slice = headerList.getSlice(currentIndex); final AnalystField field = getAnalyst().getScript().findNormalizedField(baseName, slice); if (field != null && field.isInput()) { fields.add(currentIndex); } } // allocate result array final int[] result = new int[fields.size()]; for (int i = 0; i < result.length; i++) { result[i] = fields.get(i); } return result; }