Spectroscopic Analysis: Peak Detector

Similar documents
The first thing we ll need is some numbers. I m going to use the set of times and drug concentration levels in a patient s bloodstream given below.

Excel Basics Rice Digital Media Commons Guide Written for Microsoft Excel 2010 Windows Edition by Eric Miller

Survey of Math: Excel Spreadsheet Guide (for Excel 2016) Page 1 of 9

Using Microsoft Excel

Class #10 Wednesday, November 8, 2017

Creating a new form with check boxes, drop-down list boxes, and text box fill-ins. Customizing each of the three form fields.

1 Introduction to Using Excel Spreadsheets

Part 1. Summary of For Loops and While Loops

The name of our class will be Yo. Type that in where it says Class Name. Don t hit the OK button yet.

QUICK EXCEL TUTORIAL. The Very Basics

XP: Backup Your Important Files for Safety

Lastly, in case you don t already know this, and don t have Excel on your computers, you can get it for free through IT s website under software.

Jasco FP-6500 Spectrofluorimeter Updated November 14, 2017

How to Rescue a Deleted File Using the Free Undelete 360 Program

Matlab for FMRI Module 1: the basics Instructor: Luis Hernandez-Garcia

Intro To Excel Spreadsheet for use in Introductory Sciences

CheckBook Pro 2 Help

Part 1. Creating an Array of Controls or Indicators

TLMC SHORT CLASS: THESIS FORMATTING

Microsoft Excel 2007 Lesson 7: Charts and Comments

Instructions for Using the Databases

Startup Notes for Standard CMD 2015.x Setup

Adding content to your Blackboard 9.1 class

Workshop. Import Workshop

Civil Engineering Computation

Table of Laplace Transforms

Table of Contents. How to use this document. How to use the template. Page 1 of 9

Lutheran High North Technology The Finder

Your . A setup guide. Last updated March 7, Kingsford Avenue, Glasgow G44 3EU

FRC LabVIEW Sub vi Example

It s possible to get your inbox to zero and keep it there, even if you get hundreds of s a day.

Introduction to Access 97/2000

Making Tables and Graphs with Excel. The Basics

Physics 212E Classical and Modern Physics Spring VPython Class 6: Phasors and Interference

For Volunteers An Elvanto Guide

Detailed instructions for video analysis using Logger Pro.

Excel 2013 Intermediate

_APP A_541_10/31/06. Appendix A. Backing Up Your Project Files

Introduction to Spreadsheets

1.7 Limit of a Function

2 A little on Spreadsheets

Outlook is easier to use than you might think; it also does a lot more than. Fundamental Features: How Did You Ever Do without Outlook?

DSP First Lab 02: Introduction to Complex Exponentials

Let s Make a Front Panel using FrontCAD

Navigating and Managing Files and Folders in Windows XP

DOING MORE WITH EXCEL: MICROSOFT OFFICE 2013

Project Collaboration

Burning CDs in Windows XP

Assignment III: Graphing Calculator

S A M P L E C H A P T E R

Here are a couple of warnings to my students who may be here to get a copy of what happened on a day that you missed.

Using OPUS to Process Evolved Gas Data (8/12/15 edits highlighted)

Divisibility Rules and Their Explanations

A Quick-Reference Guide. To access reddot:

Google Drive: Access and organize your files

6 Stephanie Well. It s six, because there s six towers.

Usability Test Report: Bento results interface 1

Rescuing Lost Files from CDs and DVDs

Welcome Back! Without further delay, let s get started! First Things First. If you haven t done it already, download Turbo Lister from ebay.

econnect Baccarat User Guide EC7 June 2017

TRS2006 Content Manager Plus (CMP)

Grade 6 Math Circles November 6 & Relations, Functions, and Morphisms

Module: Rasters. 8.1 Lesson: Working with Raster Data Follow along: Loading Raster Data CHAPTER 8

Excel for Algebra 1 Lesson 5: The Solver

Filter and PivotTables in Excel

Rev. C 11/09/2010 Downers Grove Public Library Page 1 of 41

