International Journal of u- and e- Service, Science and Technology Vol.7, No.1 (2014), pp.19-36 http://dx.doi.org/10.14257/ijunesst.2014.7.1.03
Developing Matlab Scripts using Meteorological Data for Environmental Monitoring and Assessment S. A.Quadri, Othman Sidek, Hadi Jafar, Nur Amira binti Amran, Ummi Nurulhaiza bt Zabah and Azizul bin Abdullah Collaborative Microelectronic Design Excellence Centre (CEDEC) Universiti Sains Malaysia, Engineering Campus, Nibong Tebal Malaysia, 14300
[email protected] Abstract The world is facing the challenge of global warming and climate change issues. The objective of the study is to examine the meteorological data that constitute the environment and their balance has prevailing effect on the global warming. The meteorological data in our study refers to temperature, humidity, carbon dioxide and oxygen. We deploy our own customized hardware setup to obtain the data. Provided with this basic data, many significant parameters such enthalpy, dew point, humidity ratio, actual vapor pressure, saturated vapor pressure, partial vapor pressure and specific volume could be derived. We have presented simple functions in Matlab programming to derive these parameters. Our concluding Matlab program is as good as calculator, and the output is visualized by plotting function. Keywords: Climate change, Global warming, Meteorological data, Matlab, Environment monitoring device, Humidity, Temperature
1. Introduction The issues of global warming and climate change have become a subject of intense interest all over the world since the last decade. Warming of the climate system is now evidenced from observations of increases in global average air and ocean temperatures, widespread melting of snow and ice, and rising global average sea level. Climate change will affect numerous sectors and productive environments, including agriculture, forestry, energy, and coastal zones. Moreover, failing to safeguard the environment eventually threatens economic and social achievements. The anthropogenic driver of climate change is the increasing concentration of greenhouse gases (GHG) in the atmosphere. Carbon dioxide (CO2) is the most important anthropogenic GHG, and the global increases in CO2 concentration are due primarily to fossil fuel use and land use change. The increase in GHG concentrations in the atmosphere affects processes and feedbacks in the climate system. Qualitatively, an increase of atmospheric GHG concentrations will lead to an average increase of the temperature of the surface-troposphere system [1-2]. The temperature trend in Malaysia, due to global warming is addressed by many researchers in the literature [3-5]. All studies in this regard certainly affirm mean annual increase of temperature. Thus showing perfect agreement with the report of the IPCC [6]. Our project has a lengthy procedure that encompasses development of hardware platform by assembling various sensors on microcontroller board; Firmware programming to facilitate sensors to obtain data and transmit data wirelessly; Matlab programming utilizing the
ISSN: 2005-4246 IJUNESST Copyright ⓒ 2014 SERSC
International Journal of u- and e- Service, Science and Technology Vol.7, No.1 (2014)
equations and formula that relates these basic parameters (temperature and humidity), thus presenting a calculator that output various derived parameters. Scientific analysis of each derived parameters and its impact on the environment. At the first stage of our study, we assemble all the sensors and deploy it to obtain the basic parameters. Section 2 concisely outlines the hardware and software description. In the next stage, we develop functions and programs to derive various temperature-humidity related parameters. Section 3 briefly discuss the potential of Matlab programming and emphasize how each relations and formulas are translated in Matlab. Finally, we visualize the output obtained from the data by plotting the graphs.
2. Experimental Setup In this section, we discuss the hardware and software issues involved in obtaining meteorological data. 2.1. Environment Monitoring Device (EMD) Our project comprises of development of Environment Monitoring Device (EMD), which is an assembly of commercial available sensors fixed on Arduino prototyping hardware platform. The user-friendly nature of the platform provides us liberty such that any number and any type of sensors could be accommodated on the board. Three different types of sensors, namely Carbon dioxide sensor, temperature & humidity sensor and oxygen sensor are fixed on the board. In order to send the output data wirelessly the board is equipped inbuilt wifi facility. The hardware setup is shown in Figure 1.
Figure 1. Hardware Setup of Environment Monitoring Device (EMD) The microcontroller on the board is programmed using the Arduino programming language. Arduino [7] is open-source software. Its flexible and easy-to-use platform provides a means to coordinate hardware components on the board. It is a potential tool for software
20
Copyright ⓒ 2014 SERSC
International Journal of u- and e- Service, Science and Technology Vol.7, No.1 (2014)
programmers and hardware designers that facilitate in creating interactive objects or environments for numerous applications. Functional block diagram of EMD is shown in Figure 2.
Figure 2. Functional Block Diagram of Environment Monitoring Device Arduino projects can be stand-alone or they can communicate with software running on a computer. In our case, all the sensor output data is wirelessly transmitted to a laptop where we have preinstalled Arduino Software. A graphical user interface displays online current readings, as shown in the Figure 3. The measurements could be easily recorded in comma separated vales (CSV) using data logger facility.
Figure 3. Graphical User Interface Display of Sensor Output
Copyright ⓒ 2014 SERSC
21
International Journal of u- and e- Service, Science and Technology Vol.7, No.1 (2014)
3. Software Development Approach The problem of global warming and climate change is massive and complex. In our opinion, collaborative effort is required from various disciples like environment experts, statisticians, hardware engineers and software programmers. Software programmers could contribute by developing programs for data abstraction, data mining, data processing and data visualization etc., thus providing a better means for indepth scientific data analysis. In this section, we make an effort to show how Matlab could be used as a prospective tool in metrological data analysis. 3.1. Matlab Programming Matlab© is a high-level language and interactive environment for numerical computation, visualization, and programming. Matlab (matrix laboratory) is a numerical computing environment and fourth-generation programming language developed by MathWorks [8]. Using Matlab, one can analyze data, develop algorithms, and create models and applications. Matlab has wide range of applications, including signal processing and communications, image and video processing, control systems, test and measurement, computational finance, and computational biology. 3.2. Key Features of Matlab a) High-level language for numerical computation, visualization, and application development. b) Interactive environment for iterative exploration, design, and problem solving. c) Mathematical functions for linear algebra, statistics, Fourier analysis, filtering, optimization, numerical integration, and solving ordinary differential equations. d) Built-in graphics for visualizing data and tools for creating custom plots. e) Development tools for improving code quality and maintainability and maximizing performance. f) Tools for building applications with custom graphical interfaces. g) Functions for integrating Matlab based algorithms with external applications and languages such as C, Java, .NET, and Microsoft ®Excel. h) Programming is elegant, user friendly and appealing. 3.3. Matlab Coding - Examples The language, tools, and built-in math functions enable us to explore multiple approaches and reach a solution faster than with spreadsheets or traditional programming languages, such as C/C++ or Java © . In this discussion, various interrelated formulas were utilized to derive these temperaturehumidity related factors, for each of these factors, respective functions are written, which are called by the main program during execution. 3.3.1. Temperature Unit Conversion: We will start with a simple and most frequently used program. The commonly used temperature units are Fahrenheit and Celsius. Many a times we
22
Copyright ⓒ 2014 SERSC
International Journal of u- and e- Service, Science and Technology Vol.7, No.1 (2014)
require conversion. When the unit of interest is degree Celsius, we require converting Fahrenheit to Celsius and vice versa. From the basic resources [9], we have the basic formula: [°C] = ([°F] − 32) / (1.8) [°F] = [°C] ×1.8 + 32 A simple code illustrating the same is shown in Figure 4.
Figure 4. Program to Convert Temperature Units 3.3.2. Saturated Vapor Pressure: The saturation vapor pressure is the pressure of a vapor when it is in equilibrium with the liquid phase. It is solely dependent on the temperature. As temperature rises, the saturation vapor pressure rises as well. Vapor pressure is a measurement of the amount of moisture in the air. It is technically the pressure of water vapor above a surface of water. When air reaches the saturation vapor pressure, the water vapor in it will be condensed [10]. The calculation is complex and requires ample knowledge of Algebra. The known parameters are temperature and humidity, obtained from the EMD kit. We proceed our calculation by using the relation among, actual vapor pressure (e), saturated vapor pressure (pvs) and partial vapor pressure (pvp), expressed in Equation 1 and 2 [11].
Equation (1) The value of e can be calculated by using the exponential rules in Algebra. We write a function named (function_pvs) with series of coefficients (a1 to a13 shown in code, see Figure 5) in order to find the value of PVS. Once, we get the value of PVS we can find PVP by using the relation:
Copyright ⓒ 2014 SERSC
23
International Journal of u- and e- Service, Science and Technology Vol.7, No.1 (2014)
Equation (2) [11]
Figure 5. Program to Calculate Saturated Vapor Pressure 3.3.3. Dew Point Temperature: The dew point is the temperature below which the water vapor in air at constant barometric pressure condenses into liquid water at the same rate at which it evaporates. The condensed water is called dew, when it forms on a solid surface. It is a water-to-air saturation temperature. The dew point is associated with relative humidity. A high relative humidity indicates that the dew point is closer to the current air temperature. Relative humidity is at all temperatures and pressures defined as the ratio of the water vapor pressure to the saturation water vapor pressure (over water) at the gas temperature. Dew point temperature is calculated using the Equation (3) [12], equivalent function in Matlab is shown in Figure 6. Equation (3)
Figure 6. Program to Calculate Dew Point
24
Copyright ⓒ 2014 SERSC
International Journal of u- and e- Service, Science and Technology Vol.7, No.1 (2014)
3.3.4. Humidity Ratio: Humidity ratio (HR) is expressed as the ratio between the actual mass of water vapor present in moist air to the mass of the dry air. It can also be expressed with the partial pressure of water vapor. The relationship of HR with atmospheric pressure and partial vapor pressure is given below [12]: HR = 0.622 (Partial vapor pressure) / (Pressure of moist air - Partial vapor pressure) Thus, we encode the relationship in Matlab as shown in Figure 7.
Figure 7. Single Line Instruction to Calculate Humidity Ratio 3.3.5. Enthalpy: Enthalpy is a measure of the total energy of a thermodynamic system. It includes the system's internal energy, as well as its volume and pressure. It is the preferred expression of system energy changes in many chemical, biological, and physical measurements, because it simplifies certain descriptions of energy transfer. Enthalpy change accounts for energy transferred to the environment at constant pressure through expansion or heating [13]. Enthalpy is the amount of heat content used or released in a system at constant pressure. Enthalpy is usually expressed as the change in enthalpy. The change in enthalpy is related to a change in internal energy (U) and a change in the volume (V), which is multiplied by the constant pressure of the system. Enthalpy (H) is the sum of the internal energy (U) and the product of pressure and volume (PV) given by the equation: H = U + PV
Equation (4) [14]
When a process occurs at constant pressure, the heat evolved (either released or absorbed) is equal to the change in enthalpy. Enthalpy is a state function which depends entirely on the state functions T, P and U. It is usually expressed as the change in enthalpy (ΔH) for a process between initial and final states: ΔH = ΔU + ΔPV
Equation (5) [14]
If temperature and pressure remain constant through the process and the work is limited to pressure-volume work, then the enthalpy change is given by the equation: ΔH = ΔU + PΔV
Equation (6) [14]
Enthalpy can also be expressed as a molar enthalpy, ΔHm, by dividing the enthalpy or change in enthalpy by the number of moles. Enthalpy is a state function. This implies that when a system changes from one state to another, the change in enthalpy is independent of the path between two states of a system. If there is no non-expansion work on the system and the pressure is still constant, then the change in enthalpy will equal the heat consumed or released by the system (q). ΔH=q
(Equation 7) [14]
This relationship can help to determine whether a reaction is endothermic or exothermic. At constant pressure, an endothermic reaction is when heat is absorbed. This means that the system consumes heat from the surroundings, so q is greater than zero. Therefore, according to the second equation, the ΔH will also be greater than zero. On the other hand, an
Copyright ⓒ 2014 SERSC
25
International Journal of u- and e- Service, Science and Technology Vol.7, No.1 (2014)
exothermic reaction at constant pressure is when heat is released. This implies that the system gives off heat to the surroundings, so q is less than zero. Furthermore, ΔH will be less than zero. When the temperature increases, the amount of molecular interactions also increases. When the number of interactions increase, then the internal energy of the system rises. According to the first equation given, if the internal energy (U) increases then the ΔH increases as temperature rises. We can use the equation for heat capacity and Equation (7) to derive this relationship. C=q/ΔT
Equation (8) [15]
At constant pressure, substitute Equation (7): Cp=ΔH/ΔT
Equation (9)
Enthalpy can be calculated from mixing ratio equation [15]: h = T • (1.01 + 0.00189X) + 2.5X (kJ/kg)
Equation (10)
Where T= Temperature (°C) and X= Mixing ratio (g/kg) The mixing ratio is the mass of water vapor in a particular mass of dry air .The unit is g/kg. The mixing ratio (mass of water vapor/mass of dry gas) is calculated using relation [15]: X = B•Pw /(Ptot -P w )
(Equation 11)
Where Pw = vapor pressure and Ptot = Total ambient pressure The value of B depends on the gas. The value 621.9907 g/kg is valid for air [16]. B = 621.9907 g/kg Thus, the equations are first simplified and then encoded in Matlab as shown in Figure 8
Figure 8. Code Line to Calculate Enthalpy Change 3.3.6. Specific Volume: Specific volume of a substance is the ratio of the substance's volume to its mass. It is inversely proportional to density. If the density of a substance doubles, its specific volume, as expressed in the same base units, is cut in half. If the density drops to 1/10 its former value, the specific volume, as expressed in the same base units, increases by a factor of 10. The density of gases changes with even slight variations in temperature, while densities of liquid and solids, which are generally thought of as incompressible, with change to a very little. Specific volume is the inverse of the density of a substance; therefore, careful consideration must be taken account when dealing with situations that involve gases. Small changes in temperature will have a noticeable effect on specific volumes. Specific volume for an ideal gas is also equal to the gas constant (R) multiplied by the temperature and then divided by the pressure. Vh= RT/P
Equation (12) [17]
The specific gas constant (R) for dry air is 287.058 J/ (kg • K) in SI units [9]. Thus, the relation is encoded in Matlab function shown in Figure 9.
26
Copyright ⓒ 2014 SERSC
International Journal of u- and e- Service, Science and Technology Vol.7, No.1 (2014)
Figure 9. Function to Calculate Specific Volume 3.3.7. Main Program: The main program is shown below, it starts requesting the user to input temperature and relative humidity values. The programs thus calling various functions executes and stores all the final values in a file.
Figure 10. Main Program
4. Results Graphs are means of visual representation depicting relationship between variables. They are very useful for researchers; facilitate better analysis and understanding that would not come from mere lists of values. In this section, we present graphs of various environmental effecting parameters plotted against time.
Copyright ⓒ 2014 SERSC
27
International Journal of u- and e- Service, Science and Technology Vol.7, No.1 (2014)
4.1. Plotting the Graphs The successful execution of the main program ends up in safely saving the respective output values in a file; in our case, we have named it as ‘output-data’ file. Simple plot functions are executed to get the graphs; the already saved file (output-data) should be loaded as a prerequisite. Thus, a set all graphs depicting various temperature-humidity parameters are plotted. Figure 11 shows few lines of code to obtain graph of enthalpy versus time, in the same way we can plot graphs for vapor pressure at saturation (pvs), partial vapor pressure(pvp), humidity ratio (hr), enthalpy (enthal), dew point (dp) and specific volume (vh). All these parameters were plotted considering the readings for one complete day, thus 24 hours x 60 minutes makes 1440 values, shown along X-axis. Figures 12 to 16 show graphs for basic parameters (temperature, relative humidity, carbon dioxide and oxygen) versus time, Figures 16 - 20 illustrate graphs for derived parameters.
Figure 11. Plotting Instructions to obtain Enthalpy versus Time Graph
Figure 12. Graph Shows Temperature Versus Time Plot
28
Copyright ⓒ 2014 SERSC
International Journal of u- and e- Service, Science and Technology Vol.7, No.1 (2014)
Figure 13. Graph Shows Relative Humidity Versus Time Plot
Figure 14. Graph Shows Atmospheric Carbon dioxide Versus Time Plot
Copyright ⓒ 2014 SERSC
29
International Journal of u- and e- Service, Science and Technology Vol.7, No.1 (2014)
Figure 15. Graph Shows Atmospheric Oxygen Versus Time Plot
Figure 16. Graph Shows Saturation Vapor Pressure Versus Time Plot
30
Copyright ⓒ 2014 SERSC
International Journal of u- and e- Service, Science and Technology Vol.7, No.1 (2014)
Figure 17. Graph Shows Dew point Versus Time Plot
Figure 18. Graph Shows Humidity Ratio Versus Time Plot
Copyright ⓒ 2014 SERSC
31
International Journal of u- and e- Service, Science and Technology Vol.7, No.1 (2014)
Figure 19. Graph Shows Enthalpy Versus Time Plot
Figure 20. Graph Shows Specific Volume Versus Time Plot
32
Copyright ⓒ 2014 SERSC
International Journal of u- and e- Service, Science and Technology Vol.7, No.1 (2014)
4.2. Comparison with other Online Calculators In order to crosscheck the results, the output obtained from the Matlab scripts is compared with two online available humidity calculators. These are available on websites [http://www.vaisala.com] and [http://easycalculation.com]. The comparison confirms the output values are almost same. Thus, translation of equations and formulas into Matlab scripts did not sacrifice the accuracy and precision of the derived parameters. As an example to illustrate, we have plotted the graph of dew point versus time taking into account for all three set of output. Let us call the output from [www.vaisala.com] as online calculator 1, shown in red color; output from [www.easycalculation.com] as online calculator 2, shown in black color; Matlab program output is shown in blue color. Figure 21 shows all the three output lines (values) almost overlapping with each other.
Figure 21. Graph plotted for Dew Points obtaining Three Different Set of Readings
5. Conclusion and Future Work The issue of global warming is one of the most critical problems of the era. Extensive research is required to be focused on scientific facts and figures. Evidence has surfaced that there is substantial increment in carbon dioxide and temperature levels; moreover, their correlation cannot be ignored. In this paper, we presented Matlab as a potential tool to study various temperature-humidity related factors. The individual contribution of each factor to cumulative effluence could be explored. Scientific data analysis and interpretation would lead to helpful conclusions about climate change. Visualization of data and appropriate decision tools, complementing level-risk analysis, could establish overall safety policies and acceptable levels.
Copyright ⓒ 2014 SERSC
33
International Journal of u- and e- Service, Science and Technology Vol.7, No.1 (2014)
One of the critical concerns of the project is about real time performance of the sensors after deployment. Issue of calibration accuracy, precision and hysteresis, has to be taken in to account in order to avoid incorrect data and false alarms, this task has been kept as a future work.
References [1] [2] [3]
[4]
[5]
[6]
[7] [8] [9] [10]
[11] [12]
[13] [14] [15]
[16] [17]
IPCC Fourth Assessment Report on Climate Change, available online, http://www.ipcc.ch/publications_and_data/ar4/wg3/en/contents.html (accessed November 2013). T. E. Downing, “Views of the frontiers in climate change adaptation economics”, Wiley Interdisciplinary Reviews: Climate Change, vol. 3, no. 2, (2012), pp. 161-170. A. L. Camerlengo, A. K. Wahab, H. N. Baharim, K. A. M. Nasir and Y. R. Lim, “Climatologically Distribution of Certain Meteorological Parameters in the Highland Areas and the Lowland Areas of Peninsular Malaysia”, Malaysian Journal of Physics, vol. 24, no. 1, (2003), pp. 39-49. W. K. Fong, H. Matsumoto, C. S. Ho and Y. F. Lun, “Energy consumption and carbon dioxide emission considerations in the urban planning process in Malaysia”, Journal of the Malaysian Institute of Planners, vol. 6, (2008), pp. 101-130. W.-K. Fong, H. Matsumoto and Y.-F. Lun, “Application of System Dynamics model as decision making tool in urban planning process toward stabilizing carbon dioxide emissions from cities”, Building and Environment, vol. 44, no. 7, (2009), pp. 1528-1537. J. T. Houghton, D. J. Ding, M. Griggs, P. J. Noguer, V. Linden and X. Dai, “Climate Change 2001: The Scientific Basis”, Contribution of Working Group I to the Third Assessment Report of the Intergovernmental Panel on Climate Change (IPCC), Cambridge University Press, New York, (2001). http://arduino.cc/ (accessed November 2013). http://www.mathworks.com/products/matlab/ (accessed November 2013). R. E. Bentley, “The Theory and Practice of Thermoelectric Thermometry”, Handbook of Temperature Measurement, Springer- Verlag, Singapore, vol. 3, (1998), pp. 15-20. H. Bob, “ITS-90 Formulations for Vapor Pressure, Frost point Temperature”, Dew point Temperature, and Enhancement Factors in the Range –100 to +100 C”, Proceedings of the Third International Symposium on Humidity & Moisture, London, vol. 1, (1998), pp. 214-222. National Weather Service Southern Region report, http://www.srh.noaa.gov/images/epz/wxcalc/rhTdFromWetBulb.pdf (accessed November 2013). M. G. Lawrence, “The relationship between relative humidity and the dew point temperature in moist air: A simple conversion and applications”, Bulletin of the American Meteorological Society, vol. 86, no. 2, (2005), pp. 225-233. G. J. V. Wylen and R. E. Sonntag, “Fundamentals of Classical Thermodynamics”, 3rd edition, Wiley, UK, (1986), pp. 99-112. R. H. Petrucci, F. G. Herring, J. D. Madura and C. Bissonnette, “General Chemistry: Principles and Modern Applications”, 10th edition, Pearson Prentice Hall, NJ, (2010), pp. 312-337. W. Wagner and A. Prub, “The IAPWS Formulation 1995 for the Thermodynamic Properties of Ordinary Water Substance for General and Scientific Use”, Journal of Physical and Chemical Reference Data, vol. 31, no. 2, (2002), pp. 387-535. P. Sirvatka, “Introduction to Meteorology”, Lecture Notes, College of DuPage, US, available online, http://weather.cod.edu/(accessed November 2013). M. J. Moran and H. N. Shapiro, “Fundamentals of Engineering Thermodynamics”, John Wiley & Sons, New York, 4th edition, (2000), pp. 142- 156.
Authors S. A. Quadri graduated as Bachelor of Engineering in Electronics & Communication from Karnataka University Dharwad. He completed his M.Tech (Computer Science & Engineering) from VTU Belgaum. He served as Assistant professor in various Engineering colleges. Before joining as Research associate in CEDEC he served 3 years as HOD of Computer Science & Engineering department in SIET College, affiliated to VTU, approved by AICTE Delhi, India. His research domain includes multisensor data fusion & neural networks.
34
Copyright ⓒ 2014 SERSC
International Journal of u- and e- Service, Science and Technology Vol.7, No.1 (2014)
Professor Othman bin Sidek an esteemed Malaysian scientist holds a PhD (Info. Sys. Eng.) from Bradford University, UK. He has served Universiti Sains Malaysia since 1984 as a lecturer, researcher, & administrator. Prior to joining USM, he was a trainee engineer with Multinational Companies & continued to take very active role in both academic & university-industry research collaborations. Professor is also the Founder of the Collaborative Micro-electronic Design Excellence Centre (CEDEC), an approved centre at USM by the Malaysian Ministry of Finance in 2005 out of his own initiative.
Hadi Jafar graduated from USM with Electronic Engineering Degree in the year of 2010. Currently doing his Masters in Embedded System title Design, Development and Test of Structure Sensor and are the one who build the sensors system.
Nur Amira binti Amran graduated from USM with Electrical Engineering Degree in the year of 2010. Currently doing Masters in Power Electronic and Device title Energy Reservoir Management System for WSN.
Ummi Nurulhaiza bt Za’bah graduated from Universiti Sains Malaysia with Degree in Electrical & Electronic Engineering in 2010. Currently doing Masters in RF system & Electromagnetic Compatibility. In this project, she is the one building the wireless communication & networking system.
Azizul bin Abdullah graduated from USM with Aerospace Engineering Degree & Masters in the year of 2008 & 2012 respectively. Currently doing his research in ‘Development of wide secured wireless sensor network (WSN) with unmanned aerial vehicle (UAV) deployment for the monitoring of ecology & global warming studies towards environment sustainability’ and are the one who analysis designs of Agrotech 2020 UAV.
Copyright ⓒ 2014 SERSC
35
International Journal of u- and e- Service, Science and Technology Vol.7, No.1 (2014)
36
Copyright ⓒ 2014 SERSC