def draw_sunpath(self): """Calculate and draw sun path to Rhino.""" self.clear_conduit() _location = self.epw.location north_ = 0 _centerPt_ = None _scale_ = 1 _sunScale_ = 1 _annual_ = True daylight_saving_period = None # temporary until we fully implement it _hoys_ = range(23) # initiate sunpath based on location sp = Sunpath.from_location(_location, north_, daylight_saving_period) # draw sunpath geometry sunpath_geo = \ sp.draw_sunpath(_hoys_, _centerPt_, _scale_, _sunScale_, _annual_) analemma = sunpath_geo.analemma_curves compass = sunpath_geo.compass_curves daily = sunpath_geo.daily_curves sun_pts = sunpath_geo.sun_geos suns = sunpath_geo.suns vectors = (geo.vector(*sun.sun_vector) for sun in suns) altitudes = (sun.altitude for sun in suns) azimuths = (sun.azimuth for sun in suns) center_pt = _centerPt_ or geo.point(0, 0, 0) hoys = (sun.hoy for sun in suns) datetimes = (sun.datetime for sun in suns) # draw the curves to canvas self.conduit = DrawSunPath( list(analemma) + list(compass) + list(daily), sun_pts) self.conduit.Enabled = True # add lights for sun in suns: light = Rhino.Geometry.Light.CreateSunLight( north_, sun.azimuth - 90, sun.altitude) sc.doc.Lights.Add(light) sc.doc.Views.Redraw()
_threshold_: Threshhold for daylight autonomy in lux (default: 300). _target_DA_: Minimum target percentage for daylight autonomy (default: 50). Returns: report: Reports, errors, warnings, etc. sDA: Spatial daylight autonomy as percentage of area for each analysis grid. DA: Daylight autonomy for each point in each analysis grid. prblm_Pts: A list of problematic test points with spatial daylight autonomy less then targetDA. """ ghenv.Component.Name = "HoneybeePlus_Spatial Daylight Autonomy" ghenv.Component.NickName = 'sDA' ghenv.Component.Message = 'VER 0.0.05\nOCT_22_2018' ghenv.Component.Category = "HoneybeePlus" ghenv.Component.SubCategory = '04 :: Daylight :: Daylight' ghenv.Component.AdditionalHelpFromDocStrings = "3" try: import ladybug.geometry as lg except ImportError as e: raise ImportError('\nFailed to import ladybug:\n\t{}'.format(e)) if _analysis_grid: states = _analysis_grid.parse_blind_states(blind_states_) sDA, DA, prblm_Pts = _analysis_grid.spatial_daylight_autonomy( _threshold_, _target_DA_, states, _occ_schedule_ ) prblm_Pts = (lg.point(s.location.x, s.location.y, s.location.z) for s in prblm_Pts)
# assign inputs _analysisGrid, blindStates_, _occSchedule_, _threshold_, _targetDA_ = IN sDA = DA = prblmPts = None try: import ladybug.geometry as lg except ImportError as e: raise ImportError('\nFailed to import ladybug:\n\t{}'.format(e)) if _analysisGrid: states = _analysisGrid.parse_blind_states(blindStates_) sDA, DA, prblmPts = _analysisGrid.spatial_daylight_autonomy( _threshold_, _targetDA_, states, _occSchedule_) prblmPts = (lg.point(s.location.x, s.location.y, s.location.z) for s in prblmPts) # assign outputs to OUT OUT = sDA, DA, prblmPts
except ImportError as e: raise ImportError('\nFailed to import ladybug:\n\t{}'.format(e)) if _location: daylightSavingPeriod = None # temporary until we fully implement it _hoys_ = _hoys_ or () # initiate sunpath based on location sp = Sunpath.from_location(_location, north_, daylightSavingPeriod) # draw sunpath geometry sunpath_geo = \ sp.draw_sunpath(_hoys_, _centerPt_, _scale_, _sunScale_, _annual_) analemma = sunpath_geo.analemma_curves compass = sunpath_geo.compass_curves daily = sunpath_geo.daily_curves sunPts = sunpath_geo.sun_geos suns = sunpath_geo.suns vectors = (geo.vector(*sun.sun_vector) for sun in suns) altitudes = (sun.altitude for sun in suns) azimuths = (sun.azimuth for sun in suns) centerPt = _centerPt_ or geo.point(0, 0, 0) hoys = (sun.hoy for sun in suns) datetimes = (sun.datetime for sun in suns) # assign outputs to OUT OUT = vectors, altitudes, azimuths, sunPts, analemma, compass, daily, centerPt, hoys, datetimes
def lb_generate_sun_path(self): #instance properties to be reterived by sunlight hours panel self.m_vectors = [] self.m_hoys = [] self.m_timestep = 1 #default - to be implemented in eto location = self.lb_location(self.m_epw_file) self.m_epw_file = "" daylightSavingPeriod = None # temporary until we fully implement it north = self.m_north_updown.Value centerPt = Rhino.Geometry.Point3d(0, 0, 0) scale = self.m_sun_path_updown.Value sunScale = self.m_sun_sphere_updown.Value annual = self.m_annual_check_box.Checked hoys = () if not self.m_annual_check_box.Checked: month = self.m_date.Value.Month day = self.m_date.Value.Day hour = self.m_time.Value.Hour minute = self.m_time.Value.Minute if not self.m_period_check_box.Checked: datetime = dt.DateTime(month, day, hour, minute) hoys = [datetime.hoy] else: to_month = self.m_to_date.Value.Month to_day = self.m_to_date.Value.Day to_hour = self.m_to_time.Value.Hour to_minute = self.m_to_time.Value.Minute anp = ap.AnalysisPeriod(\ month, day, hour, to_month, to_day, to_hour, self.m_timestep) if anp: analysisPeriod = anp dates = list(anp.datetimes) hoys = list(anp.hoys) # initiate sunpath based on location sp = Sunpath.from_location(location, north, daylightSavingPeriod) # draw sunpath geometry sunpath_geo = \ sp.draw_sunpath(hoys, centerPt, scale, sunScale, annual) analemma = sunpath_geo.analemma_curves compass = sunpath_geo.compass_curves daily = sunpath_geo.daily_curves sunPts = sunpath_geo.sun_geos suns = sunpath_geo.suns self.m_vectors = list(geo.vector(*sun.sun_vector) for sun in suns) altitudes = (sun.altitude for sun in suns) azimuths = (sun.azimuth for sun in suns) centerPt = centerPt or geo.point(0, 0, 0) self.m_hoys = list(sun.hoy for sun in suns) datetimes = (sun.datetime for sun in suns) #bake geo in scene geo_list = list(sunPts) + list(analemma) + list(compass) + list( daily) + [centerPt] LadybugEto.bakeGeo(geo_list, 'lb_sunpath') return