Skip to content

Commit bdb8a11

Browse files
authored
Merge branch 'master' into horayzon
2 parents 29d2433 + ff478f3 commit bdb8a11

File tree

13 files changed

+220
-31
lines changed

13 files changed

+220
-31
lines changed
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
## Workflow for merging PRs
2+
3+
Please read these instructions carefully and follow the steps below before
4+
requesting a review by the maintainers. This way we can ensure a smoother
5+
review process and your changes will be merged sooner.
6+
7+
Additionally, if this is the first PR you open in EXTPAR make sure to read the
8+
[*"Information for EXTPAR Developers"*](https://c2sm.github.io/extpar/development/)
9+
section in the documentation.
10+
11+
### Checklist
12+
13+
- [ ] Provide a detailed description of your changes.
14+
- [ ] If you implemented a new feature:
15+
- [ ] Document it in the correct Markdown file(s) under the
16+
[`docs/`](https://github.com/C2SM/extpar/tree/master/docs) directory.
17+
- [ ] [Add a new test](https://c2sm.github.io/extpar/testing/#add-a-new-test)
18+
or make sure your changes are already tested.
19+
- [ ] Your code follows the [style guidelines](https://c2sm.github.io/extpar/development/#coding-rules-and-best-practices).
20+
- [ ] Your changes only touch the files/lines relevant for you.
21+
- [ ] All four required checks pass (see
22+
[*"Testing and debugging"*](#testing-and-debugging) for more details).
23+
- [ ] No conflicts with the base branch.
24+
25+
If all the points above are satisfied you can ask for a review by selecting
26+
`stelliom` as a reviewer.
27+
28+
For any questions please ping `@stelliom` on this PR.
29+
30+
### Testing and debugging
31+
32+
The most important test for PRs is the one labeled
33+
*"EXTPAR Testsuite on Jenkins"*. This checks that the results of all testcases
34+
(described by the namelists in
35+
[`test/testsuite/data`](https://github.com/C2SM/extpar/tree/master/test/testsuite/data))
36+
did not change compared to the references.
37+
38+
You can launch the testsuite by writing `launch jenkins` as a comment in the
39+
PR that you want to test. Once completed, the result of the testsuite will be
40+
shown on the PR (failure or success).
41+
42+
If you need more details on the testsuite results (e.g., if you are trying to
43+
debug an error or you are simply unsure why the tests fail) you can launch the
44+
testsuite with `launch jenkins(debug)`. This will run the tests as usual, but,
45+
once completed, you will be given a URL (via a comment on the PR) to access the
46+
logfiles and namelists of all tests that were run.

docs/user_manual/user_manual_04_python_modules.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,8 @@ The data processing with CDO for it_cl_type = 2 involves 5 steps:
153153
*distance-weighted average* interpolation.
154154

155155
5. Correct data processed in step 4 with the surface height extracted
156-
in step 3.
156+
in step 3. The lapse rate and offset can be selected via the
157+
`tcorr_lapse_rate` and `tcorr_offset` entries in the namelist.
157158

158159
All subsequent processing on the data follows the general workflow of
159160
the Python scripts.

docs/user_manual/user_manual_06_namelist_input.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,9 @@ The COSMO grid is defined by a rotated latlon-grid.
179179
| `raw_data_t_clim_path` | character | | | path to T2m climatology data |
180180
| `raw_data_t_clim_coarse` | character | | | filename of coarse T2m climatology data |
181181
| `raw_data_t_clim_fine` | character | | | filename of fine T2m climatology data |
182-
| `it_cl_type` | integer | | | switch to choose between the <br> 1: new and fine <br> 2: the old and coarse over sea and the fine over land raw data set. <br> Note that the fine data set (1) is topographically corrected. |
182+
| `it_cl_type` | integer | | | switch to choose between the <br> 1: Aggregates the fine data over land, sea points are not considered. No lapse rate correction of soil temperature based on difference between CRU and ICON model topography <br> 2: Aggregates the coarse data over sea and the fine data over land. Lapse rate correction takes place (lapse rate and additional temperature offset can be specified with `tcorr_lapse_rate` and `tcorr_offset`). |
183+
| `tcorr_lapse_rate` | real | 0.0065 | | Lapse rate used for correction of the climatological 2m temperature. **Only available for `it_cl_type=2`** |
184+
| `tcorr_offset` | real | 0.0 | | Offset used for correction of the climatological 2m temperature. **Only available for `it_cl_type=2`** |
183185
| `t_clim_buffer_file` | character | | | name for T_clim buffer file |
184186

185187
## NDVI Data

python/WrapExtpar.py

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -85,14 +85,16 @@ def main():
8585
lradtopo = config.get('lradtopo', False)
8686
nhori = config.get('nhori', 24)
8787
radtopo_radius = config.get('radtopo_radius', 40000.0)
88+
tcorr_lapse_rate = config.get('tcorr_lapse_rate', 0.0065)
89+
tcorr_offset = config.get('tcorr_offset', 0.0)
8890

8991
generate_external_parameters(
9092
igrid_type, args.input_grid, iaot_type, ilu_type, ialb_type,
9193
isoil_type, itopo_type, it_cl_type, iera_type, iemiss_type,
9294
ilookup_table_lu, enable_cdnc, enable_edgar, enable_art,
93-
use_array_cache, nhori, radtopo_radius, args.raw_data_path,
94-
args.run_dir, args.account, args.host, args.no_batch_job, lurban,
95-
lsgsl, lfilter_oro, l_use_corine, lradtopo)
95+
use_array_cache, nhori, radtopo_radius, tcorr_lapse_rate, tcorr_offset,
96+
args.raw_data_path, args.run_dir, args.account, args.host,
97+
args.no_batch_job, lurban, lsgsl, lfilter_oro, l_use_corine, lradtopo)
9698

9799

98100
def generate_external_parameters(igrid_type,
@@ -112,6 +114,8 @@ def generate_external_parameters(igrid_type,
112114
use_array_cache,
113115
nhori,
114116
radtopo_radius,
117+
tcorr_lapse_rate,
118+
tcorr_offset,
115119
raw_data_path,
116120
run_dir,
117121
account,
@@ -151,6 +155,8 @@ def generate_external_parameters(igrid_type,
151155
'lradtopo': lradtopo,
152156
'nhori': nhori,
153157
'radtopo_radius': radtopo_radius,
158+
'tcorr_lapse_rate': tcorr_lapse_rate,
159+
'tcorr_offset': tcorr_offset,
154160
'lsgsl': lsgsl,
155161
'lfilter_oro': lfilter_oro,
156162
'lurban': lurban,
@@ -426,7 +432,6 @@ def setup_oro_namelist_icon(args, lonmax, lonmin, latmax, latmin):
426432
namelist['ntiles_row'] = 4
427433

428434
namelist['lscale_separation'] = ".FALSE."
429-
namelist['lsso_param'] = ".FALSE."
430435
namelist['scale_sep_files'] = "'placeholder_file'"
431436
namelist['lsso_param'] = ".TRUE."
432437

@@ -587,11 +592,15 @@ def setup_tclim_namelist(args):
587592
namelist['t_clim_buffer_file'] = 'tclim_buffer.nc'
588593

589594
namelist['it_cl_type'] = args['it_cl_type']
590-
namelist['raw_data_tclim_coarse'] = 'absolute_hadcrut3.nc'
591-
namelist['raw_data_tclim_fine'] = 'CRU_T_SOIL_clim.nc'
592595
if args['it_cl_type'] > 2:
593596
raise ValueError(f'Unknown it_cl_type {args["it_cl_type"]}')
594597

598+
namelist['raw_data_tclim_coarse'] = 'absolute_hadcrut3.nc'
599+
namelist['raw_data_tclim_fine'] = 'CRU_T_SOIL_clim.nc'
600+
601+
namelist['tcorr_lapse_rate'] = args['tcorr_lapse_rate']
602+
namelist['tcorr_offset'] = args['tcorr_offset']
603+
595604
return namelist
596605

597606

python/extpar_cru_to_buffer.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,16 +180,23 @@
180180
'smooth,maxpoints=16', '-setmisstonn',
181181
f'-remapdis,{grid}', step2_cdo, step4_cdo)
182182

183+
tcorr_lapse_rate = utils.check_tcorr_lapse_rate(
184+
itcl.get('tcorr_lapse_rate', 0.0065))
185+
tcorr_offset = utils.check_tcorr_offset(itcl.get('tcorr_offset', 0.0))
186+
183187
logging.info(f'STEP 5: '
184188
f'correct T_CL from {step4_cdo} '
185189
f'with HH_TOPO from {buffer_topo} '
190+
f'with temperature lapse rate of {tcorr_lapse_rate} K/m '
191+
f'and offset of {tcorr_offset} K for land points '
186192
f'--> {step5_cdo}')
187193
logging.info('')
188194

189195
utils.launch_shell(
190196
'cdo', lock, 'expr, T_CL = ((FR_LAND != 0.0)) ? '
191-
'T_CL+0.0065*(HSURF-HH_TOPO) : T_CL; HSURF;', '-merge', step4_cdo,
192-
step3_cdo, step5_cdo)
197+
f'T_CL+{tcorr_lapse_rate}*(HSURF-HH_TOPO){tcorr_offset:+} : '
198+
f'T_CL{tcorr_offset:+}; HSURF;', '-merge', step4_cdo, step3_cdo,
199+
step5_cdo)
193200
else:
194201

195202
logging.info('STEP 1: '

python/lib/utilities.py

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,43 @@ def check_itype_cru(itype_cru):
280280
logging.info('Process fine resolution for land, '
281281
'coarse resolution for sea')
282282

283-
return itype_cru
283+
return itype_cru
284+
285+
286+
def check_tcorr_lapse_rate(tcorr_lapse_rate):
287+
'''
288+
check tcorr_lapse_rate for correctness and return value,
289+
if not exit programme
290+
'''
291+
292+
if (tcorr_lapse_rate > 0.0098 or tcorr_lapse_rate < 0.005):
293+
logging.error(f'Invalid value entered for temperature lapse rate. '
294+
f'Use a value between 0.005 and 0.0098 K/m instead!')
295+
296+
raise ValueError(f'Invalid value entered for temperature lapse rate. '
297+
f'Use a value between 0.005 and 0.0098 K/m instead!')
298+
299+
logging.info(f'Temperate lapse rate is set to {tcorr_lapse_rate} K/m')
300+
301+
return tcorr_lapse_rate
302+
303+
304+
def check_tcorr_offset(tcorr_offset):
305+
'''
306+
check tcorr_offset for correctness and return value,
307+
if not exit programme
308+
'''
309+
310+
if (tcorr_offset > 10.0 or tcorr_offset < -10.0):
311+
logging.error(f'Invalid value entered for temperature offset. '
312+
f'Use a value between -10.0 and +10.0 K instead!')
313+
314+
raise ValueError(f'Invalid value entered for temperature offset. '
315+
f'Use a value between -10.0 and +10.0 K instead!')
316+
317+
logging.info(f'Chosen temperature offset: {tcorr_offset} K')
318+
319+
return tcorr_offset
284320

285321

286322
def determine_emiss_varnames(iemiss_type):

src/extpar_consistency_check.f90

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -497,6 +497,8 @@ PROGRAM extpar_consistency_check
497497

498498

499499
REAL (KIND=wp) :: t2mclim_hc, &
500+
& tcorr_lapse_rate, &
501+
& tcorr_offset, &
500502
& step, &
501503
& thr_cr, & !< control threshold
502504
& fill_value_real, & !< value to indicate undefined grid elements
@@ -805,8 +807,10 @@ PROGRAM extpar_consistency_check
805807
it_cl_type, &
806808
raw_data_t_clim_path, &
807809
raw_data_t_clim_filename, &
808-
t_clim_buffer_file , &
809-
t_clim_output_file )
810+
t_clim_buffer_file, &
811+
t_clim_output_file, &
812+
tcorr_lapse_rate, &
813+
tcorr_offset )
810814

811815
! read namelist for input EMISS data
812816
namelist_file = 'INPUT_EMISS'

src/mo_python_routines.f90

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -137,21 +137,26 @@ SUBROUTINE read_namelists_extpar_t_clim(namelist_file, &
137137
& raw_data_t_clim_path, &
138138
& raw_data_t_clim_filename, &
139139
& t_clim_buffer_file, &
140-
& t_clim_output_file)
140+
& t_clim_output_file, &
141+
& tcorr_lapse_rate, &
142+
& tcorr_offset)
141143

142144
CHARACTER (len=*), INTENT(IN) :: namelist_file !< filename with namelists for for EXTPAR settings
143145
INTEGER (KIND=i4), INTENT(OUT) :: it_cl_type !< integer switch to choose a land use raw data set
144146

145-
CHARACTER (len=filename_max), INTENT(OUT) :: raw_data_t_clim_path, & !< path to raw data
146-
& raw_data_t_clim_filename, & !< filename temperature climatology raw data
147-
& t_clim_buffer_file, & !< name for temperature climatology buffer
148-
& t_clim_output_file !< name for temperature climatology output file
147+
CHARACTER (len=filename_max), INTENT(OUT) :: raw_data_t_clim_path, & !< path to raw data
148+
& raw_data_t_clim_filename, & !< filename temperature climatology raw data
149+
& t_clim_buffer_file, & !< name for temperature climatology buffer
150+
& t_clim_output_file !< name for temperature climatology output file
151+
152+
REAL(KIND=wp), INTENT(OUT) :: tcorr_lapse_rate, & !< lapse rate for temperature correction
153+
& tcorr_offset !< offset for temperature correction
149154

150155

151156
INTEGER (KIND=i4) :: nuin, ierr
152157

153158
!> namelist with filename for temperature climatlogy data output
154-
NAMELIST /t_clim_raw_data/ raw_data_t_clim_path, raw_data_t_clim_filename, it_cl_type
159+
NAMELIST /t_clim_raw_data/ raw_data_t_clim_path, raw_data_t_clim_filename, it_cl_type, tcorr_lapse_rate, tcorr_offset
155160

156161
!> namelist with filename for temperature climatlogy data output
157162
NAMELIST /t_clim_io_extpar/ t_clim_buffer_file, t_clim_output_file

templates/namelist

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ input_tclim = {
33
'raw_data_tclim_coarse': '@RAW_DATA_TCLIM_COARSE@',
44
'raw_data_tclim_fine': '@RAW_DATA_TCLIM_FINE@',
55
't_clim_buffer_file': '@T_CLIM_BUFFER_FILE@',
6-
'it_cl_type': @IT_CL_TYPE@
6+
'it_cl_type': @IT_CL_TYPE@,
7+
'tcorr_lapse_rate': @TCORR_LAPSE_RATE@,
8+
'tcorr_offset': @TCORR_OFFSET@
79
}
810

911
input_alb = {

test/jenkins/test.sh

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,38 @@
22
case "$(hostname)" in
33
*co2* | *iacdipl-7*)
44
set -e
5-
podman run -e OMP_NUM_THREADS=16 -v /net/co2/c2sm-data/extpar-input-data:/data extpar:$ghprbPullId bash -c /workspace/test/jenkins/test_docker.sh || (podman image rm -f extpar:$ghprbPullId && exit 1)
6-
podman image rm -f extpar:$ghprbPullId
7-
exit 0
5+
6+
trap "podman image rm -f extpar:$ghprbPullId || true" EXIT
7+
8+
MODE=${1:-'NORMAL'}
9+
if [[ ${MODE} == "DEBUG" ]]; then
10+
CURRENT_DATETIME=$(date --iso-8601=seconds)
11+
HASH=$(echo -n "${CURRENT_DATETIME}" | sha256sum | awk '{print $1}')
12+
mkdir -p /net/co2/c2sm-services/extpar/${HASH}
13+
14+
if podman run \
15+
-e OMP_NUM_THREADS=16 \
16+
-v /net/co2/c2sm-data/extpar-input-data:/data \
17+
-v /net/co2/c2sm-services/extpar/${HASH}:/artifacts \
18+
extpar:$ghprbPullId \
19+
bash -c "/workspace/test/jenkins/test_docker.sh ${MODE}"; then
20+
REPORT_STATUS="completed successfully"
21+
STATUS=0
22+
else
23+
REPORT_STATUS="failed"
24+
STATUS=1
25+
fi
26+
27+
curl -H "Authorization: token ${GITHUB_TOKEN}" \
28+
-H "Accept: application/vnd.github+json" \
29+
-H "Content-Type: application/json" \
30+
https://api.github.com/repos/C2SM/extpar/issues/${ghprbPullId}/comments \
31+
-d "{\"body\": \"The testsuite you launched for this PR has ${REPORT_STATUS}. You can inspect the results at this [link](https://data.iac.ethz.ch/extpar/${HASH}).\"}"
32+
else
33+
podman run -e OMP_NUM_THREADS=16 -v /net/co2/c2sm-data/extpar-input-data:/data extpar:$ghprbPullId bash -c "/workspace/test/jenkins/test_docker.sh ${MODE}"
34+
STATUS="$?"
35+
fi
36+
37+
exit "${STATUS}"
838
;;
939
esac

0 commit comments

Comments
 (0)