rc-qlc 0.3.24__cp311-cp311-win32.whl → 0.3.26__cp311-cp311-win32.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (84) hide show
  1. qlc/cli/__init__.py +100 -9
  2. qlc/cli/installer.py +23 -5
  3. qlc/cli/qlc_main.py +54 -32
  4. qlc/cli/qlc_py_main.py +43 -38
  5. qlc/config/json/qlc_config.json +94 -10
  6. qlc/config/nml/mars_A1_sfc.nml +4 -5
  7. qlc/config/nml/mars_A3_sfc.nml +0 -1
  8. qlc/config/nml/mars_B1_pl.nml +2 -2
  9. qlc/{examples/cams_case_1/config/nml/mars_A3_sfc.nml → config/nml/mars_B1_sfc.nml} +7 -8
  10. qlc/config/nml/mars_C1_pl.nml +1 -1
  11. qlc/{examples/cams_case_1/config/nml/mars_C1_pl.nml → config/nml/mars_C1_sfc.nml} +7 -8
  12. qlc/config/nml/mars_C2_pl.nml +1 -1
  13. qlc/{examples/cams_case_1/config/qlc_cams.conf → config/qlc.conf} +80 -18
  14. qlc/doc/README.md +98 -62
  15. qlc/doc/USAGE.md +68 -29
  16. qlc/examples/cams_case_1/mod/b2rn/2018/b2rn_20181201-20181221_B1_pl.grb +0 -0
  17. qlc/examples/cams_case_1/mod/b2rn/2018/b2rn_20181201-20181221_C1_sfc.grb +0 -0
  18. qlc/examples/cams_case_1/mod/b2ro/2018/b2ro_20181201-20181221_B1_pl.grb +0 -0
  19. qlc/examples/cams_case_1/mod/b2ro/2018/b2ro_20181201-20181221_C1_sfc.grb +0 -0
  20. qlc/install.py +260 -106
  21. qlc/py/__main__.cp311-win32.pyd +0 -0
  22. qlc/py/averaging.cp311-win32.pyd +0 -0
  23. qlc/py/bias_plots.cp311-win32.pyd +0 -0
  24. qlc/py/control.cp311-win32.pyd +0 -0
  25. qlc/py/io.cp311-win32.pyd +0 -0
  26. qlc/py/loadmod.cp311-win32.pyd +0 -0
  27. qlc/py/loadobs.cp311-win32.pyd +0 -0
  28. qlc/py/logging_utils.cp311-win32.pyd +0 -0
  29. qlc/py/map_plots.cp311-win32.pyd +0 -0
  30. qlc/py/matched.cp311-win32.pyd +0 -0
  31. qlc/py/plot_config.cp311-win32.pyd +0 -0
  32. qlc/py/plotting.cp311-win32.pyd +0 -0
  33. qlc/py/plugin_loader.cp311-win32.pyd +0 -0
  34. qlc/py/processing.cp311-win32.pyd +0 -0
  35. qlc/py/scatter_plots.cp311-win32.pyd +0 -0
  36. qlc/py/stations.cp311-win32.pyd +0 -0
  37. qlc/py/statistics.cp311-win32.pyd +0 -0
  38. qlc/py/style.cp311-win32.pyd +0 -0
  39. qlc/py/timeseries_plots.cp311-win32.pyd +0 -0
  40. qlc/py/utils.cp311-win32.pyd +0 -0
  41. qlc/py/version.cp311-win32.pyd +0 -0
  42. qlc/sh/qlc_A1.sh +29 -11
  43. qlc/sh/qlc_B1a.sh +1 -18
  44. qlc/sh/qlc_B2.sh +8 -1
  45. qlc/sh/qlc_C5.sh +19 -30
  46. qlc/sh/qlc_D1.sh +291 -51
  47. qlc/sh/qlc_Z1.sh +6 -6
  48. qlc/sh/qlc_batch.sh +61 -0
  49. qlc/sh/qlc_common_functions.sh +17 -29
  50. qlc/sh/qlc_main.sh +32 -26
  51. qlc/sh/tex_template/beamercolorthemeCAMS2_35.sty +51 -0
  52. qlc/sh/tex_template/beamerfontthemeCAMS2_35.sty +166 -0
  53. qlc/sh/tex_template/beamerthemeCAMS2_35.sty +25 -0
  54. qlc/sh/tex_template/subcaption.sty +170 -0
  55. qlc/sh/tex_template/template.tex +109 -0
  56. rc_qlc-0.3.26.dist-info/METADATA +178 -0
  57. rc_qlc-0.3.26.dist-info/RECORD +102 -0
  58. qlc/config/json/qlc_config_example_1a_all-obs.json +0 -237
  59. qlc/config/json/qlc_config_example_1b_all-mod.json +0 -353
  60. qlc/config/json/qlc_config_example_1c_all-coll.json +0 -266
  61. qlc/config/json/qlc_config_example_2a_all-obs.json +0 -237
  62. qlc/config/json/qlc_config_example_2b_all-mod.json +0 -353
  63. qlc/config/json/qlc_config_example_2c_all-coll.json +0 -265
  64. qlc/config/json/qlc_config_example_3a-us_obs.json +0 -82
  65. qlc/config/json/qlc_config_example_3b-us_mod.json +0 -122
  66. qlc/config/json/qlc_config_example_3c-us_coll.json +0 -46
  67. qlc/config/json/qlc_config_example_4a_eu-obs.json +0 -41
  68. qlc/config/json/qlc_config_example_4b_eu-mod.json +0 -122
  69. qlc/config/json/qlc_config_example_4c_eu-coll.json +0 -45
  70. qlc/config/qlc_cams.conf +0 -26
  71. qlc/config/qlc_test.conf +0 -26
  72. qlc/config/qlc_tex.conf +0 -107
  73. qlc/examples/cams_case_1/config/json/qlc_config.json +0 -41
  74. qlc/examples/cams_case_1/config/nml/mars_B1_pl.nml +0 -19
  75. qlc/examples/cams_case_1/mod/b2ro/2018/b2ro_20181215-20181231_A3_sfc.grb +0 -0
  76. qlc/examples/cams_case_1/mod/iqi9/2018/iqi9_20181215-20181231_A3_sfc.grb +0 -0
  77. qlc/sh/qlc_start.sh +0 -23
  78. qlc/sh/qlc_start_batch.sh +0 -46
  79. rc_qlc-0.3.24.dist-info/METADATA +0 -142
  80. rc_qlc-0.3.24.dist-info/RECORD +0 -113
  81. {rc_qlc-0.3.24.dist-info → rc_qlc-0.3.26.dist-info}/WHEEL +0 -0
  82. {rc_qlc-0.3.24.dist-info → rc_qlc-0.3.26.dist-info}/entry_points.txt +0 -0
  83. {rc_qlc-0.3.24.dist-info → rc_qlc-0.3.26.dist-info}/licenses/LICENSE +0 -0
  84. {rc_qlc-0.3.24.dist-info → rc_qlc-0.3.26.dist-info}/top_level.txt +0 -0
