def test_sky_sources(): el, az, irr = sky_sources(sky_type='soc') assert len(az) == len(el) == len(irr) == 46 numpy.testing.assert_almost_equal(numpy.sum(irr), 1) el, az, irr = sky_sources(sky_type='clear_sky') assert len(az) == len(el) == len(irr) == 46 numpy.testing.assert_almost_equal(numpy.sum(irr), 1) el, az, irr = sky_sources(sky_type='clear_sky', irradiance=None) assert irr.max() > 60
def test_sky_sources(): el, az, irr = sky_sources(type='soc') assert len(az) == len(el) == len(irr) == 46 numpy.testing.assert_almost_equal(numpy.sum(irr), 1) el, az, irr = sky_sources(type='clear_sky') assert len(az) == len(el) == len(irr) == 46 numpy.testing.assert_almost_equal(numpy.sum(irr), 1) el, az, irr = sky_sources(type='clear_sky', irradiance=None) assert irr.max() > 60
def illuminate(g, isolated=True, density=9, clear_sky=False, daydate=_daydate, longitude=_longitude, latitude=_latitude, altitude=_altitude, timezone=_timezone): """ Illuminate a plant Args: isolated : is the plant isolated or within a canopy ? clear_sky: use clear_sky (homogeneous sky is used otherwise) irradiance: (float) sum of horizontal irradiance of all sources. If None diffuse horizontal clear_sky irradiance are used for clear_sky type and 20% attenuated clear_sky global horizontal irradiances are used for soc and uoc types. dates: A pandas datetime index (as generated by pandas.date_range). If None, hourly values for daydate are used. daydate: (str) yyyy-mm-dd (not used if dates is not None). longitude: (float) in degrees latitude: (float) in degrees altitude: (float) in meter timezone:(str) the time zone (not used if dates are already localised) Returns: elevation (degrees), azimuth (degrees, from North positive clockwise), and horizontal irradiance of sources """ if not clear_sky: light = light_sources(*sky_sources()) else: sun, sky = sun_sky_sources(daydate=daydate, longitude=longitude, latitude=latitude, altitude=altitude, timezone=timezone, normalisation=1) light = light_sources(*sun) + light_sources(*sky) inter_row = 80 inter_plant = 1. / density / (inter_row / 100.) * 100 pattern = (-0.5 * inter_row, -0.5 * inter_plant, 0.5 * inter_row, 0.5 * inter_plant) cs = CaribuScene(g, light=light, pattern=pattern, scene_unit='cm') raw, agg = cs.run(direct=True, simplify=True, infinite=not isolated) return cs, raw, agg
def illuminate(g, isolated=True): light = light_sources(*sky_sources()) # density =9 pl/m2 density = 9 inter_row = 80 inter_plant = 1. / density / (inter_row / 100.) * 100 pattern = (-0.5 * inter_row, -0.5 * inter_plant, 0.5 * inter_row, 0.5 * inter_plant) cs = CaribuScene(g, light=light, pattern=pattern, scene_unit='cm') raw, agg = cs.run(direct=True, simplify=True, infinite=not isolated) return cs, raw, agg
def illuminate(scene, sky=None, sun=None, pattern=None): if sky is None and sun is None: sky = sky_sources() light = [] if sky is not None: light += light_sources(*sky) if sun is not None: light += light_sources(*sun) infinite = False if pattern is not None: infinite = True cs = CaribuScene(scene, light=light, scene_unit='cm', pattern=pattern) raw, agg = cs.run(direct=True, simplify=True, infinite=infinite) return cs, raw, agg
def get_turtle_light(current_PAR, sky_type='soc', turtle_sectors=46, add_sun=False, curent_date=None, longitude=_longitude, latitude=_latitude, altitude=_altitude, timezone=_timezone): """Sun + sky source using the 46 sector turtle sky discretisation Args: current_date: a naive datetime object sky_type:(str) type of sky luminance model. One of : 'soc' (standard overcast sky), 'uoc' (uniform overcast sky) 'clear_sky' (standard clear sky) turtle_sectors : (int) the minimal number of sectors to be used for discretising the sky hemisphere. Turtle discretisation will be one of 1, 6, 16 or 46 sectors longitude: (float) in degrees latitude: (float) in degrees altitude: (float) in meter timezone:(str) the time zone """ daydate = '2000-06-21' if curent_date is not None: daydate = curent_date.strftime('%Y-%m-%d') sun = [(), (), ()] f_sun = 0 if add_sun: sky_irr = sky_irradiances(daydate=daydate, longitude=longitude, latitude=latitude, altitude=altitude, timezone=timezone) f_sun = sun_fraction(sky_irr) sun = sun_sources(irradiance=f_sun * current_PAR, daydate=daydate, latitude=latitude, longitude=longitude, altitude=altitude, timezone=timezone) sky = sky_sources(sky_type=sky_type, irradiance=current_PAR * (1 - f_sun), turtle_sectors=turtle_sectors, daydate=daydate, longitude=longitude, latitude=latitude, altitude=altitude, timezone=timezone) return light_sources(*sky) + light_sources(*sun)
def light_sources(self, seq, what='global_radiation'): """ return direct and diffuse ligh sources representing the sky and the sun for a given time period indicated by seq Irradiance are accumulated over the whole time period and multiplied by the duration of the period (second) and by scale """ # self.check([what, 'diffuse_fraction'], args={ # 'diffuse_fraction': {'localisation': self.localisation}}) latitude = self.localisation['latitude'] longitude = self.localisation['longitude'] # TO DO set actual sky data = self.data.loc[seq,:] sky_irradiance = data[what].sum() sky = sunsky.sky_sources(type='soc', irradiance=sky_irradiance, dates=seq) sun = sunsky.sun_sources(irradiance=None, dates=seq, latitude=latitude, longitude=longitude) return sun, sky
def light_sources(self, seq, what='global_radiation'): """ return direct and diffuse ligh sources representing the sky and the sun for a given time period indicated by seq Irradiance are accumulated over the whole time period and multiplied by the duration of the period (second) and by scale """ # self.check([what, 'diffuse_fraction'], args={ # 'diffuse_fraction': {'localisation': self.localisation}}) latitude = self.localisation['latitude'] longitude = self.localisation['longitude'] # TO DO set actual sky data = self.data.loc[seq,:] sky_irradiance = data[what].sum() sky = sunsky.sky_sources(sky_type='soc', irradiance=sky_irradiance, dates=seq) sun = sunsky.sun_sources(irradiance=None, dates=seq, latitude=latitude, longitude=longitude) return sun, sky