Link Search Menu Expand Document

COMBINE_ACONC檔案之篩選整併

Table of contents

背景

  • combine之後的檔案,仍有多達135項之污染物,仍須進一步進行篩選。
  • CMAQ之排放、土地利用、濃度結果皆以逐日方式儲存,需進一步整併。以環保署要求之規格,濃度須以月為單位進行比對、分析。

作業範例

污染項目的篩選

  • 以下範例為2016年、d02全年模擬結果的篩選、整併
    • 執行sort,是為確保檔案是按照一定順序處理,對不同批次、同一日期之檔案,有既定的覆蓋方式。在不同增減量方案計算時,保持基本的一致性。
    • 因日期是檔名的一部分,以底線(_)為區格,如路徑中也有含底線,將會造成錯位,須詳細確認。
    • shk.cs執行速度還算快,沒有平行運作的必要。
#note the ncks or ncrcat can not run in parallel, will conflick in memory
ls -r /nas1/cmaqruns/2016base/data/out*/POST/COMBINE_ACONC*_sCh*10.nc > fnames.txt
sort fnames.txt>a;mv a fnames.txt
for i in $(cat fnames.txt);do 
  ymd=$(echo $i|cut -d_ -f11)
  shk.cs $i $ymd.nc
done 

逐日檔案的合併

  • 因日期為檔名,直接進行ncrcat即可整併

shk.cs

  • 此腳本進一步對COMBINE_ACONC檔案進行污染項目之篩選,最終結果為經常用以檢討的9個污染項目。
  • NCO:視不同機器而異,是為確認ncksncrcat版本之一致性。
  • v:做為CAMx不同版本結果檔案之辨識
  • a:同樣是模式模擬結果濃度檔案,此值將做為CMAQ或CAMx之辨識
  • 如果目錄沒有結果檔案,程式才會執行,如果已有檔案,程式不會覆蓋。
$ cat ~/bin/shk.cs
nc=$1
if [ $HOSTNAME == '114-32-164-198.HINET-IP.hinet.net' ];then NCO='/opt/anaconda3/bin'
  elif [ $HOSTNAME == 'master' ];then NCO='/cluster/netcdf/bin'
  elif [ $HOSTNAME == 'node01' ];then NCO='/cluster/netcdf/bin'
  elif [ $HOSTNAME == 'node02' ];then NCO='/cluster/netcdf/bin'
  elif [ $HOSTNAME == 'centos8' ];then NCO='/opt/anaconda3/envs/py37/bin'
  elif [ $HOSTNAME == 'node03' ];then NCO='/opt/miniconda3/bin'
  else NCO='/usr/bin'
fi
NCKS=${NCO}/ncks
NCRCAT=${NCO}/ncrcat
v=$(ncdump -h $nc|grep PM25|wc -l)
a=$(ncdump -h $nc|grep AVERAGE|wc -l)
if [ $v != 0 ];then
  if  [ $a == 0 ];then
    #cmaq combined files
    VAR='TFLAG,CO,NO2,SO2,O3,PM25_NO3,PM25_SO4,PM25_TOT,PM10,VOC'
  else
    #version 700 nc directly from CAMx
    VAR='TFLAG,CO,NO2,SO2,O3,PNO3,PSO4,PNH4,PAR,PM25,PM10'
  fi
#camx>400, nc generated by pncgen from uamiv file
else
  VAR='TFLAG,CO,NO2,SO2,O3,PNO3,PSO4,PNH4,PAR,CCRS,FCRS,CPRM,FPRM'
fi
if ! [ -e $2 ];then
  touch $2
  $NCKS -O -v $VAR -d LAY,0,0 $1 $2
fi