def readEPW_old(self,epwfile=None):
        '''
        use pyepw to read in a epw file.  
        ##  Deprecated. no longer works with updated MetObj.__init__ behavior ##
        pyepw installation info:  pip install pyepw
        documentation: https://github.com/rbuffat/pyepw
        
        Parameters
        ------------
        epwfile:  filename of epw

        Returns
        -------
        metdata - MetObj collected from epw file
        '''
        if epwfile is None:
            try:
                epwfile = _interactive_load()
            except:
                raise Exception('Interactive load failed. Tkinter not supported on this system. Try installing X-Quartz and reloading')

        try:
            from pyepw.epw import EPW
        except:
            print('Error: pyepw not installed.  try pip install pyepw')
        epw = EPW()
        epw.read(epwfile)
        
        self.metdata = MetObj(epw)
        self.epwfile = epwfile  # either epw of csv file to pass in to gencumsky
        return self.metdata
Ejemplo n.º 2
0
def createEPWFile(urls, year):
    listYears = []
    listLinks = []
    for url in urls:
        req = Request(url, headers={"User-Agent": "Mozilla/5.0"})
        resp = urlopen(req).read()
        data = resp.decode("utf-8", 'ignore')
        epw = EPW()

        name = splitUrlName(url)

        f = open('tmp/' + name, "a+")
        f.write("\n".join(data.splitlines()))
        f.close()

        epw.read('tmp/' + name)
        os.remove('tmp/' + name)

        [listYears.append(str(year._year)) for year in epw.weatherdata]

        if str(year) in listYears:
            listLinks.append(url)

    listYears = list(dict.fromkeys(listYears))
    listYears.sort()
    return listYears, listLinks
Ejemplo n.º 3
0
    def test_read_epw(self):

        epw = EPW()
        epw.read(r"tests/data/USA_CA_San.Francisco.Intl.AP.724940_TMY3.epw")

        epw.save(self.path)
        epw2 = EPW()
        epw2.read(self.path)
Ejemplo n.º 4
0
def createEPWFile2(listYears, data, name):
    epw = EPW()

    f = open('tmp/'+name,"a+")
    f.write("".join(data).replace('\r\n','\n'))
    f.close()

    epw.read('tmp/'+name)
    os.remove('tmp/'+name)

    [listYears.append(str(year._year)) for year in epw.weatherdata]
    listYears = list(dict.fromkeys(listYears))
    listYears.sort()
    return listYears
Ejemplo n.º 5
0
    def test_create_data_periods(self):

        obj = DataPeriods()
        data_period_obj = DataPeriod()
        var_data_period_number_of_records_per_hour = 1
        data_period_obj.number_of_records_per_hour = var_data_period_number_of_records_per_hour
        var_data_period_data_period_name_or_description = "data_period_name_or_description"
        data_period_obj.data_period_name_or_description = var_data_period_data_period_name_or_description
        var_data_period_data_period_start_day_of_week = "Sunday"
        data_period_obj.data_period_start_day_of_week = var_data_period_data_period_start_day_of_week
        var_data_period_data_period_start_day = "data_period_start_day"
        data_period_obj.data_period_start_day = var_data_period_data_period_start_day
        var_data_period_data_period_end_day = "data_period_end_day"
        data_period_obj.data_period_end_day = var_data_period_data_period_end_day
        obj.add_data_period(data_period_obj)

        epw = EPW(data_periods=obj)
        epw.save(self.path, check=False)

        epw2 = EPW()
        epw2.read(self.path)
        self.assertEqual(
            epw2.data_periods.data_periods[0].number_of_records_per_hour,
            var_data_period_number_of_records_per_hour)
        self.assertEqual(
            epw2.data_periods.data_periods[0].data_period_name_or_description,
            var_data_period_data_period_name_or_description)
        self.assertEqual(
            epw2.data_periods.data_periods[0].data_period_start_day_of_week,
            var_data_period_data_period_start_day_of_week)
        self.assertEqual(
            epw2.data_periods.data_periods[0].data_period_start_day,
            var_data_period_data_period_start_day)
        self.assertEqual(epw2.data_periods.data_periods[0].data_period_end_day,
                         var_data_period_data_period_end_day)
Ejemplo n.º 6
0
    def test_create_holidays_or_daylight_savings(self):

        obj = HolidaysOrDaylightSavings()
        var_leapyear_observed = "Yes"
        obj.leapyear_observed = var_leapyear_observed
        var_daylight_saving_start_day = "daylight_saving_start_day"
        obj.daylight_saving_start_day = var_daylight_saving_start_day
        var_daylight_saving_end_day = "daylight_saving_end_day"
        obj.daylight_saving_end_day = var_daylight_saving_end_day
        holiday_obj = Holiday()
        var_holiday_holiday_name = "holiday_name"
        holiday_obj.holiday_name = var_holiday_holiday_name
        var_holiday_holiday_day = "holiday_day"
        holiday_obj.holiday_day = var_holiday_holiday_day
        obj.add_holiday(holiday_obj)

        epw = EPW(holidays_or_daylight_savings=obj)
        epw.save(self.path, check=False)

        epw2 = EPW()
        epw2.read(self.path)
        self.assertEqual(epw2.holidays_or_daylight_savings.leapyear_observed,
                         var_leapyear_observed)
        self.assertEqual(
            epw2.holidays_or_daylight_savings.daylight_saving_start_day,
            var_daylight_saving_start_day)
        self.assertEqual(
            epw2.holidays_or_daylight_savings.daylight_saving_end_day,
            var_daylight_saving_end_day)
        self.assertEqual(
            epw2.holidays_or_daylight_savings.holidays[0].holiday_name,
            var_holiday_holiday_name)
        self.assertEqual(
            epw2.holidays_or_daylight_savings.holidays[0].holiday_day,
            var_holiday_holiday_day)
    def test_create_typical_or_extreme_periods(self):

        obj = TypicalOrExtremePeriods()
        typical_or_extreme_period_obj = TypicalOrExtremePeriod()
        var_typical_or_extreme_period_typical_or_extreme_period_name = "typical_or_extreme_period_name"
        typical_or_extreme_period_obj.typical_or_extreme_period_name = var_typical_or_extreme_period_typical_or_extreme_period_name
        var_typical_or_extreme_period_typical_or_extreme_period_type = "typical_or_extreme_period_type"
        typical_or_extreme_period_obj.typical_or_extreme_period_type = var_typical_or_extreme_period_typical_or_extreme_period_type
        var_typical_or_extreme_period_period_start_day = "period_start_day"
        typical_or_extreme_period_obj.period_start_day = var_typical_or_extreme_period_period_start_day
        var_typical_or_extreme_period_period_end_day = "period_end_day"
        typical_or_extreme_period_obj.period_end_day = var_typical_or_extreme_period_period_end_day
        obj.add_typical_or_extreme_period(typical_or_extreme_period_obj)

        epw = EPW(typical_or_extreme_periods=obj)
        epw.save(self.path, check=False)

        epw2 = EPW()
        epw2.read(self.path)
        self.assertEqual(
            epw2.typical_or_extreme_periods.typical_or_extreme_periods[0].
            typical_or_extreme_period_name,
            var_typical_or_extreme_period_typical_or_extreme_period_name)
        self.assertEqual(
            epw2.typical_or_extreme_periods.typical_or_extreme_periods[0].
            typical_or_extreme_period_type,
            var_typical_or_extreme_period_typical_or_extreme_period_type)
        self.assertEqual(
            epw2.typical_or_extreme_periods.typical_or_extreme_periods[0].
            period_start_day, var_typical_or_extreme_period_period_start_day)
        self.assertEqual(
            epw2.typical_or_extreme_periods.typical_or_extreme_periods[0].
            period_end_day, var_typical_or_extreme_period_period_end_day)
    def __init__(self):
        super().__init__(
        )  # Keep this line, it triggers the parent class __init__ method.

        # This is where you define the attribute of your model, this one is pretty basic.
        epw = EPW()
        epw.read(r"SWE_Stockholm.Arlanda.024600_IWEC.epw")
        self.VdryBulb = np.empty([8760])
        jj = 0
        for wd in epw.weatherdata:
            self.VdryBulb[jj] = wd.dry_bulb_temperature
            jj = jj + 1

        self.TdryBulb = 0.
        self.ii = 0  #24 * (26)31
