Skip to content

professorchaman/Plancks_Analysis

Repository files navigation

Introduction

This Python script, plancks_analysis.py, is designed for the analysis of spectral data using Planck's radiation law. It provides functionality for system correction and Planck's fit to extract temperature and scaling factor information from the given data. This README file will guide you through the usage of this script.

Dependencies

Before using the script, ensure that you have the necessary Python libraries installed. The script relies on the following libraries:

  • ipywidgets
  • IPython
  • scipy
  • numpy
  • matplotlib
  • tqdm
  • pandas
  • pybaselines
  • spe2py
  • peakutils

You can install these libraries using the script's automatic installation feature. If any of these libraries are missing, the script will attempt to install them automatically during runtime.

Usage

To use this script, follow these steps:

  1. Open a terminal or command prompt.

  2. Navigate to the directory containing the plancks_analysis.py file.

  3. Run the script with the following command:

    bashCopy code
    python plancks_analysis.py --do_system_correction --do_planck_fit [optional arguments]

    Replace <y/n> with 'y' if you want to perform the respective operation (system correction or Planck's fit) or 'n' if you don't.

    Optional arguments:

    • --wvl_start: Specify the start wavelength for system correction in nanometers (default: 370 nm).
    • --wvl_end: Specify the end wavelength for system correction in nanometers (default: 920 nm).
    • --fit_start: Specify the start wavelength for Planck's fit in nanometers (default: 400 nm).
    • --fit_end: Specify the end wavelength for Planck's fit in nanometers (default: 580 nm).
    • --initial_temperature: Specify the initial temperature guess in Kelvin (default: 1000 K).
    • --scale_factor: Specify the initial scale factor guess (default: 1e-6).
  4. The script will perform the selected operations based on your input and display plots and information.

File Selection

  • The script will prompt you to select the data file containing the spectral data you want to analyze.
  • If system correction is enabled (--do_system_correction y), you will also need to select the tungsten halogen lamp spectrum file for system correction.

System Correction

  • If system correction is enabled, the script will perform system correction on the selected data using the lamp spectrum.
  • It will apply corrections based on the specified wavelength range (--wvl_start and --wvl_end).
  • You can view the raw data, system response, and intensity-corrected data in plots.

Planck's Fit

  • If Planck's fit is enabled, the script will perform a fitting operation to extract temperature and scaling factor information.
  • It will use the specified wavelength range (--fit_start and --fit_end) for the fitting process.
  • The script will display a plot showing the intensity-corrected data, the best-fitting model, and the input temperature.
  • Extracted temperature and scaling factor values will be logged and displayed.

Data Output

  • The script logs the extracted temperature and scaling factor values for each selected data file.
  • The results are stored in a Pandas DataFrame and printed at the end of the script's execution.
  • You can also uncomment and use the provided code to save the results to a CSV file.

Notes

  • The script provides flexibility in terms of data selection, correction, and fitting parameters.
  • It handles missing library installations automatically by attempting to install them using pip.
  • Ensure that the input data files are in the appropriate format and contain the required information for analysis.

Feel free to customize the script further to suit your specific data analysis needs or integrate it into your data processing workflow.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published