|
5 | 5 | """ |
6 | 6 |
|
7 | 7 | import os |
| 8 | +from pathlib import Path |
8 | 9 |
|
9 | 10 | import matplotlib.pyplot as plt |
10 | 11 | import nc_time_axis # noqa: F401 |
@@ -210,27 +211,35 @@ def main(args, config): |
210 | 211 | for axis in axes: |
211 | 212 | axis.grid(visible=True, ls="--", lw=0.5) |
212 | 213 | axis.legend(fontsize=8) |
213 | | - |
214 | | - _ = axes[0].set_title(config["dataset_names"]["model"]) |
| 214 | + _modelname = config["dataset_names"].get( |
| 215 | + "model", config["dataset_names"].get("model_native") |
| 216 | + ) |
| 217 | + _ = axes[0].set_title(_modelname) |
215 | 218 | _ = axes[1].set_title(config["dataset_names"]["dset_a"]) |
216 | 219 | plt.tight_layout() |
| 220 | + if not Path(args.out).exists(): |
| 221 | + Path(args.out).mkdir(parents=True) |
217 | 222 |
|
218 | 223 | img_file = os.path.join( |
219 | 224 | args.out, |
220 | | - f"{lxc.img_file_prefix(config)}_{data_var['dset_a']}_timeseries.png", |
| 225 | + f"{lxc.img_file_prefix(config)}_" |
| 226 | + f"{data_var['title'].lower().replace(' ', '_')}_timeseries.png", |
221 | 227 | ) |
222 | 228 | fig.savefig(img_file) |
223 | 229 | img_link = os.path.join( |
224 | 230 | "imgs", os.path.basename(args.out), os.path.basename(img_file) |
225 | 231 | ) |
226 | 232 |
|
227 | | - data_var_names = ", ".join( |
228 | | - [ |
229 | | - f"{config['dataset_names'][_ds]}: " |
| 233 | + data_var_names = [] |
| 234 | + for _ds in ts_data: |
| 235 | + _name = config["dataset_names"].get( |
| 236 | + _ds, config["dataset_names"].get(f"{_ds}_native") |
| 237 | + ) |
| 238 | + data_var_names.append( |
| 239 | + f"{_name}: " |
230 | 240 | f"{lxc.parse_var_name(data_var[config_names[_ds]])}" |
231 | | - for _ds in ts_data |
232 | | - ] |
233 | | - ) |
| 241 | + ) |
| 242 | + data_var_names = ", ".join(data_var_names) |
234 | 243 |
|
235 | 244 | desc_comment = f"{data_var.get('comment', '')}" |
236 | 245 |
|
|
0 commit comments