def plotFilters(invert=False, log=False, lens_only=True, macula_only=False, lens_age=[20, 40, 60, 80], spectrum=spectrum, stiles=True): ''' ''' if macula_only: filters, spectrum = filt.stockman(minLambda=400, maxLambda=700, RETURN_SPECTRUM=True, ONLY_MACULA=True, resolution=1) if lens_only and lens_age is None: filters, spectrum = filt.stockman(minLambda=400, maxLambda=700, RETURN_SPECTRUM=True, ONLY_LENS=True, resolution=1) if lens_only and lens_age is not None: spectrum = np.arange(400, 700) filters = np.zeros((len(spectrum), len(lens_age))) for i, age in enumerate(lens_age): filters[:, i] = filt.lens_age_correction(age, spectrum, stiles=stiles) fig = plt.figure() fig.set_tight_layout(True) ax = fig.add_subplot(111) pf.AxisFormat() pf.TufteAxis(ax, ['left', 'bottom'], Nticks=[5, 5]) if log: ax.semilogy(spectrum, filters, 'k', linewidth=2) else: ax.plot(spectrum, filters, 'k', linewidth=2) ax.set_xlabel('wavelength (nm)') ax.set_xlim([400, 700]) if log: ax.set_ylim([-10, max(filters)]) ax.set_ylabel('log density') else: ax.set_ylabel('density') if invert: pf.invert(ax, fig, bk_color='k') plt.show()
#! /usr/bin/env python import matplotlib.pylab as plt import numpy as np from base.optics import filters from base import spectsens as ss from base import plot as pf from genLMS import genLMS maxLambda = 770 filters, spectrum = filters.stockman(minLambda=390, maxLambda=maxLambda, RETURN_SPECTRUM=True, resolution=1) def plotCompare(compare=['stockman', 'stockSpecSens', 'neitz']): ''' ''' fig = plt.figure() fig.set_tight_layout(True) ax = fig.add_subplot(111) pf.AxisFormat() pf.TufteAxis(ax, ['left', 'bottom'], Nticks=[5, 5]) style = ['-', '--', '-.'] for i, condition in enumerate(compare): Lnorm, Mnorm, Snorm = genLMS(spectrum, filters, fundamental=condition, LMSpeaks=[559, 530, 419]) ax.plot(spectrum, Lnorm, 'r' + style[i], linewidth=2) ax.plot(spectrum, Mnorm, 'g' + style[i], linewidth=2)