Class NoiseGenerator


  • public class NoiseGenerator
    extends Object
    NoiseGenerator generates noise for readback PVs
    Version:
    0.1 02 Mar 2004
    Author:
    Paul Chu
    • Constructor Detail

      • NoiseGenerator

        public NoiseGenerator()
    • Method Detail

      • setValForPV

        public static double setValForPV​(double pvVal,
                                         double noiseLevel,
                                         double offset,
                                         boolean relative)
        input the "set" PV and return double value as the corresponding readback PV value
        Parameters:
        pvVal - the "set" PV value
        noiseLevel - noise level for the readback PV
        offset - offset from the nominal value
        relative - if noise should be set relative to pvVal
        Returns:
        readback PV value with noise added
      • noisyArrayForNominal

        public static double[] noisyArrayForNominal​(double nominalValue,
                                                    int arrayLength,
                                                    int dataLength,
                                                    double noiseLevel,
                                                    double offset)
        Get an array with noise based on a nominal value. This function is used by instrumentation, so we assume that noise is given in respective units and not in percentage.
        Parameters:
        arrayLength - total length of the array
        dataLength - length of the array to populate with data starting with index 0
        nominalValue - nominal value for entire array
        noiseLevel - level of the noise to apply
        offset - offset from the nominal value
      • getAverage

        public static double getAverage​(double[] array,
                                        int dataLength)
        Get the average from the array