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

added functionality to process a land only case with active glc - no glc yet

parent e6bcfdff
......@@ -3,7 +3,7 @@
This directory holds subdirectories with scripts that will postprocess model data for use in creating the plots and data used by LIVVkit. There are also scripts to processed observation data useful for any model analysis.
These script environments take raw output from either a stand alone ice sheet model (e.g. cism-albany)
or a coupled climate model (e.g. cesm1p2, e3sm (in beta testing))
or a coupled climate model (e.g. cesm1p2, e3sm1p0 (in beta testing))
To enable or update the scripts to work on a given machine, alter the main scripts in the target model
subdirectory to load the necessary software.
......
......@@ -18,21 +18,21 @@ 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
ncks -A -v gris_mask,area,gw $obspath/$case.gris_mask_${dataset}_grid.nc $obspath/${dataset}_ANN_climo.nc
ncks -A -v gris_mask,gris_area,gw $obspath/$case.gris_mask_${dataset}_grid.nc $obspath/${dataset}_DJF_climo.nc
ncks -A -v gris_mask,area,gw $obspath/$case.gris_mask_${dataset}_grid.nc $obspath/${dataset}_JJA_climo.nc
ncks -A -v gris_mask,area,gw $obspath/$case.gris_mask_${dataset}_grid.nc $obspath/${dataset}_01_climo.nc
ncks -A -v gris_mask,area,gw $obspath/$case.gris_mask_${dataset}_grid.nc $obspath/${dataset}_02_climo.nc
ncks -A -v gris_mask,area,gw $obspath/$case.gris_mask_${dataset}_grid.nc $obspath/${dataset}_03_climo.nc
ncks -A -v gris_mask,area,gw $obspath/$case.gris_mask_${dataset}_grid.nc $obspath/${dataset}_04_climo.nc
ncks -A -v gris_mask,area,gw $obspath/$case.gris_mask_${dataset}_grid.nc $obspath/${dataset}_05_climo.nc
ncks -A -v gris_mask,area,gw $obspath/$case.gris_mask_${dataset}_grid.nc $obspath/${dataset}_06_climo.nc
ncks -A -v gris_mask,area,gw $obspath/$case.gris_mask_${dataset}_grid.nc $obspath/${dataset}_07_climo.nc
ncks -A -v gris_mask,area,gw $obspath/$case.gris_mask_${dataset}_grid.nc $obspath/${dataset}_08_climo.nc
ncks -A -v gris_mask,area,gw $obspath/$case.gris_mask_${dataset}_grid.nc $obspath/${dataset}_09_climo.nc
ncks -A -v gris_mask,area,gw $obspath/$case.gris_mask_${dataset}_grid.nc $obspath/${dataset}_10_climo.nc
ncks -A -v gris_mask,area,gw $obspath/$case.gris_mask_${dataset}_grid.nc $obspath/${dataset}_11_climo.nc
ncks -A -v gris_mask,area,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
......
......@@ -6,7 +6,7 @@ if [ "$postprocess" = "true" ]; then
# regridding step to regrid to lat lon, currently regrids all years even if not requested
# this is not needed unless a mask file is needed in the sim output AND analysis of \hist, else regrid after climos made
if [ "$version" == "e3sm" ]; then
if [ "$version" == "e3sm_old" ]; then
#uncomment if you have a new mask file with a time dimension
#ncwa -a -time $outpath/masks/mask_ne30np4_lnd.nc $outpath/masks/mask_ne30np4_lnd_notime.nc
......@@ -40,31 +40,18 @@ 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
ncwa -O -a lat,lon -w gris_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 gris_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 gris_area -B "gris_mask == 1" $outpath/lnd/climos/${case}_DJF_climo.nc $outpath/lnd/climos/${case}_DJF_aavg_climo.nc
elif [ "$version" == "e3sm" ]; then
# only needed if no mask in sim output
#for fl in $outpath/lnd/climos/*.nc; do
#echo "add mask in original grid to climos in $fl"
#ncks -A -C -v gris_mask $mask_file $fl
#done
#echo " remapping these land climo files"
#climos_path=$outpath/lnd/climo_regrid
#mkdir -p "$climos_path"
#ls $outpath/lnd/climos/*_climo*
#ls $outpath/lnd/climos/*_climo* | ncremap -m $map_file -O $climos_path
climos_path=$outpath/lnd/climos
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
ncwa -O -a lat,lon -w gris_area -B "gris_mask == 1" $climos_path/${case}_ANN_climo.nc $climos_path/${case}_ANN_aavg_climo.nc
ncwa -O -a lat,lon -w gris_area -B "gris_mask == 1" $climos_path/${case}_JJA_climo.nc $climos_path/${case}_JJA_aavg_climo.nc
ncwa -O -a lat,lon -w gris_area -B "gris_mask == 1" $climos_path/${case}_DJF_climo.nc $climos_path/${case}_DJF_aavg_climo.nc
fi
......
......@@ -14,7 +14,8 @@ hist_path=$obspath/$casename
echo "$hist_path"
lndpath=$hist_path/climos
outseries=$hist_path/tseries
mask_file=RACMO23_masks_ZGRN11_latlon.nc
#mask_file=RACMO23_masks_ZGRN11_latlon.nc
mask_file=RACMO23_masks_ZGRN11.nc
gris_pcnt_file=greenland_percent_coverage_latlon.nc
for ivar in "${var[@]}"
......
......@@ -11,6 +11,7 @@
# total area of GrIS in model is 1.719e6
postprocess=true
postprocess_obs=true
make_plots=false
if [[ $(hostname -s) = rhea* ]]; then
......@@ -26,51 +27,35 @@ if [[ $(hostname -s) = rhea* ]]; then
outpath=/lustre/atlas1/$project/world-shared/$USER/$case/postproc
# compute center settings
obspath=/lustre/atlas1/cli115/world-shared/4ue/obs_data
area_file=/lustre/atlas1/$project/world-shared/$USER/surfdata_0.9x1.25_simyr1850_c110725.nc
map_file=/ccs/home/zender/data/maps/map_ne30np4_to_fv129x256_aave.20150901.nc
mask_file=/lustre/atlas1/$project/world-shared/4ue/$case/postproc/masks/mask_ne30np4_notime.nc
obs_mask_file=/lustre/atlas1/$project/world-shared/4ue/$case/postproc/masks/E3SMv1_ne30.clm2.gris_mask.nc
postprocess_obs=false
elif [[ $(hostname -s) = cori* ]]; then
#user settings
project=piscees
case=20180129.DECKv1b_piControl.ne30_oEC.edison
year_start=0470
year_end=0498
case=IGCLM45_MLI_titan
year_start=0002
year_end=0006
#need to specify prebase if using data created by someone else until masks are written with sim output
prebase=/global/cscratch1/sd/golaz/ACME_simulations
# prebase=/global/cscratch1/sd/dcomeau/acme_scratch/edison/archive/$case
base=/global/cscratch1/sd/$USER/acme_scratch/edison
base=/global/cscratch1/sd/$USER/acme_scratch/titan
path=$base/$case
outpath=/global/cscratch1/sd/$USER/$case/postproc
# outpath=/global/cscratch1/sd/$USER/acme_scratch/edison/$case/postproc
# outpath=/global/cscratch1/sd/$USER/$case/postproc
outpath=/global/cscratch1/sd/$USER/acme_scratch/titan/$case/postproc
# compute center settings
obspath=/project/projectdirs/piscees/postproc/obs_data
area_file=/project/projectdirs/piscees/postproc/surfdata_0.9x1.25_simyr1850_c110725.nc
map_file=/project/projectdirs/piscees/postproc/map_ne30np4_to_fv129x256_aave.20150901.nc
mask_file=/project/projectdirs/piscees/postproc/mask_ne30np4_notime.nc
obs_mask_file=/project/projectdirs/piscees/postproc/E3SMv1_ne30.clm2.gris_mask.nc
postprocess_obs=false
else
echo "machine not recognized"
fi
# this copy to local dir can be removed once masks are written with sim output
#if test -d $prebase/$case; then
# echo "Creating user owned target path for output data"
# mkdir -p $base/$case/atm/hist
# mkdir -p $base/$case/lnd/hist
# cp -uvr $prebase/$case/archive/atm/hist/*.04* $path/atm/hist
# cp -uvr $prebase/$case/archive/lnd/hist/*.04* $path/atm/hist
#else
# exit
#fi
version=e3sm
atm_vars=("PSL" "CLDLOW" "CLDHGH" "CLDMED" "CLDTOT" "TREFHT" "TS" "TSMX" "TSMN" "PRECC" "PRECL")
lnd_h0_vars=("FSDS" "QRUNOFF" "QSOIL" "TSA" "RAIN" "SNOW" "FIRA" "FLDS" "FSH" "QSNOMELT")
#glc_vars=("acab" "thk")
lnd_h0_vars=("QICE" "QICE_FRZ" "QICE_MELT" "FSDS" "QRUNOFF" "QSOIL" "TSA" "RAIN" "SNOW" "FIRA" "FLDS" "FSH" "QSNOMELT")
glc_vars=("acab" "thk")
# END OF USER INPUT SECTION
......@@ -149,32 +134,35 @@ fi
if [ "$postprocess_obs" = "true" ]; then
#if test -a $outpath/masks/${case}.$lnd.gris_mask.nc; then
# echo "already created gris_mask and area file, moving on"
#else
# echo "gris_mask file does not exist, creating"
#
# mkdir -p $outpath/masks
# ncks -O -v gris_mask,area $path/lnd/hist/${case}.${lnd}.h0.${year_start}-01.nc $outpath/masks/${case}.${lnd}.gris_mask_time.nc
# ncwa -a time $outpath/masks/${case}.${lnd}.gris_mask_time.nc $outpath/masks/${case}.${lnd}.gris_mask.nc
#
#fi # if mask file needs to be created
if test -a $outpath/masks/${case}.$lnd.gris_mask.nc; then
echo "already created gris_mask and area file, moving on"
else
echo "gris_mask file does not exist, creating"
mkdir -p $outpath/masks
ncks -O -v gris_mask,area $path/lnd/hist/${case}.${lnd}.h0.${year_start}-01.nc $outpath/masks/${case}.${lnd}.gris_mask_time.nc
ncwa -a time $outpath/masks/${case}.${lnd}.gris_mask_time.nc $outpath/masks/${case}.${lnd}.gris_mask.nc
fi # if mask file needs to be created for use with obs data
echo "process and remap cloud obs"
. atm_obs.sh
echo "process RACMO"
. lnd_obs.sh
./remap_RACMO_to_CESM2_inline.sh
. remap_RACMO_to_E3SM.sh
fi
echo "executing post processing of atm data for validation"
. atm.sh
#echo "executing post processing of atm data for validation"
#. atm.sh
echo "executing post processing of lnd data for validation"
. lnd.sh
#echo "executing post processing of lnd data for validation"
#. glc.sh
if [ "$make_plots" = "true" ]; then
echo "make the atmosphere plots"
......
#!/bin/bash
# make sure top level call of this script loads ncl and nco/4.6.6 to have weight-generation command ESMF_RegridWeightGen used in ncremap
#run a check, do you have the software to perform the postprocessing?
#if [[ $(hostname -s) = rhea* ]]; then
#if [[ $(hostname -s) = titan* ]]; then
#module unload PE-intel # CSZ
#module load PE-gnu # CSZ
#module add gsl hdf5
#module load ncl/6.1.0
#export LD_LIBRARY_PATH='/sw/redhat6/netcdf/4.3.3.1/rhel6.6_gcc4.8.2--with-dap+hdf4/lib:/sw/redhat6/szip/2.1/rhel6.6_gnu4.8.2/lib':${LD_LIBRARY_PATH}
#export PATH='/sw/redhat6/netcdf/4.3.3.1/rhel6.6_gcc4.8.2--with-dap+hdf4/bin':${PATH}
#export LD_LIBRARY_PATH="~zender/lib_rhea":${LD_LIBRARY_PATH}
#export PATH="~zender/bin_rhea":${PATH}
#module load nco
#module unload nco/4.6.5
#else
# echo "machine not recognized, make sure your path:
# $PATH
# points to a version of nco/4.6.6 or later"
#
#fi
#project=$project
obs_case=racmo23_GRN_monthly
#case=IGCLM45_MLI_titan
#path=/lustre/atlas1/$project/world-shared/$USER/$case
#obspath=/lustre/atlas1/$project/world-shared/$USER/$obs_case
#run a check, is the requested data directory for reampping there?
#if test -d $path/atm/hist; then
# echo "Directory $path/atm/hist exists"
#else
# echo "Target directory $path/atm/hist does not exist"
# exit
#fi
echo $path
echo $obspath
mkdir -p $obspath/remapped_racmo
seasons=("DJF" "JJA" "ANN")
field_names=("swsn" "swsd" "lwsn" "lwsd" "senf" "latf" "t2m" "alb" "smb")
for seas in "${seasons[@]}"
do
for rvar in "${field_names[@]}"
do
# CHECK whether I need to point to file we will be comparing to
e3smfile=$path/lnd/hist/${case}.clm2.h0.${year_end}-01.nc
obsfile=$obspath/${obs_case}/climos/${obs_case}.${rvar}.1980-1999.${seas}.nc
tmpfile=$obspath/${obs_case}/remapped_racmo/racmo23_with_latlon_tmpfile.nc
ReMapFile=$obspath/${obs_case}/remapped_racmo/racmo23_GRN_monthly.${rvar}.1980-1999.remap2e3sm.${seas}.nc
#------- RACMO lat and lon data ---
racmolatlon=$obspath/${obs_case}/RACMO23_masks_ZGRN11.nc
## PROCEDURE: remap racmo to have same size as e3sm
##-first, append lat and lon from racmolatlon file to racmofile
ncks -C -v lat,lon $racmolatlon -O $tmpfile
ncks -C -v ${rvar} $obsfile -A $tmpfile
#-- change interpolation algorithm in -a switch causes value difference
ncremap -i $tmpfile -V TREFHT -a bilinear -d $e3smfile -v ${rvar} -m $obspath/remapped_racmo/RACMO_to_CESM_remap_bilin.nc -o $ReMapFile
done # variables
done #seasons
......@@ -7,7 +7,7 @@ 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
ncrcat -O -v mcdate,time,area,$ivar $h0lnd_path/${case}.${lnd}.${freq}.*.nc $outpath/lnd/tseries/$case.$lnd.${freq}.$ivar.nc
ncrcat -O -v mcdate,time,gris_area,gris_mask,$ivar $h0lnd_path/${case}.${lnd}.${freq}.*.nc $outpath/lnd/tseries/$case.$lnd.${freq}.$ivar.nc
fi
if test -a $outpath/lnd/tseries/${case}.$lnd.${freq}.$ivar.nc; then
......@@ -28,7 +28,7 @@ ncra --mro -O -h -d time,,,12,12 $outpath/lnd/tseries/$case.$lnd.${freq}.$ivar.n
if [ "$version" == "cesm1" ]; then
echo "add mask and area variables to yearly averaged lnd data for $ivar"
ncks -A -v gris_mask,area $outpath/masks/$case.$lnd.gris_mask.nc $outpath/lnd/tseries/$case.$lnd.${freq}.yrly.$ivar.nc
ncks -A -v gris_mask,gris_area $outpath/masks/$case.$lnd.gris_mask.nc $outpath/lnd/tseries/$case.$lnd.${freq}.yrly.$ivar.nc
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
......@@ -46,12 +46,12 @@ fi
elif [ "$version" == "e3sm" ]; then
for fl in $outpath/lnd/tseries/*clm2.h0.yrly*; do
ncks -A -C -v gris_mask $mask_file $fl
done
#for fl in $outpath/lnd/tseries/*clm2.h0.yrly*; do
#ncks -A -C -v gris_mask $mask_file $fl
#done
echo "average over ice sheet region for yearly averaged lnd data for $ivar"
ncwa -O -a lndgrid -w area -B "gris_mask == 1" $outpath/lnd/tseries/$case.$lnd.${freq}.yrly.$ivar.nc $outpath/lnd/tseries/$case.$lnd.aavg.${freq}.yrly.$ivar.nc
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
if test -a $outpath/lnd/tseries/${case}.$lnd.aavg.${freq}.yrly.$ivar.nc; then
echo "Global avg yearly masked $lnd averages of $ivar made"
......
#!/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
#!/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 target 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 $obspath/${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
##On my laptop I installed PyNGL and PyNIO to use Nio and Ngl module for reading *.nc file and for contour plot
##On titan, I did not install PyNGL and PyNIO, so import Dataset from netCDF4 to read *.nc file
##probably, I will the following command for contourplot in titan python "from mpl_toolkits.basemap import Basemap"
#!/usr/bin/env python3
import numpy as np
import numpy.ma as ma
import os
from netCDF4 import Dataset
# ---------------- Data sources ------------------------
input_file1 = '/lustre/atlas1/cli115/world-shared/4ue/20180215.DECKv1b_H1.ne30_oEC.edison/postproc/lnd/climo_regrid/20180215.DECKv1b_H1.ne30_oEC.edison_JJA_climo.nc'
input_file3 = '/lustre/atlas1/cli115/world-shared/4ue/20180215.DECKv1b_H1.ne30_oEC.edison/postproc/lnd/climo_regrid/20180215.DECKv1b_H1.ne30_oEC.edison_ANN_climo.nc'
# --------------------------------------------------------------
# --------------------------------------------------------------
# input_file1 get FLDS (mean downwelling longwave rad),FIRA (mean net IR longwave rad, absorbed)
# FLDS(0,:,:), FIRA(0,:,:)
# Matrix gris_area(Greenland ice area) has values 0 and none
# Goal: print out area-weighted average of SW_d(268), SW_net(61), LW_d(235), LW_net(-46), R_net(15), SHF(7), LHF(-8),
# these variables have size[192,288]
# FSDS: atmospheric incident solar radiation
# FSA: absorbed solar radiation
# FLDS: atmospheric longwave radiation
# FIRA: net infrared (longwave) radiation
# FIRE: emitted infrared (longwave) radiation
# FSH: sensible heat
# QSOIL: ground evaporation over ice landunits
# ---read input_file2, probably get area with ice sheet with nonzero values
#ncid2 = Dataset(input_file2, mode='r')
#ices = ncid2.variables['PCT_GLC_ICESHEET'][:]
#ncid2.close()
# ---read input_files
ncid1 = Dataset(input_file1, mode='r')
#ncid11 = Dataset(input_file11, mode='r')
ncid3 = Dataset(input_file3, mode='r')
FSDS = ncid1.variables['FSDS'][0,:,:]
FSA = ncid1.variables['FSA'][0,:,:]
FLDS = ncid1.variables['FLDS'][0,:,:]
FIRA = ncid1.variables['FIRA'][0,:,:]
FSH = ncid1.variables['FSH'][0,:,:]
QSOIL = ncid1.variables['QSOIL'][0,:,:]
RAIN = ncid3.variables['RAIN'][0,:,:]
SNOW = ncid3.variables['SNOW'][0,:,:]
QRUNOFF = ncid3.variables['QRUNOFF'][0,:,:]
#T2m = ncid11.variables['TREFHT'][0,:,:]
T2m = ncid1.variables['TSA'][0,:,:]
#E3SM
GrisMask = ncid1.variables['gris_mask'][:,:]
SW_d = FSDS
SW_net = FSA
LW_d = FLDS
LW_net = -1.0 * FIRA
R_net = FSA-FIRA
SHF = -1.0 * FSH
LHF = -1.0 * 2.835e6 * QSOIL
#SMB = QICE * 3.1567e7
SMB = RAIN + SNOW - QRUNOFF - QSOIL * 3.1567e7
T2mC = T2m - 273.15
# ---grid cell area on Greenland. For other regions, the value is 9.999e35.
area = ncid1.variables['area'][:]
ncid1.close()
#ncid11.close()
ncid3.close()
# # # --- Option I: use greenland mask to mask the area where the ice sheet fraction is zero
# # # Note: some non-greenland region has non-zero ice sheet fraction.
Gris_mask = ma.masked_equal(GrisMask,0)
area_maskice = ma.masked_array(area, mask=Gris_mask.mask)
# # # --- Option II: use icesheet fraction mask to mask the area where the ice sheet fraction is zero
# ices_mask = ma.masked_equal(ices,0)
# area_maskice = ma.masked_array(area, mask=ices_mask.mask)
# # # --- Option III: first multiply area with ices, then use greenland mask to mask the area where the ice sheet fraction is zero
## -- this option gives the closest results to the Table 1 in the paper.
#areaices = np.multiply(area,ices)
#Gris_mask = ma.masked_equal(GrisMask,0)
#area_maskice = ma.masked_array(areaices, mask=Gris_mask.mask)
swdout=(ma.average(SW_d,weights=area_maskice))
swnetout=(ma.average(SW_net,weights=area_maskice))
lwdout=(ma.average(LW_d,weights=area_maskice))
lwnetout=(ma.average(LW_net,weights=area_maskice))
rnetout=(ma.average(R_net,weights=area_maskice))
shfout=(ma.average(SHF,weights=area_maskice))
lhfout=(ma.average(LHF,weights=area_maskice))