qlc/sh/qlc_C5.sh CHANGED
@@ -1,4 +1,4 @@
1
- #!/bin/sh -e
1
+ #!/bin/bash -e
2
2
 
3
3
  # Source the configuration file to load the settings
4
4
  . "$CONFIG_FILE"
@@ -59,6 +59,7 @@ sDate="${sDat//[-:]/}"
59
59
  eDate="${eDat//[-:]/}"
60
60
  mDate="$sDate-$eDate"
61
61
  ext="$PLOTEXTENSION"
62
+ ulev="$UTLS"
62
63
 
63
64
  hpath="$PLOTS_DIRECTORY/${exp1}-${exp2}_${mDate}"
64
65
 
@@ -80,14 +81,15 @@ for exp in $exps ; do
80
81
  log "Processing ${PLOTTYPE} plot for experiment: $exp"
81
82
 
82
83
  log "QLTYPE : $QLTYPE"
83
- log "TEAM_PREFIX : $TEAM_PREFIX"
84
- log "EVALUATION_PREFIX: $EVALUATION_PREFIX"
85
- log "MODEL_RESOLUTION : $MODEL_RESOLUTION"
86
- log "TIME_RESOLUTION : $TIME_RESOLUTION"
84
+ log "TEAM_PREFIX : ${TEAM_PREFIX}"
85
+ log "EVALUATION_PREFIX: ${EVALUATION_PREFIX}"
86
+ log "MODEL_RESOLUTION : ${MODEL_RESOLUTION}"
87
+ log "TIME_RESOLUTION : ${TIME_RESOLUTION}"
87
88
  log "mDate : $mDate"
88
89
  log "ext : $ext"
89
90
  log "exp1 : $exp1"
90
91
  log "exp2 : $exp2"
92
+ log "ulev : $ulev"
91
93
 
92
94
  # definition of plot file base name
93
95
  pfile="${TEAM_PREFIX}_${exp1}-${exp2}_${mDate}_${QLTYPE}"
@@ -198,7 +200,7 @@ for exp in $exps ; do
198
200
  else
199
201
  plev="${nlev}"
200
202
  fi
201
- log "${plev} plot for: $pvar"
203
+ log "Model level array index ${plev} for: $pvar"
202
204
 
203
205
  # definition of plot files for each exp + variable (log, diff for exp1)
204
206
  # tfile="${pfile}_${name}_${pvar}_${exp}"
@@ -213,15 +215,7 @@ for exp in $exps ; do
213
215
  lat='`lat`'
214
216
  lev='`lev`'
215
217
  tim='`tim`'
