Data Collection 5 — Colab Notebook

Last Updated: November 18, 2026 Download notebook (.ipynb)
  • Team Name: [Write in the name of your team.]
  • Authors: [Write in the names of the authors of this notebook.]
  • Cell Number: [Write in your cell number.]
  • J-V Apparatus Number: [Write in the number of your apparatus (JV1, JV2, or JV3) that you used for your measurements.]
  • EQE Apparatus Number: [Write in the number of the apparatus (EQE1, EQE2, or EQE3) that you used for your measurements.]

This week you will do the following data analysis:

  1. Calculate PCE values and uncertainties for all pixels. Write the PCE values, PCE uncertainties, and \(J_{sc}\) values to a CSV file. Paste the output of your CSV file in the notebook. You have done this analysis in previous Colab notebooks. Please copy, edit, and reuse your code from previous weeks.
  2. Plot your PCE values with error bars to show how they changed from the baseline to this week's data. Your figure should now have seven time points: baseline data, Data Collection 1, Data Collection 2, break week (TA data), Data Collection 3, Data Collection 4, and Data Collection 5 (this week), accounting for any pixels that may have failed during stressing. You have done this analysis in previous Colab notebooks. Please copy, edit, and reuse your code from previous weeks.
  3. Plot all spectra from the stressing stations and overplot the mean spectrum. Then, create histograms at different wavelengths to explore how the intensity distribution varies across stressing stations, and assess whether a Gaussian is a good description of the data.
  4. Create a CSV file with your EQE values for this week. Then, use all of your EQE data CSV files (Baseline through Data Collection 5) to generate subplots for each pixel showing how the EQE spectrum changes over time. Each subplot should include all seven time points (baseline, Data Collection 1, Data Collection 2, break week, Data Collection 3, Data Collection 4, and Data Collection 5), accounting for any pixels that may have failed during stressing. You have done this analysis in previous Colab notebooks. Please copy, edit, and reuse your code from previous weeks.

1 J-V Analysis

  1. Calculate the \(J_{sc}\) and PCE values for each pixel. Remember to follow the uncertainty workflow from Data Collection 2: extract SE values from the raw data, compute \(\delta V_{pmax}\) from the voltage step size, and propagate uncertainties to produce your final CSV with PCE_uncertainty (%). Remember to update the time values for this week's data.
# Your code here

Paste your PCE and uncertainties for this week's data below.

  1. Plot your PCE values with error bars for each pixel. This figure should now have seven time points: baseline data, Data Collection 1, Data Collection 2, break week (TA data), Data Collection 3, Data Collection 4, and Data Collection 5 (this week). Remember to update the time values for this week's data.
# Your code here

Question 1: How do your values from this week compare to the values from previous weeks?

2 Histograms and Distributions

2.1 Histograms

A histogram is a simple but powerful tool for exploring how values in a dataset are distributed. It divides the data into bins (value ranges) and counts how many points fall in each bin. By looking at the shape of a histogram, we can identify trends, for example, whether most data points cluster around a single value, whether there are multiple clusters, or if there is a broad or skewed spread.

In this activity, we will look at the distribution of normalized intensity values at specific wavelengths across all spectra from the stressing stations.

2.2 The Gaussian (Normal) Distribution

One common distribution is the Gaussian (normal) distribution. The Gaussian curve is described by:

\[f(x)= Ae^{-\frac{(x - \mu)^2}{2\sigma^2}}\]

where:

  • A is the amplitude (peak height)
  • \(\mu\) is the mean, or the central value of the distribution
  • \(\sigma\) is the standard deviation, describing how wide or narrow the distribution is.

A small \(\sigma\) means the data are tightly clustered near the mean; a larger \(\sigma\) means there is more variation.

2.3 Interpreting the Fit

The code below overlays a Gaussian fit on your histogram. This gives you a reference to compare against — but the data may or may not follow a Gaussian distribution. Part of your analysis is to assess whether the Gaussian is a good description of your data, and to think about what physical factors might cause the distribution to deviate from a simple bell curve.

2.4 Introduction to HDF5

Up until now, you have been working with CSV files to store and load data. This week, we will introduce a different file format: HDF5 (Hierarchical Data Format version 5).

