Skip to content

obstruse/spectrometer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

41 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Spectrometer

Based on Public Lab's Spectrometer 3.0

Python scripts to select, average, and calibrate spectrum data from USB spectrometer. Plotting with Gnuplot. Running on Raspberry Pi.

Setup

Alignment

  • Camera, diffraction grating, slit, mounted on magnets and arranged on a metal sheet:
Setup
Enlarger head with condensing lens and iris to focus light on the diffraction grating

Focus

  • Camera should be focused on the collimation slit, approximately 200mm away.
Focus
Camera with Focusing Aid

Exposure

  • Over exposure will clip the image and make it difficult to find peaks
  • Reduce camera brightness to get a solid black background

Average

$ ./spectrometer/average -h
usage: average [-h] [-x WIDTH] [-y HEIGHT] [-v VIDEODEV] [-a AVERAGEITEMS] [-c PIXELCLIP]

Spectrometer

options:
  -h, --help            show this help message and exit
  -x WIDTH, --width WIDTH
  -y HEIGHT, --height HEIGHT
  -v VIDEODEV, --video VIDEODEV
  -a AVERAGEITEMS, --average AVERAGEITEMS
  -c PIXELCLIP, --clip PIXELCLIP

Configuration file

File located at: ./spectrometer/config.ini. Commented entries indicate default values:

File Description
[Spectrometer] section header
#width=1280 image width
#height=720 image height
#videoDev=/dev/video0 USB camera device
#averageItems=20 number of frames to average
#pixelClip=250 Out Of Range warning level
#calibDefault=',,410,900' default calibration settings, HG463 and EU611

Select a line through the camera spectrum image:

cameraImage

Click AVERAGE, and wait a few moments for the image to settle down. If the value of a pixel exceeds the Out Of Range warning level, a red mark will appear at the top of the column.

Averaged

Click on prefix to set the file name prefix (e.g. 'cfl'). Click on decription to set the description (e.g. 'CFL 2700K'). Click SAVE.

Output is a JPG of the resulting average, and a CSV with the average of each pixel and the averages of each color.


Calibrate

$ ./spectrometer/calibrate -h
usage: calibrate [-h] CSVfile

Calibrate

positional arguments:
  CSVfile

options:
  -h, --help  show this help message and exit

Calibration uses landmarks to calibrate the output:

  • calibrate to landmarks in the spectrum (CFL Calibration)
  • calibrate to landmarks in the camera response (CIS Calibration)

CFL Calibration

CFL Landmarks CFL plain

Type Wavelength  
CFL 405nm mercury
  436nm mercury
  487nm terbium
  542nm terbium
  546nm mercury
  611nm europium
     

Click CFL. Use the mouse to select the Eu611 peak on the right. The keys Kp7,Kp9 (Q,E) can be used to fine-tune the selection. Select the Hg436 peak on the left with the mouse; fine-tune with Kp1,Kp3 (Z,C):

calibrate CFL

Click SAVE - the settings are saved in the calibration file.


CIS Calibration

CIS Landmarks CIS plain

Type Wavelength  
CIS 465nm blue response peak
  532nm green response peak
  596nm red response peak
  529nm the red bump
     

Click CIS. Use the mouse to select the red response peak on the right and the blue response peak on the left. Use the keys Kp7,Kp9 (Q,E) and Kp1,Kp3 (Z,C) to fine-tune the selection:

calibrate CIS

Click SAVE - the settings are saved in the calibration file.


Plot

$ ./spectrometer/plot -h

Usage: ./spectrometer/plot [-H] [-I] [-L] [--CFL] [--CIS] [--INT] CSVfile

Plot Spectrum

Options:
    -H      Show this message
    -B      -B1 enable background image.  -B0 disable
    -L      -L1 enable landmarks display. -L0 disable
    --CFL   Plot pixel averages and CFL landmarks
    --CIS   Plot color averages and CIS landmarks
    --INT   Plot pixel averages as filled curve

    CSVfile Spectrum data to plot

Spectrum data is ploted with the spectrum background image in the range 375nm - 695nm. Plot opens in gnuplot; use menu bar to save image.

Aurora

You can also combine the plot options for different results:

Everything Zoom0 Tower Sunrise

About

Python scripts to select, average, and calibrate spectrum data from USB spectrometer. Plotting with Gnuplot. Running on Raspberry Pi.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published