Package core

Class MeasurementSet

java.lang.Object
core.MeasurementSet

public class MeasurementSet extends Object
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
  • Constructor Details

    • MeasurementSet

      public MeasurementSet()
      Constructs an empty MeasurementSet.
  • Method Details

    • setParameters

      public void setParameters(Map<String,Object> params)
      Sets the measurement parameters.
      Parameters:
      params - map of parameter names to values
    • setName

      public void setName(String name)
      Sets the name of this measurement set.
      Parameters:
      name - the measurement name
    • getName

      public String getName()
      Gets the name of this measurement set.
      Returns:
      the measurement name
    • getParameters

      public Map<String,Object> 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

      public List<double[]> 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

      public MeasurementSet.StatisticsResult getAverageAndStd()
      Calculate mean and standard deviation across all measurements.
      Returns:
      StatisticsResult containing mean and std arrays
    • getStatisticsString

      public String getStatisticsString()
      Get formatted statistics as string.
      Returns:
      formatted string with wavelength, average, and standard deviation
    • saveToFile

      public void saveToFile(String filename) throws IOException
      Save measurement set to a JSON file.
      Parameters:
      filename - the path to the output file
      Throws:
      IOException - if file cannot be written
    • loadFromFile

      public static MeasurementSet loadFromFile(String filename) throws IOException
      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

      public String toString()
      Returns a formatted string representation of the measurement set. Includes parameters, statistics, and raw data.
      Overrides:
      toString in class Object
      Returns:
      formatted string containing all measurement information