HDF5 files are widely used in scientific research because they can store large, complex datasets efficiently. Unlike a CSV, which is a flat table of text, an HDF5 file is hierarchical — it organizes data into groups (like folders) and datasets (like files), with attributes (metadata) attached at every level. You can think of it like a file system inside a file.

2.4.1 What's in this file?

Each stressing station (the cubby your cell sits in) has an LED that illuminates your solar cell. We measured the emission spectrum of every LED using a spectrometer, which records how bright the light is at each wavelength. The file led_spectra.h5 contains these measurements, organized like this:

led_spectra.h5
├── wavelength                       The wavelengths (in nm) at which the
│                                    spectrometer took readings. These are
│                                    the same for every station.
└── stations/
    ├── Station01/                   One group per stressing station
    │   └── normalized_intensity     How bright this station's LED is at
    │                                each wavelength, scaled so the peak = 1
    │   attrs: teams, cell, station  Which teams and cell this station is for
    ├── Station02/
    │   └── normalized_intensity
    ...

Each station is its own group with metadata attributes that tell you which teams and solar cell it corresponds to. This makes the file self-documenting — you can browse it and understand what's inside without needing a separate reference.

You will use HDF5 files extensively in your team research project (Weeks 12–16), so this is a good opportunity to get familiar with the basics. Run the code below to explore the file structure and load the data for analysis. Be sure you have downloaded led_spectra.h5 and placed it in the same directory as your notebook.

import numpy as np
import matplotlib.pyplot as plt
import h5py

# Open the HDF5 file and explore its contents
with h5py.File('led_spectra.h5', 'r') as f:
    # Explore: what is the top-level structure?
    print("Top-level contents:", list(f.keys()))
    print()

    # Wavelength is shared across all stations
    print("wavelength:", f['wavelength'].shape, f['wavelength'].attrs['units'])
    print()

    # Stations are organized as groups, each with its own data and metadata
    station_names = list(f['stations'].keys())
    print(f"Number of stations: {len(station_names)}")
    print(f"Station names (first 5): {station_names[:5]}")
    print()

    # Look at one station to see what metadata is stored
    example_name = station_names[0]
    example = f['stations'][example_name]
    print(f"Example station ({example_name}) attributes:")
    for key, val in example.attrs.items():
        print(f"  {key}: {val}")
    print(f"  normalized_intensity: {example['normalized_intensity'].shape}")
    print()

    # Load all data into arrays for analysis
    wl = f['wavelength'][:]
    spectra = np.column_stack([
        f[f'stations/{name}/normalized_intensity'][:] for name in station_names
    ])  # shape: (n_wavelengths, n_stations)

print(f"Loaded led_spectra.h5: {spectra.shape[1]} stations, {spectra.shape[0]} wavelength points.")

Before proceeding: Look at the output above. How many stressor stations are in this dataset? What metadata is stored for each station? Notice how the HDF5 file organizes data hierarchically — each station is its own group with attributes, rather than everything being packed into a single flat table.

# Plot all spectra overlapped + mean spectrum
mean_spec = np.mean(spectra, axis=1) # axis = 1 means it is calculating the mean across columns
                                     # so getting a mean across all stressor stations for each wavelength
plt.figure()
for i in range(spectra.shape[1]):
    plt.plot(wl, spectra[:, i], alpha=0.5) # alpha is setting transparency for the spectra from each station
plt.plot(wl, mean_spec, linewidth=1, label='Mean spectrum')
plt.xlabel('Wavelength (nm)')
plt.ylabel('Normalized intensity')
plt.title('All Spectra with Mean Spectrum')
plt.legend()
plt.tight_layout()
plt.show()

2.5 Create a Histogram at a Single Wavelength

Now that you have plotted all of the spectra, you will explore how the normalized intensity varies across stressing stations at a single wavelength of your choosing.

To complete the cell below:

  1. Choose a wavelength. Look at the spectra plot above and pick a wavelength of interest (e.g., near a peak, in a valley, or on a shoulder). Set TARGET_WAVELENGTH to your chosen value in nm. If you leave it as None, it will default to the peak wavelength of the mean spectrum.
  2. Choose a binning method. Uncomment one of the two plt.hist(...) lines (Option 1 or Option 2). Option 1 lets you set the number of bins manually; Option 2 lets matplotlib choose automatically. Try both and decide which one gives a clearer picture of the distribution.
  3. Run the cell to see the histogram with a Gaussian fit overlaid.

