コード例 #1
0
    def run_m2nc(self):
        """
        First: Read in the m-map

        Second: Using the "mapping", m-maps are converted to grid

        Third: Output this grid as a netCDF file  
        """
        print("\tReading in m-map")
        if self.timexist:
            self.mmap, self.time = read_mym(self.mmap_in, path= InputDir.m_in_dir)
        else:
            self.mmap = read_mym(self.mmap_in, path= InputDir.m_in_dir)

        # Create map linking m-maps to lat/lon matrix
        print("\tCreating gridded map")
        gridmap = self.get_gridmap(self.mmap, self.mapping, self.timexist)
        
        # *** WRITE OUTPUT ***
        print("\tWriting netCDF output")
        writemap = WriteMaps(gridmap, self.map_title, self.map_var, self.map_unit, self.map_outname, self.timexist)
        writemap.maptime2nc()
コード例 #2
0
            self.rate_average = np.average(self.rate[0:t - TSCEN, ...], axis=0)

        if t == TSCEN + 1:
            self.rate_average_historic = np.average(
                self.rate[0:(TSCEN + 1 - YEAR_IN), ...], axis=0)
        else:
            self.rate_average_historic = 0

        return self.rate, self.rate_average, self.rate_average_historic


# ---------------------------------------------------------------------------- #
if __name__ == "__main__":

    # Import variables
    pym.read_mym("floorspace.out")
    pym.read_mym("Dwel_LT.dat")
    pym.read_mym("pop_q.out")
    pym.read_mym("U_Values.dat")
    pym.read_mym("Costs_UValues.dat")
    floorspace = pym.read_mym("floorspace.out")[0]
    population = pym.read_mym("pop_q.out")[0]
    HDD = pym.read_mym("HDD.out")[0]
    HDD_annual = HDD[:, :, 12]
    household_floor = pym.read_mym("HHFloor.out")[0]
    u_value_help = pym.read_mym("U_Values.dat")
    u_value = np.reshape(u_value_help, ((5, 4, 6)))
    cost_u_value_help = pym.read_mym("Costs_UValues.dat")
    cost_u_value = np.reshape(cost_u_value_help, ((5, 4, 6)))
    lifetime_help = pym.read_mym("Dwel_LT.dat")
    build_lifetime = lifetime_help[0, :]
コード例 #3
0
        return (self.new_buildings, abandoned_buildings)

    def calculate_stock(self):
        if t == 0:
            building_stock[t, ...] = initial_building_stock
        else:
            building_stock[t, ...] = building_stock[t-1, ...] + new_buildings[t, ...] + \
                abandoned_buildings[t, ...] - decommissioned[t, ...]
        return building_stock


# ---------------------------------------------------------------------------- #
if __name__ == "__main__":

    # Import variables
    pym.read_mym("floorspace.out")
    pym.read_mym("Dwel_LT.dat")
    pym.read_mym("pop_q.out")
    floorspace_per_capita, time = pym.read_mym("floorspace.out")
    population, time = pym.read_mym("pop_q.out")
    lifetime_help = pym.read_mym("Dwel_LT.dat")
    build_lifetime = lifetime_help[0, :]

    floorspace = floorspace_per_capita * population
    initial_building_stock = floorspace[0, :, :]

    # Definitions
    new_buildings = np.zeros((YEARS, NREGIONS, TURQ))
    decommissioned = np.zeros((YEARS, NREGIONS, TURQ))
    abandoned_buildings = np.zeros((YEARS, NREGIONS, TURQ))
    abandoned_residual = np.zeros((YEARS, NREGIONS, TURQ))
コード例 #4
0
        return (self.new_buildings, self.abandoned_buildings)

    def calculate_stock(self, t, initial_stock):
        if t == 0:
            self.stock[t, ...] = initial_stock
        else:
            self.stock[t, ...] = self.stock[t-1, ...] + self.new_buildings[t, ...] + \
                self.abandoned_buildings[t, ...] - self.decommissioned[t, ...]
        return self.stock


# ---------------------------------------------------------------------------- #
if __name__ == "__main__":

    # Import variables
    floorspace, time = pym.read_mym("floorspace.out", "Buildings/imports")
    population = pym.read_mym("pop_q.out", "Buildings/imports")[0]
    build_lifetime = pym.read_mym("Dwel_LT.dat", "Buildings/imports")[0]

    initial_stock = floorspace[0, :, :]
    print(build_lifetime.shape)
    print(floorspace)
    # Definitions
    # increased_floor = np.zeros((YEARS, NREGIONS, TURQ))
    # decreased_floor = np.zeros((YEARS, NREGIONS, TURQ))

    buildings = BuildingStock(floorspace, build_lifetime)

    for t in range(YEARS):
        buildings.floorspace_change()
        decommission_initial, decommissioned, abandoned_residual = buildings.decommission(
コード例 #5
0

def interpolation_function_1D(xp_data_points, interpolated_variable,  x_coordinates):
    # this function builds on the numpy 1D interpolation function
    # numpy.interp(x, xp, fp, left=None, right=None, period=None)
    fp_data_points = np.array(interpolated_variable[xp_data_points])
    y_coordinates = np.interp(x_coordinates, xp_data_points, fp_data_points)
    return y_coordinates


x = np.arange(1971, 2050)
data_path = os.path.join("demand_functions", "appliance", "imports", "data")

unit_energy_consumption_unit = pym.load_mym("UEC_unit.dat", data_path, x)

satur_price = pym.read_mym("Saturation.dat", data_path)[0]
# Fraction of cooling appliances which are air coolers
air_cooler_fraction = pym.read_mym("AirCoolFrac.dat", data_path)[0]
# Beta for cooling devices. Only 1-3 of 3rd dim used.
beta = pym.read_mym("Beta_global.dat", data_path)
# Gamma for cooling devices. Only 1-3 of 3rd dim used.
gamma = pym.read_mym("Gamma_global.dat", data_path)
# coefficient for quintile allocation of TV, washing machine and refrigerator
appliance_a = pym.read_mym("Appliance_a.dat", data_path)[0]
# Alpha coefficient for UEC development (kWh/normalising unit)
unit_energy_consumption_alpha = pym.read_mym("UEC_alpha.dat", data_path)[0]
# Beta coefficient (reduction rate) for UEC development (TV,washing,refrig)
unit_energy_consumption_beta = pym.read_mym("UEC_beta.dat", data_path)[0]
# Assumption on minimum UEC (kWh/normalising unit)
unit_energy_consumption_min_in = pym.read_mym("UEC_min.dat", data_path)[0]
unit_energy_consumption_min_scen = pym.read_mym("UEC_min.dat", data_path)[0]