216
- # crude workaround, needs to be implemented properly
217
- # plev="21" # 1000 hPa
218
- if [ "${plev}" == "21" ]; then
219
- ulev="11:15" # 100:300 hPa
220
- elif [ "${plev}" == "16" ]; then
221
- ulev="11:13" # 100:300 hPa
222
- else
223
- ulev="11:12" # default
224
- fi
218
+ ulev="${ulev}"
225
219
  facS="1*"
226
220
  facB="1*"
227
221
  facZ="1*"
@@ -736,20 +730,15 @@ file_name="${file_name%.*}" # Remove extension
736
730
  # Split the file name into parts
737
731
  IFS="_" read -ra parts <<< "$file_name"
738
732
 
739
- pqlc="${parts[5]}"
740
- pnml="${parts[6]}"
741
- # files without level type (_pl _ml _sfc)
742
- #pvar2="${parts[7]}"
743
- #pexp="${parts[8]}"
744
- #ptyp="${parts[9]}"
745
- #pdif="${parts[11]}"
746
- # files with level type (_pl _ml _sfc)
747
- tlev="${parts[7]}"
748
- pvar2="${parts[8]}"
749
- pexp="${parts[9]}"
750
- ptyp="${parts[10]}"
751
- plog="${parts[11]}"
752
- pdif="${parts[12]}"
733
+ pqlc="${parts[4]}"
734
+ pnml="${parts[5]}"
735
+ tlev="${parts[6]}"
736
+ pvar2="${parts[7]}"
737
+ pexp="${parts[8]}"
738
+ ptyp="${parts[9]}"
739
+ plog="${parts[10]}"
740
+ pdif="${parts[11]}"
741
+
753
742
  if [[ "$pvar2" == *"-"* ]]; then
754
743
  # echo "INFO: variable name '$pvar2' contains dash, display as underscore."
755
744
  pvar=$pvar2
@@ -779,7 +768,7 @@ fi
779
768
  if [ "${tlev}" != "sfc" ] ; then
780
769
  GO="GO"
781
770
  fi
782
-
771
+ #log "${GO} = GO | ${pexp} = ${exp1} | ${plog}"
783
772
  if [ "${GO}" == "GO" ] && [ "${pexp}" == "${exp1}" ] && [ "${plog}" == "" ] ; then
784
773
  plot1="$PLOTS_DIRECTORY/${exp1}/${TEAM_PREFIX}_${exp1}-${exp2}_${mDate}_${QLTYPE}_${pnml}_${tlev}_${pvar}_${exp1}_${ptyp}.${ext}"
785
774
  plot2="$PLOTS_DIRECTORY/${exp2}/${TEAM_PREFIX}_${exp1}-${exp2}_${mDate}_${QLTYPE}_${pnml}_${tlev}_${pvar}_${exp2}_${ptyp}.${ext}"
qlc/sh/qlc_D1.sh CHANGED
@@ -1,4 +1,4 @@
1
- #!/bin/sh -e
1
+ #!/bin/bash -e
2
2
 
3
3
  # Source the configuration file to load the settings
4
4
  . "$CONFIG_FILE"
@@ -40,6 +40,15 @@ else
40
40
  which python
41
41
  fi
42
42
 
43
+ # Check if qlc-py exists
44
+ if ! command_exists qlc-py; then
45
+ log "Error: qlc-py command not found" >&2
46
+ exit 1
47
+ else
48
+ log "Success: qlc-py command found"
49
+ which qlc-py
50
+ fi
51
+
43
52
  # Create output directory if not existent
44
53
  if [ ! -d "$PLOTS_DIRECTORY" ]; then
45
54
  mkdir -p "$PLOTS_DIRECTORY"
@@ -60,68 +69,299 @@ eDate="${eDat//[-:]/}"
60
69
  mDate="$sDate-$eDate"
61
70
  ext="${QLTYPE}.pdf"
62
71
 
63
- exps="$exp1 $exp2"
64
- for exp in $exps ; do
65
- log "Processing ${PLOTTYPE} plot for experiment: $exp"
66
-
67
- log "TEAM_PREFIX : $TEAM_PREFIX"
68
- log "EVALUATION_PREFIX: $EVALUATION_PREFIX"
69
- log "MODEL_RESOLUTION : $MODEL_RESOLUTION"
70
- log "TIME_RESOLUTION : $TIME_RESOLUTION"
71
- log "mDate : $mDate"
72
- log "ext : $ext"
73
- log "exp1 : $exp1"
74
- log "exp2 : $exp2"
75
-
76
- ipath="$ANALYSIS_DIRECTORY/$exp"
77
- tpath="$PLOTS_DIRECTORY/$exp"
78
- hpath="$PLOTS_DIRECTORY/${exp1}-${exp2}_${mDate}"
79
-
80
- # Create help directory if not existent
81
- if [ ! -d "$hpath" ]; then
82
- mkdir -p "$hpath"
83
- fi
84
-
85
- # Create output directory if not existent
86
- if [ ! -d "$tpath" ]; then
87
- mkdir -p "$tpath"
88
- fi
72
+ # Create a temporary list for TeX files and a temporary JSON config
73
+ hpath="$PLOTS_DIRECTORY/${exp1}-${exp2}_${mDate}"
74
+ texPlotsfile="${hpath}/texPlotfiles_${QLTYPE}.list"
75
+ texFile="${texPlotsfile%.list}.tex"
76
+ temp_config_file="${hpath}/temp_qlc_D1_config.json"
77
+
78
+ # Ensure the output directory exists
79
+ mkdir -p "$hpath"
80
+ rm -f "$texPlotsfile" "$temp_config_file" "$texFile"
81
+ touch "$texPlotsfile"
89
82
 
