Thursday, June 5, 2025

Windows: Using Operating System Scheduler

  1. Create a MATLAB Script: Save your MATLAB code in a .m file, e.g., myScript.m:
  2. 1
    2
    3
    disp('Running my daily task at 6 PM!');
    % Your code here
    exit; % Close MATLAB after execution
    
  3. Create a Batch File: Create a .bat file (e.g., run_matlab_script.bat) to run the script in MATLAB:
  4. 1
    "C:\Program Files\MATLAB\R2023a\bin\matlab.exe" -batch "run('C:\path\to\myScript.m')"
    • Replace R2023a with your MATLAB version.
    • Replace C:\path\to\myScript.m with the full path to your script.
  5. Schedule with Windows Task Scheduler:
    • Open Task Scheduler (search for it in Windows).
    • Click Create Task (not Basic Task for daily scheduling).
    • General Tab:
      • Name the task (e.g., "Run MATLAB Daily").
      • Check "Run whether user is logged on or not" for reliability.
    • Triggers Tab:
      • Click New → Set trigger to Daily at 6:00 PM.
      • Ensure "Enabled" is checked.
    • Actions Tab:
      • Click New → Action: Start a Program.
      • Browse to your .bat file (e.g., C:\path\to\run_matlab_script.bat).
    • Conditions/Settings:
      • Optional: Set conditions like "Start only if computer is on AC power."
      • Save the task, entering your user credentials if prompted.
  6. Test:
    • Right-click the task in Task Scheduler and select Run to verify it executes correctly.

Wednesday, May 28, 2025

Hysplit: Run a Sample Concentration Simulation

快捷方法,按照如图所示的步骤,单击‘Run Example’,就会得到运行的结果。
Quick method: follow the steps shown in the figure and click "Run Example" to obtain the results.
进一步,如果编辑运行需要的参数,请按照下面的步骤:
To proceed further and edit the parameters required for the run, please follow the steps below:

Step 1 配置参数 Configure Pollutant and Grid

在Concentration之下单击‘Setup Run’,在弹出的窗口再继续单击‘Pollutant, Deposition and Grids setup’,就可以在打开的新窗口对于Pollutant等进行调整,不过此为示例,已经调整到位了,无需再调整。
Under the ‘Concentration’ tab, click ‘Setup Run’. In the pop-up window, click ‘Pollutant, Deposition and Grids setup’ to open a new window where you can adjust the settings for the pollutant and related parameters. However, since this is just a sample, the settings have already been configured, and no further adjustments are needed.
Pollutant: Emission characteristics (e.g., emission rate, species like “TEST”).
Grid: Define the concentration grid (latitude-longitude intersections, resolution, and averaging period).
Deposition (optional): Parameters for deposition if needed.
全部单击‘Save’,保存这些配置。
Click ‘Save’ for each window to save the configurations.

Step 2 运行配置 Run the Simulation

在Concentration之下单击‘Run Model’,就开始运行,运行结束如下图。
Click ‘Run Model’ under the ‘Concentration’ tab to start the simulation. Once the run is complete, you will see the result as shown below.

Step 3 查看结果 View Output

按照下图的示意,单击‘Contours’,在新窗口有许多参数,可以尝试调整,也可以选择默认的配置,确定后执行‘Execute Display’。
As shown in the image below, click ‘Contours’. In the new window, you'll find many parameters available for adjustment. You can experiment with these settings or proceed with the default configuration. Once ready, click ‘Execute Display’ to generate the output.
最终弹出来的结果如下图。
The final output is shown in the image below.

Hysplit: Step-by-Step Guide to Use HYSPLIT GUI’s Built-in FTP Client

如下图所示,单击Archive。
As shown in the figure below, click ‘Archive’.
对于初学者来说,GDAS数据是一个不错的选择,覆盖全球,常用于Hysplit的模拟。其它方面请按照自己的需求而定,主要就是时间区间及下载位置,这里只是一个示例。设定好之后,就可以单击‘FTP Data File’开始下载。
For beginners, GDAS data is a good choice as it provides global coverage and is commonly used for HYSPLIT simulations. Other settings should be configured based on your specific needs, mainly the time range and download location—this is just an example. Once everything is set, you can click "FTP Data File" to start the download.
当出现‘FTP complete’,就表示下载完成了,此过程下载的文件名为‘gdas1.may24.w4’,位置在working文件夹。这就是一个简单的FTP下载过程。
When "FTP complete" appears, it means the download has finished. The downloaded file is named "gdas1.may24.w4" and is located in the ‘working’ folder. This is a simple FTP download process.
HRRR(High-Resolution Rapid Refresh)
High-Resolution: HRRR is a high-resolution weather model, meaning it operates on a fine spatial grid to capture detailed weather patterns. Specifically, it uses a 3-km horizontal resolution, allowing it to resolve smaller-scale phenomena like thunderstorms or local wind patterns that coarser models (e.g., GFS at 0.25-degree resolution) might miss.
Rapid Refresh: HRRR is updated frequently—every hour—with new data assimilation and forecasts. This rapid update cycle makes it ideal for short-term, real-time weather predictions, typically out to 18 hours (with some experimental runs extending to 48 hours).

