BMElib Mapping of Air Pollution


Environmental Crisis Management


Marc Serre and Will Vizuete


Following are instructions to use the BMElib Mapping tool in Environmental Crisis Management. The tool consists in a MATLAB numerical library called BMElib, and in a MATLAB mapping analysis tool.



·       Get access to MATLAB. See instructions at the end of this page to either download it to your computer, or use Virtual Computing Lab to access it through a remote desktop, or use Virtual Lab to access it virtually.

·       Download, unzip it into a folder named BMElib.

·       Download, unzip it into a folder named mappingAnalysis.

·       Open MATLAB, navigate to the BMElib folder, and run startup.

·       In MATLAB, navigate to the mappingAnalysis folder, and follow the instructions in the 0readme file. In short, run the analysisH2S_students.m program to reproduce the results of the example below, then change that program so it uses your observational data, and your values for the mapping parameters (arMajor, ratio, angle, zCutoffs).




Imagine that you have done air quality sampling of H2S concentrations, and obtain the observational data shown in Fig 1a below. You can create a map that interpolates these observations using a method called BME kriging. Following is an example of BME kriging using the analysisH2S_students.m program located in the mappingAnalysis folder.


You need to know three things in order to do BME kriging. First you need to know the wind direction angle, measured counter clockwise with 0 degree corresponding the East-West direction, and 90 degree corresponding to the North-South direction. The angle must be between -90 and +90, so both East-West and West-East directions are 0 degree. You then need to know the length of a typical air pollution plume along the wind direction. Finally you need to know the aspect ratio of a plume, which is the ratio of the length of the plume by the width of the plume.


Let us imagine that you obtained a model prediction of the plume.  Upon inspection of the air quality model prediction, let us imagine that you find that the wind is aligned with the 60 degree angle direction. Furthermore, let us imagine that you see that the length of a typical air pollution plume is about 10 km along the wind, and that the width of that typical plume is about 2 km across the wind direction. Hence the ratio of length over the width is 5. The spatial coordinates in fig. 1a are expressed in longitude and latitude degrees, where 1 degree is about 100 km. Hence the length of the plume of 10 km is expressed as 0.1 degree. Using these parameter (angle =60 degree, length of plume = arMajor = 0.1 degree, and ratio = 5), you get the interpolation shown in fig. 1b. As you can see, this map exhibits an anisotropy at angle=60 degree and ratio=5.



Figure 1: Map of (a) the H2S observations, (b) the BME estimate of H2S concentrations



You may further want to know where you should place your next sampling points. A good guide for the placement of your next sampling points is to choose locations where the estimation error variance is high. The map of the estimation error variance is shown in fig. 2a. As you can see, the estimation error variance is high in locations that are far from any sampled locations.


If you know a toxic level for this air pollutant, then you may want to know where the air pollution levels are greater than that toxic level. You may do this by calculating the probability that the air pollutant is greater than that toxic level. Let us imagine that the toxic level you are interested in is 100 ppb. Fig. 2b shows Prob[H2S>100 ppb], with a color scheme of red when Prob[H2S>100 ppb] is greater than 0.9 (i.e. where you are sure there is exceedance of the toxic level), blue where Prob[H2S>100 ppb]<0.05 (i.e. where you are sure the air is safe). The remaining area is not colored, and represents the area where you are uncertain whether there is exceedance of the toxic level.


Note that in the example we use a toxic cutoff level of 100 ppb, but this is purely a fictitious example. In fact in this example we are actually using three cutoff levels (zCutoffs=[10 100 1000]). This is because in reality you will obtain these cutoff levels based on a literature review to know levels at which people start to feel various adverse effects. As a result you may create map a map like fig. 2b for various toxic cutoff levels, with an action that depend on the toxic level considered and the health effect at that cutoff level. For example you may consider a low toxic cutoff level where the action is to mitigate the effect for people at risk, and another, higher, cutoff level where the action to is to evacuate all people.



Figure 2: Map of (a) the estimation error variance, and (b) the exceedance areas using a toxic level of 100 ppb




Information on MATLAB



MATLAB is a high performance language for technical computing from Mathworks.


Running MATLAB on your computer

To run MATLAB on your local computer you just need to obtain the software from the UNC and follow their instructions to install it on your computer. In short, search for Matlab, enter your onyen, click on the “Term” tab, note the license number for Students (334072) and Faculty/Staff (334062), start the MATLAB Installer (to get it to and click on “Download R2019b”), and follow the instructions.


Running MATLAB remotely on a UNC computer using Virtual Computing Lab

Go to the UNC Virtual Computing Lab, login with your onyen, click on Reservation and then on “new reservation”, select a computer with MATLAB, such as “Matlab 9.7 R2019b, Windows 10 (Full Blade)”, click on “Create Reservation”. Once the reservation is ready, click on the ‘Connect!’ button, save the password and click on ‘Get RDP File’, double click on the downloaded RDP file, click on ‘Connect’, and enter the password.

Once you have accessed the remote computer, you can access data on your computer by using File Explorer, going to “Matlab 9.7 R2019b, Windows 10 (Full Blade)”, then to the C drive on your computer. You should copy file from your computer to the remote computer or speed up computer processing time. If you are using BMElib, you should install it directly on the remote computer.


Running MATLAB via a browser using Virtual Lab

Using Virtual Lab you can run MATLAB on your local computer without installing the MATLAB software. All you need on your computer is a web browser and navigating to, and clicking on the “Matlab” icon. Once Matlab starts you can access your local desktop by navigating to “C:\Users\yourusername\Desktop”. If you are using BMElib, you should put the BMElib folder on your desktop and access it in Matlab by navigating to C:\Users\yourusername\Desktop\BMELIBfold.


Running MATLAB from the UNC computer cluster

For advanced users with large jobs, it may be useful to run MATLAB from the computer clusters provided by Research Computing at UNC. Consult the Research Computing Presentations, and read about how to use their use their resources (e.g. “Using Longleaf”), how to use linux (e.g. “Linux introduction”), and how to use matlab on the cluster (e.g. “Introduction to Matlab”)


Learning how to use MATLAB :

Check out the material available from the MATLAB on-line documentation on Getting Started with Matlab available at the following link: