Stressor LED Spectrum — Colab Notebook
- Team Name:
[Determine a name for your team for the rest of the semester.] - Authors:
[Write in the names of the authors of this notebook.] - Cell Number:
[Write in the number of your cell.]
Reminder. To maintain consistency in your notebooks between team members, it is important to add markdown cells to discuss what you are doing and answer the questions. Also, make sure to put inline comments in your code.
1 Analysis
1.1 Plot Normalized LED Spectrum
Plot the normalized spectrum of your stressing LEDs and save the normalized data to a CSV file for future use. You can use code from the updated Python tutorial or AI tools.
Start by importing useful libraries.
import numpy as np
import pandas as pd
import matplotlib.pyplot as pltRead in LED file from the spectrometer. The LED spectrometer file is not csv, but space-delimited so this also converts it to csv format. You will need to edit the code below to match your LED spectrum file name. This code also adds column names to each file of wavelength and value of the spectrum.
# Read your LED spectrum file and convert it into csv format
# Update the filename below to match your LED spectrum file
LED = pd.read_csv('your_LEDspectrum_filename.txt', sep=r'\s+', names=["Wavelength (nm)", "Intensity"])Truncate the data from the spectrometer to be in the relevant range of 350 - 800 nm. This sets the value of data outside of this range to zero.
# "def" defines a function — in this case, a function to truncate your data
def truncate(f):
# Convert 'Wavelength (nm)' column to numeric type
f['Wavelength (nm)'] = pd.to_numeric(f['Wavelength (nm)'])
# Set values to zero if wavelength is outside 350-800 nm or value is negative
mask = (f['Wavelength (nm)'] < 350) | (f['Wavelength (nm)'] > 800) | (f['Intensity'] < 0)
f.loc[mask, 'Intensity'] = 0.0
return f
# Call the truncate function on your LED data
LED = truncate(LED)Next, we normalize the LED spectrum, so that the largest peak has a relative intensity of 1. The y-axis values are in arbitrary units before doing this.
# Find the maximum value from your LED spectrum data and divide the
# entire spectrum by that max value to normalize it
LEDnorm = LED.copy()
LEDnorm['Normalized Intensity'] = LED['Intensity'] / np.max(LED['Intensity'])Create a plot of your normalized spectrum. Make sure to have correct axis labels and units.
# Your code here1.2 Save Normalized Data
It is important to understand the slight variations in the stressor LEDs. In a few weeks, you will be looking at the data from all stressing stations. To make this process go smoothly, create a CSV file with the wavelength and normalized intensity values.
# Save wavelength and normalized intensity only
# Update the CSV file name below
LEDnorm[['Wavelength (nm)', 'Normalized Intensity']].to_csv("YYYY_MM_DD_normalizedLED_cell#.csv", index=False)Look at your CSV file to be sure it contains the data you want it to contain. Then download a copy of your file and put it in your team Google Drive folder so can be added to the aggregate dataset later this semester.
3 Use of AI (required)
- How your team used AI tools: Describe the specific tasks where AI-assisted tools were involved. For example, did AI help with writing, debugging, optimizing, or refining your code? Which components of the analysis did your team use AI on?
- When your team used AI tools: Specify at what stage(s) of your programming process you used AI. Was it during initial code development, troubleshooting, etc.?
- Which AI tools your team used: Identify the AI tools or platforms your team consulted (e.g., ChatGPT, GitHub Copilot, etc.).