Package core
Class MeasurementSet
java.lang.Object
core.MeasurementSet
Container for measurement data with metadata.
Handles storage, statistics, and file I/O for spectrometer measurements.
Stores multiple spectra (each with 6 channels) along with measurement parameters.
- Version:
- 1.0
- Author:
- Spectrometer Control Software
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classContainer for statistical results (mean and standard deviation). -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddMeasurement(double[] measurement) Adds a single measurement (spectrum) to the set.voidclear()Clears all measurements, parameters, and name.Calculate mean and standard deviation across all measurements.List<double[]> Returns an unmodifiable list of all measurements.getName()Gets the name of this measurement set.Gets a copy of the measurement parameters.Get formatted statistics as string.booleanisEmpty()Checks if the measurement set is empty.static MeasurementSetloadFromFile(String filename) Load measurement set from a JSON file.voidsaveToFile(String filename) Save measurement set to a JSON file.voidSets the name of this measurement set.voidsetParameters(Map<String, Object> params) Sets the measurement parameters.intsize()Returns the number of measurements stored.toString()Returns a formatted string representation of the measurement set.
-
Constructor Details
-
MeasurementSet
public MeasurementSet()Constructs an empty MeasurementSet.
-
-
Method Details
-
setParameters
Sets the measurement parameters.- Parameters:
params- map of parameter names to values
-
setName
Sets the name of this measurement set.- Parameters:
name- the measurement name
-
getName
Gets the name of this measurement set.- Returns:
- the measurement name
-
getParameters
Gets a copy of the measurement parameters.- Returns:
- a new HashMap containing all parameters
-
addMeasurement
public void addMeasurement(double[] measurement) Adds a single measurement (spectrum) to the set.- Parameters:
measurement- array of 6 channel values- Throws:
IllegalArgumentException- if measurement length is not 6
-
getMeasurements
Returns an unmodifiable list of all measurements.- Returns:
- unmodifiable List of measurement arrays
-
clear
public void clear()Clears all measurements, parameters, and name. -
isEmpty
public boolean isEmpty()Checks if the measurement set is empty.- Returns:
- true if no measurements are stored
-
size
public int size()Returns the number of measurements stored.- Returns:
- the size of the measurement set
-
getAverageAndStd
Calculate mean and standard deviation across all measurements.- Returns:
- StatisticsResult containing mean and std arrays
-
getStatisticsString
Get formatted statistics as string.- Returns:
- formatted string with wavelength, average, and standard deviation
-
saveToFile
Save measurement set to a JSON file.- Parameters:
filename- the path to the output file- Throws:
IOException- if file cannot be written
-
loadFromFile
Load measurement set from a JSON file.- Parameters:
filename- the path to the input file- Returns:
- a new MeasurementSet populated from the file
- Throws:
IOException- if file cannot be read or parsed
-
toString
Returns a formatted string representation of the measurement set. Includes parameters, statistics, and raw data.
-