LASS Simulator

開發步驟
  • 確認執行環境
  • 架構設計
  • 系統基礎帶起
  • CLI start
  • Log start
  • CFG start
  • simulation installation check
  • unit test start
  • start car,  Deposition, status with simulation
  • plot total value
  • export ESRI for single and animation
  • 支援初始化地理位置設定
  • limit wind effect


需求

  • 希望能有效模擬 PM2.5 感測現象,進而提供一些實驗設計參考

規格

  • 模擬功能
  • 能模擬因人口,車輛的影響
  • 能模擬特定燃燒,工廠排放的影響
  • 能模擬境內與境外之間的移動特性,比方說境外污染影響
  • 能區分高空與低空污染
  • 能模擬下雨,沈積,風,颱風的效應
  • 能模擬特定氣候效應
  • 能模擬特定區域現象
  • 模擬區域特性如地理特性能有標準介面以提供匯入定義
  • 模擬結果能與目前實際感測值做比較
  • 能做小時,天,週,月,年的模擬

  • 系統功能
  • 開源,分享
  • 主設計使用 Python
  • 使用 SimPy , NumPy
  • 使用者參數集中管理與設定
  • 核心使用 Command line interface
  • 方便客製化設計
  • 支援結果繪出 ESRI ASCII Raster format, 能支援動態模擬
  • 工廠資訊匯入

設計

基本
  • 時間單位:分鐘
  • 空間單位:1m 平方,1m 立方
  • Cfg : 設定參數,包含各個 Producer 的常態特性,動態特性參數
  • 有邊界


Producer
  • Village : 一般性的,內含人車以及基本產生量
  • Population : 人口
  • Car : 車輛
  • Factory : 
  • Combustion :  特定燃燒

Consumer
  • Climate : 下雨,颱風等
  • Deposition : 沈積
Effect
  • Wind : 
  • Diffusion : 
Boundry
  • 邊界只有平均值,沒有累積量

Status
  • Map : 整張地圖
  • Position : 固定長寬的空間,用 X@Y 來 index
  • pm_total : pm 總量
  • pm_value : pm 量測值 ug/m3
  • Area : 一堆 Position 的組合

設定
  • 地理
  • 以經緯度範圍設定模擬區域
  • 精細度可選
  • 100m, 1km, 10km

基本演算法

  • 持續 monitor status
  • Producers 給予特定的產生條件,持續產生
  • Consumer 持續減少數值
  • Apply effects

total ↔ value
  • 固定空間大小來當除數
  • 配上高度比例,分成生活段(可量測)與高空段(未量測)

跨邊界效應
  • 邊界以 value 標示,total 無限
  • 污染離開邊界,會更新邊界 value 值
  • 污染由邊界傳入,需計算 value * 時間為傳入量
  • 邊界值可以依模擬條件,隨時更新,或由模擬條件漸進更新



Files/Directories Definition


doc
  • README.txt : release note
Codes : codes
Include :
  • sim.ini
Output
  • ESRI export naming rule:
  • output/name_timestamp.asc  (ex: abc_20160708210000.asc) 
  • output/name.xml
  • sim.log : system log 
Lib : the code that may easy to be reused
test:
sim.py : startup program

帶起步驟設計

Basic fundation, classes/cfg/reporting
車輛與沈積效應的平衡
Wind effect + boundry handler
大地圖, grouping → 走向全台灣模擬
Climate effect
Real data input, real data comparsion

Versions

V0.0.1 
  • Basic application fundation, CFG, logging, CLI, unit test, simulation
  • Quick support  Deposition, Car, Population
V0.1
  • Export ESRI
  • Some setting from file
  • Quick wind effect



Installation

  • We use python 3
  • pip3 install simpy
  • pip3 install configobj
  • pip3 install matplotlib
  • pip3 install numpy

執行
  • python3 sim.py

Study


Current Progress

wuulong$ python3 sim.py
FastCLI> help

Documented commands (type help <topic>):
========================================
about  help  quit  save_esri  save_esri_xml  set  show  simrun  test

FastCLI> help about
About this software
FastCLI> about
G.Fast Monitor version: v0.1
FastCLI> help save_esri
Save map to RSRI ASCII format
        save_esri [ name ] 
        ; name: export file name prefix
        ex: save_esri map
        ESRI export naming rule:
          name_timestamp.asc  (ex: abc_20160708210000.asc) 
        
FastCLI> help save_esri_xml
Save map to RSRI ASCII xml format
        save_esri_xml [ name ] 
        ; name: export file name prefix
        ex: save_esri_xml sim
        ESRI export naming rule:
          name.xml
        
FastCLI> help set
set scli variable, can be new or update.
        set var_name var_value
        ex: set mac_addr 001122334455