83
+ # Dynamically discover variables from config, validated against existing .nc files.
84
+ log "Discovering variables from config and validating against files in ${ANALYSIS_DIRECTORY}/${exp1}..."
85
+ validated_vars=()
86
+ if [[ -z "${MARS_RETRIEVALS[*]}" ]]; then
87
+ log "Warning: MARS_RETRIEVALS array is not defined in the configuration. Falling back to filename parsing."
88
+ # Fallback to the old method if config arrays are missing
89
+ myvar_list_array=($(find "${ANALYSIS_DIRECTORY}/${exp1}" -type f -name "*.nc" ! -name "*_tavg.nc" -print0 | \
90
+ xargs -0 -n 1 basename | \
91
+ sed -E 's/.*_[A-Z][0-9]+_[a-z]+_(.*)\.nc/\1/' | \
92
+ sort -u))
93
+ else
90
94
  for name in "${MARS_RETRIEVALS[@]}"; do
95
+ myvar_array_name="myvar_${name}[@]"
96
+ myvars=("${!myvar_array_name}")
97
+
98
+ for var_name in "${myvars[@]}"; do
99
+ # Check if a file for this variable exists for the first experiment.
100
+ # The pattern looks for any file ending in _<var_name>.nc
101
+ if compgen -G "${ANALYSIS_DIRECTORY}/${exp1}/*_${var_name}.nc" > /dev/null; then
102
+ validated_vars+=("$var_name")
103
+ fi
104
+ done
105
+ done
106
+ # De-duplicate the results
107
+ myvar_list_array=($(printf "%s\n" "${validated_vars[@]}" | sort -u))
108
+ fi
109
+
110
+
111
+ if [ ${#myvar_list_array[@]} -eq 0 ]; then
112
+ log "Error: Could not find any variables to process. Check config and analysis files. Exiting."
113
+ exit 1
114
+ fi
115
+ myvar_list_string=$(IFS=,; echo "${myvar_list_array[*]}")
116
+ log "Found variables: ${myvar_list_string}"
117
+
118
+ # Dynamically create a temporary JSON config file with three entries.
119
+ cat > "$temp_config_file" << EOM
120
+ [
121
+ {
122
+ "name": "${TEAM_PREFIX}",
123
+ "logdir": "${QLC_HOME}/log",
124
+ "workdir": "${QLC_HOME}/run",
125
+ "output_base_name": "${hpath}/${QLTYPE}",
126
+ "station_file": "${STATION_FILE:-""}",
127
+ "obs_path": "${OBS_DATA_PATH:-""}",
128
+ "obs_dataset_type": "${OBS_DATASET_TYPE:-""}",
129
+ "obs_dataset_version": "${OBS_DATASET_VERSION:-""}",
130
+ "start_date": "${sDat}",
131
+ "end_date": "${eDat}",
132
+ "variable": "${myvar_list_string}",
133
+ "plot_region": "${REGION:-""}",
134
+ "station_radius_deg": ${STATION_RADIUS_DEG:-0.5},
135
+ "plot_type": "${PLOT_TYPE:-""}",
136
+ "time_average": "${TIME_AVERAGE:-""}",
137
+ "station_plot_group_size": ${STATION_PLOT_GROUP_SIZE:-5},
138
+ "show_stations": false,
139
+ "show_min_max": true,
140
+ "log_y_axis": false,
141
+ "fix_y_axis": true,
142
+ "show_station_map": true,
143
+ "load_station_timeseries_obs": true,
144
+ "show_station_timeseries_obs": true,
145
+ "show_station_timeseries_mod": false,
146
+ "show_station_timeseries_com": false,
147
+ "save_plot_format": "${PLOTEXTENSION}",
148
+ "save_data_format": "nc",
149
+ "multiprocessing": ${MULTIPROCESSING:-false},
150
+ "n_threads": ${N_THREADS:-4},
151
+ "debug": ${DEBUG:-false},
152
+ "global_attributes": {
153
+ "title": "Air pollutants over ${REGION:-""}, ${myvar_list_string}",
154
+ "summary": "netCDF output: ${OBS_DATASET_TYPE:-""} observations for selected stations.",
155
+ "author": "$(echo $USER)",
156
+ "history": "Processed for CAMS2_35bis (qlc_v${QLC_VERSION})",
157
+ "Conventions": "CF-1.8"
158
+ }
159
+ },
160
+ {
161
+ "name": "${TEAM_PREFIX}",
162
+ "logdir": "${QLC_HOME}/log",
163
+ "workdir": "${QLC_HOME}/run",
164
+ "output_base_name": "${hpath}/${QLTYPE}",
165
+ "station_file": "${STATION_FILE:-""}",
166
+ "mod_path": "${ANALYSIS_DIRECTORY:-""}",
167
+ "model": "${MODEL:-""}",
168
+ "experiments": "${exp1},${exp2}",
169
+ "exp_labels": "${EXP_LABELS:-""}",
170
+ "start_date": "${sDat}",
171
+ "end_date": "${eDat}",
172
+ "variable": "${myvar_list_string}",
173
+ "plot_region": "${REGION:-""}",
174
+ "station_radius_deg": ${STATION_RADIUS_DEG:-0.5},
175
+ "model_level": ${MODEL_LEVEL:-null},
176
+ "plot_type": "${PLOT_TYPE:-""}",
177
+ "time_average": "${TIME_AVERAGE:-""}",
178
+ "station_plot_group_size": ${STATION_PLOT_GROUP_SIZE:-5},
179
+ "show_stations": false,
180
+ "show_min_max": true,
181
+ "log_y_axis": false,
182
+ "fix_y_axis": true,
183
+ "show_station_map": true,
184
+ "show_station_timeseries_obs": false,
185
+ "show_station_timeseries_mod": true,
186
+ "show_station_timeseries_com": false,
187
+ "save_plot_format": "${PLOTEXTENSION}",
188
+ "save_data_format": "nc",
189
+ "multiprocessing": ${MULTIPROCESSING:-false},
190
+ "n_threads": ${N_THREADS:-4},
191
+ "debug": ${DEBUG:-false},
192
+ "global_attributes": {
193
+ "title": "Air pollutants over ${REGION:-""}, ${myvar_list_string}",
194
+ "summary": "netCDF output: Model data for ${exp1},${exp2} for selected stations.",
195
+ "author": "$(echo $USER)",
196
+ "history": "Processed for CAMS2_35bis (qlc_v${QLC_VERSION})",
197
+ "Conventions": "CF-1.8"
198
+ }
199
+ },
200
+ {
201
+ "name": "${TEAM_PREFIX}",
202
+ "logdir": "${QLC_HOME}/log",
203
+ "workdir": "${QLC_HOME}/run",
204
+ "output_base_name": "${hpath}/${QLTYPE}",
205
+ "station_file": "${STATION_FILE:-""}",
206
+ "obs_path": "${OBS_DATA_PATH:-""}",
207
+ "obs_dataset_type": "${OBS_DATASET_TYPE:-""}",
208
+ "obs_dataset_version": "${OBS_DATASET_VERSION:-""}",
209
+ "mod_path": "${ANALYSIS_DIRECTORY:-""}",
210
+ "model": "${MODEL:-""}",
211
+ "experiments": "${exp1},${exp2}",
212
+ "exp_labels": "${EXP_LABELS:-""}",
213
+ "start_date": "${sDat}",
214
+ "end_date": "${eDat}",
215
+ "variable": "${myvar_list_string}",
216
+ "plot_region": "${REGION:-""}",
217
+ "station_radius_deg": ${STATION_RADIUS_DEG:-0.5},
218
+ "model_level": ${MODEL_LEVEL:-null},
219
+ "plot_type": "${PLOT_TYPE:-""}",
220
+ "time_average": "${TIME_AVERAGE:-""}",
221
+ "station_plot_group_size": ${STATION_PLOT_GROUP_SIZE:-5},
222
+ "show_stations": false,
223
+ "show_min_max": true,
224
+ "log_y_axis": false,
225
+ "fix_y_axis": true,
226
+ "show_station_map": true,
227
+ "load_station_timeseries_obs": false,
228
+ "show_station_timeseries_obs": false,
229
+ "show_station_timeseries_mod": false,
230
+ "show_station_timeseries_com": true,
231
+ "save_plot_format": "${PLOTEXTENSION}",
232
+ "save_data_format": "nc",
233
+ "multiprocessing": ${MULTIPROCESSING:-false},
234
+ "n_threads": ${N_THREADS:-4},
235
+ "debug": ${DEBUG:-false},
236
+ "global_attributes": {
237
+ "title": "Air pollutants over ${REGION:-""}, ${myvar_list_string}",
238
+ "summary": "netCDF output: Collocated model and observation data for selected stations.",
239
+ "author": "$(echo $USER)",
240
+ "history": "Processed for CAMS2_35bis (qlc_v${QLC_VERSION})",
241
+ "Conventions": "CF-1.8"
242
+ }
243
+ }
244
+ ]
245
+ EOM
246
+
247
+ log "Generated temporary config file for qlc-py: ${temp_config_file}"
248
+
249
+ # Execute qlc-py with the temporary config file.
250
+ # Note: qlc-py expects the config via stdin when using '--config -'
251
+ log "Executing qlc-py with the multi-entry config file..."
252
+ qlc-py --config "${temp_config_file}"
253
+
254
+ # After the run, find the specific final collocation plot(s) and add them to the TeX list.
255
+ log "Searching for final collocation plots in ${hpath}..."
256
+ rm -f "$texPlotsfile" # Start with an empty list
257
+ touch "$texPlotsfile" # Ensure the file exists before grep is called
91
258
 
92
- log "name : $name"
259
+ # Loop through each variable to control the order of plots in the TeX file
260
+ for var in "${myvar_list_array[@]}"; do
261
+ log "Ordering plots for variable: $var"
93
262
 
94
- # Define the corresponding arrays based on the name
95
- param_var="param_${name}[@]"
96
- ncvar_var="ncvar_${name}[@]"
97
- myvar_var="myvar_${name}[@]"
263
+ # Helper function to find a plot and add it to the list if it exists and is not already there
264
+ add_plot_if_found() {
265
+ local plot_pattern=$1
266
+ # Use find and sort to ensure a consistent order if multiple files match
267
+ find "${hpath}" -maxdepth 1 -type f -name "${plot_pattern}" 2>/dev/null | sort | while IFS= read -r plot_file; do
268
+ if [ -n "$plot_file" ] && ! grep -qF "$plot_file" "$texPlotsfile"; then
269
+ echo "$plot_file" >> "$texPlotsfile"
270
+ log "Added plot to TeX list: $plot_file"
271
+ fi
272
+ done
273
+ }
98
274
 
99
- # Use variable indirection to access the arrays
100
- param=("${!param_var}")
101
- ncvar=("${!ncvar_var}")
102
- myvar=("${!myvar_var}")
275
+ # Find plots in the specified order using more precise patterns
276
+ # 1. Time series plots (individual experiments first, then collocated)
277
+ add_plot_if_found "*${var}*collocated*regional_mean*.${PLOTEXTENSION}"
278
+
279
+ # 2. Bias plot
280
+ add_plot_if_found "*${var}*collocated*regional_bias*.${PLOTEXTENSION}"
281
+
282
+ # 3. All statistics plots
283
+ add_plot_if_found "*${var}*collocated*stats_plot_Error_Metrics*.${PLOTEXTENSION}"
284
+ add_plot_if_found "*${var}*collocated*stats_plot_Correlation_Metrics*.${PLOTEXTENSION}"
285
+ add_plot_if_found "*${var}*collocated*stats_plot_Descriptive_Statistics*.${PLOTEXTENSION}"
103
286
 
104
- cd $ipath
287
+ # 4. Value map plots (individual experiments)
288
+ add_plot_if_found "*${var}*val.${PLOTEXTENSION}"
289
+
290
+ done
291
+
292
+ # ----------------------------------------------------------------------------------------
293
+ # Generate a .tex file with frames for each plot found, for inclusion in the final presentation.
294
+ # ----------------------------------------------------------------------------------------
295
+ log "Generating TeX file for plots: ${texFile}"
296
+
297
+ # Create the main .tex file for this section with a subsection header
298
+ tQLTYPE=$(echo "$QLTYPE" | sed 's/_/\\_/g')
299
+ cat > "$texFile" <<EOF
300
+ %===============================================================================
301
+ \subsection{${tQLTYPE} -- ${mDate} (${TIME_AVERAGE})}
302
+ EOF
105
303
 
106
- # Loop through the variables for this $name
107
- for ((i = 0; i < ${#ncvar[@]}; i++)); do
304
+ # Loop through the found plot files and generate a TeX frame for each
305
+ if [ -s "$texPlotsfile" ]; then
306
+ # Read from the ordered file list
307
+ while IFS= read -r plot_path; do
308
+ plot_filename=$(basename -- "$plot_path")
309
+ var_name_tex=""
310
+ title_prefix=""
108
311
 
109
- myvar_name="${myvar[i]}"
110
- log "myvar_name : $myvar_name"
312
+ # Extract the variable name for the title
313
+ for var in "${myvar_list_array[@]}"; do
314
+ if [[ "$plot_filename" == *"${var}"* ]]; then
315
+ var_name_tex=$(echo "$var" | sed 's/_/\\_/g')
316
+ break
317
+ fi
318
+ done
111
319
 
112
- tfile="${EVALUATION_PREFIX}_${exp1}-${exp2}_${myvar_name}_${mDate}_${name}_$ext"
113
- log "${PLOTTYPE} plot for: $myvar_name - $tpath/$tfile"
114
- log "work in progress, plot scripts to be implemented ..."
320
+ # Use a case statement for robust title generation
321
+ case "$plot_filename" in
322
+ *regional_bias*)
323
+ title_prefix="Collocation time series bias" ;;
324
+ *stats_plot_Error_Metrics*)
325
+ title_prefix="Collocation error stats" ;;
326
+ *stats_plot_Correlation_Metrics*)
327
+ title_prefix="Collocation correlation stats" ;;
328
+ *stats_plot_Descriptive_Statistics*)
329
+ title_prefix="Collocation descriptive stats" ;;
330
+ *val.*)
331
+ title_prefix="Collocation map value plot" ;;
332
+ *regional_mean*)
333
+ title_prefix="Collocation time series" ;;
334
+ *)
335
+ title_prefix="Collocation station plot" ;;
336
+ esac
337
+
338
+ title_final="${title_prefix} for ${var_name_tex} of ${exp1} vs ${exp2}"
115
339
 
116
- touch $tpath/$tfile
117
- ls -lh $tpath/$tfile
340
+ # Append the frame to the main .tex file
341
+ cat >> "$texFile" <<EOF
342
+ %===============================================================================
343
+ \frame{
344
+ \frametitle{${title_final}}
345
+ \vspace{0mm}
346
+ \centering
347
+ \includegraphics[width=0.9\textwidth]{${plot_path}}
348
+ }
349
+ EOF
350
+ log "Generated TeX frame for $plot_filename"
351
+ done < "$texPlotsfile"
352
+ log "Finished generating TeX file."
353
+ log "${texFile}"
354
+ cat "${texFile}"
355
+ else
356
+ log "No plots found to generate TeX file."
357
+ fi
118
358
 
119
- done # ncvar
120
- done # name
121
- done # exps
359
+ # ----------------------------------------------------------------------------------------
360
+ # End of TeX file generation
361
+ # ----------------------------------------------------------------------------------------
122
362
 
123
- log "$ipath"
124
- log "$tpath"
363
+ log "$ANALYSIS_DIRECTORY"
364
+ log "$PLOTS_DIRECTORY"
125
365
 
126
366
  log "----------------------------------------------------------------------------------------"
127
367
  log "End ${SCRIPT} at `date`"
qlc/sh/qlc_Z1.sh CHANGED
@@ -1,4 +1,4 @@
1
- #!/bin/sh -e
1
+ #!/bin/bash -e
2
2
 
