Skip to content

Commit

Permalink
Move repository directory
Browse files Browse the repository at this point in the history
  • Loading branch information
stefan-voelk committed Nov 6, 2024
1 parent 1861ec6 commit b1d0fae
Show file tree
Hide file tree
Showing 14 changed files with 25 additions and 24 deletions.
10 changes: 2 additions & 8 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,8 @@ __pycache__/
# ignore Jupyter Notebooks
/ipynb/

# ignore REPOSITORIES
example/repository/*.nc
# exceptions
!example/repository/co2_bg.nc
!example/repository/ch4_bg.nc
!example/repository/n2o_bg.nc
!example/repository/resp_RF.nc
!example/repository/resp_cont.nc
# ignore repositories and input data
example/input/*.nc
tests/repository/*.*
tests/repository/cache
# exceptions
Expand Down
20 changes: 11 additions & 9 deletions example/example.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ inv = ["CO2", "H2O", "NOx", "distance"]
# possible values: "NO", "NO2"
nox = "NO"
# Output / response species
# possible values: "CO2", "H2O"
# possible values: "CO2", "H2O", "cont"
out = ["CO2", "H2O", "cont"]

# Emission inventories
[inventories]
dir = "repository/"
dir = "input/"
files = [
"emi_inv_2020.nc",
# "emi_inv_2030.nc",
Expand Down Expand Up @@ -42,7 +42,7 @@ concentrations = false

# Time settings
[time]
dir = "repository/"
dir = "../repository/"
# Time range in years: t_start, t_end, step, (t_end not included)
range = [2020, 2051, 1]
# Time evolution of emissions
Expand All @@ -52,18 +52,20 @@ range = [2020, 2051, 1]

# Background concentrations
[background]
CO2.file = "repository/co2_bg.nc"
dir = "../repository/"
CO2.file = "co2_bg.nc"
CO2.scenario = "SSP2-4.5"
#CO2.scenario = "SSP1-1.9"
#CO2.scenario = "SSP4-6.0"
#CO2.scenario = "SSP3-7.0"
CH4.file = "repository/ch4_bg.nc"
CH4.file = "ch4_bg.nc"
CH4.scenario = "SSP2-4.5"
N2O.file = "repository/n2o_bg.nc"
N2O.file = "n2o_bg.nc"
N2O.scenario = "SSP2-4.5"

# Response options
[responses]
dir = "../repository/"
CO2.response_grid = "0D"
CO2.conc.method = "Sausen&Schumann"
#CO2.rf.method = "IPCC_2001_1" # IPCC 2001, Table 6.2 first row
Expand All @@ -72,13 +74,13 @@ CO2.conc.method = "Sausen&Schumann"
CO2.rf.method = "Etminan_2016" # Etminan et al. 2016

H2O.response_grid = "2D"
H2O.rf.file = "repository/resp_RF.nc"
H2O.rf.file = "resp_RF.nc"
CH4.response_grid = "2D"
CH4.tau.file = "repository/resp_ch4.nc"
CH4.tau.file = "resp_ch4.nc"
CH4.rf.method = "Etminan_2016"

cont.response_grid = "cont"
cont.resp.file = "repository/resp_cont.nc"
cont.resp.file = "resp_cont.nc"
cont.G_comp = 0.04 # conventional: 0.04; hydrogen: 0.12
cont.eff_fac = 1.0 # efficiency factor compared to kerosene (1.0)
cont.PMrel = 1.0 # relative PM emissions compared to kerosene (1.0)
Expand Down
3 changes: 2 additions & 1 deletion openairclim/construct_conc.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@ def interp_bg_conc(config, spec):
dict: Dictionary with np.ndarray of interpolated concentrations,
key is species
"""
inp_file = config["background"][spec]["file"]
dir_name = config["background"]["dir"]
inp_file = dir_name + config["background"][spec]["file"]
scenario = config["background"][spec]["scenario"]
conc = xr.load_dataset(inp_file)[scenario]
conc_dict = {spec: conc}
Expand Down
2 changes: 1 addition & 1 deletion openairclim/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ def run(file_name):
cccov_tot_dict = oac.calc_cccov_tot(config, cccov_dict)

# Calculate contrail RF
rf_cont_dict = oac.calc_cont_RF(config, cccov_tot_dict, inv_dict)
rf_cont_dict = oac.calc_cont_rf(config, cccov_tot_dict, inv_dict)
oac.write_to_netcdf(
config, rf_cont_dict, result_type="RF", mode="a"
)
Expand Down
7 changes: 5 additions & 2 deletions openairclim/read_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,13 @@ def check_config(config):
response_files = []
for spec in species_2d:
resp_flag = False
resp_dir = config["responses"]["dir"]
# At least one resp_type must be defined in config
for resp_type in ["conc", "rf", "tau"]:
for resp_type in ["conc", "rf", "tau", "resp"]:
try:
filename = config["responses"][spec][resp_type]["file"]
filename = (
resp_dir + config["responses"][spec][resp_type]["file"]
)
response_files.append(filename)
resp_flag = True
except KeyError:
Expand Down
3 changes: 2 additions & 1 deletion openairclim/read_netcdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,9 @@ def open_netcdf_from_config(config, section, species, resp_type):
"""
xr_dict = {}
section_dict = config[section]
dir_name = section_dict["dir"]
for spec in species:
inp_file = section_dict[spec][resp_type]["file"]
inp_file = dir_name + section_dict[spec][resp_type]["file"]
xr_dict[spec] = xr.load_dataset(inp_file)
return xr_dict

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Binary file added repository/resp_ch4.nc
Binary file not shown.
File renamed without changes.
2 changes: 1 addition & 1 deletion utils/create_artificial_inventories.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
# Number of samples in output emission inventory
OUT_SIZE = 10000
#
OUT_PATH = "../example/repository/"
OUT_PATH = "../example/input/"
#
# Coordinate ranges
# lon, lat ranges in deg
Expand Down
2 changes: 1 addition & 1 deletion utils/create_time_evolution.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import matplotlib.pyplot as plt

# GENERAL CONSTANTS
REPO_PATH = "../example/repository/"
REPO_PATH = "../example/input/"

# SCALING CONSTANTS
SCALING_TIME = np.arange(1990, 2200, 1)
Expand Down

0 comments on commit b1d0fae

Please sign in to comment.