lnd.sh 4.13 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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
#!/bin/bash

# land

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

if [ "$version" == "e3sm" ]; then
#ncwa -a -time $outpath/masks/mask_ne30np4_lnd.nc $outpath/masks/mask_ne30np4_lnd_notime.nc 
#for fl in $path/lnd/hist/*h0*; do
#echo "first add mask in original grid to monthly lnd output in $fl"
#ncks -A -C -v gris_mask $outpath/masks/mask_ne30np4_lnd_notime.nc $fl
#done

# regridding step to regrid to lat lon, currently regrids all years even if not requested
#h0lnd_path=$outpath/lnd/hist_regrid
#mkdir -p "$h0lnd_path"
#ls $path/lnd/hist/*h0* | ncremap -m $map_file -O $h0lnd_path
h0lnd_path=$path/archive/lnd/hist

else 
h0lnd_path=$path/lnd/hist
fi

echo "make land h0 climos"
mkdir -p "$outpath/lnd/climos"

ncclimo -c $case -s ${year_start} -e ${year_end} -m ${lnd} -i ${h0lnd_path} -o ${outpath}/lnd/climos
if test -a $outpath/lnd/climos/${case}_ANN_climo.nc; then
       	echo "File $outpath/lnd/climos/${case}_ANN_climo.nc exists"
else
       	echo "File $outpath/lnd/climos/${case}_ANN_climo.nc does not exist"
	exit
fi

if [ "$version" == "cesm1" ]; then

h0lnd_path=$outpath/lnd/climos

echo "average land monthly climos over ice sheet region"
ncwa -O -a lat,lon -w area -B "gris_mask == 1" $outpath/lnd/climos/${case}_ANN_climo.nc $outpath/lnd/climos/${case}_ANN_aavg_climo.nc
ncwa -O -a lat,lon -w area -B "gris_mask == 1" $outpath/lnd/climos/${case}_JJA_climo.nc $outpath/lnd/climos/${case}_JJA_aavg_climo.nc
ncwa -O -a lat,lon -w area -B "gris_mask == 1" $outpath/lnd/climos/${case}_DJF_climo.nc $outpath/lnd/climos/${case}_DJF_aavg_climo.nc

mkdir -p "$outpath/lnd/davg"

#echo "make annualized daily averages for land for all variables"
#ls $path/lnd/hist/$case.$lnd.h1.*.nc |  /ccs/home/zender/bin_rhea/ncclimo --job_nbr=12 -c $case -C dly -s ${year_start} -e ${year_end} -o $outpath/lnd/davg -m $lnd 
#/ccs/home/zender/bin_rhea/ncclimo --job_nbr=12 -c $case -C dly -s ${year_start} -e ${year_end} -o $outpath/lnd/davg -m $lnd -i $path/lnd/hist


#echo "loop over each variable to create and process time series for h1 vars"
#qsub rhea_tseries_lnd.sh 

#for ivar in "${lnd_h1_vars[@]}"
#do
#echo $ivar

#echo "concatenate all daily dates to be averaged into annualized land time series for $ivar"
#ncrcat -O -F -v $ivar $outpath/lnd/davg/*$year_start*$year_end*_climo.nc $outpath/lnd/davg/$case.$lnd.h1.$ivar.davg.${year_start}-${year_end}.nc
#
#echo "add mask and area variables to annualized daily land averages for $ivar"
#ncks -A -v gris_mask,area $outpath/masks/$case.$lnd.gris_mask.nc $outpath/lnd/davg/$case.$lnd.h1.$ivar.davg.${year_start}-${year_end}.nc

#echo "average over ice sheet region for annualized avgd daily land values for $ivar"
#ncwa -O -a lat,lon -w area -B "gris_mask == 1" $outpath/lnd/davg/$case.$lnd.h1.$ivar.davg.${year_start}-${year_end}.nc $outpath/lnd/davg/$case.$lnd.h1.$ivar.davg.aavg.${year_start}-${year_end}.nc
#

#if test -a $outpath/lnd/davg/$case.$lnd.h1.$ivar.davg.aavg.${year_start}-${year_end}.nc; then
#        echo "Annualized daily masked $lnd area averages made"
#else
#        echo "Annualized daily masked $lnd area averages failed"
#       exit
#fi

#done

elif [ "$version" == "e3sm" ]; then

for fl in $outpath/lnd/climos/*.nc; do
echo "add mask in original grid to climos in $fl"
ncks -A -C -v gris_mask $outpath/masks/mask_ne30np4_lnd_notime.nc $fl
done

# regrid climos to lat lon
climos_path=$outpath/lnd/climo_regrid
mkdir -p "$climos_path"

echo " remapping these land climo files"
ls $outpath/lnd/climos/*_climo* 
ls $outpath/lnd/climos/*_climo* | ncremap -m $map_file -O $climos_path

echo "average land monthly climos over ice sheet region"
ncwa -O -a lat,lon -w area -B "gris_mask == 1" $climos_path/${case}_ANN_climo.nc $climos_path/${case}_ANN_aavg_climo.nc
ncwa -O -a lat,lon -w area -B "gris_mask == 1" $climos_path/${case}_JJA_climo.nc $climos_path/${case}_JJA_aavg_climo.nc
ncwa -O -a lat,lon -w area -B "gris_mask == 1" $climos_path/${case}_DJF_climo.nc $climos_path/${case}_DJF_aavg_climo.nc

fi

echo "loop over each variable to create and process time series for h0 vars"
mkdir -p "$outpath/lnd/tseries"

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

. tseries_lnd_h0.sh 

done

echo "LAND POSTPROCESSING COMPLETE"
echo "  "

fi # to postprocess or not