Ejemplo n.º 9
0
    def test_read_epw(self):

        epw = EPW()
        epw.read(r"tests/data/USA_CA_San.Francisco.Intl.AP.724940_TMY3.epw")

        epw.save(self.path)
        epw2 = EPW()
        epw2.read(self.path)
Ejemplo n.º 10
0
    def test_create_comments_1(self):

        obj = Comments1()
        var_comments_1 = "comments_1"
        obj.comments_1 = var_comments_1

        epw = EPW(comments_1=obj)
        epw.save(self.path, check=False)

        epw2 = EPW()
        epw2.read(self.path)
        self.assertEqual(epw2.comments_1.comments_1, var_comments_1)
Ejemplo n.º 11
0
    def test_create_comments_2(self):

        obj = Comments2()
        var_comments_2 = "comments_2"
        obj.comments_2 = var_comments_2

        epw = EPW(comments_2=obj)
        epw.save(self.path, check=False)

        epw2 = EPW()
        epw2.read(self.path)
        self.assertEqual(epw2.comments_2.comments_2, var_comments_2)
    def test_create_typical_or_extreme_periods(self):

        obj = TypicalOrExtremePeriods()
        typical_or_extreme_period_obj = TypicalOrExtremePeriod()
        var_typical_or_extreme_period_typical_or_extreme_period_name = "typical_or_extreme_period_name"
        typical_or_extreme_period_obj.typical_or_extreme_period_name = var_typical_or_extreme_period_typical_or_extreme_period_name
        var_typical_or_extreme_period_typical_or_extreme_period_type = "typical_or_extreme_period_type"
        typical_or_extreme_period_obj.typical_or_extreme_period_type = var_typical_or_extreme_period_typical_or_extreme_period_type
        var_typical_or_extreme_period_period_start_day = "period_start_day"
        typical_or_extreme_period_obj.period_start_day = var_typical_or_extreme_period_period_start_day
        var_typical_or_extreme_period_period_end_day = "period_end_day"
        typical_or_extreme_period_obj.period_end_day = var_typical_or_extreme_period_period_end_day
        obj.add_typical_or_extreme_period(typical_or_extreme_period_obj)

        epw = EPW(typical_or_extreme_periods=obj)
        epw.save(self.path, check=False)

        epw2 = EPW()
        epw2.read(self.path)
        self.assertEqual(
            epw2.typical_or_extreme_periods.typical_or_extreme_periods[0].typical_or_extreme_period_name,
            var_typical_or_extreme_period_typical_or_extreme_period_name)
        self.assertEqual(
            epw2.typical_or_extreme_periods.typical_or_extreme_periods[0].typical_or_extreme_period_type,
            var_typical_or_extreme_period_typical_or_extreme_period_type)
        self.assertEqual(
            epw2.typical_or_extreme_periods.typical_or_extreme_periods[0].period_start_day,
            var_typical_or_extreme_period_period_start_day)
        self.assertEqual(
            epw2.typical_or_extreme_periods.typical_or_extreme_periods[0].period_end_day,
            var_typical_or_extreme_period_period_end_day)
Ejemplo n.º 13
0
    def test_create_comments_1(self):

        obj = Comments1()
        var_comments_1 = "comments_1"
        obj.comments_1 = var_comments_1

        epw = EPW(comments_1=obj)
        epw.save(self.path, check=False)

        epw2 = EPW()
        epw2.read(self.path)
        self.assertEqual(epw2.comments_1.comments_1, var_comments_1)
