"""Synthetic schedule, four-cell distribution and three-band photon accounting. The schedule/spectrum describe the nominal input; spatial cells scale that input. These are separate accounting examples, not a coupled crop or lighting model. """ import math import time from light_kernel import schedule, spatial, spectrum DEFAULT=dict(ppfd=200,photoperiod=16,lights_on=6,distribution='uniform',area_weights='equal',spectral_mix='s1') BOUNDS=dict(ppfd=(0,2000),photoperiod=(0,24),lights_on=(0,23.5)) ENUMS=dict(distribution=('uniform','uneven'),area_weights=('equal','last_triple'),spectral_mix=('s1','s2')) def run(name,p): if name != 'light' or set(p)!=set(BOUNDS)|set(ENUMS):raise ValueError('Unknown experiment or parameters') for k,(lo,hi) in BOUNDS.items(): if type(p[k]) not in (int,float) or not math.isfinite(p[k]) or not lo<=p[k]<=hi:raise ValueError('Parameter out of range: '+k) for k,values in ENUMS.items(): if p[k] not in values:raise ValueError('Unknown option: '+k) for k in ('photoperiod','lights_on'): if abs(p[k]*2-round(p[k]*2))>1e-8:raise ValueError('Use half-hour lighting steps') start=time.perf_counter() cuts=sorted({0.,24.,p['lights_on'],(p['lights_on']+p['photoperiod'])%24}) rows=[(a,b,p['ppfd'] if ((a+b)/2-p['lights_on'])%24