Skip to content

Commit 6b0a245

Browse files
make --closedcontourcmd resolution specific (#824)
* make --closedcontourcmd resolution specific * use pm-cpu * update syntax, add data path for v3 * update example * update tc_analysis pre-processing and run scripts
1 parent ad1e7ce commit 6b0a245

File tree

3 files changed

+57
-45
lines changed

3 files changed

+57
-45
lines changed

auxiliary_tools/run_tc_analysis.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import os
2+
from e3sm_diags.parameter.core_parameter import CoreParameter
3+
from e3sm_diags.parameter.tc_analysis_parameter import TCAnalysisParameter
4+
from e3sm_diags.run import runner
5+
6+
simulations = ['tc-v2.LR.amip.2000_2014']
7+
sim_names = ['v2.LR.amip_0101']
8+
9+
data_path = '/global/homes/c/chengzhu/tests/tc_analysis/'
10+
11+
for idx, sim in enumerate(simulations):
12+
print(sim)
13+
param = CoreParameter()
14+
param.test_data_path = data_path+sim
15+
param.test_name = sim_names[idx]
16+
param.test_start_yr = "2000"
17+
param.test_end_yr = "2014"
18+
19+
param.reference_data_path = '/global/cfs/cdirs/e3sm/diagnostics/observations/Atm/tc-analysis'
20+
param.ref_start_yr = '1979'
21+
param.ref_end_yr = '2018'
22+
23+
prefix = f'/global/cfs/cdirs/e3sm/www/chengzhu/tc_analysis_test/'
24+
param.results_dir = os.path.join(prefix, sim)
25+
runner.sets_to_run = ['tc_analysis']
26+
runner.run_diags([param])

examples/use_zppy_to_run_e3sm_diags/zstash_extract_E3SM_data_from_NERSC_HPSS.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
# $ screen
88

99
# Active e3sm_unified to use zstash
10-
source /global/common/software/e3sm/anaconda_envs/load_latest_e3sm_unified_cori-haswell.sh
10+
source /global/common/software/e3sm/anaconda_envs/load_latest_e3sm_unified_pm-cpu.sh
1111

1212
# Make a new folder to recieve extracted datasets.
1313
mkdir -p /global/cfs/cdirs/e3smpub/E3SM_simulations/v2.LR.historical_0101
@@ -18,6 +18,8 @@ cd /global/cfs/cdirs/e3smpub/E3SM_simulations/v2.LR.historical_0101
1818

1919
# retrive h0(monthly) atmospheric data, size = 821 G
2020
zstash extract --hpss=/home/projects/e3sm/www/WaterCycle/E3SMv2/LR/v2.LR.historical_0101 "archive/atm/hist/*h0*"
21+
# retrive h1(daily) atmospheric data
22+
zstash extract --hpss=/home/projects/e3sm/www/WaterCycle/E3SMv2/LR/v2.LR.historical_0101 "archive/atm/hist/*h1*"
2123
# retrive h2(6 hourly) atmospheric data, size = 195 G [Optional] only needed for Tropical Cycle Analysis
2224
zstash extract --hpss=/home/projects/e3sm/www/WaterCycle/E3SMv2/LR/v2.LR.historical_0101 "archive/atm/hist/*h2*"
2325
# retrive h4(3 hourly) atmospheric data, size = 195 G [Optional] only needed for Diurnal Cycle of Precipitation
Lines changed: 28 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,100 +1,84 @@
11
#!/bin/bash
22

33
# 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
66

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
88

99
#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}/
1915

2016
#res = 30/120 for ne30/ne120 grids
2117
res=30 # res = 30/120 for ne30/ne120 grids
2218
pg2=true # Set false for v1 production simulations
2319
atm_name="eam" # Use "cam" for v1 production simulations
2420

2521

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-
4022
mkdir -p $result_dir
4123
file_name=${caseid}_${start}_${end}
4224

4325
# 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:
4826
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
5030
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"
5135
fi
5236
echo $out_type
5337
# 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
5538
GenerateConnectivityFile --in_mesh ${result_dir}outCSne$res.g --out_type $out_type --out_connect ${result_dir}connect_CSne${res}_v2.dat
5639

5740
# Get the list of files
5841
cd ${drc_in};eval ls ${drc_in}/${caseid}.$atm_name.h2.*{${start}..${end}}*.nc >${result_dir}inputfile_${file_name}.txt
5942
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
6243

6344
cd ${result_dir}
6445
# Detection threshold including:
6546
# 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
6858

6959
cat ${result_dir}out.dat0* > ${result_dir}cyclones_${file_name}.txt
7060

7161
# 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"
7362
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"
7463
rm ${result_dir}cyclones_${file_name}.txt
7564

7665
# 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
7866
HistogramNodes --in ${result_dir}cyclones_stitch_${file_name}.dat --iloncol 2 --ilatcol 3 --out ${result_dir}cyclones_hist_${file_name}.nc
7967

8068
# 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
8370
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
8471

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
8672
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
8773
cat ${result_dir}aew_out.dat0* > ${result_dir}aew_${file_name}.txt
8874

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"
9075
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"
9176
rm ${result_dir}aew_${file_name}.txt
9277

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
9478
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+
9580
rm ${result_dir}*out.dat00*.dat
9681
rm ${result_dir}${caseid}*.nc
9782
rm ${result_dir}*.txt
98-
mv $result_dir $result_dir_fin
9983

10084
exit

0 commit comments

Comments
 (0)