This GitLab instance is undergoing maintenance and is operating in read-only mode.

You are on a read-only GitLab instance.
tseries_lnd_h0.sh 2.69 KB
Newer Older
1
2
3
4
5
6
7
8
9
#!/bin/bash

freq=h0

if test -a $h0lnd_path/${case}.${lnd}.${freq}.${year_start}-01.nc; then
echo "make time series of monthly average lnd data for $ivar"
if [ "$version" == "cesm1" ]; then
ncrcat -O -v mcdate,time,$ivar $h0lnd_path/${case}.${lnd}.${freq}.*.nc $outpath/lnd/tseries/$case.$lnd.${freq}.$ivar.nc
elif [ "$version" == "e3sm" ]; then
10
ncrcat -O -v mcdate,time,gris_area,gris_mask,$ivar $h0lnd_path/${case}.${lnd}.${freq}.*.nc $outpath/lnd/tseries/$case.$lnd.${freq}.$ivar.nc
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
fi

if test -a $outpath/lnd/tseries/${case}.$lnd.${freq}.$ivar.nc; then
        echo "Monthly $lnd averages of $ivar made"
else
        echo "Monthly $lnd averages of $ivar failed"
        exit
fi
else
        echo "File $h0lnd_path/$case.$lnd.${freq}.${year_start}-01.nc does not exist"
        echo "No time series or monthly averages made"

fi

echo "make yearly average time series from monthly average time series of $ivar"
ncra --mro -O -h -d time,,,12,12 $outpath/lnd/tseries/$case.$lnd.${freq}.$ivar.nc $outpath/lnd/tseries/$case.$lnd.${freq}.yrly.${ivar}.nc

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

 echo "add mask and area variables to yearly averaged lnd data for $ivar"
31
 ncks -A -v gris_mask,gris_area $outpath/masks/$case.$lnd.gris_mask.nc $outpath/lnd/tseries/$case.$lnd.${freq}.yrly.$ivar.nc 
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
 ncks -A -v PCT_GLC_ICESHEET $base/surfdata_0.9x1.25_lat_lon_simyr1850_c180218.nc $outpath/lnd/tseries/$case.$lnd.${freq}.yrly.$ivar.nc 
 
 ncap2 -O -s 'areaice=PCT_GLC_ICESHEET*0.01*area' $outpath/lnd/tseries/$case.$lnd.${freq}.yrly.$ivar.nc -o $outpath/lnd/tseries/$case.$lnd.${freq}.yrly_ai.$ivar.nc 

echo "average over ice sheet region for yearly averaged lnd data for $ivar"
ncwa -O -a lat,lon -w areaice -B "gris_mask == 1" $outpath/lnd/tseries/$case.$lnd.${freq}.yrly_ai.$ivar.nc $outpath/lnd/tseries/$case.$lnd.aavg.${freq}.yrly_ai.$ivar.nc

if test -a $outpath/lnd/tseries/${case}.$lnd.aavg.${freq}.yrly_ai.$ivar.nc; then
        echo "Global avg yearly masked $lnd averages of $ivar made"
else
        echo "Global avg yearly masked $lnd averages of $ivar failed"
	exit
fi


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

49
50
51
#for fl in $outpath/lnd/tseries/*clm2.h0.yrly*; do
#ncks -A -C -v gris_mask $mask_file $fl
#done
52
53

echo "average over ice sheet region for yearly averaged lnd data for $ivar"
54
ncwa -O -a lat,lon -w gris_area -B "gris_mask == 1" $outpath/lnd/tseries/$case.$lnd.${freq}.yrly.$ivar.nc $outpath/lnd/tseries/$case.$lnd.aavg.${freq}.yrly.$ivar.nc
55
56
57
58
59
60
61
62
63
64
65
66

if test -a $outpath/lnd/tseries/${case}.$lnd.aavg.${freq}.yrly.$ivar.nc; then
        echo "Global avg yearly masked $lnd averages of $ivar made"
else
        echo "Global avg yearly masked $lnd averages of $ivar failed"
	exit
fi

fi # if CESM or E3SM

echo "$ivar yearly $lnd time series complete"