Example #1
0
    def onCalibColorBtn(self, event):
        if NO_MEASUREMENTS:
            # get previous spectra:
            nm, spectra = self.currentMon.getSpectra()
        else:
            # do spectral measurement:
            useBits = self.currentMon.getUseBits()
            _size = self.currentMon.getSizePix()
            nm, spectra = monitors.getRGBspectra(stimSize=0.5,
                                                 photometer=self.photom,
                                                 winSize=_size)
            self.currentMon.setSpectra(nm, spectra)
            self.btnPlotSpectra.Enable(True)  # can now plot spectra
            self.unSavedMonitor = True

        self.onCopyCalib(1)  # create a new dated calibration

        # dkl
        dkl_rgb = monitors.makeDKL2RGB(nm, spectra)
        self.currentMon.setDKL_RGB(dkl_rgb)
        self.DKLgrid.setData(dkl_rgb)
        # lms
        lms_rgb = monitors.makeLMS2RGB(nm, spectra)
        self.currentMon.setLMS_RGB(lms_rgb)
        self.LMSgrid.setData(lms_rgb)
    def get_dkl2rgb(self):

        assert all([len(self.wavelengths) == len(i) for i in self.power])

        return monitors.makeDKL2RGB(self.wavelengths, self.power)
Example #3
0

# Get the spectra data
datafile = './spectra_data/spectra.csv'

wavelengths = []
power = []

with open(datafile, 'rb') as f:
    reader = csv.reader(f)
    for i, line in enumerate(reader):
        if i == 0:
            print line
            continue
        line = map(float, line)
        wavelengths.append(line[0])
        power.append(line[1:])

wavelengths = np.array(wavelengths) # 1xN
power = np.transpose(power) # should be a 3xN matrix

dkl2rgb = monitors.makeDKL2RGB(wavelengths, power)
lms2rgb = monitors.makeLMS2RGB(wavelengths, power)

mon.setDKL2RGB(dkl2rgb)
mon.setLMS2RGB(lms2rgb)

mon.saveMon()