Ejemplo n.º 14
0
    def test_create_location(self):

        obj = Location()
        var_city = "city"
        obj.city = var_city
        var_state_province_region = "state_province_region"
        obj.state_province_region = var_state_province_region
        var_country = "country"
        obj.country = var_country
        var_source = "source"
        obj.source = var_source
        var_wmo = "wmo"
        obj.wmo = var_wmo
        var_latitude = (90.0 + -90.0) * 0.5
        obj.latitude = var_latitude
        var_longitude = (180.0 + -180.0) * 0.5
        obj.longitude = var_longitude
        var_timezone = (12.0 + -12.0) * 0.5
        obj.timezone = var_timezone
        var_elevation = ((9999.9 - 1.0) + -1000.0) * 0.5
        obj.elevation = var_elevation

        epw = EPW(location=obj)
        epw.save(self.path, check=False)

        epw2 = EPW()
        epw2.read(self.path)
        self.assertEqual(epw2.location.city, var_city)
        self.assertEqual(epw2.location.state_province_region,
                         var_state_province_region)
        self.assertEqual(epw2.location.country, var_country)
        self.assertEqual(epw2.location.source, var_source)
        self.assertEqual(epw2.location.wmo, var_wmo)
        self.assertAlmostEqual(epw2.location.latitude, var_latitude)
        self.assertAlmostEqual(epw2.location.longitude, var_longitude)
        self.assertAlmostEqual(epw2.location.timezone, var_timezone)
        self.assertAlmostEqual(epw2.location.elevation, var_elevation)
    def test_create_holidays_or_daylight_savings(self):

        obj = HolidaysOrDaylightSavings()
        var_leapyear_observed = "Yes"
        obj.leapyear_observed = var_leapyear_observed
        var_daylight_saving_start_day = "daylight_saving_start_day"
        obj.daylight_saving_start_day = var_daylight_saving_start_day
        var_daylight_saving_end_day = "daylight_saving_end_day"
        obj.daylight_saving_end_day = var_daylight_saving_end_day
        holiday_obj = Holiday()
        var_holiday_holiday_name = "holiday_name"
        holiday_obj.holiday_name = var_holiday_holiday_name
        var_holiday_holiday_day = "holiday_day"
        holiday_obj.holiday_day = var_holiday_holiday_day
        obj.add_holiday(holiday_obj)

        epw = EPW(holidays_or_daylight_savings=obj)
        epw.save(self.path, check=False)

        epw2 = EPW()
        epw2.read(self.path)
        self.assertEqual(
            epw2.holidays_or_daylight_savings.leapyear_observed,
            var_leapyear_observed)
        self.assertEqual(
            epw2.holidays_or_daylight_savings.daylight_saving_start_day,
            var_daylight_saving_start_day)
        self.assertEqual(
            epw2.holidays_or_daylight_savings.daylight_saving_end_day,
            var_daylight_saving_end_day)
        self.assertEqual(
            epw2.holidays_or_daylight_savings.holidays[0].holiday_name,
            var_holiday_holiday_name)
        self.assertEqual(
            epw2.holidays_or_daylight_savings.holidays[0].holiday_day,
            var_holiday_holiday_day)
Ejemplo n.º 16
0
    def test_create_data_periods(self):

        obj = DataPeriods()
        data_period_obj = DataPeriod()
        var_data_period_number_of_records_per_hour = 1
        data_period_obj.number_of_records_per_hour = var_data_period_number_of_records_per_hour
        var_data_period_data_period_name_or_description = "data_period_name_or_description"
        data_period_obj.data_period_name_or_description = var_data_period_data_period_name_or_description
        var_data_period_data_period_start_day_of_week = "Sunday"
        data_period_obj.data_period_start_day_of_week = var_data_period_data_period_start_day_of_week
        var_data_period_data_period_start_day = "data_period_start_day"
        data_period_obj.data_period_start_day = var_data_period_data_period_start_day
        var_data_period_data_period_end_day = "data_period_end_day"
        data_period_obj.data_period_end_day = var_data_period_data_period_end_day
        obj.add_data_period(data_period_obj)

        epw = EPW(data_periods=obj)
        epw.save(self.path, check=False)

        epw2 = EPW()
        epw2.read(self.path)
        self.assertEqual(
            epw2.data_periods.data_periods[0].number_of_records_per_hour,
            var_data_period_number_of_records_per_hour)
        self.assertEqual(
            epw2.data_periods.data_periods[0].data_period_name_or_description,
            var_data_period_data_period_name_or_description)
        self.assertEqual(
            epw2.data_periods.data_periods[0].data_period_start_day_of_week,
            var_data_period_data_period_start_day_of_week)
        self.assertEqual(
            epw2.data_periods.data_periods[0].data_period_start_day,
            var_data_period_data_period_start_day)
        self.assertEqual(
            epw2.data_periods.data_periods[0].data_period_end_day,
            var_data_period_data_period_end_day)