3
3
  # Source the configuration file to load the settings
4
4
  . "$CONFIG_FILE"
@@ -20,7 +20,7 @@ for param in "$@"; do
20
20
  log "Subscript $0 received parameter: $param"
21
21
  done
22
22
 
23
- log "$0 TEX_DIRECTORY = $TEX_DIRECTORY"
23
+ log "$0 TEX_DIRECTORY = ${TEX_DIRECTORY}"
24
24
  pwd -P
25
25
 
26
26
  # module load for ATOS
@@ -90,10 +90,10 @@ log "--------------------------------------------------------------------------
90
90
  log "Processing ${PLOTTYPE}:"
91
91
 
92
92
  log "QLTYPE : $QLTYPE"
93
- log "TEAM_PREFIX : $TEAM_PREFIX"
94
- log "EVALUATION_PREFIX: $EVALUATION_PREFIX"
95
- log "MODEL_RESOLUTION : $MODEL_RESOLUTION"
96
- log "TIME_RESOLUTION : $TIME_RESOLUTION"
93
+ log "TEAM_PREFIX : ${TEAM_PREFIX}"
94
+ log "EVALUATION_PREFIX: ${EVALUATION_PREFIX}"
95
+ log "MODEL_RESOLUTION : ${MODEL_RESOLUTION}"
96
+ log "TIME_RESOLUTION : ${TIME_RESOLUTION}"
97
97
  log "mDate : $mDate"
