Git Product home page Git Product logo

spectroscopy's Introduction

Spectroscopy

Scripts for light spectroscopy

AS7265x_plot.py - a python script for plotting light spectra obtained from the Sparkfun's AS7265x spectrophotometer.

AS7265x_animate.py - Similar to AS7265x_plot.py but it reads the input from the serial port, updates the figure in real time, saves the measurements into a log file, and saves the figure when the Space key is pressed.

Details of the AS7265x_plot.py

measurements - the array of measurements from the sensors. Copy the measurements (e.g. from the Arduino serial monitor) to this array.

I sort the measurements in the order of increasing wavelengths and put the result into the array called data. This is not required for interpolation but might be needed for further processing.

The measured signal is interpolated using radial basis functions from scipy. I tried different functions and found that the multiquadric function works best provided that the following corrections are made:

  • When the amplitude of the signal is negative it is put to zero.
  • The amplitude of the signal at the wavelengths below the lowest channel (410 nm) and above the largest channel (940nm) is a Gaussian function with the FWHM=20nm according to the sensors' specifications.

You can see, why these corrections are needed by testing them when the signal is a single pulse,

A = np.zeros(18)
A[10] = 1

or a train of pulses with increasing amplitudes,

A = np.arange(1,19)

Examples of spectra plotted with AS7265x_plot.py

Red LED

Orange LED

Blue LED

White LED

Infrared LED from a remote control

Details of the AS7265x_animate.py

No need to manually copy the measurements from the Arduino serial monitor. You don't even have to start Arduino serial monitor.

Specify the serial port, the name of the log file and the folder where to save the figures

ser = serial.Serial('COM3',9600)
logfile = 'log.txt'
figdir = 'tst' # folder to save figures

In the Arduino sketch, comment or remove the lines

//Serial.println("AS7265x Spectral Triad");

//Serial.println("A,B,C,D,E,F,G,H,I,J,K,L,R,S,T,U,V,W");

so that only the numeric arrays of measurements are sent to the serial port.

spectroscopy's People

Contributors

burubaxair avatar

Stargazers

Radoslaw Frankowski avatar Derek Konigsberg avatar Adrian avatar

Watchers

James Cloos avatar  avatar Tommy Van Pelt avatar

Forkers

moonberry-pl

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.