Ejemplo n.º 17
0
    def test_create_ground_temperatures(self):

        obj = GroundTemperatures()
        ground_temperature_obj = GroundTemperature()
        var_ground_temperature_ground_temperature_depth = 1.1
        ground_temperature_obj.ground_temperature_depth = var_ground_temperature_ground_temperature_depth
        var_ground_temperature_depth_soil_conductivity = 2.2
        ground_temperature_obj.depth_soil_conductivity = var_ground_temperature_depth_soil_conductivity
        var_ground_temperature_depth_soil_density = 3.3
        ground_temperature_obj.depth_soil_density = var_ground_temperature_depth_soil_density
        var_ground_temperature_depth_soil_specific_heat = 4.4
        ground_temperature_obj.depth_soil_specific_heat = var_ground_temperature_depth_soil_specific_heat
        var_ground_temperature_depth_january_average_ground_temperature = 5.5
        ground_temperature_obj.depth_january_average_ground_temperature = var_ground_temperature_depth_january_average_ground_temperature
        var_ground_temperature_depth_february_average_ground_temperature = 6.6
        ground_temperature_obj.depth_february_average_ground_temperature = var_ground_temperature_depth_february_average_ground_temperature
        var_ground_temperature_depth_march_average_ground_temperature = 7.7
        ground_temperature_obj.depth_march_average_ground_temperature = var_ground_temperature_depth_march_average_ground_temperature
        var_ground_temperature_depth_april_average_ground_temperature = 8.8
        ground_temperature_obj.depth_april_average_ground_temperature = var_ground_temperature_depth_april_average_ground_temperature
        var_ground_temperature_depth_may_average_ground_temperature = 9.9
        ground_temperature_obj.depth_may_average_ground_temperature = var_ground_temperature_depth_may_average_ground_temperature
        var_ground_temperature_depth_june_average_ground_temperature = 10.10
        ground_temperature_obj.depth_june_average_ground_temperature = var_ground_temperature_depth_june_average_ground_temperature
        var_ground_temperature_depth_july_average_ground_temperature = 11.11
        ground_temperature_obj.depth_july_average_ground_temperature = var_ground_temperature_depth_july_average_ground_temperature
        var_ground_temperature_depth_august_average_ground_temperature = 12.12
        ground_temperature_obj.depth_august_average_ground_temperature = var_ground_temperature_depth_august_average_ground_temperature
        var_ground_temperature_depth_september_average_ground_temperature = 13.13
        ground_temperature_obj.depth_september_average_ground_temperature = var_ground_temperature_depth_september_average_ground_temperature
        var_ground_temperature_depth_october_average_ground_temperature = 14.14
        ground_temperature_obj.depth_october_average_ground_temperature = var_ground_temperature_depth_october_average_ground_temperature
        var_ground_temperature_depth_november_average_ground_temperature = 15.15
        ground_temperature_obj.depth_november_average_ground_temperature = var_ground_temperature_depth_november_average_ground_temperature
        var_ground_temperature_depth_december_average_ground_temperature = 16.16
        ground_temperature_obj.depth_december_average_ground_temperature = var_ground_temperature_depth_december_average_ground_temperature
        obj.add_ground_temperature(ground_temperature_obj)

        epw = EPW(ground_temperatures=obj)
        epw.save(self.path, check=False)

        epw2 = EPW()
        epw2.read(self.path)
        self.assertAlmostEqual(
            epw2.ground_temperatures.ground_temperatures[0].ground_temperature_depth,
            var_ground_temperature_ground_temperature_depth)
        self.assertAlmostEqual(
            epw2.ground_temperatures.ground_temperatures[0].depth_soil_conductivity,
            var_ground_temperature_depth_soil_conductivity)
        self.assertAlmostEqual(
            epw2.ground_temperatures.ground_temperatures[0].depth_soil_density,
            var_ground_temperature_depth_soil_density)
        self.assertAlmostEqual(
            epw2.ground_temperatures.ground_temperatures[0].depth_soil_specific_heat,
            var_ground_temperature_depth_soil_specific_heat)
        self.assertAlmostEqual(
            epw2.ground_temperatures.ground_temperatures[0].depth_january_average_ground_temperature,
            var_ground_temperature_depth_january_average_ground_temperature)
        self.assertAlmostEqual(
            epw2.ground_temperatures.ground_temperatures[0].depth_february_average_ground_temperature,
            var_ground_temperature_depth_february_average_ground_temperature)
        self.assertAlmostEqual(
            epw2.ground_temperatures.ground_temperatures[0].depth_march_average_ground_temperature,
            var_ground_temperature_depth_march_average_ground_temperature)
        self.assertAlmostEqual(
            epw2.ground_temperatures.ground_temperatures[0].depth_april_average_ground_temperature,
            var_ground_temperature_depth_april_average_ground_temperature)
        self.assertAlmostEqual(
            epw2.ground_temperatures.ground_temperatures[0].depth_may_average_ground_temperature,
            var_ground_temperature_depth_may_average_ground_temperature)
        self.assertAlmostEqual(
            epw2.ground_temperatures.ground_temperatures[0].depth_june_average_ground_temperature,
            var_ground_temperature_depth_june_average_ground_temperature)
        self.assertAlmostEqual(
            epw2.ground_temperatures.ground_temperatures[0].depth_july_average_ground_temperature,
            var_ground_temperature_depth_july_average_ground_temperature)
        self.assertAlmostEqual(
            epw2.ground_temperatures.ground_temperatures[0].depth_august_average_ground_temperature,
            var_ground_temperature_depth_august_average_ground_temperature)
        self.assertAlmostEqual(
            epw2.ground_temperatures.ground_temperatures[0].depth_september_average_ground_temperature,
            var_ground_temperature_depth_september_average_ground_temperature)
        self.assertAlmostEqual(
            epw2.ground_temperatures.ground_temperatures[0].depth_october_average_ground_temperature,
            var_ground_temperature_depth_october_average_ground_temperature)
        self.assertAlmostEqual(
            epw2.ground_temperatures.ground_temperatures[0].depth_november_average_ground_temperature,
            var_ground_temperature_depth_november_average_ground_temperature)
        self.assertAlmostEqual(
            epw2.ground_temperatures.ground_temperatures[0].depth_december_average_ground_temperature,
            var_ground_temperature_depth_december_average_ground_temperature)
import os
from tqdm import tqdm
import copy
import csv
from pyepw.epw import EPW

tmy_epw = EPW()
multi_epw = EPW()

tmy_filename = "USA_IL_Chicago-OHare.Intl.AP.725300_TMY3.epw"
multi_filename = 'multiyear.epw'

tmy_epw.read(tmy_filename)
lat = tmy_epw.location.latitude
lon = tmy_epw.location.longitude

multi_epw = copy.deepcopy(tmy_epw)
multi_epw.weatherdata = []

with open('darksky_interp.csv') as csvfile:
    reader = csv.reader(csvfile, delimiter=',')
    next(reader)
    for row in tqdm(reader):
        day = int(row[0]) % 8760
        wd = tmy_epw.weatherdata[day]
        new_wd = copy.deepcopy(wd)
        new_wd.year = row[2]
        new_wd.dry_bulb_temperature = row[6]
        new_wd.atmospheric_station_pressure = int(float(row[7]))
        new_wd.relative_humidity = float(row[8]) * 100
        new_wd.dew_point_temperature = row[9]
Ejemplo n.º 19
0
from pvlib import solarposition
from pvlib.location import Location
from pvlib import tracking
from ugrid_tools_ThEl import scale_series

# Loading the Typical Meteorological year" for Johannesburg
datafile = "Data/ZAF_Johannesburg.683680_IWEC.epw"
# Specify coordinates:
latitude = -29
longitude = 28
# Define the orientation of the PV panel (28° is the optimum for south africa):
surface_tilt = 28
surface_azimuth = 0

# Read the TMY file and write the relevant results in numpy arrays:
epw = EPW()
epw.read(datafile)

N = len(epw.weatherdata)
I_hor = np.zeros(N)
I_d_hor = np.zeros(N)
I_0 = np.zeros(N)
DNI = np.zeros(N)
albedo = np.zeros(N)
T = np.zeros(N)

for i in range(N):
    wd = epw.weatherdata[i]
    print wd.year, wd.month, wd.day, wd.hour, wd.minute, wd.dry_bulb_temperature
    I_hor[i] = wd.global_horizontal_radiation
    I_d_hor[i] = wd.diffuse_horizontal_radiation
