def find_nearest_phpp_climate(_epw_file): """ Finds the nearest PHPP Climate zone to the EPW Lat / Long Methodology copied from the PHPP v 9.6a (SI) Climate worksheet """ #--------------------------------------------------------------------------- # Get the Long and Lat if _epw_file: try: ep = epw.EPW(_epw_file) location = ep.location latitude = location.latitude longitude = location.longitude except Exception as e: print(e) print('Error reading Location from EPW for some reason?') else: latitude = 40 longitude = -74 print('No EPW file input? I will just use NYC then.') #--------------------------------------------------------------------------- # Find the closest PHPP Climate/Location climate_data = LBT2PH.climate.phpp_climate_data() for each in climate_data: eachLat = float(each.get('Latitude', 0)) eachLong = float(each.get('Longitude', 0)) a = math.sin(math.pi / 180 * eachLat) b = math.sin(math.pi / 180 * latitude) c = math.cos(math.pi / 180 * eachLat) d = math.cos(math.pi / 180 * latitude) e = math.cos(math.pi / 180 * (eachLong - longitude)) f = a * b + c * d * e g = max([-1, f]) h = min([1, g]) j = math.acos(h) kmFromEPWLocation = 6378 * j each['distToEPW'] = kmFromEPWLocation climate_data.sort(key=lambda e: e['distToEPW']) climate_set_to_use = climate_data[0] dataSet = climate_set_to_use.get('Dataset', 'US0055b-New York') alt = '=J23' country = climate_set_to_use.get('Country', 'US-United States of America') region = climate_set_to_use.get('Region', 'New York') climate_set_to_use = LBT2PH.climate.PHPP_ClimateDataSet( dataSet, alt, country, region) return [climate_set_to_use]
def lb_location(self, epw_file=None): if epw_file.endswith(".epw"): ep = epw.EPW(epw_file) location = ep.location self.m_loc_name_text_box.Text = location.city self.m_numeric_lat_updown.Value = location.latitude self.m_numeric_long_updown.Value = location.longitude self.m_elev_updown.Value = location.elevation self.m_timezone_dropdown.SelectedIndex = location.time_zone + 12 else: name = self.m_loc_name_text_box.Text latitude = self.m_numeric_lat_updown.Value longitude = self.m_numeric_long_updown.Value timeZone = self.m_timezone_dropdown.SelectedIndex - 12 elevation = self.m_elev_updown.Value location = loc.Location(name, '-', latitude, longitude, timeZone, elevation) return location
# assign inputs _epwFile = IN[0] location = dryBulbTemperature = dewPointTemperature = relativeHumidity = windSpeed = windDirection = directNormalRadiation = diffuseHorizontalRadiation = globalHorizontalRadiation = directNormalIlluminance = diffuseHorizontalIlluminance = globalHorizontalIlluminance = totalSkyCover = liquidPrecipitationDepth = barometricPressure = modelYear = None try: import ladybug.epw as epw import ladybug.output as output except ImportError: raise ImportError('\nFailed to import ladybug:\n\t{}'.format(e)) if _epwFile: epw_data = epw.EPW(_epwFile) location = epw_data.location dryBulbTemperature = output.wrap(epw_data.dry_bulb_temperature.values) dewPointTemperature = output.wrap(epw_data.dew_point_temperature.values) relativeHumidity = output.wrap(epw_data.relative_humidity.values) windDirection = output.wrap(epw_data.wind_direction.values) windSpeed = output.wrap(epw_data.wind_speed.values) directNormalRadiation = output.wrap( epw_data.direct_normal_radiation.values) diffuseHorizontalRadiation = output.wrap( epw_data.diffuse_horizontal_radiation.values) globalHorizontalRadiation = output.wrap( epw_data.global_horizontal_radiation.values) directNormalIlluminance = output.wrap( epw_data.direct_normal_illuminance.values) diffuseHorizontalIlluminance = output.wrap( epw_data.diffuse_horizontal_illuminance.values) globalHorizontalIlluminance = output.wrap( epw_data.global_horizontal_illuminance.values) totalSkyCover = output.wrap(epw_data.total_sky_cover.values)
ghenv.Component.Category = 'Ladybug' ghenv.Component.SubCategory = '0 :: Import' ghenv.Component.AdditionalHelpFromDocStrings = '2' try: import ladybug.epw as epw except ImportError as e: raise ImportError('\nFailed to import ladybug:\n\t{}'.format(e)) try: from ladybug_rhino.grasshopper import all_required_inputs except ImportError as e: raise ImportError('\nFailed to import ladybug_rhino:\n\t{}'.format(e)) if all_required_inputs(ghenv.Component): epw_data = epw.EPW(_epw_file) location = epw_data.location dry_bulb_temperature = epw_data.dry_bulb_temperature dew_point_temperature = epw_data.dew_point_temperature relative_humidity = epw_data.relative_humidity wind_speed = epw_data.wind_speed wind_direction = epw_data.wind_direction direct_normal_rad = epw_data.direct_normal_radiation diffuse_horizontal_rad = epw_data.diffuse_horizontal_radiation global_horizontal_rad = epw_data.global_horizontal_radiation horizontal_infrared_rad = epw_data.horizontal_infrared_radiation_intensity direct_normal_ill = epw_data.direct_normal_illuminance diffuse_horizontal_ill = epw_data.diffuse_horizontal_illuminance global_horizontal_ill = epw_data.global_horizontal_illuminance total_sky_cover = epw_data.total_sky_cover barometric_pressure = epw_data.atmospheric_station_pressure
# assign inputs _epwFile = IN[0] location = None try: import ladybug.epw as epw except ImportError as e: raise ImportError('\nFailed to import ladybug:\n\t{}'.format(e)) if _epwFile: ep = epw.EPW(_epwFile) location = ep.location # assign outputs to OUT OUT = (location, )
# You should have received a copy of the GNU General Public License # along with Ladybug; If not, see <http://www.gnu.org/licenses/>. # # @license GPL-3.0+ <http://spdx.org/licenses/GPL-3.0+> """ Import location from an epw - Args: _epw_file: An epw file path on your system as a string. Returns: location: Location data (use this output to construct the sun path). """ ghenv.Component.Name = "LadybugPlus_Import Location" ghenv.Component.NickName = 'importLoc' ghenv.Component.Message = 'VER 0.0.04\nFEB_07_2018' ghenv.Component.Category = "LadybugPlus" ghenv.Component.SubCategory = '00 :: Ladybug' ghenv.Component.AdditionalHelpFromDocStrings = "2" try: import ladybug.epw as epw except ImportError as e: raise ImportError('\nFailed to import ladybug:\n\t{}'.format(e)) if _epw_file: ep = epw.EPW(_epw_file) location = ep.location
ghenv.Component.Name = "LadybugPlus_Import EPW" ghenv.Component.NickName = 'importEpw' ghenv.Component.Message = 'VER 0.0.01\nJUL_28_2017' ghenv.Component.Category = "LadybugPlus" ghenv.Component.SubCategory = '00 :: Ladybug' ghenv.Component.AdditionalHelpFromDocStrings = "1" try: import ladybug.epw as epw import ladybug.output as output except ImportError: raise ImportError('\nFailed to import ladybug:\n\t{}'.format(e)) if _epwFile: epwData = epw.EPW(_epwFile) location = epwData.location dryBulbTemperature = output.wrap(epwData.dryBulbTemperature.values) dewPointTemperature = output.wrap(epwData.dewPointTemperature.values) relativeHumidity = output.wrap(epwData.relativeHumidity.values) windDirection = output.wrap(epwData.windDirection.values) windSpeed = output.wrap(epwData.windSpeed.values) directNormalRadiation = output.wrap(epwData.directNormalRadiation.values) diffuseHorizontalRadiation = output.wrap( epwData.diffuseHorizontalRadiation.values) globalHorizontalRadiation = output.wrap( epwData.globalHorizontalRadiation.values) directNormalIlluminance = output.wrap( epwData.directNormalIlluminance.values) diffuseHorizontalIlluminance = output.wrap( epwData.diffuseHorizontalIlluminance.values)