In math, the rate of change is called the slope and is often described by the ratio rise

Some (semi-)advanced tips for LibreOffice

Heuristic Evaluation of Covalence

MIS 0855 Data Science (Section 006) Fall 2017 In-Class Exercise (Day 18) Finding Bad Data in Excel

Taskbar: Working with Several Windows at Once

Basics of Stata, Statistics 220 Last modified December 10, 1999.

PHY Microprocessor Interfacing Techniques LabVIEW Tutorial - Part X File Output and Input

MAKING TABLES WITH WORD BASIC INSTRUCTIONS. Setting the Page Orientation. Inserting the Basic Table. Daily Schedule

Clickteam Fusion 2.5 Creating a Debug System - Guide

Our Changing Forests Level 2 Graphing Exercises (Google Sheets)

Learning to use the drawing tools

QSalesData User Guide

File Storage Techniques in LabVIEW

Word: Print Address Labels Using Mail Merge

Dealing with the way Mail Merge changed in MS Word 2003

Depending on the computer you find yourself in front of, here s what you ll need to do to open SPSS.

Financial Statements Using Crystal Reports

Textures and UV Mapping in Blender

Creating a Box-and-Whisker Graph in Excel: Step One: Step Two:

Organizing Screens with Mission Control

Become strong in Excel (2.0) - 5 Tips To Rock A Spreadsheet!

Assignment 0. Nothing here to hand in

The WideRuled Story Generator Tutorial Alex Mitchell Communications and New Media Programme National University of Singapore

Where Did I Save That File?

How to Make Graphs with Excel 2007

I m kicking off this book with Outlook s Greatest Hits, the things you ll

Microsoft Access 2010

Introduction to IgorPro

the NXT-G programming environment

Using GitHub to Share with SparkFun a

CSCI 1100L: Topics in Computing Lab Lab 11: Programming with Scratch

Procedures: Algorithms and Abstraction

Data. Selecting Data. Sorting Data

C Pointers 2013 Author Riko H i

Transcription:

Electronics and Instrumentation Laboratory Sacramento State Physics Department Spectroscopic Analysis: Peak Detector Purpose: The purpose of this experiment is a common sort of experiment in spectroscopy. Data from a monochrometer (intensity versus wavelength) needs to be analyzed to determine the intensities and line centers of all of the features in the spectrum. In real life, it is likely that this process would be done with the same software that logs the data. However, for the sake of this task, let s assume that the spectra are stored in tab-delimited spreadsheet files. Topics: Reading Spreadsheets, XY Graphs, Sequences, Analysis, Writing Spreadsheets, While Loops, Backing Up, Creating SubVIs, Multiple XY Graphs. Procedure: This is a pretty complicated VI that brings together many items. We ll go through this in several stages, adding stuff with every step. This was coded in LabVIEW 7.1, Student Edition, but aside from some icon changes will work in 8.0 also. Open LabVIEW and create a new VI. On the diagram, add the items so that it is similar to that shown below. We have used the Express VI for building and XY graph, but used the more traditional VI for reading from a spreadsheet file. The data in the spreadsheet file is assumed to be organized in a columnar format, with the first column containing the wavelength data and the second the signal intensity. If the data is stored in other formats, the way the data is extracted might need to be changed. The conversion from 1D array to Dynamic