Note

Tuesday, May 27, 2025

Hysplit: To run the sample data

Hysplit安装成功后,其实就已经包含了示例数据,它位于安装位置的子目录working里面,请检查是否含有这三个文件oct1618.BIN(该文件是ARL格式的气象数据)/sample_traj/sample_conc。其中sample_traj定义了模拟过程的起始位置。
Once HYSPLIT is successfully installed, it already includes sample data located in the working subdirectory of the installation folder. Please check whether the following three files are present: oct1618.BIN (which is meteorological data in ARL format), sample_traj, and sample_conc. The sample_traj file defines the starting location for the simulation.

Step 1 双击“Run Hysplit” Double-click “Run HYSPLIT”

看到如下图所示的GUI,含有Meteorology/Trajectory/Concentration/Advanced.
You will see a GUI as shown below, which includes the tabs: Meteorology, Trajectory, Concentration, and Advanced.

Step 2 单击Trajectory Click on Trajectory

单击Trajectory后,选择Quick Start和Run Example。它会依据预定义的sample_traj开始运行oct1618.BIN。
After clicking 'Trajectory', select 'Quick Start' and then 'Run Example'. It will run based on the predefined `sample_traj` using the `oct1618.BIN` file.
'starting time'等在此软件使用的都是UTC时间,注意与希望的时间进行换算
In this software, terms like “starting time” are all based on UTC. Please remember to convert accordingly to your desired local time.
几乎瞬间会得到一个运行结果,如下所示,黑色的星号就是计算的起始位置。
The result will appear almost instantly, as shown below. The black asterisk indicates the starting location of the calculation.
这就是一个非常简易的利用自带数据的操作过程。
This is a very simple operation process using the built-in data.

Step 3 查验气象数据 Verify Meteorological Data

在Trajactory之下找到Setup Run,弹出如下所示的配置窗口。
Under ‘Trajectory’, find and click ‘Setup Run’, and a configuration window like the one shown below will pop up.
在Selected Files,已经列出了oct1618.BIN文件,如果没有列出该文件,请通过“Add Meteorology Files”添加该文件。
In ‘Selected Files’, the file ‘oct1618.BIN’ should already be listed. If it is not, please click ‘Add Meteorology Files’ to add it manually.
单击“Setup starting locations”,如下图,你就会看到初涉的起始点是同一位置的不同高度,当然可以被修改为不同的位置或者高度。
Click ‘Setup starting locations’ (as shown below), and you will see that the initial starting points are set to the same location at different altitudes. Of course, these can be modified to different locations or altitudes as needed.

Step 4 运行此配置 Run the Simulation

单击Trajectory之下的Run Model,运行之后会得到如下结果。
Click ‘Run Model’ under the ‘Trajectory’ tab. After running, you will get the following results.
这个模拟的过程就是利用气象数据oct1618.BIN来得到的结果。
Click 'Run Model' under the 'Trajectory' tab. After execution, the results will be displayed as shown below.

Step 5 查看结果 View the output

Trajectory->Display->Trajectory,得到如下图所示,稍有调整,单击Execute Display。
Go to Trajectory → Display → Trajectory, as shown below. Make slight adjustments if needed, then click 'Execute Display'.
立即就得到一个展示结果,如下图。
The display result will appear immediately, as shown below. The trajplot program will run, generating trajplot.html in the working directory, as indicated by "Output will be in SVG".
同时,与结果一同输出的还有MESSAGE和tdump,他们也在working之下,可以作为运行过程相关参数的参考。
At the same time, the output also includes the MESSAGE and tdump files, which are located under the working directory. These files can serve as a reference for the parameters used during the run.

Sunday, April 6, 2025

FlexPart: Tips

[1]. flex_extract Documentation. Flex_extract is an open-source software to retrieve meteorological fields from the MARS archive of the European Centre for Medium-Range Weather Forecasts (ECMWF) to serve as input for the FLEXTRA/FLEXPART atmospheric transport modelling system.
Flex_extract 是一款开源软件,用于从欧洲中期天气预报中心(ECMWF)的 MARS 数据库中提取气象场数据,为 FLEXTRA/FLEXPART 大气输送模拟系统提供输入数据。
job.temp. The file needs to be transferred to: ../flex_extract/Templates

