How to use the uwg.utilities function in uwg

To help you get started, we’ve selected a few uwg examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github chriswmackey / Dragonfly / uwg / uwg.py View on Github external
self._header    # header data
            self.epwinput   # timestep data for weather
            self.lat        # latitude
            self.lon        # longitude
            self.GMT        # GMT
            self.nSoil      # Number of soil depths
            self.Tsoil      # nSoil x 12 matrix for soil temperture (K)
            self.depth_soil # nSoil x 1 matrix for soil depth (m)
        """

        # Make dir path to epw file
        self.climateDataPath = os.path.join(self.epwDir, self.epwFileName)

        # Open epw file and feed csv data to climate_data
        try:
            climate_data = utilities.read_csv(self.climateDataPath)
        except Exception as e:
            raise Exception("Failed to read epw file! {}".format(e.message))

        # Read header lines (1 to 8) from EPW and ensure TMY2 format.
        self._header = climate_data[0:8]

        # Read weather data from EPW for each time step in weather file. (lines 8 - end)
        self.epwinput = climate_data[8:]

        # Read Lat, Long (line 1 of EPW)
        self.lat = float(self._header[0][6])
        self.lon = float(self._header[0][7])
        self.GMT = float(self._header[0][8])

        # Read in soil temperature data (assumes this is always there)
        # ref: http://bigladdersoftware.com/epx/docs/8-2/auxiliary-programs/epw-csv-format-inout.html
github chriswmackey / Dragonfly / uwg / uwg.py View on Github external
self.sensAnth           # non-building sensible heat (W/m^2)
            self.SchTraffic         # Traffice schedule

            self.BEM                # list of BEMDef objects extracted from readDOE
            self.Sch                # list of Schedule objects extracted from readDOE

        """

        uwg_param_file_path = os.path.join(self.uwgParamDir, self.uwgParamFileName)

        if not os.path.exists(uwg_param_file_path):
            raise Exception("Param file: '{}' does not exist.".format(uwg_param_file_path))

        # Open .uwg file and feed csv data to initializeDataFile
        try:
            uwg_param_data = utilities.read_csv(uwg_param_file_path)
        except Exception as e:
            raise Exception("Failed to read .uwg file! {}".format(e.message))

        # The initialize.uwg is read with a dictionary so that users changing
        # line endings or line numbers doesn't make reading input incorrect
        self._init_param_dict = {}
        count = 0
        while count < len(uwg_param_data):
            row = uwg_param_data[count]
            row = [row[i].replace(" ", "") for i in range(len(row))]  # strip white spaces

            # Optional parameters might be empty so handle separately
            is_optional_parameter = (
                row != [] and
                (
                    row[0] == "albRoof" or
github chriswmackey / Dragonfly / uwg / uwg.py View on Github external
readDOE_file = open(self.readDOE_file_path, 'rb')  # open pickle file in binary form
        refDOE = pickle.load(readDOE_file)
        refBEM = pickle.load(readDOE_file)
        refSchedule = pickle.load(readDOE_file)
        readDOE_file.close()

        # Define building energy models
        k = 0
        self.r_glaze_total = 0.             # Glazing ratio for total building stock
        self.SHGC_total = 0.                # SHGC addition for total building stock
        self.alb_wall_total = 0.            # albedo wall addition for total building stock
        h_floor = self.flr_h or 3.05  # average floor height

        total_urban_bld_area = math.pow(self.charLength, 2)*self.bldDensity * \
            self.bldHeight/h_floor  # total building floor area
        area_matrix = utilities.zeros(16, 3)

        self.BEM = []           # list of BEMDef objects
        self.Sch = []           # list of Schedule objects

        for i in range(16):    # 16 building types
            for j in range(3):  # 3 built eras
                if self.bld[i][j] > 0.:
                    # Add to BEM list
                    self.BEM.append(refBEM[i][j][self.zone])
                    self.BEM[k].frac = self.bld[i][j]
                    self.BEM[k].fl_area = self.bld[i][j] * total_urban_bld_area

                    # Overwrite with optional parameters if provided
                    if self.glzR:
                        self.BEM[k].building.glazingRatio = self.glzR
                    if self.albRoof:
github chriswmackey / Dragonfly / uwg / uwg.py View on Github external
# Read header lines (1 to 8) from EPW and ensure TMY2 format.
        self._header = climate_data[0:8]

        # Read weather data from EPW for each time step in weather file. (lines 8 - end)
        self.epwinput = climate_data[8:]

        # Read Lat, Long (line 1 of EPW)
        self.lat = float(self._header[0][6])
        self.lon = float(self._header[0][7])
        self.GMT = float(self._header[0][8])

        # Read in soil temperature data (assumes this is always there)
        # ref: http://bigladdersoftware.com/epx/docs/8-2/auxiliary-programs/epw-csv-format-inout.html
        soilData = self._header[3]
        self.nSoil = int(soilData[1])           # Number of ground temperature depths
        self.Tsoil = utilities.zeros(self.nSoil, 12)  # nSoil x 12 matrix for soil temperture (K)
        self.depth_soil = utilities.zeros(self.nSoil, 1)   # nSoil x 1 matrix for soil depth (m)

        # Read monthly data for each layer of soil from EPW file
        for i in range(self.nSoil):
            self.depth_soil[i][0] = float(soilData[2 + (i*16)])  # get soil depth for each nSoil
            # Monthly data
            for j in range(12):
                # 12 months of soil T for specific depth
                self.Tsoil[i][j] = float(soilData[6 + (i*16) + j]) + 273.15

        # Set new directory path for the moprhed EPW file
        self.newPathName = os.path.join(self.destinationDir, self.destinationFileName)
github chriswmackey / Dragonfly / uwg / uwg.py View on Github external
row[0] == "SHGC"
                )
            )
            try:
                if row == [] or "#" in row[0]:
                    count += 1
                    continue
                elif row[0] == "SchTraffic":
                    # SchTraffic: 3 x 24 matrix
                    trafficrows = uwg_param_data[count+1:count+4]
                    self._init_param_dict[row[0]] = [utilities.str2fl(r[:24]) for r in trafficrows]
                    count += 4
                elif row[0] == "bld":
                    # bld: 17 x 3 matrix
                    bldrows = uwg_param_data[count+1:count+17]
                    self._init_param_dict[row[0]] = [utilities.str2fl(r[:3]) for r in bldrows]
                    count += 17
                elif is_optional_parameter:
                    self._init_param_dict[row[0]] = float(row[1]) if row[1] != "" else None
                    count += 1
                else:
                    self._init_param_dict[row[0]] = float(row[1])
                    count += 1
            except ValueError:
                print("Error while reading parameter at {} {}".format(count, row))

        ipd = self._init_param_dict

        # Define Simulation and Weather parameters
        if self.Month is None: self.Month = ipd['Month']
        if self.Day is None: self.Day = ipd['Day']
        if self.nDay is None: self.nDay = ipd['nDay']