#!/bin/tcsh #======================================================================================== # name: ncson.tcsh # # category: TC-shell script # # description # This script constructs time series of SON mean (different from sequential SON time # series) for specified variables of netCDF data. The resulting files may be useful # when testing the statistical significance for the climatological difference of two # experiments. # # input: netCDF monthly time series (e.g., 1979.01-2016.12) # # output: netCDF SON time series # # call: NCO commands (ncrcat) and CDO commands (settaxis, mulc, add, divc) # # usage # ./ncson.tcsh: to execute # # note: works on denali@EES # # history # 2017.11.22: originally written # # author # m.yoshimori (myoshimo AT ees.hokudai.ac.jp) #======================================================================================== set diri = '/mnt/logan/data/ERAI/y1979-y2016' # input file path set diro = '/mnt/logan/myoshimo/tmp' # output file path set fin = 'ts_an_sfc_y1979-y2016_mon.nc' # input file name set syear = '1979' # start year set eyear = '1993' # end year cd $diro foreach var ("t2m" "stl1") # unpacking netCDF #if (-f tmp0) /bin/rm -f tmp0 #ncpdq -v ${var} -U ${diri}/${fin} tmp0 # extract SON ncrcat -F -d time,9,180,12 ${diri}/${fin} ts_${var}_y${syear}-y${eyear}_sep.nc ncrcat -F -d time,10,180,12 ${diri}/${fin} ts_${var}_y${syear}-y${eyear}_oct.nc ncrcat -F -d time,11,180,12 ${diri}/${fin} ts_${var}_y${syear}-y${eyear}_nov.nc # SON mean cdo settaxis,1850-10-01,00:00,1year ts_${var}_y${syear}-y${eyear}_sep.nc tmp1.nc cdo settaxis,1850-10-01,00:00,1year ts_${var}_y${syear}-y${eyear}_oct.nc tmp2.nc cdo settaxis,1850-10-01,00:00,1year ts_${var}_y${syear}-y${eyear}_nov.nc tmp3.nc cdo -b 64 mulc,30. tmp1.nc tmp4.nc # multiply 30 for Sep. cdo -b 64 mulc,31. tmp2.nc tmp5.nc # multiply 31 for Oct. cdo -b 64 mulc,30. tmp3.nc tmp6.nc # multiply 30 for Nov. cdo -b 64 add tmp4.nc tmp5.nc tmp7.nc cdo -b 64 add tmp6.nc tmp7.nc tmp8.nc cdo -b 64 divc,91. tmp8.nc tmp9.nc # devide by 91 for SON average cdo settaxis,1850-10-01,00:00,1year tmp9.nc ${diro}/ts_${var}_y${syear}-y${eyear}_son.nc # delete intermediate files /bin/rm -f ts_${var}_y${syear}-y${eyear}_sep.nc ts_${var}_y${syear}-y${eyear}_oct.nc ts_${var}_y${syear}-y${eyear}_nov.nc tmp?.nc end exit