Thursday, March 27, 2025

How to install HYSPLIT on Windows

在安装HYSPLIT之前,需要先安装Tcl/Tk和ImageMagick。
Before installing HYSPLIT, you need to install Tcl/Tk and ImageMagick first.

Tcl/Tk

打开Air Resources Laboratory - HYSPLIT Graphical Utilities,直接单击下图红框的链接,开始下载tcl.zip,下载后解压,并将整个文件夹放在你希望的地方,我一般放在C盘之下某个文件夹之下。
Open the "Air Resources Laboratory - HYSPLIT Graphical Utilities" page and click the link in the red box shown below to download tcl.zip. After downloading, extract the files and place the entire folder wherever you prefer — I usually place it in a subfolder under the C drive.

ImageMagick

继续在Air Resources Laboratory - HYSPLIT Graphical Utilities,单击下图红框的链接。
Still on the Air Resources Laboratory - HYSPLIT Graphical Utilities page, click the link in the red box shown below.
在新页面继续单击下方红框处的链接,选择最新版的软件。
On the new page, click the link in the red box again to select the latest version of the software.
在新打开的页面,找到Windows Binary Release之下,选择ImageMagick-XXXXXXX-dll.exe下载。
On the newly opened page, find the section titled Windows Binary Release, and select ImageMagick-XXXXXXX-dll.exe to download.
下载后,双击开始安装,安装在默认位置即可,当出现下图所示窗口时,务必选择两处,直至安装完毕。
After downloading, double-click the file to begin installation. Install it in the default location. When the window shown below appears, make sure to check both options before proceeding, and continue until the installation is complete.

HYSPLIT

参考Air Resources Laboratory - HYSPLIT Registration Instructions,该软件含有注册版本与非注册版本,注册版本仅多一个Forecast功能。一般,我们先安装非注册版本,注册版本根据需求来选择。打开HYSPLIT for Windows - Public (unregistered) Version Download,填写自己的邮箱即可开始下载。来到了下载列表,一般我选择最新版的.zip版本下载,解压后将其放在合适的位置即可使用。
According to the Air Resources Laboratory - HYSPLIT Registration Instructions, the software includes both a registered and an unregistered version. The registered version only provides one additional feature — Forecast.
Generally, we start by installing the unregistered version, and the registered version can be used as needed.
Go to the HYSPLIT for Windows - Public (unregistered) Version Download page, enter your email address to begin the download.
Once you reach the download list, it's recommended to download the latest .zip version. After downloading, extract the files and place them in a suitable location — the software is then ready to use.
Unzip the file and move the HYSPLIT folder and everything therein to the C: drive. The end result should have directories C:\HYSPLIT\exec, C:\HYSPLIT\working, and others. Then create the "Run Hysplit" shortcut on your desktop. To create the shortcut, open Windows Explorer and navigate to the C:\HYSPLIT\guicode directory. Right-click the hysplit.tcl file and then choose "Send To > Desktop (Create shortcut)." Rename the created shortcut to "Run Hysplit."
我们还需要另外一个路径,找到之前存放Tcl/Tk位置,找到其完整路径(XXXXXX\tcl\bin\wish86t.exe)并复制。
We also need another path: locate the folder where you previously saved Tcl/Tk, find the full path to wish86t.exe (e.g., `XXXXXX\tcl\bin\wish86t.exe`), and copy it.
回到刚刚在Desktop创建的"Run Hysplit",右键找到Properties,在Target里面加入刚刚找到的路径,注意两个路径在一起,并有一个空格分开,最后单击OK完成。
Then, go back to the "Run Hysplit" shortcut you just created on your Desktop, right-click it and select Properties. In the Target field, add the path you just copied after the existing path. Make sure the two paths are separated by a space. Finally, click OK to save the changes.
双击"Run Hysplit",就可以运行了。
Now, double-click "Run Hysplit" to launch the program.

Test the Installation with GUI

如图所示打开Contour Map,并在新窗口按照下图所示配置测试数据,最终单击“Run CONTOUR”。
As shown in the figure, open Contour Map, and in the new window, configure the test data as illustrated. Finally, click "Run CONTOUR".
如果返回如下图的结果,就表示安装成功了。
If you get a result like the one shown below, it means the installation was successful.

References

  1. HYSPLIT - Wikipedia
  2. Air Resources Laboratory - HYSPLIT - Hybrid Single Particle Lagrangian Integrated Trajectory model
  3. HYSPLIT Basic Tutorial Contents ©
  4. Hysplit User's Guide. April 2025.

Monday, March 24, 2025

Matlab: 本地部署Deepseek,对话模式

