public class DataSetUtils extends DataSetUtilsHelper
| Modifier and Type | Class and Description |
|---|---|
static class |
DataSetUtils.Compression
Supported Compression Types
|
static class |
DataSetUtils.ErrType
Error type short handle
|
| Modifier and Type | Field and Description |
|---|---|
protected static boolean |
useFloat32BinaryStandard |
BYTE_ARRAY_CACHE_LOCK, byteArrayCache, STRING_BUFFER_CACHE_LOCK, stringBuilderCache| Modifier and Type | Method and Description |
|---|---|
static AbstractDataSet<?> |
copyDataSet(DataSet ds)
perform and return a deep copy of the data set
|
protected static double[] |
cropToLength(double[] in,
int length)
small helper routine to crop data array in case it's to long
|
static double |
error(DataSet dataSet,
DataSetUtils.ErrType eType,
double x)
convenience short-hand notation for getting error variable at an exact x
value.
|
static double |
error(DataSet dataSet,
DataSetUtils.ErrType eType,
int index)
convenience short-hand notation for getting error variable at a specific
data point index.
|
protected static double |
error(DataSet dataSet,
DataSetUtils.ErrType eType,
int index,
double x,
boolean interpolate)
convenience short-hand notation for getting error variables.
|
static double[] |
errors(DataSet dataSet,
DataSetUtils.ErrType eType)
convenience short-hand notation for getting error variables (if defined
for dataset)
|
static String |
getFileName(DataSet dataSet,
String fileName)
Produce a filename from a dataSet and a String that can contain
{datafield;type;format} style placeholders.
|
static String |
getISODate(long timeMillis,
String format)
Get ISO date from milliseconds since Jan 01, 1970
|
protected static String |
getKey(String line,
String replace) |
protected static String |
getValue(String line) |
static DoubleErrorDataSet |
readDataSetFromByteArray(byte[] byteArray)
Read a Dataset from a byte array containing comma separated values.
The data format is a custom extension of csv with an additional #-commented Metadata Header and a $-commented column header. |
static DataSet |
readDataSetFromFile(String fileName)
Read a Dataset from a file containing comma separated values.
Automatically determines compression from the file extension. The data format is a custom extension of csv with an additional #-commented Metadata Header and a $-commented column header. |
static DataSet |
readDataSetFromFile(String fileName,
DataSetUtils.Compression compression)
Read a Dataset from a file containing comma separated values.
The data format is a custom extension of csv with an additional #-commented Metadata Header and a $-commented column header. |
static DoubleErrorDataSet |
readDataSetFromStream(de.gsi.dataset.utils.DataSetUtils.SplitCharByteInputStream inputStream)
Read a Dataset from a stream containing comma separated values.
The data format is a custom extension of csv with an additional #-commented Metadata Header and a $-commented column header. |
protected static void |
readNumericDataFromReader(BufferedReader inputReader,
DoubleErrorDataSet dataSet) |
static void |
setUseFloat32BinaryStandard(boolean state) |
static boolean |
useFloat32BinaryStandard() |
static void |
writeDataSetToByteArray(DataSet dataSet,
ByteArrayOutputStream byteOutput,
boolean binary,
boolean asFloat)
Write data set into byte buffer.
|
static String |
writeDataSetToFile(DataSet dataSet,
Path path,
String fileName)
Export the contents of the supplied dataSet to file as comma separated
values with an additional comment header containing metaData if
existent.
The filename can contain placeholders of the form {metadatafield;type;format}, where metadatafield references a field in the metadata as specified by the metaDataDataSet interface. |
static String |
writeDataSetToFile(DataSet dataSet,
Path path,
String fileName,
boolean binary)
Export the contents of the supplied dataSet to file as comma separated
values with an additional comment header containing metaData if
existent.
The filename can contain placeholders of the form {metadatafield;type;format}, where metadatafield references a field in the metadata as specified by the metaDataDataSet interface. |
static String |
writeDataSetToFile(DataSet dataSet,
Path path,
String fileName,
DataSetUtils.Compression compression)
Export the contents of the supplied dataSet to file as comma separated
values with an additional comment header containing metaData if
existent.
The filename can contain placeholders of the form {metadatafield;type;format}, where metadatafield references a field in the metadata as specified by the metaDataDataSet interface. |
static String |
writeDataSetToFile(DataSet dataSet,
Path path,
String fileName,
DataSetUtils.Compression compression,
boolean binary)
Export the contents of the supplied dataSet to file as comma separated
values with an additional comment header containing metaData if
existent.
The filename can contain placeholders of the form {metadatafield;type;format}, where metadatafield references a field in the metadata as specified by the metaDataDataSet interface. |
protected static void |
writeHeaderDataToStream(OutputStream outputStream,
DataSet dataSet) |
protected static void |
writeMetaDataToStream(OutputStream outputStream,
DataSet dataSet) |
protected static void |
writeNumericDataToStream(OutputStream outputFile,
DataSet dataSet) |
getCachedDoubleArray, getCachedStringBuilder, integralSimple, mean, readDoubleArrayFromBuffer, release, release, rootMeanSquare, toDoubleArray, toFloatArray, writeDoubleArrayAsFloatToByteBuffer, writeDoubleArrayToByteBufferpublic static boolean useFloat32BinaryStandard()
public static void setUseFloat32BinaryStandard(boolean state)
public static AbstractDataSet<?> copyDataSet(DataSet ds)
ds - data set to be copiedpublic static double error(DataSet dataSet, DataSetUtils.ErrType eType, int index)
dataSet - the source data seteType - the error typeindex - the data set indexpublic static double error(DataSet dataSet, DataSetUtils.ErrType eType, double x)
dataSet - the source data seteType - the error typex - the data set x-value for which the error should be interpolatedprotected static double error(DataSet dataSet, DataSetUtils.ErrType eType, int index, double x, boolean interpolate)
dataSet - the source data seteType - the error typeindex - the data set indexx - the data set x-value for which the error should be interpolatedinterpolate - determines if the value at index or the interpolated
value at x should be returnedprotected static double[] cropToLength(double[] in,
int length)
in - input data arraylength - length of output arraypublic static double[] errors(DataSet dataSet, DataSetUtils.ErrType eType)
dataSet - the source data seteType - the error typepublic static String getISODate(long timeMillis, String format)
timeMillis - time to be convertedformat - time format stringpublic static String getFileName(DataSet dataSet, String fileName)
dataSet - A dataSet containing all the data field referenced in the
filename patternfileName - Filename (with "{metadatafield;type;format}" placeholders
for variables)public static String writeDataSetToFile(DataSet dataSet, Path path, String fileName, boolean binary)
dataSet - The DataSet to exportpath - Path to the location of the filefileName - Filename (with "{metadatafield;type;format}" placeholders
for variables)binary - true: whether to store data as binary or stringpublic static String writeDataSetToFile(DataSet dataSet, Path path, String fileName)
dataSet - The DataSet to exportpath - Path to the location of the filefileName - Filename (with "{metadatafield;type;format}" placeholders
for variables)public static String writeDataSetToFile(DataSet dataSet, Path path, String fileName, DataSetUtils.Compression compression)
dataSet - The DataSet to exportpath - Path to the location of the filefileName - Filename (with "{metadatafield;type;format}" placeholders
for variables)compression - compression type @see Compressionpublic static String writeDataSetToFile(DataSet dataSet, Path path, String fileName, DataSetUtils.Compression compression, boolean binary)
dataSet - The DataSet to exportpath - Path to the location of the filefileName - Filename (with "{metadatafield;type;format}" placeholders
for variables)compression - Compression of the file (GZIP, ZIP or NONE). Supply
AUTO or omit this value to use file extension.binary - true: whether to store data as binary or stringpublic static void writeDataSetToByteArray(DataSet dataSet, ByteArrayOutputStream byteOutput, boolean binary, boolean asFloat)
dataSet - The DataSet to exportbyteOutput - byte output stream (N.B. keep caching this object)binary - true: encode data as binary (smaller size,
performance), or false as string (human readable,
easier debugging)asFloat - true: encode data as binary floats (smaller size,
performance), or false as double (better precision)protected static void writeHeaderDataToStream(OutputStream outputStream, DataSet dataSet)
protected static void writeMetaDataToStream(OutputStream outputStream, DataSet dataSet)
protected static void writeNumericDataToStream(OutputStream outputFile, DataSet dataSet)
public static DataSet readDataSetFromFile(String fileName)
fileName - Path and name of file containing csv data.public static DataSet readDataSetFromFile(String fileName, DataSetUtils.Compression compression)
fileName - Path and name of file containing csv data.compression - Compression of the file (GZIP, ZIP or NONE). Supply
AUTO or omit this value to use file extension.public static DoubleErrorDataSet readDataSetFromByteArray(byte[] byteArray)
byteArray - byte array.public static DoubleErrorDataSet readDataSetFromStream(de.gsi.dataset.utils.DataSetUtils.SplitCharByteInputStream inputStream)
inputStream - Path and name of file containing csv data.protected static void readNumericDataFromReader(BufferedReader inputReader, DoubleErrorDataSet dataSet)
Copyright © 2019 GSI Helmholtzzentrum für Schwerionenforschung GmbH. All rights reserved.