Commit 4a9051e3 authored by Evans, Katherine's avatar Evans, Katherine
Browse files

put atm obs processing in its own directory

parent 26267d0c
#!/bin/bash
# atmosphere obs data processing
datasets=("CLOUDSAT" "ISCCP")
for dataset in "${datasets[@]}"
do
# to get this working, need to apply to all climos and using cesm1/e3sm specific mask file that has already been created
#echo "remapping ${dataset} climos onto CESM grid"
#file_w_data_on_source_grid=$outpath/masks/${case}.clm2.gris_mask.nc
#ncremap -i $file_w_data_on_source_grid -V CLDTOT -a bilinear -d /lustre/atlas1/cli900/world-shared/cesm/obs_data/${dataset}_01_climo.nc -v gris_mask -o $obspath/$case.gris_mask_${dataset}_grid.nc
done
for dataset in "${datasets[@]}"
do
echo "add mask and area variables to annualized daily averages"
ncks -A -v gris_mask,gw $obspath/$case.gris_mask_${dataset}_grid.nc $obspath/${dataset}_ANN_climo.nc
ncks -A -v gris_mask,gw $obspath/$case.gris_mask_${dataset}_grid.nc $obspath/${dataset}_DJF_climo.nc
ncks -A -v gris_mask,gw $obspath/$case.gris_mask_${dataset}_grid.nc $obspath/${dataset}_JJA_climo.nc
ncks -A -v gris_mask,gw $obspath/$case.gris_mask_${dataset}_grid.nc $obspath/${dataset}_01_climo.nc
ncks -A -v gris_mask,gw $obspath/$case.gris_mask_${dataset}_grid.nc $obspath/${dataset}_02_climo.nc
ncks -A -v gris_mask,gw $obspath/$case.gris_mask_${dataset}_grid.nc $obspath/${dataset}_03_climo.nc
ncks -A -v gris_mask,gw $obspath/$case.gris_mask_${dataset}_grid.nc $obspath/${dataset}_04_climo.nc
ncks -A -v gris_mask,gw $obspath/$case.gris_mask_${dataset}_grid.nc $obspath/${dataset}_05_climo.nc
ncks -A -v gris_mask,gw $obspath/$case.gris_mask_${dataset}_grid.nc $obspath/${dataset}_06_climo.nc
ncks -A -v gris_mask,gw $obspath/$case.gris_mask_${dataset}_grid.nc $obspath/${dataset}_07_climo.nc
ncks -A -v gris_mask,gw $obspath/$case.gris_mask_${dataset}_grid.nc $obspath/${dataset}_08_climo.nc
ncks -A -v gris_mask,gw $obspath/$case.gris_mask_${dataset}_grid.nc $obspath/${dataset}_09_climo.nc
ncks -A -v gris_mask,gw $obspath/$case.gris_mask_${dataset}_grid.nc $obspath/${dataset}_10_climo.nc
ncks -A -v gris_mask,gw $obspath/$case.gris_mask_${dataset}_grid.nc $obspath/${dataset}_11_climo.nc
ncks -A -v gris_mask,gw $obspath/$case.gris_mask_${dataset}_grid.nc $obspath/${dataset}_12_climo.nc
echo "average over ice sheet region for cloud data"
ncwa -O -a lat,lon -w area -B "gris_mask == 1" $obspath/${dataset}_ANN_climo.nc $obspath/${dataset}_ANN_aavg_climo.nc
ncwa -O -a lat,lon -w area -B "gris_mask == 1" $obspath/${dataset}_JJA_climo.nc $obspath/${dataset}_JJA_aavg_climo.nc
ncwa -O -a lat,lon -w area -B "gris_mask == 1" $obspath/${dataset}_DJF_climo.nc $obspath/${dataset}_DJF_aavg_climo.nc
ncwa -O -a lat,lon -w area -B "gris_mask == 1" $obspath/${dataset}_01_climo.nc $obspath/${dataset}_01_aavg_climo.nc
ncwa -O -a lat,lon -w area -B "gris_mask == 1" $obspath/${dataset}_02_climo.nc $obspath/${dataset}_02_aavg_climo.nc
ncwa -O -a lat,lon -w area -B "gris_mask == 1" $obspath/${dataset}_03_climo.nc $obspath/${dataset}_03_aavg_climo.nc
ncwa -O -a lat,lon -w area -B "gris_mask == 1" $obspath/${dataset}_04_climo.nc $obspath/${dataset}_04_aavg_climo.nc
ncwa -O -a lat,lon -w area -B "gris_mask == 1" $obspath/${dataset}_05_climo.nc $obspath/${dataset}_05_aavg_climo.nc
ncwa -O -a lat,lon -w area -B "gris_mask == 1" $obspath/${dataset}_06_climo.nc $obspath/${dataset}_06_aavg_climo.nc
ncwa -O -a lat,lon -w area -B "gris_mask == 1" $obspath/${dataset}_07_climo.nc $obspath/${dataset}_07_aavg_climo.nc
ncwa -O -a lat,lon -w area -B "gris_mask == 1" $obspath/${dataset}_08_climo.nc $obspath/${dataset}_08_aavg_climo.nc
ncwa -O -a lat,lon -w area -B "gris_mask == 1" $obspath/${dataset}_09_climo.nc $obspath/${dataset}_09_aavg_climo.nc
ncwa -O -a lat,lon -w area -B "gris_mask == 1" $obspath/${dataset}_10_climo.nc $obspath/${dataset}_10_aavg_climo.nc
ncwa -O -a lat,lon -w area -B "gris_mask == 1" $obspath/${dataset}_11_climo.nc $obspath/${dataset}_11_aavg_climo.nc
ncwa -O -a lat,lon -w area -B "gris_mask == 1" $obspath/${dataset}_12_climo.nc $obspath/${dataset}_12_aavg_climo.nc
done
#!/bin/bash
module load nco/4.6.9
#var=("t2m")
var=("t2m" "swsn" "swsd" "lwsn" "lwsd" "smb" "latf" "senf" "gbot" "alb")
casename=racmo23_GRN_monthly
file_start_year=1958
start_year=1980
end_year=1999
hist_path=$base/$casename
lndpath=$hist_path/climos
outseries=$hist_path/tseries
mask_file=RACMO23_masks_ZGRN11_latlon.nc
gris_pcnt_file=greenland_percent_coverage_latlon.nc
for ivar in "${var[@]}"
do
echo "make RACMO23 climos for" $ivar
filename=${ivar}.1958-2013.BN_1958_2013.MM.nc
outfile=$casename.${ivar}.$start_year-$end_year
tseries_file=$casename.${ivar}.ann_tseries
mkdir -p "$outseries"
mkdir -p "$lndpath"
#cd "$hist_path"
let "go=($start_year-$file_start_year)*12"
let "stop=($end_year-$file_start_year)*12"
month=("01" "02" "03" "04" "05" "06" "07" "8" "9" "10" "11" "12")
for m in "${month[@]}"
do
# set the time to start averging to $go
mon=$go
# set the time to start averging for each month
let mon="($go+$m)"
ncra -O -h -F -d time,$mon,$stop,12 $hist_path/$filename $lndpath/$outfile.$m.nc
# -F = fortran indexing (starts with 1)
# -O
# -h keep history
# -d dimension
done
#stupid fix because bash bug with 07 08 and 09 sometimes
mv -f $lndpath/$outfile.8.nc $lndpath/$outfile.08.nc
mv -f $lndpath/$outfile.9.nc $lndpath/$outfile.09.nc
if [ "$ivar" == "smb" ]; then
echo "create DJF sum to get mmWE/season or year $ivar"
ncra -O -y ttl -h -F $lndpath/$outfile.12.nc $lndpath/$outfile.01.nc $lndpath/$outfile.02.nc $lndpath/$outfile.DJF.nc
echo "create JJA sum $ivar"
ncra -O -y ttl -h -F $lndpath/$outfile.06.nc $lndpath/$outfile.07.nc $lndpath/$outfile.08.nc $lndpath/$outfile.JJA.nc
echo "create ANN sum $ivar"
ncra -O -y ttl -h -F $lndpath/$outfile.01.nc $lndpath/$outfile.02.nc $lndpath/$outfile.03.nc \
$lndpath/$outfile.04.nc $lndpath/$outfile.05.nc $lndpath/$outfile.06.nc \
$lndpath/$outfile.07.nc $lndpath/$outfile.08.nc $lndpath/$outfile.09.nc \
$lndpath/$outfile.10.nc $lndpath/$outfile.11.nc $lndpath/$outfile.12.nc \
$lndpath/$outfile.ANN.nc
else
# all others are monthly averaged
echo "create DJF avg $ivar"
ncra -O -h -F $lndpath/$outfile.12.nc $lndpath/$outfile.01.nc $lndpath/$outfile.02.nc $lndpath/$outfile.DJF.nc
echo "create JJA avg $ivar"
ncra -O -h -F $lndpath/$outfile.06.nc $lndpath/$outfile.07.nc $lndpath/$outfile.08.nc $lndpath/$outfile.JJA.nc
echo "create ANN avg/month"
ncra -O -h -F $lndpath/$outfile.01.nc $lndpath/$outfile.02.nc $lndpath/$outfile.03.nc \
$lndpath/$outfile.04.nc $lndpath/$outfile.05.nc $lndpath/$outfile.06.nc \
$lndpath/$outfile.07.nc $lndpath/$outfile.08.nc $lndpath/$outfile.09.nc \
$lndpath/$outfile.10.nc $lndpath/$outfile.11.nc $lndpath/$outfile.12.nc \
$lndpath/$outfile.ANN.nc
fi
wait
echo "make annual time series for RACMO23 $ivar"
#uses nco's --mro, multi-record output feature see nco documentation section 3.18, -h retains history of commands
if [ "$ivar" == "smb" ]; then # make an annual sum not average for smb, since we want an integrated annual not avg flux
ncra --mro -O -y ttl -h -d time,,,12,12 $hist_path/$filename $outseries/${tseries_file}.nc
else # average other variables
ncra --mro -O -h -d time,,,12,12 $hist_path/$filename $outseries/${tseries_file}.nc
fi
echo "add mask and area variables to time series of $ivar"
ncks -A -v gridarea,GrIS_mask $hist_path/$mask_file -o $outseries/${tseries_file}.nc
#if [ "$ivar" == "smb" ]; then
#echo "average over ice sheet for $ivar without the percent of glacier"
#ncwa -O -a lat,lon -w gridarea -B "GrIS_mask == 1" $outseries/${tseries_file}.nc $outseries/${tseries_file}_aavg.nc
#
#else
echo "average over ice sheet for $ivar" without the percent of glacier
ncwa -O -a lat,lon -w gridarea -B "GrIS_mask == 1" $outseries/${tseries_file}.nc $outseries/${tseries_file}_aavg.nc
#fi
if test -a $outseries/${tseries_file}_aavg.nc; then
echo "Global avg annual time series of ${casename} made"
else
echo "Global avg annual time series of ${casename} NOT made"
exit
fi
done
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment