forked from AWI-ESM/release_evaluation_tool2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreval.py
More file actions
111 lines (93 loc) · 3.8 KB
/
reval.py
File metadata and controls
111 lines (93 loc) · 3.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
"""
AWI-CM3 Release Evaluation Tool (Reval.py)
This script provides a comprehensive evaluation framework for analyzing and visualizing
data from the AWI-CM-v3.3 climate model. It integrates scientific libraries for data
processing, statistical analysis, and high-quality visualizations, enabling effective
assessment of model performance against observations and reanalysis datasets.
Key Features:
- Data Processing & Analysis:
- Uses PyFESOM2, xarray, SciPy, and scikit-learn for structured climate data handling.
- Visualization:
- Leverages Matplotlib, Seaborn, Cartopy, and cmocean for high-quality plots.
- FESOM-Specific Routines:
- Includes functions for handling FESOM2 mesh structures, model data, and
meridional overturning circulation (MOC).
- Automated Job Submission:
- Supports SLURM-based batch processing for large-scale evaluations.
- Multi-Experiment Support:
- Handles spin-up, preindustrial control, and historical simulations with
configurable paths and settings.
2021-12-10: Jan Streffing: First jupyter notebook version for https://doi.org/10.5194/gmd-15-6399-2022
2024-04-03: Jan Streffing: Addition of significance metrics for https://doi.org/10.5194/egusphere-2024-2491
2025-02-04: Jan Streffing: Re-write has parallel scripts
"""
import os
import subprocess
from natsort import natsorted
import shutil
############################
# Slurm Configuration #
############################
SBATCH_SETTINGS = """\
#!/bin/bash
#SBATCH --job-name={job_name}
#SBATCH --output=logs/{job_name}.log
#SBATCH --error=logs/{job_name}.log
#SBATCH --time=00:10:00
#SBATCH --mem=64G
#SBATCH --ntasks=128
#SBATCH --ntasks-per-node=128
#SBATCH --partition=compute
#SBATCH -A bb1469
"""
############################
# Script Execution #
############################
# Ensure required directories exist
os.makedirs("logs", exist_ok=True)
# Locate all Python scripts in the "scripts" subfolder
script_files = natsorted(
[f for f in os.listdir("scripts") if f.endswith(".py") and f != "__init__.py"]
)
# Default: Disable all scripts (set to True to enable)
SCRIPTS = {script: False for script in script_files} # All disabled by default
# Enable scripts manually here:
SCRIPTS.update({
"part1_mesh_plot.py": False,
"part2_rad_balance.py": False,
"part3_hovm_temp.py": False,
"part4_cmpi.py": False,
"part5_sea_ice_thickness.py": False,
"part6_ice_conc_timeseries.py": False,
"part7_mld.py": False,
"part8_t2m_vs_era5.py": False,
"part9_rad_vs_ceres.py": False,
"part10_clt_vs_modis.py": True,
"part11_zonal_plots.py": False,
"part12_qbo.py": False,
"part13_fesom_bias_maps.py": False,
"part14_fesom_salt.py": False,
"part15_enso.py": False,
"part16_clim_change.py": False,
"part17_moc.py": False,
})
# Submit jobs
for script, run in SCRIPTS.items():
if run:
job_script = f"slurm_{script}.sh"
script_path = os.path.join("scripts", script)
# Write the SLURM script
with open(job_script, "w") as f:
f.write(SBATCH_SETTINGS.format(job_name=script))
f.write("\nsource /home/a/a270092/loadconda.sh\n") # Load Python module if required
f.write("\nconda activate reval\n") # Load Python module if required
f.write(f"python {script_path}\n")
# Submit job
print(f"Submitting {script} as:")
subprocess.run(["sbatch", job_script])
print(f"___________________________")
destination = f"tmp/{job_script}"
shutil.move(job_script, destination)
else:
print(f"Skipped {script} (disabled)")
print(f"___________________________")