Ejemplo n.º 20
0
    def test_create_design_conditions(self):

        obj = DesignConditions()
        design_condition_obj = DesignCondition()
        var_design_condition_title_of_design_condition = "title_of_design_condition"
        design_condition_obj.title_of_design_condition = var_design_condition_title_of_design_condition
        var_design_condition_unkown_field = "unkown_field"
        design_condition_obj.unkown_field = var_design_condition_unkown_field
        var_design_condition_design_stat_heating = "Heating"
        design_condition_obj.design_stat_heating = var_design_condition_design_stat_heating
        var_design_condition_coldestmonth = int((12 + 1) * 0.5)
        design_condition_obj.coldestmonth = var_design_condition_coldestmonth
        var_design_condition_db996 = 5.5
        design_condition_obj.db996 = var_design_condition_db996
        var_design_condition_db990 = 6.6
        design_condition_obj.db990 = var_design_condition_db990
        var_design_condition_dp996 = 7.7
        design_condition_obj.dp996 = var_design_condition_dp996
        var_design_condition_hr_dp996 = 8.8
        design_condition_obj.hr_dp996 = var_design_condition_hr_dp996
        var_design_condition_db_dp996 = 9.9
        design_condition_obj.db_dp996 = var_design_condition_db_dp996
        var_design_condition_dp990 = 10.10
        design_condition_obj.dp990 = var_design_condition_dp990
        var_design_condition_hr_dp990 = 11.11
        design_condition_obj.hr_dp990 = var_design_condition_hr_dp990
        var_design_condition_db_dp990 = 12.12
        design_condition_obj.db_dp990 = var_design_condition_db_dp990
        var_design_condition_ws004c = 13.13
        design_condition_obj.ws004c = var_design_condition_ws004c
        var_design_condition_db_ws004c = 14.14
        design_condition_obj.db_ws004c = var_design_condition_db_ws004c
        var_design_condition_ws010c = 15.15
        design_condition_obj.ws010c = var_design_condition_ws010c
        var_design_condition_db_ws010c = 16.16
        design_condition_obj.db_ws010c = var_design_condition_db_ws010c
        var_design_condition_ws_db996 = 17.17
        design_condition_obj.ws_db996 = var_design_condition_ws_db996
        var_design_condition_wd_db996 = 18.18
        design_condition_obj.wd_db996 = var_design_condition_wd_db996
        var_design_condition_design_stat_cooling = "Cooling"
        design_condition_obj.design_stat_cooling = var_design_condition_design_stat_cooling
        var_design_condition_hottestmonth = int((12 + 1) * 0.5)
        design_condition_obj.hottestmonth = var_design_condition_hottestmonth
        var_design_condition_dbr = 21.21
        design_condition_obj.dbr = var_design_condition_dbr
        var_design_condition_db004 = 22.22
        design_condition_obj.db004 = var_design_condition_db004
        var_design_condition_wb_db004 = 23.23
        design_condition_obj.wb_db004 = var_design_condition_wb_db004
        var_design_condition_db010 = 24.24
        design_condition_obj.db010 = var_design_condition_db010
        var_design_condition_wb_db010 = 25.25
        design_condition_obj.wb_db010 = var_design_condition_wb_db010
        var_design_condition_db020 = 26.26
        design_condition_obj.db020 = var_design_condition_db020
        var_design_condition_wb_db020 = 27.27
        design_condition_obj.wb_db020 = var_design_condition_wb_db020
        var_design_condition_wb004 = 28.28
        design_condition_obj.wb004 = var_design_condition_wb004
        var_design_condition_db_wb004 = 29.29
        design_condition_obj.db_wb004 = var_design_condition_db_wb004
        var_design_condition_wb010 = 30.30
        design_condition_obj.wb010 = var_design_condition_wb010
        var_design_condition_db_wb010 = 31.31
        design_condition_obj.db_wb010 = var_design_condition_db_wb010
        var_design_condition_wb020 = 32.32
        design_condition_obj.wb020 = var_design_condition_wb020
        var_design_condition_db_wb020 = 33.33
        design_condition_obj.db_wb020 = var_design_condition_db_wb020
        var_design_condition_ws_db004 = 34.34
        design_condition_obj.ws_db004 = var_design_condition_ws_db004
        var_design_condition_wd_db004 = 35.35
        design_condition_obj.wd_db004 = var_design_condition_wd_db004
        var_design_condition_dp004 = 36.36
        design_condition_obj.dp004 = var_design_condition_dp004
        var_design_condition_hr_dp004 = 37.37
        design_condition_obj.hr_dp004 = var_design_condition_hr_dp004
        var_design_condition_db_dp004 = 38.38
        design_condition_obj.db_dp004 = var_design_condition_db_dp004
        var_design_condition_dp010 = 39.39
        design_condition_obj.dp010 = var_design_condition_dp010
        var_design_condition_hr_dp010 = 40.40
        design_condition_obj.hr_dp010 = var_design_condition_hr_dp010
        var_design_condition_db_dp010 = 41.41
        design_condition_obj.db_dp010 = var_design_condition_db_dp010
        var_design_condition_dp020 = 42.42
        design_condition_obj.dp020 = var_design_condition_dp020
        var_design_condition_hr_dp020 = 43.43
        design_condition_obj.hr_dp020 = var_design_condition_hr_dp020
        var_design_condition_db_dp020 = 44.44
        design_condition_obj.db_dp020 = var_design_condition_db_dp020
        var_design_condition_en004 = 45.45
        design_condition_obj.en004 = var_design_condition_en004
        var_design_condition_db_en004 = 46.46
        design_condition_obj.db_en004 = var_design_condition_db_en004
        var_design_condition_en010 = 47.47
        design_condition_obj.en010 = var_design_condition_en010
        var_design_condition_db_en010 = 48.48
        design_condition_obj.db_en010 = var_design_condition_db_en010
        var_design_condition_en020 = 49.49
        design_condition_obj.en020 = var_design_condition_en020
        var_design_condition_db_en020 = 50.50
        design_condition_obj.db_en020 = var_design_condition_db_en020
        var_design_condition_hrs_84_and_db12_8_or_20_6 = 51.51
        design_condition_obj.hrs_84_and_db12_8_or_20_6 = var_design_condition_hrs_84_and_db12_8_or_20_6
        var_design_condition_design_stat_extremes = "Extremes"
        design_condition_obj.design_stat_extremes = var_design_condition_design_stat_extremes
        var_design_condition_ws010 = 53.53
        design_condition_obj.ws010 = var_design_condition_ws010
        var_design_condition_ws025 = 54.54
        design_condition_obj.ws025 = var_design_condition_ws025
        var_design_condition_ws050 = 55.55
        design_condition_obj.ws050 = var_design_condition_ws050
        var_design_condition_wbmax = 56.56
        design_condition_obj.wbmax = var_design_condition_wbmax
        var_design_condition_dbmin_mean = 57.57
        design_condition_obj.dbmin_mean = var_design_condition_dbmin_mean
        var_design_condition_dbmax_mean = 58.58
        design_condition_obj.dbmax_mean = var_design_condition_dbmax_mean
        var_design_condition_dbmin_stddev = 59.59
        design_condition_obj.dbmin_stddev = var_design_condition_dbmin_stddev
        var_design_condition_dbmax_stddev = 60.60
        design_condition_obj.dbmax_stddev = var_design_condition_dbmax_stddev
        var_design_condition_dbmin05years = 61.61
        design_condition_obj.dbmin05years = var_design_condition_dbmin05years
        var_design_condition_dbmax05years = 62.62
        design_condition_obj.dbmax05years = var_design_condition_dbmax05years
        var_design_condition_dbmin10years = 63.63
        design_condition_obj.dbmin10years = var_design_condition_dbmin10years
        var_design_condition_dbmax10years = 64.64
        design_condition_obj.dbmax10years = var_design_condition_dbmax10years
        var_design_condition_dbmin20years = 65.65
        design_condition_obj.dbmin20years = var_design_condition_dbmin20years
        var_design_condition_dbmax20years = 66.66
        design_condition_obj.dbmax20years = var_design_condition_dbmax20years
        var_design_condition_dbmin50years = 67.67
        design_condition_obj.dbmin50years = var_design_condition_dbmin50years
        var_design_condition_dbmax50years = 68.68
        design_condition_obj.dbmax50years = var_design_condition_dbmax50years
        obj.add_design_condition(design_condition_obj)

        epw = EPW(design_conditions=obj)
        epw.save(self.path, check=False)

        epw2 = EPW()
        epw2.read(self.path)
        self.assertEqual(
            epw2.design_conditions.design_conditions[0].title_of_design_condition,
            var_design_condition_title_of_design_condition)
        self.assertEqual(
            epw2.design_conditions.design_conditions[0].unkown_field,
            var_design_condition_unkown_field)
        self.assertEqual(
            epw2.design_conditions.design_conditions[0].design_stat_heating,
            var_design_condition_design_stat_heating)
        self.assertEqual(
            epw2.design_conditions.design_conditions[0].coldestmonth,
            var_design_condition_coldestmonth)
        self.assertAlmostEqual(
            epw2.design_conditions.design_conditions[0].db996,
            var_design_condition_db996)
        self.assertAlmostEqual(
            epw2.design_conditions.design_conditions[0].db990,
            var_design_condition_db990)
        self.assertAlmostEqual(
            epw2.design_conditions.design_conditions[0].dp996,
            var_design_condition_dp996)
        self.assertAlmostEqual(
            epw2.design_conditions.design_conditions[0].hr_dp996,
            var_design_condition_hr_dp996)
        self.assertAlmostEqual(
            epw2.design_conditions.design_conditions[0].db_dp996,
            var_design_condition_db_dp996)
        self.assertAlmostEqual(
            epw2.design_conditions.design_conditions[0].dp990,
            var_design_condition_dp990)
        self.assertAlmostEqual(
            epw2.design_conditions.design_conditions[0].hr_dp990,
            var_design_condition_hr_dp990)
        self.assertAlmostEqual(
            epw2.design_conditions.design_conditions[0].db_dp990,
            var_design_condition_db_dp990)
        self.assertAlmostEqual(
            epw2.design_conditions.design_conditions[0].ws004c,
            var_design_condition_ws004c)
        self.assertAlmostEqual(
            epw2.design_conditions.design_conditions[0].db_ws004c,
            var_design_condition_db_ws004c)
        self.assertAlmostEqual(
            epw2.design_conditions.design_conditions[0].ws010c,
            var_design_condition_ws010c)
        self.assertAlmostEqual(
            epw2.design_conditions.design_conditions[0].db_ws010c,
            var_design_condition_db_ws010c)
        self.assertAlmostEqual(
            epw2.design_conditions.design_conditions[0].ws_db996,
            var_design_condition_ws_db996)
        self.assertAlmostEqual(
            epw2.design_conditions.design_conditions[0].wd_db996,
            var_design_condition_wd_db996)
        self.assertEqual(
            epw2.design_conditions.design_conditions[0].design_stat_cooling,
            var_design_condition_design_stat_cooling)
        self.assertEqual(
            epw2.design_conditions.design_conditions[0].hottestmonth,
            var_design_condition_hottestmonth)
        self.assertAlmostEqual(
            epw2.design_conditions.design_conditions[0].dbr,
            var_design_condition_dbr)
        self.assertAlmostEqual(
            epw2.design_conditions.design_conditions[0].db004,
            var_design_condition_db004)
        self.assertAlmostEqual(
            epw2.design_conditions.design_conditions[0].wb_db004,
            var_design_condition_wb_db004)
        self.assertAlmostEqual(
            epw2.design_conditions.design_conditions[0].db010,
            var_design_condition_db010)
        self.assertAlmostEqual(
            epw2.design_conditions.design_conditions[0].wb_db010,
            var_design_condition_wb_db010)
        self.assertAlmostEqual(
            epw2.design_conditions.design_conditions[0].db020,
            var_design_condition_db020)
        self.assertAlmostEqual(
            epw2.design_conditions.design_conditions[0].wb_db020,
            var_design_condition_wb_db020)
        self.assertAlmostEqual(
            epw2.design_conditions.design_conditions[0].wb004,
            var_design_condition_wb004)
        self.assertAlmostEqual(
            epw2.design_conditions.design_conditions[0].db_wb004,
            var_design_condition_db_wb004)
        self.assertAlmostEqual(
            epw2.design_conditions.design_conditions[0].wb010,
            var_design_condition_wb010)
        self.assertAlmostEqual(
            epw2.design_conditions.design_conditions[0].db_wb010,
            var_design_condition_db_wb010)
        self.assertAlmostEqual(
            epw2.design_conditions.design_conditions[0].wb020,
            var_design_condition_wb020)
        self.assertAlmostEqual(
            epw2.design_conditions.design_conditions[0].db_wb020,
            var_design_condition_db_wb020)
        self.assertAlmostEqual(
            epw2.design_conditions.design_conditions[0].ws_db004,
            var_design_condition_ws_db004)
        self.assertAlmostEqual(
            epw2.design_conditions.design_conditions[0].wd_db004,
            var_design_condition_wd_db004)
        self.assertAlmostEqual(
            epw2.design_conditions.design_conditions[0].dp004,
            var_design_condition_dp004)
        self.assertAlmostEqual(
            epw2.design_conditions.design_conditions[0].hr_dp004,
            var_design_condition_hr_dp004)
        self.assertAlmostEqual(
            epw2.design_conditions.design_conditions[0].db_dp004,
            var_design_condition_db_dp004)
        self.assertAlmostEqual(
            epw2.design_conditions.design_conditions[0].dp010,
            var_design_condition_dp010)
        self.assertAlmostEqual(
            epw2.design_conditions.design_conditions[0].hr_dp010,
            var_design_condition_hr_dp010)
        self.assertAlmostEqual(
            epw2.design_conditions.design_conditions[0].db_dp010,
            var_design_condition_db_dp010)
        self.assertAlmostEqual(
            epw2.design_conditions.design_conditions[0].dp020,
            var_design_condition_dp020)
        self.assertAlmostEqual(
            epw2.design_conditions.design_conditions[0].hr_dp020,
            var_design_condition_hr_dp020)
        self.assertAlmostEqual(
            epw2.design_conditions.design_conditions[0].db_dp020,
            var_design_condition_db_dp020)
        self.assertAlmostEqual(
            epw2.design_conditions.design_conditions[0].en004,
            var_design_condition_en004)
        self.assertAlmostEqual(
            epw2.design_conditions.design_conditions[0].db_en004,
            var_design_condition_db_en004)
        self.assertAlmostEqual(
            epw2.design_conditions.design_conditions[0].en010,
            var_design_condition_en010)
        self.assertAlmostEqual(
            epw2.design_conditions.design_conditions[0].db_en010,
            var_design_condition_db_en010)
        self.assertAlmostEqual(
            epw2.design_conditions.design_conditions[0].en020,
            var_design_condition_en020)
        self.assertAlmostEqual(
            epw2.design_conditions.design_conditions[0].db_en020,
            var_design_condition_db_en020)
        self.assertAlmostEqual(
            epw2.design_conditions.design_conditions[0].hrs_84_and_db12_8_or_20_6,
            var_design_condition_hrs_84_and_db12_8_or_20_6)
        self.assertEqual(
            epw2.design_conditions.design_conditions[0].design_stat_extremes,
            var_design_condition_design_stat_extremes)
        self.assertAlmostEqual(
            epw2.design_conditions.design_conditions[0].ws010,
            var_design_condition_ws010)
        self.assertAlmostEqual(
            epw2.design_conditions.design_conditions[0].ws025,
            var_design_condition_ws025)
        self.assertAlmostEqual(
            epw2.design_conditions.design_conditions[0].ws050,
            var_design_condition_ws050)
        self.assertAlmostEqual(
            epw2.design_conditions.design_conditions[0].wbmax,
            var_design_condition_wbmax)
        self.assertAlmostEqual(
            epw2.design_conditions.design_conditions[0].dbmin_mean,
            var_design_condition_dbmin_mean)
        self.assertAlmostEqual(
            epw2.design_conditions.design_conditions[0].dbmax_mean,
            var_design_condition_dbmax_mean)
        self.assertAlmostEqual(
            epw2.design_conditions.design_conditions[0].dbmin_stddev,
            var_design_condition_dbmin_stddev)
        self.assertAlmostEqual(
            epw2.design_conditions.design_conditions[0].dbmax_stddev,
            var_design_condition_dbmax_stddev)
        self.assertAlmostEqual(
            epw2.design_conditions.design_conditions[0].dbmin05years,
            var_design_condition_dbmin05years)
        self.assertAlmostEqual(
            epw2.design_conditions.design_conditions[0].dbmax05years,
            var_design_condition_dbmax05years)
        self.assertAlmostEqual(
            epw2.design_conditions.design_conditions[0].dbmin10years,
            var_design_condition_dbmin10years)
        self.assertAlmostEqual(
            epw2.design_conditions.design_conditions[0].dbmax10years,
            var_design_condition_dbmax10years)
        self.assertAlmostEqual(
            epw2.design_conditions.design_conditions[0].dbmin20years,
            var_design_condition_dbmin20years)
        self.assertAlmostEqual(
            epw2.design_conditions.design_conditions[0].dbmax20years,
            var_design_condition_dbmax20years)
        self.assertAlmostEqual(
            epw2.design_conditions.design_conditions[0].dbmin50years,
            var_design_condition_dbmin50years)
        self.assertAlmostEqual(
            epw2.design_conditions.design_conditions[0].dbmax50years,
            var_design_condition_dbmax50years)
