Skip to content

Commit

Permalink
Update path setting in other scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
measrainsey committed Oct 22, 2024
1 parent 58da8ed commit 329f4e8
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 27 deletions.
68 changes: 46 additions & 22 deletions message_ix_buildings/chilled/core/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
from message_ix_buildings.chilled.util.util import (
get_archs,
get_logger,
get_paths,
load_all_scenarios_data,
load_parametric_analysis_data,
)
Expand All @@ -56,7 +57,11 @@


def create_climate_variables_maps(config: "Config", start_time: datetime.datetime):
out_path = os.path.join(config.project_path, "out", "version", config.vstr)
project_path = get_paths(config, "project_path")
dle_path = get_paths(config, "dle_path")
isimip_bias_adj_path = get_paths(config, "isimip_bias_adj_path")

out_path = os.path.join(project_path, "out", "version", config.vstr)
archetype_path = os.path.join(out_path, "rasters")
save_path = os.path.join(out_path, "VDD_ene_calcs")

Expand Down Expand Up @@ -105,10 +110,10 @@ def map_calculated_variables(args):
endstr = ".nc"

if str(clim) == "hist":
isi_folder = config.isimip_ewemib_path
isi_folder = isimip_ewemib_path
filestr = climate_filestr_hist
else:
isi_folder = config.isimip_bias_adj_path
isi_folder = isimip_bias_adj_path
filestr = climate_filestr_future

