Skip to content

Commit 9a271c0

Browse files
authored
Merge pull request #19 from dlr-pa/chore/move-repo-dir
Move repository directory
2 parents 1861ec6 + a99c42a commit 9a271c0

15 files changed

+34
-28
lines changed

.gitignore

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,8 @@ __pycache__/
1919
# ignore Jupyter Notebooks
2020
/ipynb/
2121

22-
# ignore REPOSITORIES
23-
example/repository/*.nc
24-
# exceptions
25-
!example/repository/co2_bg.nc
26-
!example/repository/ch4_bg.nc
27-
!example/repository/n2o_bg.nc
28-
!example/repository/resp_RF.nc
29-
!example/repository/resp_cont.nc
22+
# ignore repositories and input data
23+
example/input/*.nc
3024
tests/repository/*.*
3125
tests/repository/cache
3226
# exceptions

example/example.toml

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,17 @@ inv = ["CO2", "H2O", "NOx", "distance"]
99
# possible values: "NO", "NO2"
1010
nox = "NO"
1111
# Output / response species
12-
# possible values: "CO2", "H2O"
12+
# possible values: "CO2", "H2O", "cont"
1313
out = ["CO2", "H2O", "cont"]
1414

1515
# Emission inventories
1616
[inventories]
17-
dir = "repository/"
17+
dir = "input/"
1818
files = [
19-
"emi_inv_2020.nc",
20-
# "emi_inv_2030.nc",
21-
# "emi_inv_2040.nc",
22-
"emi_inv_2050.nc",
19+
"rnd_inv_2020.nc",
20+
"rnd_inv_2030.nc",
21+
"rnd_inv_2040.nc",
22+
"rnd_inv_2050.nc",
2323
# "rnd_inv_2060.nc",
2424
# "rnd_inv_2070.nc",
2525
# "rnd_inv_2080.nc",
@@ -42,7 +42,7 @@ concentrations = false
4242

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

5353
# Background concentrations
5454
[background]
55-
CO2.file = "repository/co2_bg.nc"
55+
dir = "../repository/"
56+
CO2.file = "co2_bg.nc"
5657
CO2.scenario = "SSP2-4.5"
5758
#CO2.scenario = "SSP1-1.9"
5859
#CO2.scenario = "SSP4-6.0"
5960
#CO2.scenario = "SSP3-7.0"
60-
CH4.file = "repository/ch4_bg.nc"
61+
CH4.file = "ch4_bg.nc"
6162
CH4.scenario = "SSP2-4.5"
62-
N2O.file = "repository/n2o_bg.nc"
63+
N2O.file = "n2o_bg.nc"
6364
N2O.scenario = "SSP2-4.5"
6465

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

7476
H2O.response_grid = "2D"
75-
H2O.rf.file = "repository/resp_RF.nc"
77+
H2O.rf.file = "resp_RF.nc"
7678
CH4.response_grid = "2D"
77-
CH4.tau.file = "repository/resp_ch4.nc"
79+
CH4.tau.file = "resp_ch4.nc"
7880
CH4.rf.method = "Etminan_2016"
7981

8082
cont.response_grid = "cont"
81-
cont.resp.file = "repository/resp_cont.nc"
83+
cont.resp.file = "resp_cont.nc"
8284
cont.G_comp = 0.04 # conventional: 0.04; hydrogen: 0.12
8385
cont.eff_fac = 1.0 # efficiency factor compared to kerosene (1.0)
8486
cont.PMrel = 1.0 # relative PM emissions compared to kerosene (1.0)

example/run.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
"""Demonstration of OpenAirClim simulation run"""
22

3+
# if you have not added the oac folder to your PATH, then you also need to
4+
# import sys and append to PATH using sys.path.append(`.../oac`)
5+
import os
36
import openairclim as oac
47

8+
# change directory to match current file
9+
os.chdir(os.path.dirname(os.path.abspath(__file__)))
510
oac.run("example.toml")

openairclim/construct_conc.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,8 @@ def interp_bg_conc(config, spec):
101101
dict: Dictionary with np.ndarray of interpolated concentrations,
102102
key is species
103103
"""
104-
inp_file = config["background"][spec]["file"]
104+
dir_name = config["background"]["dir"]
105+
inp_file = dir_name + config["background"][spec]["file"]
105106
scenario = config["background"][spec]["scenario"]
106107
conc = xr.load_dataset(inp_file)[scenario]
107108
conc_dict = {spec: conc}

openairclim/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ def run(file_name):
195195
cccov_tot_dict = oac.calc_cccov_tot(config, cccov_dict)
196196

197197
# Calculate contrail RF
198-
rf_cont_dict = oac.calc_cont_RF(config, cccov_tot_dict, inv_dict)
198+
rf_cont_dict = oac.calc_cont_rf(config, cccov_tot_dict, inv_dict)
199199
oac.write_to_netcdf(
200200
config, rf_cont_dict, result_type="RF", mode="a"
201201
)

openairclim/read_config.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,13 @@ def check_config(config):
9191
response_files = []
9292
for spec in species_2d:
9393
resp_flag = False
94+
resp_dir = config["responses"]["dir"]
9495
# At least one resp_type must be defined in config
95-
for resp_type in ["conc", "rf", "tau"]:
96+
for resp_type in ["conc", "rf", "tau", "resp"]:
9697
try:
97-
filename = config["responses"][spec][resp_type]["file"]
98+
filename = (
99+
resp_dir + config["responses"][spec][resp_type]["file"]
100+
)
98101
response_files.append(filename)
99102
resp_flag = True
100103
except KeyError:

openairclim/read_netcdf.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,8 +208,9 @@ def open_netcdf_from_config(config, section, species, resp_type):
208208
"""
209209
xr_dict = {}
210210
section_dict = config[section]
211+
dir_name = section_dict["dir"]
211212
for spec in species:
212-
inp_file = section_dict[spec][resp_type]["file"]
213+
inp_file = dir_name + section_dict[spec][resp_type]["file"]
213214
xr_dict[spec] = xr.load_dataset(inp_file)
214215
return xr_dict
215216

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

repository/resp_ch4.nc

14.2 KB
Binary file not shown.
File renamed without changes.

utils/create_artificial_inventories.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
# Number of samples in output emission inventory
1818
OUT_SIZE = 10000
1919
#
20-
OUT_PATH = "../example/repository/"
20+
OUT_PATH = "../example/input/"
2121
#
2222
# Coordinate ranges
2323
# lon, lat ranges in deg

utils/create_time_evolution.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import matplotlib.pyplot as plt
66

77
# GENERAL CONSTANTS
8-
REPO_PATH = "../example/repository/"
8+
REPO_PATH = "../example/input/"
99

1010
# SCALING CONSTANTS
1111
SCALING_TIME = np.arange(1990, 2200, 1)

0 commit comments

Comments
 (0)