Exemple #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)
import numpy as np
import csv
from psychopy import monitors

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)
print wavelengths.shape
# power = np.transpose(power)
power = np.transpose(power)
print power.shape

m = monitors.makeLMS2RGB(wavelengths, power)
print m
    def get_lms2rgb(self):

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

        return monitors.makeLMS2RGB(self.wavelengths, self.power)