atm.sh 5.22 KB
Newer Older
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
#!/bin/bash

# atmosphere

if [ "$postprocess" = "true" ]; then

# regridding step to regrid to lat lon, currently regrids all years even if not requested
# this block can be removed once mask files are included in sim output
if [ "$version" == "e3sm" ]; then

#in the event you get a mask file with a time dimension, remove it first
#ncwa -a -time $outpath/masks/mask_ne30np4.nc tmp.nc 
#ncks -x -v time tmp.nc $outpath/masks/mask_ne30np4_notime.nc

for fl in $path/atm/hist/*h0*; do
echo "first add mask in original grid to monthly atm output in $fl"
ncks --no_tmp_fl -A -C -v gris_mask $mask_file $fl 
done
fi

h0atm_path=$outpath/atm/hist_regrid
mkdir -p "$h0atm_path"
ls $path/atm/hist/*h0* | ncremap -m $map_file -O $h0atm_path

else
h0atm_path=$path/atm/hist

fi

#run a check, is the requested data directory there?
if test -d $h0atm_path; then
        echo "Directory $h0atm_path exists"
else
        echo "Target directory $h0atm_path does not exist, you prob need to activate remapping"
        exit
fi

echo "make atm climos"
mkdir -p $outpath/atm/climos
ncclimo -a sdd -c ${case} -s ${year_start} -e ${year_end} -m ${atm} -i ${h0atm_path} -o ${outpath}/atm/climos

if test -a $outpath/atm/climos/${case}_ANN_climo.nc; then
      	echo "File $outpath/atm/climos/${case}_ANN_climo.nc exists"
else
      	echo "File $outpath/atm/climos/${case}_ANN_climo.nc does not exist"
	exit
fi

if [ "$version" == "cesm1" ]; then
echo "add mask and area variables to monthly atm climos"
ncks -A -v gris_mask,area $outpath/masks/$case.$lnd.gris_mask.nc $outpath/atm/climos/${case}_ANN_climo.nc
ncks -A -v gris_mask,area $outpath/masks/$case.$lnd.gris_mask.nc $outpath/atm/climos/${case}_DJF_climo.nc
ncks -A -v gris_mask,area $outpath/masks/$case.$lnd.gris_mask.nc $outpath/atm/climos/${case}_JJA_climo.nc
ncks -A -v gris_mask,area $outpath/masks/$case.$lnd.gris_mask.nc $outpath/atm/climos/${case}_01_climo.nc
ncks -A -v gris_mask,area $outpath/masks/$case.$lnd.gris_mask.nc $outpath/atm/climos/${case}_02_climo.nc
ncks -A -v gris_mask,area $outpath/masks/$case.$lnd.gris_mask.nc $outpath/atm/climos/${case}_03_climo.nc
ncks -A -v gris_mask,area $outpath/masks/$case.$lnd.gris_mask.nc $outpath/atm/climos/${case}_04_climo.nc
ncks -A -v gris_mask,area $outpath/masks/$case.$lnd.gris_mask.nc $outpath/atm/climos/${case}_05_climo.nc
ncks -A -v gris_mask,area $outpath/masks/$case.$lnd.gris_mask.nc $outpath/atm/climos/${case}_06_climo.nc
ncks -A -v gris_mask,area $outpath/masks/$case.$lnd.gris_mask.nc $outpath/atm/climos/${case}_07_climo.nc
ncks -A -v gris_mask,area $outpath/masks/$case.$lnd.gris_mask.nc $outpath/atm/climos/${case}_08_climo.nc
ncks -A -v gris_mask,area $outpath/masks/$case.$lnd.gris_mask.nc $outpath/atm/climos/${case}_09_climo.nc
ncks -A -v gris_mask,area $outpath/masks/$case.$lnd.gris_mask.nc $outpath/atm/climos/${case}_10_climo.nc
ncks -A -v gris_mask,area $outpath/masks/$case.$lnd.gris_mask.nc $outpath/atm/climos/${case}_11_climo.nc
ncks -A -v gris_mask,area $outpath/masks/$case.$lnd.gris_mask.nc $outpath/atm/climos/${case}_12_climo.nc
fi

echo "average over ice sheet region of atm climos "
ncwa -O -a lat,lon -w area -B "gris_mask == 1" $outpath/atm/climos/${case}_ANN_climo.nc $outpath/atm/climos/${case}_ANN_aavg_climo.nc 
ncwa -O -a lat,lon -w area -B "gris_mask == 1" $outpath/atm/climos/${case}_JJA_climo.nc $outpath/atm/climos/${case}_JJA_aavg_climo.nc 
ncwa -O -a lat,lon -w area -B "gris_mask == 1" $outpath/atm/climos/${case}_DJF_climo.nc $outpath/atm/climos/${case}_DJF_aavg_climo.nc 
ncwa -O -a lat,lon -w area -B "gris_mask == 1" $outpath/atm/climos/${case}_01_climo.nc $outpath/atm/climos/${case}_01_aavg_climo.nc 
ncwa -O -a lat,lon -w area -B "gris_mask == 1" $outpath/atm/climos/${case}_02_climo.nc $outpath/atm/climos/${case}_02_aavg_climo.nc 
ncwa -O -a lat,lon -w area -B "gris_mask == 1" $outpath/atm/climos/${case}_03_climo.nc $outpath/atm/climos/${case}_03_aavg_climo.nc 
ncwa -O -a lat,lon -w area -B "gris_mask == 1" $outpath/atm/climos/${case}_04_climo.nc $outpath/atm/climos/${case}_04_aavg_climo.nc 
ncwa -O -a lat,lon -w area -B "gris_mask == 1" $outpath/atm/climos/${case}_05_climo.nc $outpath/atm/climos/${case}_05_aavg_climo.nc 
ncwa -O -a lat,lon -w area -B "gris_mask == 1" $outpath/atm/climos/${case}_06_climo.nc $outpath/atm/climos/${case}_06_aavg_climo.nc 
ncwa -O -a lat,lon -w area -B "gris_mask == 1" $outpath/atm/climos/${case}_07_climo.nc $outpath/atm/climos/${case}_07_aavg_climo.nc 
ncwa -O -a lat,lon -w area -B "gris_mask == 1" $outpath/atm/climos/${case}_08_climo.nc $outpath/atm/climos/${case}_08_aavg_climo.nc 
ncwa -O -a lat,lon -w area -B "gris_mask == 1" $outpath/atm/climos/${case}_09_climo.nc $outpath/atm/climos/${case}_09_aavg_climo.nc 
ncwa -O -a lat,lon -w area -B "gris_mask == 1" $outpath/atm/climos/${case}_10_climo.nc $outpath/atm/climos/${case}_10_aavg_climo.nc 
ncwa -O -a lat,lon -w area -B "gris_mask == 1" $outpath/atm/climos/${case}_11_climo.nc $outpath/atm/climos/${case}_11_aavg_climo.nc 
ncwa -O -a lat,lon -w area -B "gris_mask == 1" $outpath/atm/climos/${case}_12_climo.nc $outpath/atm/climos/${case}_12_aavg_climo.nc 

echo "make yearly time series for atm h0 data"
mkdir -p $outpath/atm/tseries

for ivar in "${atm_vars[@]}"
do

. tseries_atm_h0.sh 

done

        echo "ATM POSTPROCESSING COMPLETE "
        echo " "

fi # to postprocess or not