Data type will be automatically performed if you wire the arrays to the Build XY Express VI directly. The front panel, as this VI has been started, will only require an XY graph indicator, as shown to the right. We have changed the labels to reflect the kind of data displayed on the graph. If you have not wired a path to the read spreadsheet file subvi, when this is run, a dialog box will open that will ask for you to select the file that you want to open. To test this VI, run the VI and select one of the enclosed data files. They each contain the same simulated spectrum, with three peaks, but with different degrees of random noise added to the signal. Moving on, we d now like to be able to identify peaks in the spectrum and record their positions, amplitudes, and relative amplitudes. When we are complete, the diagram and panel will look something like the screen shot on the next page. For now, ignore the Sequence structure. The 1D array containing the signal is wired to a VI that comes with LabVIEW called Peak Detector. This VI reads from an array of numbers and identifies the local maxima (or minima if you opt to identify valleys) in the array. In doing this procedure, Peak Detector needs to know the threshold (amplitudes of peaks to consider) and the width. The width actually isn t specifically how wide the peaks are, but rather, the number of points that the VI will use in it s quadratic least squares fit that it implements in doing this. There is a bit of a balancing act that needs to be done with the width. If it is too wide, the extracted amplitudes and positions might be shifted. However, if it is too narrow, you might risk identifying noise as peaks. To give us some flexibility, we ll add controls to the front panel for each of these inputs to the Peak Detector VI. The outputs of the peak detector contain Number of Peaks (an integer number), the locations (1D array), and amplitudes (1D array). The locations and amplitudes have the same index; i.e. if the first item in the array of locations has an amplitude that is found in the first item of the amplitudes array. The locations identified are based on the index of the input array. If the Peak Detector finds that there is a peak at the 13 th element of the input array, the location will be 13. If it finds the peak is at a point exactly halfway between the 7 th and 8 th elements in the input array, the location will be 7.5. While this does technically identify where

the peaks are, it doesn t provide any wavelength information. For this, we ll have to do some analysis of the array of wavelengths. We assume that the spectrum was collected with a nice uniform scan. If the wavelength steps are not uniform, hope isn t lost, but I wouldn t want to be in your shoes. As shown at the top of the diagram, we identify the number of elements in the array, the starting value and the ending value. This allows us to find the intercept (wavelength for starting index 0) and slope (change in wavelength for each increment in index number). If we multiply the locations array by the slope and then add the starting wavelength to the result, we ll end up with a new array that reports the locations in wavelength. This is displayed on the panel, along with another array that reports intensities. Sometimes it is helpful to see the relative intensities of the detected peaks. To do this, take the intensities array and divide by the largest value in the array. This can be found by using the Array Max and Min VI. Build a 2D array from the three individual arrays. Personally, I like to make the decision myself as to if I d like to save the data, rather than just have it done automatically. I also like to put this into the next step of a sequence structure. Why? Because I d like the full analysis to be done before the box pops up. If the VI that prompts the question isn t forced to occur after the processing is done, the multitasking power of LabVIEW causes the dialog box to pop up immediately. This seems pretty undesirable to me.

So, after you finish the stuff above, drag a sequence structure around everything and then add a frame after by right clicking on the header of the sequence. Jump to this new frame using the navigation arrows and add the Display Message Express VI. Fill in the text in the fields as requested. Create a case structure that will save an array to a spreadsheet file if the Display Message is true, and does nothing if it is false. How do you get the 2D array there? At the bottom of the case structure, right click and add a Sequence Local. Wire the 2D array to this local in the first frame, and wire it out in the second frame. The Sequence Local is the way that you move data long inside a sequence. After you write data to it, you can use it in any subsequent frame in the sequence. If you haven t wired in a file path, when the VI runs, a dialog box will open and ask you where you d like to put the file. Now, when this VI is run, a dialog will open that asks you for the file. Then it will find and display the peak locations (in wavelength), amplitudes, and relative amplitudes of the spectrum according to the values of the threshold and width that you ve set. Play around with these settings for the different sample spectra. You may want to reset the default values of threshold and width to things that are more convenient. Now, let s move this along some more. If you have been playing with adjusting the width and threshold, by now you ve gotten tired of reloading the data. Let s solve this by putting a while loop into the VI. Should this loop go around the entire sequence? This won t accomplish much because you will still have to reload the file. Just add the while loop around the bulk of the stuff inside frame 0 (remember to exclude the read spreadsheet subvi unless you want to keep loading the file). Whether you include the creation of the 2D array inside the loop is up to you, it actually won t matter. Don t forget to add a stop button on your front panel. Speaking of the panel, let s also add an indicator that will tell us how many peaks that have been identified by the VI. We could use a simple numeric indicator, but why don t we take advantage of the Build Text Express VI. This VI allows you to merge text and numbers into a string with a lot less work than older versions of LabVIEW required. If you drop the Express VI into the diagram, a dialog box will open that will guide you through adding a variable into a text string. Wire up the output from the Peak Detector VI that gives this number and you re good to go. The indicator on the front panel can be moved to a convenient place. Frame 0 of your panel should now look something like the one shown at the top of the next page. As the program runs now, if you tell the VI not to save the data by mistake, you re out of luck. This isn t a big problem for a spectrum with a couple of peaks, because the data is still on the array indicator on the panel. You can just write them down. But if your file has a lot of lines, you might not feel like doing this. Let s build a hidden backup. As shown on the next page, I ve added another sequence structure to the VI. This time, I used what is called a Flat Sequence because this is a really simple step. Instead of cycling through the frames, you see them all at once. I have in the second frame, a write spreadsheet VI with a file path wired up for a change. If I had left it at this, the second time this VI ran, a dialog box would pop up asking if I wanted to overwrite the file. Since we want the backup to be as unobtrusive as possible, this isn t desirable. So I added a frame that takes the file name and deletes it first.