98
98
  log "ext : $ext"
99
99
  log "exp1 : $exp1"
qlc/sh/qlc_batch.sh ADDED
@@ -0,0 +1,61 @@
1
+ #!/bin/bash -e
2
+ SCRIPT="$0"
3
+ # user specific configuration file
4
+ QLC_DIR="$HOME/qlc"
5
+ CONFIG_DIR="$QLC_DIR/config"
6
+ CONFIG_FILE="$CONFIG_DIR/qlc.conf"
7
+
8
+ # Source the configuration file and automatically export all defined variables
9
+ # to make them available to any subscripts that are called.
10
+ set -a
11
+ . "$CONFIG_FILE"
12
+ set +a
13
+
14
+ # Source the common functions script to make the 'log' function available
15
+ . "$SCRIPTS_PATH/qlc_common_functions.sh"
16
+
17
+ log "________________________________________________________________________________________"
18
+ log "Start ${SCRIPT} at `date`"
19
+ #log "----------------------------------------------------------------------------------------"
20
+ #log "Copyright (c) 2021-2025 ResearchConcepts io GmbH. All Rights Reserved. "
21
+ #log "Questions / comments to: Swen M. Metzger <sm@researchconcepts.io> "
22
+ log "----------------------------------------------------------------------------------------"
23
+ if [ "$1" == "" ] ;then
24
+ log "type, e.g.:"
25
+ log "sqlc b2ro b2rn 2018-12-01 2018-12-21 mars"
26
+ log "sqlc b2ro b2rn 2018-12-01 2018-12-21"
27
+ log " "
28
+ log "Use option 'mars' to retrieve files and then submit a a dependency job once all data have been retrieved."
29
+ log "Or, option 'mars' can be skipped, if all data are already present in $MARS_RETRIEVAL_DIRECTORY"
30
+ log "________________________________________________________________________________________"
31
+ log "End ${SCRIPT} at `date`"
32
+ log "________________________________________________________________________________________"
33
+ exit 0
34
+ fi
35
+ if [ "$5" == "mars" ] ;then
36
+ jobid='${SLURM_JOB_ID}'
37
+ cat > $HOME/qlc/run/qlc_batch.sh$$<<EOF
38
+ #!/bin/ksh -e
39
+ #SBATCH --job-name=$HOME/qlc/run/qlc_batch.sh$$
40
+ #SBATCH --output=log-%J.out
41
+ #SBATCH --error=err-%J.out
42
+ #SBATCH --export=ALL
43
+ $HOME/qlc/bin/qlc $1 $2 $3 $4 $5
44
+ echo "SLURM_JOB_ID = ${jobid}"
45
+ sbatch --dependency=afterok:${jobid} --mail-user=$USER@ecmwf.int $HOME/qlc/bin/qlc $1 $2 $3 $4
46
+ EOF
47
+ else
48
+ cat > $HOME/qlc/run/qlc_batch.sh$$<<EOF
49
+ #!/bin/ksh -e
50
+ #SBATCH --job-name=$HOME/qlc/run/qlc_batch.sh$$
51
+ #SBATCH --output=log-%J.out
52
+ #SBATCH --error=err-%J.out
53
+ $HOME/qlc/bin/qlc $1 $2 $3 $4
54
+ EOF
55
+ fi
56
+ sbatch $HOME/qlc/run/qlc_batch.sh$$
57
+ squeue -u "$USER"
58
+ log "________________________________________________________________________________________"
59
+ log "End ${SCRIPT} at `date`"
60
+ log "________________________________________________________________________________________"
61
+ exit 0
@@ -1,4 +1,4 @@
1
- #!/bin/sh
1
+ #!/bin/bash
2
2
 