import json
import os
from tqdm import tqdm
import requests
import time
import copy

from datetime import datetime
from datetime import timezone
from datetime import timedelta
from pyepw.epw import EPW
import pandas as pd
import numpy as np

df = pd.DataFrame()
tmy_epw = EPW()

load_dotenv()

DARKSKY_API_KEY = os.getenv("DARKSKY_API_KEY")
tmy_filename = "USA_IL_Chicago-OHare.Intl.AP.725300_TMY3.epw"

if DARKSKY_API_KEY == None:
    print("Darksky API Key not set!")

tmy_epw.read(tmy_filename)
lat = tmy_epw.location.latitude
lon = tmy_epw.location.longitude

for y in range(2009, 2020):
    print(y)
Ejemplo n.º 22
0
    def test_create_ground_temperatures(self):

        obj = GroundTemperatures()
        ground_temperature_obj = GroundTemperature()
        var_ground_temperature_ground_temperature_depth = 1.1
        ground_temperature_obj.ground_temperature_depth = var_ground_temperature_ground_temperature_depth
        var_ground_temperature_depth_soil_conductivity = 2.2
        ground_temperature_obj.depth_soil_conductivity = var_ground_temperature_depth_soil_conductivity
        var_ground_temperature_depth_soil_density = 3.3
        ground_temperature_obj.depth_soil_density = var_ground_temperature_depth_soil_density
        var_ground_temperature_depth_soil_specific_heat = 4.4
        ground_temperature_obj.depth_soil_specific_heat = var_ground_temperature_depth_soil_specific_heat
        var_ground_temperature_depth_january_average_ground_temperature = 5.5
        ground_temperature_obj.depth_january_average_ground_temperature = var_ground_temperature_depth_january_average_ground_temperature
        var_ground_temperature_depth_february_average_ground_temperature = 6.6
        ground_temperature_obj.depth_february_average_ground_temperature = var_ground_temperature_depth_february_average_ground_temperature
        var_ground_temperature_depth_march_average_ground_temperature = 7.7
        ground_temperature_obj.depth_march_average_ground_temperature = var_ground_temperature_depth_march_average_ground_temperature
        var_ground_temperature_depth_april_average_ground_temperature = 8.8
        ground_temperature_obj.depth_april_average_ground_temperature = var_ground_temperature_depth_april_average_ground_temperature
        var_ground_temperature_depth_may_average_ground_temperature = 9.9
        ground_temperature_obj.depth_may_average_ground_temperature = var_ground_temperature_depth_may_average_ground_temperature
        var_ground_temperature_depth_june_average_ground_temperature = 10.10
        ground_temperature_obj.depth_june_average_ground_temperature = var_ground_temperature_depth_june_average_ground_temperature
        var_ground_temperature_depth_july_average_ground_temperature = 11.11
        ground_temperature_obj.depth_july_average_ground_temperature = var_ground_temperature_depth_july_average_ground_temperature
        var_ground_temperature_depth_august_average_ground_temperature = 12.12
        ground_temperature_obj.depth_august_average_ground_temperature = var_ground_temperature_depth_august_average_ground_temperature
        var_ground_temperature_depth_september_average_ground_temperature = 13.13
        ground_temperature_obj.depth_september_average_ground_temperature = var_ground_temperature_depth_september_average_ground_temperature
        var_ground_temperature_depth_october_average_ground_temperature = 14.14
        ground_temperature_obj.depth_october_average_ground_temperature = var_ground_temperature_depth_october_average_ground_temperature
        var_ground_temperature_depth_november_average_ground_temperature = 15.15
        ground_temperature_obj.depth_november_average_ground_temperature = var_ground_temperature_depth_november_average_ground_temperature
        var_ground_temperature_depth_december_average_ground_temperature = 16.16
        ground_temperature_obj.depth_december_average_ground_temperature = var_ground_temperature_depth_december_average_ground_temperature
        obj.add_ground_temperature(ground_temperature_obj)

        epw = EPW(ground_temperatures=obj)
        epw.save(self.path, check=False)

        epw2 = EPW()
        epw2.read(self.path)
        self.assertAlmostEqual(
            epw2.ground_temperatures.ground_temperatures[0].
            ground_temperature_depth,
            var_ground_temperature_ground_temperature_depth)
        self.assertAlmostEqual(
            epw2.ground_temperatures.ground_temperatures[0].
            depth_soil_conductivity,
            var_ground_temperature_depth_soil_conductivity)
        self.assertAlmostEqual(
            epw2.ground_temperatures.ground_temperatures[0].depth_soil_density,
            var_ground_temperature_depth_soil_density)
        self.assertAlmostEqual(
            epw2.ground_temperatures.ground_temperatures[0].
            depth_soil_specific_heat,
            var_ground_temperature_depth_soil_specific_heat)
        self.assertAlmostEqual(
            epw2.ground_temperatures.ground_temperatures[0].
            depth_january_average_ground_temperature,
            var_ground_temperature_depth_january_average_ground_temperature)
        self.assertAlmostEqual(
            epw2.ground_temperatures.ground_temperatures[0].
            depth_february_average_ground_temperature,
            var_ground_temperature_depth_february_average_ground_temperature)
        self.assertAlmostEqual(
            epw2.ground_temperatures.ground_temperatures[0].
            depth_march_average_ground_temperature,
            var_ground_temperature_depth_march_average_ground_temperature)
        self.assertAlmostEqual(
            epw2.ground_temperatures.ground_temperatures[0].
            depth_april_average_ground_temperature,
            var_ground_temperature_depth_april_average_ground_temperature)
        self.assertAlmostEqual(
            epw2.ground_temperatures.ground_temperatures[0].
            depth_may_average_ground_temperature,
            var_ground_temperature_depth_may_average_ground_temperature)
        self.assertAlmostEqual(
            epw2.ground_temperatures.ground_temperatures[0].
            depth_june_average_ground_temperature,
            var_ground_temperature_depth_june_average_ground_temperature)
        self.assertAlmostEqual(
            epw2.ground_temperatures.ground_temperatures[0].
            depth_july_average_ground_temperature,
            var_ground_temperature_depth_july_average_ground_temperature)
        self.assertAlmostEqual(
            epw2.ground_temperatures.ground_temperatures[0].
            depth_august_average_ground_temperature,
            var_ground_temperature_depth_august_average_ground_temperature)
        self.assertAlmostEqual(
            epw2.ground_temperatures.ground_temperatures[0].
            depth_september_average_ground_temperature,
            var_ground_temperature_depth_september_average_ground_temperature)
        self.assertAlmostEqual(
            epw2.ground_temperatures.ground_temperatures[0].
            depth_october_average_ground_temperature,
            var_ground_temperature_depth_october_average_ground_temperature)
        self.assertAlmostEqual(
            epw2.ground_temperatures.ground_temperatures[0].
            depth_november_average_ground_temperature,
            var_ground_temperature_depth_november_average_ground_temperature)
        self.assertAlmostEqual(
            epw2.ground_temperatures.ground_temperatures[0].
            depth_december_average_ground_temperature,
            var_ground_temperature_depth_december_average_ground_temperature)