Try several different wavelengths (e.g., near the peaks, in the valleys between peaks, on the shoulders). Does the shape of the distribution change depending on which wavelength you choose? Does the Gaussian fit describe some wavelengths better than others?

# Select a wavelength and edit the TARGET_WAVELENGTH variable to create histogram
TARGET_WAVELENGTH = None  # UPDATE THIS to your chosen wavelength (e.g., 460)

# Histogram at chosen wavelength + Gaussian fit
if TARGET_WAVELENGTH is None:
    idx = int(np.nanargmax(mean_spec))
    target_nm = float(wl[idx]) # Safety check - did you update your wavelength variable above?
else:
    # It will find the closest wavelength value to what is placed in TARGET_WAVELENGTH variable
    idx = int(np.nanargmin(np.abs(wl - TARGET_WAVELENGTH)))
    target_nm = float(wl[idx])

vals = spectra[idx, :] # pulls all intensity values at that wavelength across stations
vals = vals[~np.isnan(vals)] # drop any NaN values
mu = float(np.mean(vals))
sigma = float(np.std(vals, ddof=1)) if len(vals) > 1 else 0.0

# Decide which binning method to use and UNCOMMENT (remove the #) the line of code
# of the method you select. Perhaps try both methods and choose the one you think
# works best.
# 'density = True' in the plt.hist normalizes the bin heights such that the integral of the histogram is equal to 1.

#Option 1: You set the bin width
plt.hist(vals, bins=20, density=True, edgecolor='black') #you set bin width

#Option 2: Bin width is auto-set
#plt.hist(vals, density=True, edgecolor="black")

if sigma > 0: # this if statement is a safety check - kicks you out if there is zero spread
    xs = np.linspace(vals.min(), vals.max(), 200)
    pdf = 1.0 / (sigma * np.sqrt(2 * np.pi)) * np.exp(-0.5 * ((xs - mu) / sigma) ** 2)
    plt.plot(xs, pdf, linewidth=2.0, label='Gaussian fit')
    plt.legend()
plt.xlabel('Normalized intensity')
plt.ylabel('Density')
plt.title(f'Histogram at {target_nm:.2f} nm\nGaussian fit: μ={mu:.4f}, σ={sigma:.4f}')
plt.tight_layout()
plt.show()

# Print the fit parameters of your Gaussian
print(f"Used wavelength: {target_nm:.2f} nm\nGaussian μ={mu:.6f}, σ={sigma:.6f}")

Question 2: Look at your histograms at several different wavelengths. Describe the shape of the distributions you observe. Is a Gaussian a good model for the data at every wavelength? If not, what features do you see (e.g., multiple peaks, skewness, outliers), and what might cause them?

Question 3: Compare the fitted values of \(\mu\) and \(\sigma\) across the wavelengths you explored. How do the spread and center of the distribution change at different parts of the spectrum? What does this tell you about the consistency of the stressing station lights?

3 EQE Analysis

  1. Create a CSV file with your EQE values for this week. Remember you can copy and paste code from previous notebooks. Consider using a loop in your python code to be more efficient.
  2. Use all of your EQE data CSV files (Baseline through this week [Data Collection 5]) to generate subplots for each pixel showing how the EQE spectrum changes over time. Each subplot should include all seven time points (baseline, Data Collection 1, Data Collection 2, break week, Data Collection 3, Data Collection 4, and Data Collection 5), accounting for any pixels that may have failed during stressing.
# Your code here

Question 4: Discuss what you observe from looking at the comparison of all of your EQE curves.

4 Author Contributions (required)

List the name of each team member and please describe briefly how each member contributed to the work in lab this week. (e.g., taking a measurement, updating the Colab notebook, etc.)

5 Use of AI (required)

  1. 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?
  2. 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.?
  3. Which AI tools your team used: Identify the AI tools or platforms your team consulted (e.g., ChatGPT, GitHub Copilot, etc.).