FastCLI> help show
show simcli variables, if miss variable name, show all
        show variable_name
        system variables list:
            ;log level definition, DEBUG=10,INFO=20,WARNING=30,ERROR=40,CRITICAL=50
            log_level_console=20     #the console message log level
            log_level_file=40        #file message log level
            ;device console real time display
            dev_console_display=1    #(0) don't display (1) display
        ex: show mac_addr 
FastCLI> help simrun
Start simulation
FastCLI> help test
current debug command
FastCLI> 
root        : INFO     G.Fast Monitor version: v0.0.1
FastCLI> simrun
root        : INFO     Simulation start!
Simulation Descriptor:
1* deposition -10 every time unit.
5* population +1 every time unit.
2* car +1000 when minute mode 3 ==0.
root        : INFO     Map Descriptor:
Current positions count = 100
        0.000000        0.000000        0.000000        0.000000        0.000000        0.000000        0.000000        0.000000        0.000000        0.000000
        0.000000        0.000000        0.000000        0.000000        0.000000        0.000000        0.000000        0.000000        0.000000        0.000000
        0.000000        0.000000        0.000000        0.000000        0.000000        0.000000        0.000000        0.000000        0.000000        0.000000
        0.000000        0.000000        0.000000        0.000000        0.000000        0.000000        0.000000        0.000000        0.000000        0.000000
        0.000000        0.000000        0.000000        0.000000        0.000000        0.000000        0.000000        0.000000        0.000000        0.000000
        0.000000        0.000000        0.000000        0.000000        0.000000        0.000000        0.000000        0.000000        0.000000        0.000000
        0.000000        0.000000        0.000000        0.000000        0.000000        0.000000        0.000000        0.000000        0.000000        0.000000
        0.000000        0.000000        0.000000        0.000000        0.000000        0.000000        0.000000        0.000000        0.000000        0.000000
        0.000000        0.000000        0.000000        0.000000        0.000000        0.000000        0.000000        0.000000        0.000000        0.000000
        0.000000        0.000000        0.000000        0.000000        0.000000        0.000000        0.000000        0.000000        0.000000        0.000000

2016-10-21 16:00:00
2016-10-21 16:01:00
2016-10-21 16:02:00
2016-10-21 16:03:00
2016-10-21 16:04:00
2016-10-21 16:05:00
2016-10-21 16:06:00
2016-10-21 16:07:00
2016-10-21 16:08:00
2016-10-21 16:09:00
2016-10-21 16:10:00
2016-10-21 16:11:00
2016-10-21 16:12:00
2016-10-21 16:13:00
root        : INFO     Map Descriptor:
Current positions count = 100
        -0.007000        -0.007000        -0.007000        -0.007000        -0.007000        -0.007000        -0.007000        -0.007000        -0.007000        -0.007000
        -0.007000        -0.007000        -0.007000        -0.007000        -0.007000        -0.007000        -0.007000        -0.007000        -0.007000        0.093000
        -0.007000        -0.007000        0.093000        -0.007000        -0.007000        -0.007000        0.093000        -0.007000        -0.007000        -0.007000
        -0.007000        -0.007000        0.093000        -0.007000        -0.007000        -0.007000        -0.007000        -0.007000        -0.007000        -0.007000
        -0.007000        -0.007000        -0.007000        -0.007000        -0.007000        -0.007000        -0.007000        -0.007000        -0.007000        -0.007000
        -0.007000        -0.007000        -0.007000        -0.007000        -0.007000        -0.007000        -0.007000        -0.007000        -0.007000        -0.007000
        -0.007000        -0.007000        -0.007000        0.093000        0.093000        -0.007000        -0.007000        -0.007000        -0.007000        -0.007000
        0.093000        -0.007000        -0.007000        -0.007000        -0.007000        -0.007000        -0.007000        -0.007000        -0.007000        -0.007000
        -0.007000        -0.007000        -0.007000        -0.007000        -0.007000        0.093000        -0.007000        -0.007000        -0.007000        -0.007000
        0.093000        -0.007000        -0.007000        -0.007000        -0.007000        -0.007000        -0.007000        -0.007000        0.093000        -0.007000

pm_total history: [1500.0, 1000.0, 500.0, 2000.0, 1500.0, 1000.0, 2500.0, 2000.0, 1500.0, 3000.0, 2500.0, 2000.0, 3500.0, 3000.0]
FastCLI> help

Documented commands (type help <topic>):
========================================
about  help  quit  save_esri  save_esri_xml  set  show  simrun  test

FastCLI> save_esri_xml test
 
2D Raster export display demo by QGIS
 
QGIS plugin:   Loop Visible Layers  (網格資料圖層動態播放)

Problems

3D 問題