filepath = os.path.join(
Expand All @@ -135,12 +140,12 @@ def map_calculated_variables(args):
t_oa_gbm = t_out_ave.groupby("time.month")

i_sol_v = xr.open_dataarray(
os.path.join(config.dle_path, "EWEMBI_vert_irrad_1980-2009_avg.nc")
os.path.join(dle_path, "EWEMBI_vert_irrad_1980-2009_avg.nc")
) # Values in daily Wh/m2

# Horizontal irradiation
i_sol_h = xr.open_dataarray(
os.path.join(config.dle_path, "EWEMBI_horiz_irrad_1980-2009_avg.nc")
os.path.join(dle_path, "EWEMBI_horiz_irrad_1980-2009_avg.nc")
) # Values in daily Wh/m2

if config.arch_setting == "regional":
Expand Down Expand Up @@ -756,7 +761,8 @@ def read_netcdf_files(input_args):


def aggregate_urban_rural_files(config: "Config"):
out_path = os.path.join(config.project_path, "out", "version", config.vstr)
project_path = get_paths(config, "project_path")
out_path = os.path.join(project_path, "out", "version", config.vstr)
save_path = os.path.join(out_path, "VDD_ene_calcs")

output_path_vdd = os.path.join(
Expand Down Expand Up @@ -834,7 +840,8 @@ def aggregate_urban_rural_files(config: "Config"):


def make_vdd_total_maps(config: "Config"):
out_path = os.path.join(config.project_path, "out", "version", config.vstr)
project_path = get_paths(config, "project_path")
out_path = os.path.join(project_path, "out", "version", config.vstr)
save_path = os.path.join(out_path, "VDD_ene_calcs")

output_path_vdd = os.path.join(
Expand Down Expand Up @@ -1133,7 +1140,9 @@ def make_map(


def process_construction_shares(config: "Config"):
out_path = os.path.join(config.project_path, "out", "version", config.vstr)
project_path = get_paths(config, "project_path")
dle_path = get_paths(config, "dle_path")
out_path = os.path.join(project_path, "out", "version", config.vstr)
floorarea_path = os.path.join(out_path, "floorarea_country")

output_path = os.path.join(
Expand All @@ -1153,7 +1162,7 @@ def process_construction_shares(config: "Config"):

# If constr_setting == 1, then process construction shares. Otherwise, skip
if config.constr_setting == 1:
input_path = config.dle_path
input_path = dle_path

dsc = xr.Dataset()
for urt in config.urts:
Expand Down Expand Up @@ -1226,8 +1235,10 @@ def process_construction_shares(config: "Config"):


def process_floor_area_maps(config: "Config"):
input_path = config.dle_path
out_path = os.path.join(config.project_path, "out", "version", config.vstr)
project_path = get_paths(config, "project_path")
dle_path = get_paths(config, "dle_path")
input_path = dle_path
out_path = os.path.join(project_path, "out", "version", config.vstr)
save_path = os.path.join(out_path, "floorarea_country")

output_path = os.path.join(
Expand Down Expand Up @@ -1354,8 +1365,11 @@ def process_floor_area_maps(config: "Config"):


def process_country_maps(config: "Config"):
input_path = config.dle_path
out_path = os.path.join(config.project_path, "out", "version", config.vstr)
project_path = get_paths(config, "project_path")
dle_path = get_paths(config, "dle_path")

input_path = dle_path
out_path = os.path.join(project_path, "out", "version", config.vstr)
save_path = os.path.join(out_path, "floorarea_country")

output_path = os.path.join(
Expand Down Expand Up @@ -1436,8 +1450,11 @@ def process_country_maps(config: "Config"):


def process_final_maps(config: "Config"):
input_path = config.dle_path
out_path = os.path.join(config.project_path, "out", "version", config.vstr)
project_path = get_paths(config, "project_path")
dle_path = get_paths(config, "dle_path")

input_path = dle_path
out_path = os.path.join(project_path, "out", "version", config.vstr)
vdd_path = os.path.join(
out_path,
"VDD_ene_calcs",
Expand Down Expand Up @@ -1835,8 +1852,11 @@ def process_final_maps(config: "Config"):
def process_iso_tables(config: "Config"):
start = datetime.datetime.now()

input_path = config.dle_path
out_path = os.path.join(config.project_path, "out", "version", config.vstr)
project_path = get_paths(config, "project_path")
dle_path = get_paths(config, "dle_path")

input_path = dle_path
out_path = os.path.join(project_path, "out", "version", config.vstr)
vdd_path = os.path.join(out_path, "VDD_ene_calcs", config.gcm, config.rcp)
floorarea_path = os.path.join(out_path, "floorarea_country", config.gcm, config.rcp)
finalmaps_path = os.path.join(out_path, "final_maps", config.gcm, config.rcp)
Expand Down Expand Up @@ -2140,7 +2160,11 @@ def aggregate_ncfile(args: tuple) -> xr.Dataset:


def create_climate_outputs(config: "Config", start_time: datetime.datetime):
out_path = os.path.join(config.project_path, "out", "version", config.vstr)
project_path = get_paths(config, "project_path")
dle_path = get_paths(config, "dle_path")
isimip_bias_adj_path = get_paths(config, "isimip_bias_adj_path")
isimip_ewemib_path = get_paths(config, "isimip_ewemib_path")
out_path = os.path.join(project_path, "out", "version", config.vstr)
archetype_path = os.path.join(out_path, "rasters")
save_path = os.path.join(out_path, "VDD_ene_calcs")

Expand Down Expand Up @@ -2180,10 +2204,10 @@ def create_climate_outputs(config: "Config", start_time: datetime.datetime):
nyrs_clim = int(years_clim[1]) - int(years_clim[0]) + 1

if str(clim) == "hist":
isi_folder = config.isimip_ewemib_path
isi_folder = isimip_ewemib_path
filestr = config.climate_filestr_hist
else:
isi_folder = config.isimip_bias_adj_path
isi_folder = isimip_bias_adj_path
filestr = config.climate_filestr_future

filepath = os.path.join(
Expand Down Expand Up @@ -2226,12 +2250,12 @@ def create_climate_outputs(config: "Config", start_time: datetime.datetime):
# Vertical irradiation
# i_sol_v = xr.open_dataarray(input_folder+'CERES_vert_irrad_2001-13_avg.nc') #Values in daily Wh/m2
i_sol_v = xr.open_dataarray(
os.path.join(config.dle_path, "EWEMBI_vert_irrad_1980-2009_avg.nc")
os.path.join(dle_path, "EWEMBI_vert_irrad_1980-2009_avg.nc")
) # Values in daily Wh/m2

# Horizontal irradiation
i_sol_h = xr.open_dataarray(
os.path.join(config.dle_path, "EWEMBI_horiz_irrad_1980-2009_avg.nc")
os.path.join(dle_path, "EWEMBI_horiz_irrad_1980-2009_avg.nc")
) # Values in daily Wh/m2

# i_sol = i_sol.sel(time=slice(years_clim[0],years_clim[1]))
Expand Down
7 changes: 4 additions & 3 deletions message_ix_buildings/chilled/postprocess/postprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
import pandas as pd

from message_ix_buildings.chilled.util.config import Config
from message_ix_buildings.chilled.util.util import get_logger
from message_ix_buildings.chilled.util.util import get_logger, get_paths

log = get_logger(__name__)
cfg = Config()
cfg = Config(user="MEAS")
dle_path = get_paths(cfg, "dle_path")


def get_sturm_data(input_path, input_version_name):
Expand Down Expand Up @@ -254,4 +255,4 @@ def postprocess_electricity_demand(input_path, input_version_name):
)


postprocess_electricity_demand(cfg.dle_path, cfg.vstr)
postprocess_electricity_demand(dle_path, cfg.vstr)
9 changes: 7 additions & 2 deletions message_ix_buildings/chilled/preprocess/archetypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from message_ix_buildings.chilled.util.util import (
get_archs,
get_logger,
get_paths,
read_arch_inputs_df,
read_arch_reg_df,
)
Expand All @@ -23,7 +24,9 @@


def create_archetypes(config: "Config"):
out_path = os.path.join(config.project_path, "out", "version")
project_path = get_paths(config, "dle_path")

out_path = os.path.join(project_path, "out", "version")
archetype_path = os.path.join(out_path, config.vstr, "rasters")

# if archetypes folder does not exist, create it
Expand Down Expand Up @@ -101,7 +104,9 @@ def create_archetypes(config: "Config"):


def create_archetype_variables(config: "Config"):
out_path = os.path.join(config.project_path, "out", "version")
project_path = get_paths(config, "dle_path")

out_path = os.path.join(project_path, "out", "version")
archetype_path = os.path.join(out_path, config.vstr, "rasters")

# get archs
Expand Down

0 comments on commit 329f4e8

Please sign in to comment.