-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmask_lowlandrange.sh
executable file
·144 lines (123 loc) · 4.7 KB
/
mask_lowlandrange.sh
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
#!/bin/bash
#################### INPUT ARGUMENT: VARIABLE,BASIN,MODEL,SCENARIO ############################################################################
## /home/raid9/gergel/agg_snowpack
variable=$1
basin=$2
model=$3
scenario=$4
season=$5
#### format of filename depends on which variable it is
if [ "SWE" = "$variable" ]
then
timecalc="monday1"
elif [ "TotalSoilMoist" = "$variable" ]
then
#timecalc="monday1"
timecalc="monmean" ## changed for average soil moisture
elif [ "pr" = "$variable" ] || [ "petNatVeg" = "$variable" ] || [ "petShort" = "$variable" ] || [ "petTall" = "$variable" ] || [ "Transp" = "$variable" ] || [ "Evaporation" = "$variable" ]
then
timecalc="monsum"
else
timecalc="monmean"
fi
if [ "CCSM4" = "$model" ]
then
modnum="r6i1p1"
else
modnum="r1i1p1"
fi
#### and which scenario it is
if [ "historical" = "$scenario" ]
then
years="1950_2005"
else
years="2006_2099"
fi
#### filename
if [ "pr" = "$variable" ] || [ "tasmin" = "$variable" ] || [ "tasmax" = "$variable" ]
then
inputfile="/raid9/gergel/agg_snowpack/is_summ/cat.WUS.summ.diana.tight/${model}_${scenario}_${variable}.${timecalc}.nc"
else
inputfile="/raid9/gergel/agg_snowpack/is_summ/${model}_${modnum}_${scenario}_monthly.rec/vic_${variable}_${model}_${modnum}_${scenario}_${years}_WUSA_monthly_${timecalc}.nc"
fi
tmp="/raid9/gergel/agg_snowpack/goodleap/tmp_${model}_${variable}_${scenario}.nc"
if [ "TotalSoilMoist" = "$variable" ]
then
outputfile="/raid9/gergel/agg_snowpack/goodleap/${basin}/${model}__${scenario}.${timecalc}.${variable}.${years}_${basin}_summer.nc"
else
outputfile="/raid9/gergel/agg_snowpack/goodleap/${basin}/${model}__${scenario}.${timecalc}.${variable}.${years}_${basin}_${season}.nc"
fi
###################################### RUN THIS PART TO REGRID FORCING FILES AND COMMENT OUT THE BOTTOM CDO PART #############################################################
## reset grid from generic to latlon
## cdo setgrid,$grid $inputfile $output
##############################################################################################################################################################################
#### lat lon boundaries depend on mtn range
if [ "$variable" = "TotalSoilMoist" ] && [ "$basin" = "coastalnorth" ]
then
cdo selmon,6,7,8 $inputfile $tmp
elif [ "$variable" = "TotalSoilMoist" ] && [ "$basin" != "coastalnorth" ]
then
echo "now processing $inputfile with cdo selmon"
cdo selmon,6,7,8 $inputfile $outputfile
elif [ "$variable" = "pr" ] || [ "$variable" = "tasmax" ] || [ "$variable" = "tasmin" ] && [ "$basin" = "coastalnorth" ] || [ "$basin" = "cascades" ] || [ "$basin" = "california" ] || [ "$basin" = "northernrockies" ] || [ "$basin" = "southernrockies" ] || [ "$basin" = "whites" ]
then
if [ "$season" = "mam" ]
then
echo "processing $inputfile with mam"
cdo selmon,3,4,5 $inputfile $tmp
elif [ "$season" = "jja" ]
then
echo "processing $inputfile with jja"
cdo selmon,6,7,8 $inputfile $tmp
elif [ "$season" = "winter" ]
then
echo "processing $inputfile with winter"
cdo selmon,11,12,1,2,3 $inputfile $tmp
else
echo "processing $inputfile with jja"
cdo selmon,6,7,8 $inputfile $tmp
fi
elif [ "$variable" = "pr" ] || [ "$variable" = "tasmin" ] || [ "$variable" = "tasmax" ] && [ "$basin" != "coastalnorth" ]
then
if [ "$season" = "mam" ]
then
echo "processing $inputfile with $basin mam"
cdo selmon,3,4,5 $inputfile $outputfile
elif [ "$season" = "jja" ]
then
echo "processing $inputfile with $basin jja"
cdo selmon,6,7,8 $inputfile $outputfile
elif [ "$season" = "winter" ]
then
echo "processing $inputfile with winter"
cdo selmon,11,12,1,2,3 $inputfile $outputfile
else
echo "processing $inputfile with $basin jja"
cdo selmon,6,7,8 $inputfile $outputfile
fi
fi
if [ "$basin" = "coastalnorth" ]
then
echo "now processing $inputfile with $basin mask"
cdo masklonlatbox,-124.5,-122,48,41.5 $tmp $outputfile
elif [ "$basin" = "northernrockies" ]
then
echo "now processing $inputfile with $basin mask"
cdo masklonlatbox,-119.5,-107.5,49.0,42.37 $tmp $outputfile
elif [ "$basin" = "southernrockies" ]
then
echo "now processing $inputfile with $basin mask"
cdo masklonlatbox,-113.0,-104.0,42.37,35.0 $tmp $outputfile
elif [ "$basin" = "whites" ]
then
echo "now processing $inputfile with $basin mask"
cdo masklonlatbox,-111,-108,36,32 $tmp $outputfile
elif [ "$basin" = "cascades" ]
then
echo "now processing $inputfile with $basin mask"
cdo masklonlatbox,-123.25,-119.5,49.0,41.5 $tmp $outputfile
elif [ "$basin" = "california" ]
then
echo "now processing $inputfile with $basin mask"
cdo masklonlatbox,-122.5,-117,41.5,34.5 $tmp $outputfile
fi