一、下载Ollama,修改默认安装路径
二、本地部署模型
三、MATLAB安装LLMs
四、Matlab检测代码

一、下载Ollama,修改默认安装路径

Ollama 是一个可以让你使用并管理 AI 模型的工具,相当于 R1 的承载器具,因此我们在本地部署模型前必须先安装 Ollama。打开 「Ollama 官网:」https://ollama.com/,点击“Download”。
选择适合你电脑的版本,例如“「Windows」”点击“「Download for Windows」”。
安装到指定的路径
下载完成后,双击安装,默认会装到C盘。通过如下方式修改,举例:我想安装在D:\Ollama
  1. 把下载的安装包放在D:\Ollama下
  2. 在D:\Ollama下,打开cmd,输入此命令敲回车即可 OllamaSetup.exe /DIR="D:\Ollama"
  3. 此时就可以看到Ollama被安装到指定路径了。(如果你下载完直接点了安装,也不用担心,直接控制面板程序卸载,卸载了,重新安装即可)

二、本地部署模型

  1. 部署之前,增加环境变量
  2. 增加这个环境变量的话,下载的模型会存储在此,避免占用C盘内存。 注意:增加后,重启电脑以确保生效。
  3. 本地部署deepseek模型
  4. 在cmd下输入命令③代码,即可安装。

      三、MATLAB安装LLMs

      打开网页,添加此到当前Matlab。

      四、Matlab检测代码

      第一步,现在cmd里面运行部署的模型ollama run deepseek-r1:14b。
      第二步,matlab中运行:file

      References

Wednesday, March 12, 2025

Matlab: Wind Rose

风速玫瑰图的制作参考“风向频率玫瑰图”,各风向的风速代表该方向的平均风速。风速玫瑰如下图。数据中0°表示静风,360°表示正北风。
The creation of the wind speed rose diagram follows the wind direction frequency rose diagram, where the wind speed for each direction represents the average wind speed in that direction. The wind speed rose diagram is shown below. In the dataset, 0° represents calm wind, while 360° indicates due north wind.
风向频率玫瑰图的制作参考“风向玫瑰图”,所不同的是这个玫瑰图有37个风向,分别是0:10:360,0°表示静风,360°是为正北风。测试数据的制图结果如下图,静风频率位于下图的中间,一个红边的圆形,例子中的这个静风频率太小了,所以看起来是一个红点。
The creation of the wind direction frequency rose diagram is based on the wind rose diagram, but with a key difference: this diagram includes 37 wind directions, ranging from 0° to 360° in 10° increments. In this dataset, 0° represents calm wind, while 360° indicates due north wind. The plotted results for the test data are shown below. The calm wind frequency is represented by a red-bordered circle in the center of the diagram. In this example, the calm wind frequency is very low, so it appears as a red dot.
The combination of wind frequency, wind direction, and wind speed.

Monday, March 3, 2025

Matlab: Export the selected polygons from the Shapefile

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
% Shp Path
shppath='NFDB_poly_20210707.shp';
S = readgeotable(shppath);
[~, prjname, ~]=fileparts(shppath);
prjpath=[prjname, '.prj'];

% Example: Select polygons where 'LandType' is 'Forest' and 'Area' > 1000
selected_rows = S(S.SRC_AGENCY == "MB" & S.YEAR ==2017, :);


% Loop
for ii=5:10
    rows=selected_rows(selected_rows.MONTH==ii, :);


    otpath=2017*100+ii;
    copyfile(prjpath, [num2str(otpath), '.prj']);
    otpath=[num2str(otpath), '.shp'];

    shapewrite(rows, otpath);
    

end

Wednesday, February 26, 2025

Data: Purple Air Data

File. V2
  1. https://www2.purpleair.com/
  2. https://api.purpleair.com/#api-sensors-get-sensors-data
  3. https://develop.purpleair.com/dashboards/organization

Monday, February 17, 2025

Matlab: Batch Mapping

This program requires all images and shapefiles to be in a **Geographic Coordinate System**.
Mapping with a large number of latitude and longitude points.

Wednesday, February 12, 2025

Matlab: MCD64A1

This program can extract burnt locations from MCD64A1 products. file.

Thursday, January 30, 2025

MODIS tile distribution

原始影像来自MOD44W。files
The original imagery is from MOD44W.
每次下载后,请在E盘下打开MXD文件。
After each download, please open the MXD file in the E drive.
本目录的目的在于确定目标区域覆盖的MODIS分区(TILES)。
The purpose of this directory is to determine the MODIS tiles covering the target area.
List of the target areas:
Manitoba: h11v03, h11v04, h12v03, h13v03; -95, 49, -102, 60
Winnipeg: h11v03, h11v04 (most); -97, 49, -95, 51