本文整理汇总了Java中com.jmatio.types.MLCell类的典型用法代码示例。如果您正苦于以下问题:Java MLCell类的具体用法?Java MLCell怎么用?Java MLCell使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MLCell类属于com.jmatio.types包,在下文中一共展示了MLCell类的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: writeHistoricalData
import com.jmatio.types.MLCell; //导入依赖的package包/类
public void writeHistoricalData(ForecastErrorsHistoricalData forecastErrorsHistoricalData) throws IOException {
Objects.requireNonNull(forecastErrorsHistoricalData, "forecast errors historical data is null");
// LOGGER.debug("Preparing stochastic variables mat data");
// MLStructure stochasticVariables = stochasticVariablesAsMLStructure(forecastErrorsHistoricalData.getStochasticVariables());
LOGGER.debug("Preparing injections mat data");
MLCell injections = histoDataHeadersAsMLChar(forecastErrorsHistoricalData.getForecastsData().columnKeyList());
LOGGER.debug("Preparing injections countries mat data");
MLCell injectionsCountries = injectionCountriesAsMLChar(forecastErrorsHistoricalData.getStochasticVariables());
LOGGER.debug("Preparing forecasts mat data");
MLDouble forecastsData = histoDataAsMLDouble("forec_filt", forecastErrorsHistoricalData.getForecastsData());
LOGGER.debug("Preparing snapshots mat data");
MLDouble snapshotsData = histoDataAsMLDouble("snap_filt", forecastErrorsHistoricalData.getSnapshotsData());
LOGGER.debug("Saving mat data into " + matFile.toString());
List<MLArray> mlarray = new ArrayList<>();
// mlarray.add((MLArray) stochasticVariables );
mlarray.add((MLArray) injections);
mlarray.add((MLArray) forecastsData);
mlarray.add((MLArray) snapshotsData);
mlarray.add((MLArray) injectionsCountries);
MatFileWriter writer = new MatFileWriter();
writer.write(matFile.toFile(), mlarray);
}
开发者ID:itesla,项目名称:ipst,代码行数:23,代码来源:FEAMatFileWriter.java
示例2: readStringsArrayFromMat
import com.jmatio.types.MLCell; //导入依赖的package包/类
public static String[] readStringsArrayFromMat(Path matFile, String stringsArrayName) throws IOException {
Objects.requireNonNull(matFile, "mat file is null");
Objects.requireNonNull(stringsArrayName, "strings array name is null");
MatFileReader matFileReader = new MatFileReader();
Map<String, MLArray> matFileContent = matFileReader.read(matFile.toFile());
MLCell stringsArray = (MLCell) matFileContent.get(stringsArrayName);
String[] strings = new String[stringsArray.getN()];
for (int i = 0; i < stringsArray.getN(); i++) {
strings[i] = ((MLChar) stringsArray.get(0, i)).getString(0);
}
return strings;
}
开发者ID:itesla,项目名称:ipst,代码行数:13,代码来源:Utils.java
示例3: createMLStruct
import com.jmatio.types.MLCell; //导入依赖的package包/类
/** Create ML Structure with data for a channel
* @param index Index of channel in model
* @param name Channel name
* @param times Time stamps
* @param values Values
* @param severities Severities
* @return {@link MLStructure}
*/
private MLStructure createMLStruct(final int index, final String name,
final List<Instant> times,
final List<Double> values,
final List<AlarmSeverity> severities)
{
final MLStructure struct = new MLStructure("channel" + index, new int[] { 1, 1 });
final int N = values.size();
final int[] dims = new int[] { N, 1 };
final MLCell time = new MLCell(null, dims);
final MLDouble value = new MLDouble(null, dims);
final MLCell severity = new MLCell(null, dims);
for (int i=0; i<N; ++i)
{
setCellText(time, i, TimestampHelper.format(times.get(i)));
value.set(values.get(i), i);
setCellText(severity, i, severities.get(i).toString());
}
struct.setField("name", new MLChar(null, name));
struct.setField("time", time);
struct.setField("value", value);
struct.setField("severity", severity);
return struct;
}
开发者ID:kasemir,项目名称:org.csstudio.display.builder,代码行数:32,代码来源:MatlabFileExportJob.java
示例4: writeToMatlab
import com.jmatio.types.MLCell; //导入依赖的package包/类
/**
* 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);
}
开发者ID:openimaj,项目名称:openimaj,代码行数:25,代码来源:WordIndex.java
示例5: writeToMatlab
import com.jmatio.types.MLCell; //导入依赖的package包/类
/**
* 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 );
}
开发者ID:openimaj,项目名称:openimaj,代码行数:24,代码来源:TimeIndex.java
示例6: main
import com.jmatio.types.MLCell; //导入依赖的package包/类
public static void main(String[] args) throws IOException {
// MLCell cell = new MLCell("data", new int[]{100000,1});
// Random r = new Random();
// for (int i = 0; i < 100000; i++) {
// MLCell inner = new MLCell(null, new int[]{2,1});
// inner.set(new MLChar(null,"Dummy String" + r.nextDouble()), 0, 0);
// MLDouble d = new MLDouble(null, new double[][]{new
// double[]{r.nextDouble()}});
// inner.set(d, 1, 0);
// cell.set(inner, i,0);
// }
// ArrayList<MLArray> arr = new ArrayList<MLArray>();
// arr.add(cell);
// new MatFileWriter( "mat_file.mat", arr);
final MatFileReader reader = new MatFileReader("/Users/ss/Development/python/storm-spams/XYs.mat");
final Map<String, MLArray> content = reader.getContent();
final MLCell cell = (MLCell) content.get("XYs");
System.out.println(cell.get(0, 0));
System.out.println(cell.get(0, 1));
}
开发者ID:openimaj,项目名称:openimaj,代码行数:21,代码来源:MatlabIO.java
示例7: prepareFolds
import com.jmatio.types.MLCell; //导入依赖的package包/类
private void prepareFolds() {
final MLArray setfolds = this.content.get("set_fold");
if(setfolds==null) return;
if (setfolds.isCell()) {
this.folds = new ArrayList<Fold>();
final MLCell foldcells = (MLCell) setfolds;
final int nfolds = foldcells.getM();
System.out.println(String.format("Found %d folds", nfolds));
for (int i = 0; i < nfolds; i++) {
final MLDouble training = (MLDouble) foldcells.get(i, 0);
final MLDouble test = (MLDouble) foldcells.get(i, 1);
final MLDouble validation = (MLDouble) foldcells.get(i, 2);
final Fold f = new Fold(toIntArray(training), toIntArray(test),
toIntArray(validation));
folds.add(f);
}
} else {
throw new RuntimeException(
"Can't find set_folds in expected format");
}
}
开发者ID:openimaj,项目名称:openimaj,代码行数:23,代码来源:BillMatlabFileDataGenerator.java
示例8: histoDataHeadersAsMLChar
import com.jmatio.types.MLCell; //导入依赖的package包/类
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;
}
开发者ID:itesla,项目名称:ipst,代码行数:14,代码来源:FEAMatFileWriter.java
示例9: injectionCountriesAsMLChar
import com.jmatio.types.MLCell; //导入依赖的package包/类
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;
}
开发者ID:itesla,项目名称:ipst,代码行数:13,代码来源:FEAMatFileWriter.java
示例10: writeMatlabFile2
import com.jmatio.types.MLCell; //导入依赖的package包/类
public void writeMatlabFile2() throws Exception
{
// Example values
final VType[] values = new VType[10];
for (int i=0; i<10; ++i)
values[i] = new ArchiveVNumber(VTypeHelper.getTimestamp(null), AlarmSeverity.NONE, "OK",
ValueFactory.displayNone(),
Math.exp(-((5.0-i)*(5.0-i))) );
// Turn values into Matlab data
final int[] dims = new int[] { values.length, 1 };
final MLDouble value = new MLDouble(null, dims);
final MLCell time = new MLCell(null, dims);
final MLCell severity = new MLCell(null, dims);
final MLCell status = new MLCell(null, dims);
for (int i=0; i<values.length; ++i)
{
value.set(VTypeHelper.toDouble(values[i]), i);
setCellText(time, i, TimestampHelper.format(VTypeHelper.getTimestamp(values[i])));
setCellText(severity, i, VTypeHelper.getSeverity(values[i]).toString());
setCellText(severity, i, VTypeHelper.getMessage(values[i]));
}
final MLStructure struct = new MLStructure("channel0", new int[] { 1, 1 });
struct.setField("value", value);
struct.setField("time", time);
struct.setField("severity", severity);
struct.setField("status", status);
// Write to file
final MatFileIncrementalWriter writer = new MatFileIncrementalWriter("mat_file2.mat");
writer.write(struct);
writer.close();
}
开发者ID:kasemir,项目名称:org.csstudio.display.builder,代码行数:34,代码来源:JMatioDemo.java
示例11: prepareVocabulary
import com.jmatio.types.MLCell; //导入依赖的package包/类
private void prepareVocabulary() {
this.keepIndex = new HashSet<Integer>();
final MLDouble keepIndex = (MLDouble) this.content.get("voc_keep_terms_index");
if(keepIndex != null){
final double[] filterIndexArr = keepIndex.getArray()[0];
for (final double d : filterIndexArr) {
this.keepIndex.add((int) d - 1);
}
}
final MLCell vocLoaded = (MLCell) this.content.get("voc");
if(vocLoaded!=null){
this.indexToVoc = new HashMap<Integer, Integer>();
final ArrayList<MLArray> vocArr = vocLoaded.cells();
int index = 0;
int vocIndex = 0;
this.voc = new HashMap<Integer, String>();
for (final MLArray vocArrItem : vocArr) {
final MLChar vocChar = (MLChar) vocArrItem;
final String vocString = vocChar.getString(0);
if (filter && this.keepIndex.contains(index)) {
this.voc.put(vocIndex, vocString);
this.indexToVoc.put(index, vocIndex);
vocIndex++;
}
index++;
}
} else {
}
}
开发者ID:openimaj,项目名称:openimaj,代码行数:35,代码来源:BillMatlabFileDataGenerator.java
示例12: getMeasurements
import com.jmatio.types.MLCell; //导入依赖的package包/类
private LinkedList<IndependentMeasurement> getMeasurements(MatFileReader matFileReader, String sourcePath) {
LinkedList<IndependentMeasurement> measurements = new LinkedList<IndependentMeasurement>();
try {
MLStructure root = (MLStructure) matFileReader.getMLArray(rootKey);
MLCell accX = (MLCell) root.getField(accXKey);
MLCell accY = (MLCell) root.getField(accYKey);
MLCell accZ = (MLCell) root.getField(accZKey);
MLCell label = (MLCell) root.getField(labelKey);
fillSampleProperyLists(root);
int nOfSamples = (int) Math.round(((MLDouble) root.getField(nOfSamplesKey)).get(0));
for (int i = 0; i < nOfSamples; i++) {
double[] accXValues = getSampleRow(accX, i);
double[] accYValues = getSampleRow(accY, i);
double[] accZValues = getSampleRow(accZ, i);
double[] labelValues = getSampleRow(label, i);
List<IndependentMeasurement> newMeasurements = getMeasurementsFromSample(accXValues, accYValues, accZValues,
labelValues, i);
measurements.addAll(newMeasurements);
}
} catch (NullPointerException e) {
throwInvalidFormatException(sourcePath, e);
}
return measurements;
}
开发者ID:NLeSC,项目名称:eEcology-Classification,代码行数:28,代码来源:AnnotatedMeasurementsMatLoader.java
示例13: setCellText
import com.jmatio.types.MLCell; //导入依赖的package包/类
private void setCellText(final MLCell cell, final int index, final String text)
{
cell.set(new MLChar(null, text), index);
}
开发者ID:kasemir,项目名称:org.csstudio.display.builder,代码行数:5,代码来源:JMatioDemo.java
示例14: MatlabFileDataGenerator
import com.jmatio.types.MLCell; //导入依赖的package包/类
public MatlabFileDataGenerator(File matfile) throws IOException {
MatFileReader reader = new MatFileReader(matfile);
Map<String, MLArray> content = reader.getContent();
this.data= (MLCell) content.get("XYs");
this.index = 0;
}
开发者ID:openimaj,项目名称:openimaj,代码行数:7,代码来源:MatlabFileDataGenerator.java
示例15: getSampleRow
import com.jmatio.types.MLCell; //导入依赖的package包/类
private double[] getSampleRow(MLCell rows, int i) {
MLDouble sampleXML = (MLDouble) rows.cells().get(i);
double[] values = new DoubleMatrix(sampleXML.getArray()).toArray();
return values;
}
开发者ID:NLeSC,项目名称:eEcology-Classification,代码行数:6,代码来源:AnnotatedMeasurementsMatLoader.java
示例16: getContent
import com.jmatio.types.MLCell; //导入依赖的package包/类
/**
* Returns the content of the field/cell/object.
*
* @param array
* the parent structure/cell
* @param m
* column or -1
* @param n
* row or -1
* @return if both m and n are -1, returns {@link MLArray}, if n is -1, returns
* content under index m, if both m and n are not-negative, returns
* content of (m,n)
*/
public Object getContent( MLArray array, int m, int n )
{
int type = array.getType();
Object result = null;
switch ( type )
{
case MLArray.mxINT8_CLASS:
case MLArray.mxINT16_CLASS:
case MLArray.mxINT32_CLASS:
case MLArray.mxINT64_CLASS:
case MLArray.mxUINT8_CLASS:
case MLArray.mxUINT16_CLASS:
case MLArray.mxUINT32_CLASS:
case MLArray.mxUINT64_CLASS:
case MLArray.mxSINGLE_CLASS:
case MLArray.mxDOUBLE_CLASS:
MLNumericArray<?> numeric = (MLNumericArray<?>) array;
if ( m > -1 && n > -1 )
{
result = numeric.get( m, n );
}
else if ( m > -1 )
{
result = numeric.get( m );
}
else
{
result = array;
}
break;
case MLArray.mxCHAR_CLASS:
MLChar mlchar = (MLChar) array;
if ( m > -1 && n > -1 )
{
result = mlchar.getChar( m, n );
}
else if ( m > -1 )
{
result = mlchar.getString( m );
}
else
{
result = mlchar;
}
break;
case MLArray.mxCELL_CLASS:
MLCell mlcell = (MLCell) array;
if ( m > -1 && n > -1 )
{
result = getContent( mlcell.get( m, n ), 0, -1);
}
else if ( m > -1 )
{
result = getContent( mlcell.get( m ), 0, -1 );
}
else
{
result = getContent( mlcell.get( 0 ), -1, -1 );
}
break;
default:
result = array;
}
return result;
}
开发者ID:gradusnikov,项目名称:jmatio,代码行数:82,代码来源:MLArrayQuery.java
示例17: testMLCell
import com.jmatio.types.MLCell; //导入依赖的package包/类
/**
* Test <code>MatFileFilter</code> options
* @throws IOException
*/
@Test
public void testMLCell() throws IOException
{
//array name
String name = "doublearr";
String name2 = "name";
//file name in which array will be storred
String fileName = "mlcell.mat";
File outFile = temp.newFile( fileName );
//test column-packed vector
double[] src = new double[] { 1.3, 2.0, 3.0, 4.0, 5.0, 6.0 };
//create 3x2 double matrix
//[ 1.0 4.0 ;
// 2.0 5.0 ;
// 3.0 6.0 ]
MLDouble mlDouble = new MLDouble( name, src, 3 );
MLChar mlChar = new MLChar( name2, "none" );
MLCell mlCell = new MLCell("cl", new int[] {2,1} );
mlCell.set(mlChar, 0);
mlCell.set(mlDouble, 1);
//write array to file
ArrayList<MLArray> list = new ArrayList<MLArray>();
list.add( mlCell );
//write arrays to file
new MatFileWriter( outFile, list );
//read array form file
MatFileReader mfr = new MatFileReader( outFile );
MLCell mlArrayRetrived = (MLCell)mfr.getMLArray( "cl" );
assertEquals(mlDouble, mlArrayRetrived.get(1) );
assertEquals(mlChar, mlArrayRetrived.get(0) );
}
开发者ID:gradusnikov,项目名称:jmatio,代码行数:46,代码来源:MatIOTest.java
示例18: setCellText
import com.jmatio.types.MLCell; //导入依赖的package包/类
/** Set element of cell array to text
* @param cell Cell array to update
* @param index Index of cell element
* @param text Text to place in cell element
*/
private void setCellText(final MLCell cell, final int index, final String text)
{
cell.set(new MLChar(null, text), index);
}
开发者ID:kasemir,项目名称:org.csstudio.display.builder,代码行数:10,代码来源:MatlabFileExportJob.java
注:本文中的com.jmatio.types.MLCell类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论