3
3
  # Source the configuration file to load the settings
4
4
  . "$CONFIG_FILE"
@@ -13,27 +13,13 @@ HOST=`hostname -s | awk '{printf $1}' | cut -c 1`
13
13
 
14
14
  # Function to log messages to a file
15
15
  log() {
16
- local timestamp
17
- timestamp1=$(date +"%Y-%m-%d %H:%M:%S")
18
- timestamp2=$(date +"%Y%m%d%H%M")
19
- # timestamp2=$(date +"%Y%m%d%H")
20
- local log_message="[$timestamp1] $1"
21
-
22
- # Create log directory if not existent
23
- if [ ! -d "$WORKING_DIRECTORY/log" ]; then
24
- mkdir -p $WORKING_DIRECTORY/log
25
- fi
26
-
27
- # Specify the log file path
28
- # local log_file="$WORKING_DIRECTORY/log/qlc_${timestamp2}_$$.log"
29
- local log_file="$WORKING_DIRECTORY/log/qlc_${timestamp2}.log"
30
-
31
- # Append the log message to the log file
32
- echo "$log_message" >> "$log_file"
33
- # echo "$log_message" | tee -a "$log_file"
34
-
35
- # Also print the log message to the standard output (console)
36
- echo "$log_message"
16
+ # Create a log message and write to stdout and log file
17
+ # We use a subshell to ensure all output is captured and redirected atomically
18
+ (
19
+ local log_message
20
+ log_message=$(printf "[%s] %s" "$(date +"%Y-%m-%d %H:%M:%S")" "$*")
21
+ echo "$log_message"
22
+ )
37
23
  }
38
24
 
39
25
  # Define the sorting function
@@ -53,15 +39,15 @@ sort_files() {
53
39
  # Initialize arrays
54
40
  fnam=()
55
41
 
56
- # workaround for system dependency
42
+ # workaround for system dependency (obsolete)
57
43
  if [ "${myOS}" == "Darwin" ]; then
58
- # var_element=8
59
- var_element=9
60
- exp_element=10
44
+ # var_element=9
45
+ # exp_element=10
46
+ var_element=7
47
+ exp_element=8
61
48
  else
62
- # var_element=7
63
- var_element=8
64
- exp_element=9
49
+ var_element=7
50
+ exp_element=8
65
51
  fi
66
52
 
67
53
  # Read the list of files from the file list
@@ -72,6 +58,8 @@ sort_files() {
72
58
  var="${parts[$var_element]}"
73
59
  fvar+=("$var")
74
60
  vars+=" $var" # Create a space-separated list of variable names
61
+ # echo "file $file"
62
+ # echo "var $var"
75
63
  done < "$files_list"
76
64
 
77
65
  # Get unique variable list