private MLCell histoDataHeadersAsMLChar(List<String> histoDataHeaders) { int colsSize = histoDataHeaders.size() - 2; MLCell injections = new MLCell("inj_ID", new int[]{1, colsSize}); int i = 0; for (String colkey : histoDataHeaders) { if (colkey.equals("forecastTime") || colkey.equals("datetime")) { continue; } injections.set(new MLChar("", colkey), 0, i); i++; } return injections; }
/** * Write a CSV wordIndex to a {@link MLCell} writen to a .mat data file * * @param path * @throws IOException */ public static void writeToMatlab(String path) throws IOException { final Path wordMatPath = new Path(path + "/words/wordIndex.mat"); final FileSystem fs = HadoopToolsUtil.getFileSystem(wordMatPath); final LinkedHashMap<String, IndependentPair<Long, Long>> wordIndex = readWordCountLines(path); final MLCell wordCell = new MLCell("words", new int[] { wordIndex.size(), 2 }); System.out.println("... reading words"); for (final Entry<String, IndependentPair<Long, Long>> ent : wordIndex.entrySet()) { final String word = ent.getKey(); final int wordCellIndex = (int) (long) ent.getValue().secondObject(); final long count = ent.getValue().firstObject(); wordCell.set(new MLChar(null, word), wordCellIndex, 0); wordCell.set(new MLDouble(null, new double[][] { new double[] { count } }), wordCellIndex, 1); } final ArrayList<MLArray> list = new ArrayList<MLArray>(); list.add(wordCell); new MatFileWriter(Channels.newChannel(fs.create(wordMatPath)), list); }
/** * Write a CSV wordIndex to a {@link MLCell} writen to a .mat data file * * @param path * @throws IOException */ public static void writeToMatlab(String path) throws IOException { final Path wordMatPath = new Path(path + "/words/wordIndex.mat"); final FileSystem fs = HadoopToolsUtil.getFileSystem(wordMatPath); final LinkedHashMap<String, IndependentPair<Long, Long>> wordIndex = readWordCountLines(path); final MLCell wordCell = new MLCell("words", new int[] { wordIndex.size(), 2 }); System.out.println("... reading words"); for (final Entry<String, IndependentPair<Long, Long>> ent : wordIndex.entrySet()) { final String word = ent.getKey(); final int wordCellIndex = (int) (long) ent.getValue().secondObject(); final long count = ent.getValue().firstObject(); wordCell.set(new MLChar(null, word), wordCellIndex, 0); wordCell.set(new MLDouble(null, new double[][] { new double[] { count } }), wordCellIndex, 1); } final ArrayList<MLArray> list = new ArrayList<MLArray>(); list.add(wordCell); new MatFileWriter(Channels.newChannel(fs.create(wordMatPath)), list); }
/** * Write a CSV timeIndex to a {@link MLCell} writen to a .mat data file * @param path * @throws IOException */ public static void writeToMatlab(String path) throws IOException { Path timeMatPath = new Path(path + "/times/timeIndex.mat"); FileSystem fs = HadoopToolsUtil.getFileSystem(timeMatPath); LinkedHashMap<Long, IndependentPair<Long, Long>> timeIndex = readTimeCountLines(path); MLCell timeCell = new MLCell("times",new int[]{timeIndex.size(),2}); System.out.println("... reading times"); for (Entry<Long, IndependentPair<Long, Long>> ent : timeIndex.entrySet()) { long time = (long)ent.getKey(); int timeCellIndex = (int)(long)ent.getValue().secondObject(); long count = ent.getValue().firstObject(); timeCell.set(new MLDouble(null, new double[][]{new double[]{time}}), timeCellIndex,0); timeCell.set(new MLDouble(null, new double[][]{new double[]{count}}), timeCellIndex,1); } ArrayList<MLArray> list = new ArrayList<MLArray>(); list.add(timeCell); new MatFileWriter(Channels.newChannel(fs.create(timeMatPath)),list ); }
/** * Write a CSV timeIndex to a {@link MLCell} writen to a .mat data file * @param path * @throws IOException */ public static void writeToMatlab(String path) throws IOException { Path timeMatPath = new Path(path + "/times/timeIndex.mat"); FileSystem fs = HadoopToolsUtil.getFileSystem(timeMatPath); LinkedHashMap<Long, IndependentPair<Long, Long>> timeIndex = readTimeCountLines(path); MLCell timeCell = new MLCell("times",new int[]{timeIndex.size(),2}); System.out.println("... reading times"); for (Entry<Long, IndependentPair<Long, Long>> ent : timeIndex.entrySet()) { long time = (long)ent.getKey(); int timeCellIndex = (int)(long)ent.getValue().secondObject(); long count = ent.getValue().firstObject(); timeCell.set(new MLDouble(null, new double[][]{new double[]{time}}), timeCellIndex,0); timeCell.set(new MLDouble(null, new double[][]{new double[]{count}}), timeCellIndex,1); } ArrayList<MLArray> list = new ArrayList<MLArray>(); list.add(timeCell); new MatFileWriter(Channels.newChannel(fs.create(timeMatPath)),list ); }
private MLCell injectionTypesAsMLChar(List<StochasticVariable> stochasticVariables) { int colsSize = stochasticVariables.size() * 2; MLCell injectionsTypes = new MLCell("type_ID", new int[]{1, colsSize}); int i = 0; for (StochasticVariable injection : stochasticVariables) { String type = ""; switch (injection.getType()) { case StochasticVariable.TYPE_LOAD: type = "L"; break; case StochasticVariable.TYPE_DISPATCHABLE_GENERATOR: type = "G"; break; default: type = "W"; break; } injectionsTypes.set(new MLChar("", type), 0, i); i++; injectionsTypes.set(new MLChar("", type), 0, i); // twice, for P and Q i++; } return injectionsTypes; }
private MLCell injectionCountriesAsMLChar(List<StochasticVariable> stochasticVariables) { int colsSize = stochasticVariables.size() * 2; MLCell injectionsCountries = new MLCell("nat_ID", new int[]{1, colsSize}); int i = 0; for (StochasticVariable injection : stochasticVariables) { injectionsCountries.set(new MLChar("", injection.getCountry().name()), 0, i); i++; injectionsCountries.set(new MLChar("", injection.getCountry().name()), 0, i); // twice, for P and Q i++; } return injectionsCountries; }
MLChar mlChar = new MLChar(name2, "none"); MLCell mlCell = new MLCell("cl", new int[]{2, 1}); mlCell.set(mlChar, 0); mlCell.set(mlDouble, 1);
break; case MLArray.mxCELL_CLASS: MLCell cell = new MLCell(name, dims, type, attributes); for (int i = 0; i < cell.getM() * cell.getN(); i++) { tag = new ISMatTag(buf);
break; case MLArray.mxCELL_CLASS: MLCell cell = new MLCell(name, dims, type, attributes); for ( int i = 0; i < cell.getM()*cell.getN(); i++ )
break; case MLArray.mxCELL_CLASS: MLCell cell = new MLCell(name, dims, type, attributes); for (int i = 0; i < cell.getM() * cell.getN(); i++) { tag = new ISMatTag(buf);
break; case MLArray.mxCELL_CLASS: MLCell cell = new MLCell(name, dims, type, attributes); for ( int i = 0; i < cell.getM()*cell.getN(); i++ )
break; case MLArray.mxCELL_CLASS: MLCell cell = new MLCell(name, dims, type, attributes); for (int i = 0; i < cell.getM() * cell.getN(); i++) { tag = new ISMatTag(buf);