|
1 | 1 | #!/bin/bash |
2 | 2 |
|
3 | 3 | # A Bash script to post-process E3SM 6 hourly (h2) instantaneous output to generate a text file storing Tropical Cyclone tracks |
4 | | -# tempestremap and tempestextremes are built in e3sm-unified from version 1.5.0. This script has been tested using Cori login node. |
5 | | -# To request an interactive session as follows: salloc --nodes=1 --partition=debug --time=30:00 -C haswell |
| 4 | +# tempestremap and tempestextremes are built in e3sm-unified from version 1.5.0. This script has been tested using Perlmutter login node. |
| 5 | +# To request an interactive session as follows: salloc --nodes=1 --partition=debug --time=30:00 -C cpu |
6 | 6 |
|
7 | | -source /global/common/software/e3sm/anaconda_envs/load_latest_e3sm_unified_cori-haswell.sh |
| 7 | +source /global/common/software/e3sm/anaconda_envs/load_latest_e3sm_unified_pm-cpu.sh |
8 | 8 |
|
9 | 9 | #For typical EAM v2 ne gp2 grids. |
10 | | -start="0051" |
11 | | -end="0060" |
12 | | -caseid="20210528.v2rc3e.piControl.ne30pg2_EC30to60E2r2.chrysalis" |
13 | | -drc_in=/global/cfs/cdirs/e3smdata/zppy_complete_run_nersc_output/${caseid}/archive/atm/hist |
14 | | -# Warning: because somehow tempest-remap only can writes grid file on SCRATCH space. The resulted files will be moved to another path at the end. |
15 | | -result_dir_fin=/global/cfs/cdirs/e3sm/e3sm_diags/postprocessed_e3sm_v2_data_for_e3sm_diags/${caseid}/ |
16 | | -mkdir -p $result_dir_fin |
17 | | -result_dir=$SCRATCH/tests/tc-analysis/ |
18 | | - |
| 10 | +start="2000" |
| 11 | +end="2014" |
| 12 | +caseid="v2.LR.amip_0101" |
| 13 | +drc_in=/global/cfs/cdirs/e3smpub/E3SM_simulations/${caseid}/archive/atm/hist |
| 14 | +result_dir=/global/homes/c/chengzhu/tests/tc_analysis/tc-v2.LR.amip.${start}_${end}/ |
19 | 15 |
|
20 | 16 | #res = 30/120 for ne30/ne120 grids |
21 | 17 | res=30 # res = 30/120 for ne30/ne120 grids |
22 | 18 | pg2=true # Set false for v1 production simulations |
23 | 19 | atm_name="eam" # Use "cam" for v1 production simulations |
24 | 20 |
|
25 | 21 |
|
26 | | -##For typical v1 ne SE grids. |
27 | | -#start="1880" |
28 | | -#end="1881" |
29 | | -#caseid="20180215.DECKv1b_H1.ne30_oEC.edison" |
30 | | -#drc_in=/global/cfs/cdirs/e3smpub/E3SM_simulations/${caseid}/archive/atm/hist |
31 | | -#result_dir=/global/cfs/cdirs/e3sm/e3sm_diags/postprocessed_e3sm_v1_data_for_e3sm_diags/${caseid}/tc-analysis/ |
32 | | -# |
33 | | -##res = 30/120 for ne30/ne120 grids |
34 | | -#res=30 # res = 30/120 for ne30/ne120 grids |
35 | | -#pg2=false # Set false for v1 production simulations |
36 | | -#atm_name="cam" # Use "cam" for v1 production simulations |
37 | | - |
38 | | - |
39 | | - |
40 | 22 | mkdir -p $result_dir |
41 | 23 | file_name=${caseid}_${start}_${end} |
42 | 24 |
|
43 | 25 | # Generate mesh files (.g). |
44 | | -#/global/homes/p/paullric/tempestremap/bin/GenerateCSMesh --res $res --alt --file ${result_dir}outCSne$res.g |
45 | | -GenerateCSMesh --res $res --alt --file ${result_dir}outCSne$res.g |
46 | | -out_type="CGLL" |
47 | | -# For v2 production simulation with pg2 grids: |
48 | 26 | if $pg2; then |
49 | | - GenerateVolumetricMesh --in ${result_dir}outCSne$res.g --out ${result_dir}outCSne$res.g --np 2 --uniform |
| 27 | + # For v2 and v3 production simulation with pg2 grids: |
| 28 | + GenerateCSMesh --res $res --alt --file ${result_dir}outCSMeshne$res.g |
| 29 | + GenerateVolumetricMesh --in ${result_dir}outCSMeshne$res.g --out ${result_dir}outCSne$res.g --np 2 --uniform |
50 | 30 | out_type="FV" |
| 31 | +else |
| 32 | + # For v1 production simulation with np4 grids: |
| 33 | + GenerateCSMesh --res $res --alt --file ${result_dir}outCSne$res.g |
| 34 | + out_type="CGLL" |
51 | 35 | fi |
52 | 36 | echo $out_type |
53 | 37 | # Generate connectivity files (.dat) |
54 | | -#/global/homes/p/paullric/tempestextremes/bin/GenerateConnectivityFile --in_mesh ${result_dir}outCSne$res.g --out_type CGLL --out_connect ${result_dir}connect_CSne${res}_v2.dat |
55 | 38 | GenerateConnectivityFile --in_mesh ${result_dir}outCSne$res.g --out_type $out_type --out_connect ${result_dir}connect_CSne${res}_v2.dat |
56 | 39 |
|
57 | 40 | # Get the list of files |
58 | 41 | cd ${drc_in};eval ls ${drc_in}/${caseid}.$atm_name.h2.*{${start}..${end}}*.nc >${result_dir}inputfile_${file_name}.txt |
59 | 42 | cd ${drc_in};eval ls ${caseid}.$atm_name.h2.*{${start}..${end}}*.nc >${result_dir}outputfile_${file_name}.txt |
60 | | -#cd ${drc_in};eval ls ${drc_in}/${caseid}.cam.h2.*{${start}..${end}}*.nc >${result_dir}inputfile_${file_name}.txt |
61 | | -#cd ${drc_in};eval ls ${caseid}.cam.h2.*{${start}..${end}}*.nc >${result_dir}outputfile_${file_name}.txt |
62 | 43 |
|
63 | 44 | cd ${result_dir} |
64 | 45 | # Detection threshold including: |
65 | 46 | # The sea-level pressure (SLP) must be a local minimum; SLP must have a sufficient decrease (300 Pa) compared to surrounding nodes within 4 degree radius; The average of the 200 hPa and 500 hPa level temperature decreases by 0.6 K in all directions within a 4 degree radius from the location to fSLP minima |
66 | | -#/global/homes/p/paullric/tempestextremes/bin/DetectNodes --verbosity 0 --in_connect ${result_dir}connect_CSne${res}_v2.dat --closedcontourcmd "PSL,300.0,4.0,0;_AVG(T200,T500),-0.6,4,0.30" --mergedist 6.0 --searchbymin PSL --outputcmd "PSL,min,0;_VECMAG(UBOT,VBOT),max,2" --timestride 1 --in_data_list ${result_dir}inputfile_${file_name}.txt --out ${result_dir}out.dat |
67 | | -DetectNodes --verbosity 0 --in_connect ${result_dir}connect_CSne${res}_v2.dat --closedcontourcmd "PSL,300.0,4.0,0;_AVG(T200,T500),-0.6,4,0.30" --mergedist 6.0 --searchbymin PSL --outputcmd "PSL,min,0;_VECMAG(UBOT,VBOT),max,2" --timestride 1 --in_data_list ${result_dir}inputfile_${file_name}.txt --out ${result_dir}out.dat |
| 47 | + |
| 48 | +# --closedcontourcmd threshold is resolution depended. |
| 49 | +if [ $res == 120 ]; then |
| 50 | + echo $res |
| 51 | + DetectNodes --verbosity 0 --in_connect ${result_dir}connect_CSne${res}_v2.dat --closedcontourcmd "PSL,300.0,4.0,0;_AVG(T200,T500),-0.6,4,0.30" --mergedist 6.0 --searchbymin PSL --outputcmd "PSL,min,0;_VECMAG(UBOT,VBOT),max,2" --timestride 1 --in_data_list ${result_dir}inputfile_${file_name}.txt --out ${result_dir}out.dat |
| 52 | +elif [ $res == 30 ]; then |
| 53 | + echo $res |
| 54 | + DetectNodes --verbosity 0 --in_connect ${result_dir}connect_CSne${res}_v2.dat --closedcontourcmd "PSL,300.0,4.0,0;_AVG(T200,T500),-0.6,4,1.0" --mergedist 6.0 --searchbymin PSL --outputcmd "PSL,min,0;_VECMAG(UBOT,VBOT),max,2" --timestride 1 --in_data_list ${result_dir}inputfile_${file_name}.txt --out ${result_dir}out.dat |
| 55 | +else |
| 56 | + echo “$res value not supported” |
| 57 | +fi |
68 | 58 |
|
69 | 59 | cat ${result_dir}out.dat0* > ${result_dir}cyclones_${file_name}.txt |
70 | 60 |
|
71 | 61 | # Stitch all candidate nodes in time to form tracks, with a maximum distance between candidates of 6.0, minimum time steps of 6, and with a maximum gap size of one (most consecutive time steps with no associated candidate). And there is threshold for wind speed, lat and lon. |
72 | | -#/global/homes/p/paullric/tempestextremes/bin/StitchNodes --in_fmt "lon,lat,slp,wind" --in_connect ${result_dir}connect_CSne${res}_v2.dat --range 6.0 --mintime 6 --maxgap 1 --in ${result_dir}cyclones_${file_name}.txt --out ${result_dir}cyclones_stitch_${file_name}.dat --threshold "wind,>=,17.5,6;lat,<=,40.0,6;lat,>=,-40.0,6" |
73 | 62 | StitchNodes --in_fmt "lon,lat,slp,wind" --in_connect ${result_dir}connect_CSne${res}_v2.dat --range 6.0 --mintime 6 --maxgap 1 --in ${result_dir}cyclones_${file_name}.txt --out ${result_dir}cyclones_stitch_${file_name}.dat --threshold "wind,>=,17.5,6;lat,<=,40.0,6;lat,>=,-40.0,6" |
74 | 63 | rm ${result_dir}cyclones_${file_name}.txt |
75 | 64 |
|
76 | 65 | # Generate histogram of detections |
77 | | -#/global/homes/p/paullric/tempestextremes/bin/HistogramNodes --in ${result_dir}cyclones_stitch_${file_name}.txt --iloncol 2 --ilatcol 3 --out ${result_dir}cyclones_hist_${file_name}.nc |
78 | 66 | HistogramNodes --in ${result_dir}cyclones_stitch_${file_name}.dat --iloncol 2 --ilatcol 3 --out ${result_dir}cyclones_hist_${file_name}.nc |
79 | 67 |
|
80 | 68 | # Calculate relative vorticity |
81 | | -sed -i 's/.nc/_vorticity.nc/' ${result_dir}outputfile_${file_name}.txt |
82 | | -#/global/homes/p/paullric/tempestextremes/bin/VariableProcessor --in_data_list ${result_dir}inputfile_${file_name}.txt --out_data_list ${result_dir}outputfile_${file_name}.txt --var "_CURL{4,0.5}(U850,V850)" --varout "VORT" --in_connect ${result_dir}connect_CSne${res}_v2.dat |
| 69 | +sed -i 's/\.nc/_vorticity.nc/' ${result_dir}outputfile_${file_name}.txt |
83 | 70 | VariableProcessor --in_data_list ${result_dir}inputfile_${file_name}.txt --out_data_list ${result_dir}outputfile_${file_name}.txt --var "_CURL{4,0.5}(U850,V850)" --varout "VORT" --in_connect ${result_dir}connect_CSne${res}_v2.dat |
84 | 71 |
|
85 | | -#/global/homes/p/paullric/tempestextremes/bin/DetectNodes --verbosity 0 --in_connect ${result_dir}connect_CSne${res}_v2.dat --closedcontourcmd "VORT,-5.e-6,4,0" --mergedist 2.0 --searchbymax VORT --outputcmd "VORT,max,0" --in_data_list ${result_dir}outputfile_${file_name}.txt --out ${result_dir}aew_out.dat --minlat -35.0 --maxlat 35.0 |
86 | 72 | DetectNodes --verbosity 0 --in_connect ${result_dir}connect_CSne${res}_v2.dat --closedcontourcmd "VORT,-5.e-6,4,0" --mergedist 2.0 --searchbymax VORT --outputcmd "VORT,max,0" --in_data_list ${result_dir}outputfile_${file_name}.txt --out ${result_dir}aew_out.dat --minlat -35.0 --maxlat 35.0 |
87 | 73 | cat ${result_dir}aew_out.dat0* > ${result_dir}aew_${file_name}.txt |
88 | 74 |
|
89 | | -#/global/homes/p/paullric/tempestextremes/bin/StitchNodes --in_fmt "lon,lat,VORT" --in_connect ${result_dir}connect_CSne${res}_v2.dat --range 3.0 --minlength 8 --maxgap 0 --min_endpoint_dist 10.0 --in ${result_dir}aew_${file_name}.txt --out ${result_dir}aew_stitch_5e-6_${file_name}.dat --threshold "lat,<=,25.0,8;lat,>=,0.0,8" |
90 | 75 | StitchNodes --in_fmt "lon,lat,VORT" --in_connect ${result_dir}connect_CSne${res}_v2.dat --range 3.0 --minlength 8 --maxgap 0 --min_endpoint_dist 10.0 --in ${result_dir}aew_${file_name}.txt --out ${result_dir}aew_stitch_5e-6_${file_name}.dat --threshold "lat,<=,25.0,8;lat,>=,0.0,8" |
91 | 76 | rm ${result_dir}aew_${file_name}.txt |
92 | 77 |
|
93 | | -#/global/homes/p/paullric/tempestextremes/bin/HistogramNodes --in ${result_dir}aew_stitch_5e-6_${file_name}.dat --iloncol 2 --ilatcol 3 --nlat 256 --nlon 512 --out ${result_dir}aew_hist_${file_name}.nc |
94 | 78 | HistogramNodes --in ${result_dir}aew_stitch_5e-6_${file_name}.dat --iloncol 2 --ilatcol 3 --nlat 256 --nlon 512 --out ${result_dir}aew_hist_${file_name}.nc |
| 79 | + |
95 | 80 | rm ${result_dir}*out.dat00*.dat |
96 | 81 | rm ${result_dir}${caseid}*.nc |
97 | 82 | rm ${result_dir}*.txt |
98 | | -mv $result_dir $result_dir_fin |
99 | 83 |
|
100 | 84 | exit |
0 commit comments