Exercise Related to the Course “Physics and Chemistry of Air Pollution and Their Effects” This Exercise Is Mandatory in Order to Pass the Course

Total Page:16

File Type:pdf, Size:1020Kb

Exercise Related to the Course “Physics and Chemistry of Air Pollution and Their Effects” This Exercise Is Mandatory in Order to Pass the Course Exercise related to the course “Physics and Chemistry of Air Pollution and their Effects” This exercise is mandatory in order to pass the course. The main reason why we require all students to do this is to get everybody familiar with MATLAB (or other advanced data analysis software) and spend more time on data analysis than just learning the software. The course is short and intensive, so it is imperative to have some basic skills when the course starts. While doing this exercise you are (if not experienced) likely to get stuck a few times. When that happens then read the help files, search the internet, ask colleagues and succeed! Using MATLAB is a lot about determination. And – last, working together with your fellow students to solve this exercise is of course good, but do take the time to understand the problem and the solution on your own. The University of Helsinki provides its students and staff with MATLAB. It is recommended that you learn to use a software that you can continue using after the Hyytiälä course. If you do not have access to MATLAB (and even if you do), there are several freeware and open source alternatives available. To mention a few: - FreeMat (very MATLAB like) http://freemat.sourceforge.net/ - Octave (own MATLAB like language) http://www.gnu.org/software/octave/ - R http://www.r-project.org/ - SageMath (Python language) http://sagemath.org/index.html - SciLab (very MATLAB like) http://www.scilab.org/ A lot more alternatives can be found e.g. at - http://www.freestatistics.info/en/stat.php - http://en.wikipedia.org/wiki/List_of_numerical_analysis_software Please learn at least the basics of your software BEFORE the course! The task Use the supplied data file and to make a plot with 1. Daily averaged SO2 concentration and temperature at 67.2 m against the days of 1 January 2006 – 31 March 2006 2. Label axes (NB two y-axes!), put reasonable colours/dots for the variables 3. Save the figure and send it by e-mail to [email protected] latest by Monday, th March 14 . Feel free to include suggestions how this exercise could be improved. st 4. There will be a short MATLAB session on on Monday, March 21 . The solution for this exercise will be shown and discussed then. Your end result should look something like Fig. 1. On the next page you will find an outline on how to solve the problem. The supplied file is a .dat file that contains a matrix that can be directly imported to Matlab either with the load (or similar) command or using the graphical interface. The file contains the following variables as half hourly averages for from 1 January 2006 to 30 June 2006. Download it from http://www.atm.helsinki.fi/ABS/courses/matlab_exdata_2011field_course.dat Column 1 Column 2 Column 3 Time, YYYYMMDDHHmmss [SO2], ppb, 67,2 m T, qC, 67,2 m Data that you will be working on in the course will be formatted similarly but with many more columns/variables. Since you are likely to do these operations many times later in the course it is very well worth making m-files (functions) to do the routines. Fig. 1. The result of the exercise. In order to successfully make the plot you have to do something like this: x Load the data file x Convert date and time to day of the year (day with decimals) by using the datenum and floor function. o This is not straightforward. For example the time 21 January 2006, 12:43 is written as the number 2006012124300. To extract day from this use day=floor(rem(2006012112300,10^7)/10^5) o For info on floor and rem see the help file x Extract/delete entries from the matrix so that you are left with values from 1 Jan to 31 March. x Calculate daily averages for each variable and put these together in a new matrix with date and the two variables as columns o The reshape function will be invaluable here. Count the number of days and number of data points per day… o Since data contains NaN then you cannot use normal mean function. Use nanmean. What is the danger by doing this? o Note: nanmean is part of the statistical toolbox. If you do not have this one you get the equivalent (and better) files from http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?objectId=68 37&objectType=file o Put together a new matrix with date/day, and mean [SO2] and T. x Make a plot of both T and [SO2] against time. Use connected lines in the plot. Left hand y-axis should be SO2 concentration, right hand y-axis T in qC and x-axis time in days. .
Recommended publications
  • A Comparative Evaluation of Matlab, Octave, R, and Julia on Maya 1 Introduction
    A Comparative Evaluation of Matlab, Octave, R, and Julia on Maya Sai K. Popuri and Matthias K. Gobbert* Department of Mathematics and Statistics, University of Maryland, Baltimore County *Corresponding author: [email protected], www.umbc.edu/~gobbert Technical Report HPCF{2017{3, hpcf.umbc.edu > Publications Abstract Matlab is the most popular commercial package for numerical computations in mathematics, statistics, the sciences, engineering, and other fields. Octave is a freely available software used for numerical computing. R is a popular open source freely available software often used for statistical analysis and computing. Julia is a recent open source freely available high-level programming language with a sophisticated com- piler for high-performance numerical and statistical computing. They are all available to download on the Linux, Windows, and Mac OS X operating systems. We investigate whether the three freely available software are viable alternatives to Matlab for uses in research and teaching. We compare the results on part of the equipment of the cluster maya in the UMBC High Performance Computing Facility. The equipment has 72 nodes, each with two Intel E5-2650v2 Ivy Bridge (2.6 GHz, 20 MB cache) proces- sors with 8 cores per CPU, for a total of 16 cores per node. All nodes have 64 GB of main memory and are connected by a quad-data rate InfiniBand interconnect. The tests focused on usability lead us to conclude that Octave is the most compatible with Matlab, since it uses the same syntax and has the native capability of running m-files. R was hampered by somewhat different syntax or function names and some missing functions.
    [Show full text]
  • Freemat V3.6 Documentation
    FreeMat v3.6 Documentation Samit Basu November 16, 2008 2 Contents 1 Introduction and Getting Started 5 1.1 INSTALL Installing FreeMat . 5 1.1.1 General Instructions . 5 1.1.2 Linux . 5 1.1.3 Windows . 6 1.1.4 Mac OS X . 6 1.1.5 Source Code . 6 2 Variables and Arrays 7 2.1 CELL Cell Array Definitions . 7 2.1.1 Usage . 7 2.1.2 Examples . 7 2.2 Function Handles . 8 2.2.1 Usage . 8 2.3 GLOBAL Global Variables . 8 2.3.1 Usage . 8 2.3.2 Example . 9 2.4 INDEXING Indexing Expressions . 9 2.4.1 Usage . 9 2.4.2 Array Indexing . 9 2.4.3 Cell Indexing . 13 2.4.4 Structure Indexing . 14 2.4.5 Complex Indexing . 16 2.5 MATRIX Matrix Definitions . 17 2.5.1 Usage . 17 2.5.2 Examples . 17 2.6 PERSISTENT Persistent Variables . 19 2.6.1 Usage . 19 2.6.2 Example . 19 2.7 STRING String Arrays . 20 2.7.1 Usage . 20 2.8 STRUCT Structure Array Constructor . 22 2.8.1 Usage . 22 2.8.2 Example . 22 3 4 CONTENTS 3 Functions and Scripts 25 3.1 ANONYMOUS Anonymous Functions . 25 3.1.1 Usage . 25 3.1.2 Examples . 25 3.2 FUNCTION Function Declarations . 26 3.2.1 Usage . 26 3.2.2 Examples . 28 3.3 KEYWORDS Function Keywords . 30 3.3.1 Usage . 30 3.3.2 Example . 31 3.4 NARGIN Number of Input Arguments . 32 3.4.1 Usage .
    [Show full text]
  • Towards a Fully Automated Extraction and Interpretation of Tabular Data Using Machine Learning
    UPTEC F 19050 Examensarbete 30 hp August 2019 Towards a fully automated extraction and interpretation of tabular data using machine learning Per Hedbrant Per Hedbrant Master Thesis in Engineering Physics Department of Engineering Sciences Uppsala University Sweden Abstract Towards a fully automated extraction and interpretation of tabular data using machine learning Per Hedbrant Teknisk- naturvetenskaplig fakultet UTH-enheten Motivation A challenge for researchers at CBCS is the ability to efficiently manage the Besöksadress: different data formats that frequently are changed. Significant amount of time is Ångströmlaboratoriet Lägerhyddsvägen 1 spent on manual pre-processing, converting from one format to another. There are Hus 4, Plan 0 currently no solutions that uses pattern recognition to locate and automatically recognise data structures in a spreadsheet. Postadress: Box 536 751 21 Uppsala Problem Definition The desired solution is to build a self-learning Software as-a-Service (SaaS) for Telefon: automated recognition and loading of data stored in arbitrary formats. The aim of 018 – 471 30 03 this study is three-folded: A) Investigate if unsupervised machine learning Telefax: methods can be used to label different types of cells in spreadsheets. B) 018 – 471 30 00 Investigate if a hypothesis-generating algorithm can be used to label different types of cells in spreadsheets. C) Advise on choices of architecture and Hemsida: technologies for the SaaS solution. http://www.teknat.uu.se/student Method A pre-processing framework is built that can read and pre-process any type of spreadsheet into a feature matrix. Different datasets are read and clustered. An investigation on the usefulness of reducing the dimensionality is also done.
    [Show full text]
  • The Freemat Primer Page 1 of 218 Table of Contents About the Authors
    The Freemat 4.0 Primer By Gary Schafer Timothy Cyders First Edition August 2011 The Freemat Primer Page 1 of 218 Table of Contents About the Authors......................................................................................................................................5 Acknowledgements...............................................................................................................................5 User Assumptions..................................................................................................................................5 How This Book Was Put Together........................................................................................................5 Licensing...............................................................................................................................................6 Using with Freemat v4.0 Documentation .............................................................................................6 Topic 1: Working with Freemat.................................................................................................................7 Topic 1.1: The Main Screen - Ver 4.0..................................................................................................7 Topic 1.1.1: The File Browser Section...........................................................................................10 Topic 1.1.2: The History Section....................................................................................................10 Topic 1.1.3: The
    [Show full text]
  • Freemat V4.0 Documentation
    FreeMat v4.0 Documentation Samit Basu October 4, 2009 2 Contents 1 Introduction and Getting Started 39 1.1 INSTALL Installing FreeMat . 39 1.1.1 General Instructions . 39 1.1.2 Linux . 39 1.1.3 Windows . 40 1.1.4 Mac OS X . 40 1.1.5 Source Code . 40 2 Variables and Arrays 41 2.1 CELL Cell Array Definitions . 41 2.1.1 Usage . 41 2.1.2 Examples . 41 2.2 Function Handles . 42 2.2.1 Usage . 42 2.3 GLOBAL Global Variables . 42 2.3.1 Usage . 42 2.3.2 Example . 42 2.4 INDEXING Indexing Expressions . 43 2.4.1 Usage . 43 2.4.2 Array Indexing . 43 2.4.3 Cell Indexing . 46 2.4.4 Structure Indexing . 47 2.4.5 Complex Indexing . 49 2.5 MATRIX Matrix Definitions . 49 2.5.1 Usage . 49 2.5.2 Examples . 49 2.6 PERSISTENT Persistent Variables . 51 2.6.1 Usage . 51 2.6.2 Example . 51 2.7 STRUCT Structure Array Constructor . 51 2.7.1 Usage . 51 2.7.2 Example . 52 3 4 CONTENTS 3 Functions and Scripts 55 3.1 ANONYMOUS Anonymous Functions . 55 3.1.1 Usage . 55 3.1.2 Examples . 55 3.2 FUNCTION Function Declarations . 56 3.2.1 Usage . 56 3.2.2 Examples . 57 3.3 KEYWORDS Function Keywords . 60 3.3.1 Usage . 60 3.3.2 Example . 60 3.4 NARGIN Number of Input Arguments . 61 3.4.1 Usage . 61 3.4.2 Example . 61 3.5 NARGOUT Number of Output Arguments .
    [Show full text]
  • Sageko Matlabin Korvaaja?
    Mikko Moilanen Sageko Matlabin korvaaja? Opinnäytetyö Tietotekniikan koulutusohjelma Elokuu 2012 KUVAILULEHTI Opinnäytetyön päivämäärä 4.9.2012 Tekijä(t) Koulutusohjelma ja suuntautuminen Mikko Moilanen Tietotekniikan koulutusohjelma Nimeke Sageko Matlabin korvaaja? Tiivistelmä Tässä insinöörityössä tutkitaan voiko Sagella korvata Matlabin korkeakouluopinnoissa matemaattisen analyysin opiskelutyövälineenä. Tutkimuksen perusteella arvioidaan, että onko Sagella tulevaisuutta ohjelmistona, varmistetaan Sagen toimivuus matemaattisessa analyysissa ja selvitetään, että miten helppoa yksittäisen käyttäjän on ottaa Sage käyttöön ja miten oppilaitos saa Sagen käyttöönsä. Matlab on kiistaton standardiohjelmisto matemaattisessa mallinnuksessa ja analyysissa. Sen peruslisenssimaksut ja Toolboxien lisenssimaksut ovat kuitenkin kohonneet ehkä juuri tästä syystä korkeiksi ja mikään ei estä lisenssimaksujen jatkuvaa kohoamista. Näin ollen halvemman vaihtoehdon löytäminen Matlabille korkeakouluopintojen työvälineenä on mielenkiintoinen ja hyödyllinen tutkimuskohde. Eräs mielenkiintoinen vaihtoehto Matlabille on Sage, koska se kokoaa lähes 100 matemaattista laskentaohjelmistoa yhden ja saman käyttöliittymän alle. Sage on myös suunniteltu toimimaan palvelin/asiakas -mallilla WWW-selaimella, mistä voi olla erityistä hyötyä laajoissa asennuksissa ylläpidon ja luokkahuoneidan varaamisen kannalta . Tutkimuksen tuloksena havaittiin Sagen olevan niin erilainen ja epäyhteensopiva Matlabin kanssa, että Matlab ei ole suoraan korvattavissa Sagella. Sen sijaan todettiin,
    [Show full text]
  • They Have Very Good Docs At
    Intro to the Julia programming language Brendan O’Connor CMU, Dec 2013 They have very good docs at: http://julialang.org/ I’m borrowing some slides from: http://julialang.org/blog/2013/03/julia-tutorial-MIT/ 1 Tuesday, December 17, 13 Julia • A relatively new, open-source numeric programming language that’s both convenient and fast • Version 0.2. Still in flux, especially libraries. But the basics are very usable. • Lots of development momentum 2 Tuesday, December 17, 13 Why Julia? Dynamic languages are extremely popular for numerical work: ‣ Matlab, R, NumPy/SciPy, Mathematica, etc. ‣ very simple to learn and easy to do research in However, all have a “split language” approach: ‣ high-level dynamic language for scripting low-level operations ‣ C/C++/Fortran for implementing fast low-level operations Libraries in C — no productivity boost for library writers Forces vectorization — sometimes a scalar loop is just better slide from ?? 2012 3 Bezanson, Karpinski, Shah, Edelman Tuesday, December 17, 13 “Gang of Forty” Matlab Maple Mathematica SciPy SciLab IDL R Octave S-PLUS SAS J APL Maxima Mathcad Axiom Sage Lush Ch LabView O-Matrix PV-WAVE Igor Pro OriginLab FreeMat Yorick GAUSS MuPad Genius SciRuby Ox Stata JLab Magma Euler Rlab Speakeasy GDL Nickle gretl ana Torch7 slide from March 2013 4 Bezanson, Karpinski, Shah, Edelman Tuesday, December 17, 13 Numeric programming environments Core properties Dynamic Fast? and math-y? C/C++/ Fortran/Java − + Matlab + − Num/SciPy + − R + − Older table: http://brenocon.com/blog/2009/02/comparison-of-data-analysis-packages-r-matlab-scipy-excel-sas-spss-stata/ Tuesday, December 17, 13 - Dynamic vs Fast: the usual tradeof - PL quality: more subjective.
    [Show full text]
  • Pipenightdreams Osgcal-Doc Mumudvb Mpg123-Alsa Tbb
    pipenightdreams osgcal-doc mumudvb mpg123-alsa tbb-examples libgammu4-dbg gcc-4.1-doc snort-rules-default davical cutmp3 libevolution5.0-cil aspell-am python-gobject-doc openoffice.org-l10n-mn libc6-xen xserver-xorg trophy-data t38modem pioneers-console libnb-platform10-java libgtkglext1-ruby libboost-wave1.39-dev drgenius bfbtester libchromexvmcpro1 isdnutils-xtools ubuntuone-client openoffice.org2-math openoffice.org-l10n-lt lsb-cxx-ia32 kdeartwork-emoticons-kde4 wmpuzzle trafshow python-plplot lx-gdb link-monitor-applet libscm-dev liblog-agent-logger-perl libccrtp-doc libclass-throwable-perl kde-i18n-csb jack-jconv hamradio-menus coinor-libvol-doc msx-emulator bitbake nabi language-pack-gnome-zh libpaperg popularity-contest xracer-tools xfont-nexus opendrim-lmp-baseserver libvorbisfile-ruby liblinebreak-doc libgfcui-2.0-0c2a-dbg libblacs-mpi-dev dict-freedict-spa-eng blender-ogrexml aspell-da x11-apps openoffice.org-l10n-lv openoffice.org-l10n-nl pnmtopng libodbcinstq1 libhsqldb-java-doc libmono-addins-gui0.2-cil sg3-utils linux-backports-modules-alsa-2.6.31-19-generic yorick-yeti-gsl python-pymssql plasma-widget-cpuload mcpp gpsim-lcd cl-csv libhtml-clean-perl asterisk-dbg apt-dater-dbg libgnome-mag1-dev language-pack-gnome-yo python-crypto svn-autoreleasedeb sugar-terminal-activity mii-diag maria-doc libplexus-component-api-java-doc libhugs-hgl-bundled libchipcard-libgwenhywfar47-plugins libghc6-random-dev freefem3d ezmlm cakephp-scripts aspell-ar ara-byte not+sparc openoffice.org-l10n-nn linux-backports-modules-karmic-generic-pae
    [Show full text]
  • Lab 1 Intro to MATLAB and Freemat
    Lab 1 Intro to MATLAB and FreeMat Objectives concepts 1. Variables, vectors, and arrays 2. Plotting data 3. Script files skills 1. Use MATLAB to solve homework problems 2. Plot lab data and mathematical models 3. Write script files to save, edit and debug MATLAB commands 4. Solve systems of equations Key Prerequisites None Required Resources Access to MATLAB (buy here) or FreeMat (download here) Circuit analysis is often a computationally challenging activity. Even powerful programmable calculators can be inadequate to the task. In this lab we develop some basic proficiency with MATLAB and its red-haired cousin FreeMat, so that you can use these tools for your homework and future lab activities. You are welcome to use MATLAB or FreeMat for this lab. Since most people will probably be using FreeMat on their home computers, this lab will illustrate concepts with FreeMat. For what we will be using them for, however, the two are almost identical. 1 Lab 1: Intro to MATLAB and FreeMat Vocabulary All key vocabulary used in this lab are listed below, with closely related words listed together: variable, function vector, array plot, axes, legend script file Discussion and Procedure Part 1. Basics and Simple Arithmetic Before we begin, we’ll need to identify the main components of the MATLAB/FreeMat environment, shown in figure 1. These include the Current Directory, indicating what folder you are looking at in the “Listing of Current Directory” window. You can change the current directory by clicking the manila folder to the right of the Current Directory. Figure 1. The FreeMat Environment 2 Lab 1: Intro to MATLAB and FreeMat We spend much of our time in MATLAB working in the Command Window, which is where we type instructions.
    [Show full text]
  • A Comparative Evaluation of Matlab, Octave, Freemat, and Scilab for Research and Teaching
    A COMPARATIVE EVALUATION OF MATLAB, OCTAVE, FREEMAT, AND SCILAB FOR RESEARCH AND TEACHING Neeraj Sharma and Matthias K. Gobbert Department of Mathematics and Statistics, University of Maryland, Baltimore County {nsharma1,gobbert}@umbc.edu Technical Report HPCF–2010–7, www.umbc.edu/hpcf > Publications Abstract: The commercial software package Matlab is the most widely used numerical compu- tational package. GNU Octave, FreeMat, and Scilab are other numerical computational packages that have many of the same features as Matlab. Unlike Matlab, the other three packages are free of charge to the user and easily available to download to Linux, Windows, or Mac OS X operating systems. Are these packages viable alternatives to Matlab for uses in research or teaching? We review in depth the basic operations of Matlab, such as solving a system of linear equations, com- puting eigenvalues and eigenvectors, and plotting in two-dimensions. In addition, we research a more complex test problem resulting from a finite difference discretization of the Poisson equation in two spatial dimensions. Then, we compare the results we receive from GNU Octave, FreeMat, and Scilab to our previously found Matlab results. All packages gave identical numerical results, though Scilab exhibited a limitation in the size of the linear system it could solve in the complex test problem and FreeMat was hampered by the lack of a conjugate gradient function. The available graphical functions differ in functionality, but give equivalent plots, though FreeMat has limited three-dimensional graphics capabilities at present. Based on these tests, we conclude that GNU Octave is the most compatible with Matlab due to its numerical abilities and the similarity of its syntax.
    [Show full text]
  • Freemat: Why Are We Doing This and How Do I Get Started?
    FreeMat: Why are we doing this and how do I get started? Bruce Emerson∗ COCC Science Department (Dated: September 16, 2013) This short (hopefully) document will attempt to provide a rationale for compelling students in my physics classes to learn how to use FreeMat (a MATLAB clone) to present and analyze data and generate appropriate graphics for use in their lab reports and other documents. Like learning to use LATEX this is another skill set that is widely, though not universally, used across the scientific and engineering disciplines. Additionally this document will provide basic guidance for installing the software on your personal computer and generating some basic outputs relevant to labs. 1. WHY? ming. In Electrical Fundamentals there is a simulation program called SPICE which shares many coding fea- This is, of course, the fundamental question. Why tures with all the math engines. might you see it as valid to spend the effort, and it will Think of it this way: If you open up the hood of your take effort, to learn how to use a math calculating engine car and learn how the various systems look and interact like FreeMat? On a philosophical level I would suggest you then understand better how a car functions. While it that your are in a physics class to engage with the pro- is true that different manufacturers use different specific cess of figuring out how the universe works. Physics, and parts providers you still understand a great deal about all the sciences, are engaged in the effort to 'look under how a Ford truck works if you know how your Toyota the hood' of Mother Nature and try understand how it Camry works.
    [Show full text]
  • Mathematical Software Tools Applicable to Remote Learning and Scientific Research in Case of Isolation
    INTERNATIONAL SCIENTIFIC JOURNAL "MATHEMATICAL MODELING" WEB ISSN 2603-2929; PRINT ISSN 2535-0986 Mathematical software tools applicable to remote learning and scientific research in case of isolation Svilen Rachev1, Milena Racheva1, Andrey Andreev1,2, Dobrin Ganchev1 Technical University of Gabrovo, Bulgaria1 Bulgarian Academy of Science, Sofia, Bulgaria2 [email protected] Abstract: This paper is devoted to some up-to-date computational tools, which are on-line available and appropriate to remote learning as well as to scientific research implementation relevant to mathematics and their applications. The following aspects are concerned and discussed: some of the opportunities and benefits afforded by the software tools which are taken into consideration; necessary requirements which have to be met in order to use these tools; some disadvantages and drawbacks which may arise. Comparison of fees and prices for different mathematical software tools is done. For purpose of illustration realistic examples are also given. Keywords: MATHEMATICAL SOFTWARE, COMPUTER ALGEBRA SYSTEMS, FREE SOFTWARE, CLOUD COMPUTING 1. Introduction implementation and an environment in which the language to be used. Nowadays, the mathematical software tools used in research This means that, using CAS, one may manipulate mathematical and engineering play a crucial role in the development of expressions in a way as if he do it manually. technology, education and science. For example, the treatment of complex numerical analysis with the aid of mathematical software Computer algebra systems can be conditionally divided into two is currently used in all branches of physical, medical and social types: sciences. For that matter, by means of Computer aided design (CAD) software the level of scientific research and in particular of specialized, which are devoted to a specific part of engineering science can be significantly improved.
    [Show full text]