The Delete VI (shown at right) is buried a bit in the File I/O, but it s there. The path gets passed through it, so you can take the output of this directly into the write spreadsheet VI. In fact, I don t have to use the sequence at all if I use this pass through, but better safe than sorry: I want to make sure the file is deleted before the saving happens. Choose a convenient file name (with full path to ensure you know where it will end up) and you have a handy backup file created each time you run the program. It now occurs to me that this might be a handy little trick to use at other times I want to back up data files. It might be nice to have as a subvi that I can grab anytime I need it. Use your position/size/select tool (the arrow) from the tools palate and select the entire sequence (but not the file name). When this is highlighted, go to the Edit pulldown menu and select Create SubVI. The frame and it s contents will disappear and a generic looking icon will take it s place with the two wires connected to it. Double click on the icon and a new LabVIEW panel window will open. Open the diagram that goes with it and you ll see that it has the frame structure that used to be in our main VI. Save this subvi with a unique name (like backupdata.vi) and if you want, you can create your own icon and change the wiring terminals as I have done. I did it for aesthetics, not for function. Put this VI somewhere handy and you can use it in other programs. The second frame of the diagram will now look something similar to what is below.

What you have now is a very handy piece of software. In fact, at this point, I started to play around with real, not simulated data. As I was looking at some spectra of molecular nitrogen, I found that the XY graph was small enough that it was tough to see where the locations were. I decided that for me personally, it would be nice to have some sort of marker on the graph that would show where the identified peaks were. Hmmmm. To do this, we ll have to return to frame 0 of our main sequence structure. (Actually, our only sequence structure now that we ve subvied the backup.) Since the graph is an XY plot, we ll need some sort of XY data. X is easy the locations, but Y has several possibilities. We could use the amplitudes, or the largest amplitude, or something else. I opted for something else. I ve taken the largest peak and added 10% to it. But how do I get the wavelength and amplitude info into the graph, particularly since the data changes each time we go through the while loop? To pass data around the loop, you use what is called a shift register. Right click on the left edge of the while loop and Add Shift Register. Notice that a little box appears on each side of the while loop. This tool allows us to take the result of a calculation in a while loop and feed it into the next time around. If we wire the locations array into the right side shift register, it is available to us on the left side for the next time through. This array can be combined with the wavelength array from the data using the Merge Signals VI prior to going into the Build XY VI.

Then put the marker amplitude into an array of the same size as the locations array using the initialize array VI. It will be merged with the signal array. Make sure you don t cross the pairs up or the data displayed won t mean anything. The top signals in each of the merges should go together, as should the bottom ones. By default, both sets of data will be line graphs with no markers. Fine for the spectrum, but not useful for the markers, which would just show a straight line across the top of the spectrum. On the front panel, expand the legend to show the second line and modify it so that it has symbols. If you want, add drop down lines that go to infinity so they cross the x-axis. The figure below is a capture of the front panel after analyzing one of the noisier spectrums. Author Information: William DeGraffenreid Department of Physics and Astronomy California State University, Sacramento degraff@csus.edu