Dr. Kuang's Utilities

daily_traj.cs程式說明

Table of contents

背景

發展歷程

重要選項考量與未來可能發展

daily_traj.cs程式分段重點

  1. 接收get_M-A0064.cs之下載與轉檔結果。
  2. 執行軌跡模式ftuv10.py
  3. 執行檔案轉換csv_to_geojson
  4. 執行通風指數程式addVI.py
  5. git更新上傳

程式說明

get_M-A0064.cs結果之接收

#!/bin/bash
yesd=$(date -v-1d +%Y%m%d)
for i in 0 1 2 3;do
  ymd=$(date -v+${i}d -j -f "%Y%m%d" "${yesd}" +%Y%m%d)
  y=$(date -v+${i}d -j -f "%Y%m%d" "${yesd}" +%Y)
  ddd=$(date -v+${i}d -j -f "%Y%m%d" "${yesd}" +%Y-%m-%d)
  for d in 1 3;do
    fn=U10V10_d0${d}_${ddd}_06:00:00
#   if ! [ -e /Users/Data/cwb/e-service/btraj_WRFnests/CWB_forecast/$fn ];then
      cp /Users/Data/cwb/WRF_3Km/${y}/${ymd}/$fn /Users/Data/cwb/e-service/btraj_WRFnests/CWB_forecast/$fn
#   fi
  done
done

執行ftuv10.py

for d in $today $Tomorr $AftTmw;do
cd /Library/WebServer/Documents
for t in zhongshan zhongming jiayi qianjin;do
  $PY -t $t -d ${d}12 -b True
  fn=trj_results/btrj${t}${d}12_mark.csv
  rm -f trj_results/today_$t.csv
  if [ -e $fn ];then cp $fn trj_results/today_$t.csv;fi
done
...
test $d == $today && dir=00
test $d == $Tomorr && dir=p1
test $d == $AftTmw && dir=p2
cat header.txt today.csv > $dir/today_marks.csv
done

執行csv_to_geojson

CJ=/opt/anaconda3/bin/csv_to_geojson
...
#geojson for leaflet-ajax
cat headLL2.txt today.csv > today${today}12.csv
$CJ today${today}12.csv

執行addVI.py

VI=/Users/kuang/bin/addVI.py
...
for dir in 00 m1 m2 p1 p2;do
  cd $dir
  $VI today_marks.csv
  cd ..
done

git更新上傳

cd /Users/kuang/GitHub/sinotec2.github.io/traj/trj_results
for i in 00 m1 m2 p1 p2;do cp -r /Library/WebServer/Documents/trj_results/$i .;done
chmod -R o+r ??
cd /Users/kuang/GitHub/sinotec2.github.io
su kuang
GT=/usr/local/bin/git
$GT pull origin main
$GT add traj
$GT commit -m "update traj"
TOKEN=$(cat /Users/kuang/bin/git.token)
$GT push https://sinotec2:$TOKEN@github.com/sinotec2/sinotec2.github.io.git main

自動執行

## trajectories update
#MIN HOUR DOM MON DOW CMD
0    4    *   *   *   /Library/WebServer/Documents/trj_results/daily_traj.cs >& /Library/WebServer/Documents/trj_results/daily_traj.out

程式下載