diff options
| author | Christian Kolset <christian.kolset@gmail.com> | 2025-11-17 09:24:55 -0700 |
|---|---|---|
| committer | Christian Kolset <christian.kolset@gmail.com> | 2025-11-17 10:27:54 -0700 |
| commit | d78171c31310f73a1b189e0946b744accdfb4850 (patch) | |
| tree | 5ad8286ff08ec61869ec8e918e844d8df4456c81 | |
| parent | 8f81b92b4942879edb32f9420514b7e402144a44 (diff) | |
Updated meeting notes, fixed typo in scpectroscopy problem and changed integration method to simpson.
Ammended meeting note commit.
| -rw-r--r-- | admin/meeting-notes/2025-03-14.md | 2 | ||||
| -rw-r--r-- | admin/meeting-notes/2025-11-17.md | 98 | ||||
| -rw-r--r-- | tutorials/module_4/Spectroscopy problem.md | 4 | ||||
| -rw-r--r-- | tutorials/module_4/spectroscopy_problem/spectroscopy.py | 27 |
4 files changed, 117 insertions, 14 deletions
diff --git a/admin/meeting-notes/2025-03-14.md b/admin/meeting-notes/2025-03-14.md index 9834fca..4b50f7d 100644 --- a/admin/meeting-notes/2025-03-14.md +++ b/admin/meeting-notes/2025-03-14.md @@ -1,4 +1,4 @@ -## Updates +l## Updates - Finishing off Module 1 - Slow progress diff --git a/admin/meeting-notes/2025-11-17.md b/admin/meeting-notes/2025-11-17.md new file mode 100644 index 0000000..a1fe4d7 --- /dev/null +++ b/admin/meeting-notes/2025-11-17.md @@ -0,0 +1,98 @@ +## Updates +- https://pythonnumericalmethods.studentorg.berkeley.edu/notebooks/Index.html +- Numerical Methods for Engineers Steven C Chapra + +--- +## Topics +and questions + +- [ ] Decide on textbook +- [ ] Spectroscopy problem +- [ ] Module 4: Revise lecture order for 4.2 plotting philosophy +- [ ] Module 5: Go over outline + +--- +## Discussion + +- Slight changes to module 4 outline + +> Module 4: Outline +>1. Introduction to Data and Scientific Datasets +> a. What is scientific data +> b. Data Processing flow work +> c. Intro to Pandas +> d. Manipulating data frames +> e. Problem 1: Create a dataframe from Numpy arrays +> f. Problem 2: Selecting data from a dataframe to calculate work done. +> +> 2. Interpreting Data +> a. Understanding your data +> b. Purpose +> c. Composition +> d. Color +> e. Problem 1: Composing or fixing a plot. Apply PCC +> f. Data don't lie +> g. Problem 2: Misleading plots by changing axis limits or omitting context. Explain *why* it's misleading. +> +> 3. Importing, Exporting and Managing Data +> a. File types +> b. Importing spreadsheets with pandas +> c. Handling header, units and metadata +> d. Writing and editing data in pandas +> e. Problem: Importing time stamped data pressure and temperature data. Convert timestaps to datetime and plot timperature vs. time +> f. Problem: [TBD] +> +> 4. Statistical Analysis I +> a. Engineering Models +> b. Statistics Review +> c. Statistics function in python (Numpy and Pandas describe) +> d. Statistical Distributions +> e. Spectrocopy (basics) +> f. Problem: Statistical tools in Spectroscopy readings (intensity vs wavelangth) to compute mean, variance and detect outliers. +> g. Problem 2: Fit a Gaussian distribution to the same data and overlay it on the histogram. +> +> 5. Statistical Analysis II: Regression and Smoothing +> a. Linear Square Regression and Line of Best Fit +> b. Linear, Exponential and Power functions +> d. Polynomial +> e. Using scipy +> f. How well did we do? (R and R^2) +> g. Extrapolation and limitations +> h. Moving averages +> i. Problem 1: Fit a linear and polynomial model to stress-strain data. Compute R^2 and discuss which model fits better. +> j. Problem 2: Apply a moving average to noisy temperature data and compare raw vs. smoothed signals. +> +> 6. Data Filtering and Signal Processing +> a. What is it and why it matters - noise vs. signal +> b. Moving average and window functions +> c. Frequency domain basics (sampling rate, Nyquist frequency) +> d. Fourier transform overiew (numpy.fft, scipy.fft) +> e. Low-pass and high-pass filters (scipy.singla.butter, filtfilt) +> f. Example: Removing high-frequency noise from a displacement signal +> g. Example: Removing noise from an image to help for further analysis (PIV) +> h. Problem 1: Generate a synthetic signal (sum of two sine waves+random noise). Apply a moving average and FFT to show frequency components.) +> i. Problem 2: Design a Butterworkth low-pass filter to isolate the funcamental frequency of a vibration signal (e.g. roating machinery). Plot before and after. +> +> 7. Data Visualization and Presentation +> a. Review of PCC framework +> b. Plotting with Pandas and Matplotlib +> c. Subplots, twin axes, and annotations +> d. Colomaps and figure aesthetics +> e. Exporitn gplots for reports (DPI, figure size) +> f. Creating dashboards or summary figures +> g. Problem 1: Using pandas to plot spectroscopy data from raw data. Add labels, units, title, and annotations for peaks +> h. Problem 2: Create a multi-panel figure showing raw data, fitted curve, and residuals. Format with consistent style, legend and color scheme for publication-ready quality. +> + + +Module 5: Outline + +Lectures +1. Supervised learning: Classification +2. Supervised learning: Regression +3. Unsupervised learning: Clustering +4. Unsupervised learning: Dimensional reduction + +--- +## Action + diff --git a/tutorials/module_4/Spectroscopy problem.md b/tutorials/module_4/Spectroscopy problem.md index 5252d46..29d26f5 100644 --- a/tutorials/module_4/Spectroscopy problem.md +++ b/tutorials/module_4/Spectroscopy problem.md @@ -99,7 +99,7 @@ Calibrate wavelength by converting the length dimension from pixels to nm. $$ \lambda_p=I+C_1p+C_2p^2+C_3p^3 $$ -- Solve for C1 C2 and C3, use $I=195.54$ +- Solve for C1, C2 and C3, use $I=195.54$ Well-known/defined Hg lines: @@ -154,5 +154,3 @@ $$ $$ n_{1,2}=\frac{\int_{\lambda_0-\Delta\lambda}^{\lambda_0+\Delta\lambda} I(\lambda)d\lambda}{\frac{1}{4\pi}hv_{1,2}A_{1,2}l}\tag{1} $$ - -|
\ No newline at end of file diff --git a/tutorials/module_4/spectroscopy_problem/spectroscopy.py b/tutorials/module_4/spectroscopy_problem/spectroscopy.py index 404e5ca..1ef6579 100644 --- a/tutorials/module_4/spectroscopy_problem/spectroscopy.py +++ b/tutorials/module_4/spectroscopy_problem/spectroscopy.py @@ -15,7 +15,7 @@ Problem: - Interpolate and convert x-axis from pixels to nm (true wavelength) using Hg lamp data (using data in file: **Lampa_Calibrare_Mercur.xlsx**) - Find response function of the spectrometer using the tungsten lamp data from file: "**Calibrare Intensitate Oxigen.xlsx**)": $R=\frac{I_{measured}}{I_{true}}$ (where True is computed by Planck's law of radiation (see notes in the pptx above) - Convert y-axis from Intensity [a.u.] into Intensity in [W/(cm^2*sr*nm)] by dividing the measured Oxygen spectrum with the response function: $I_{oxygen, true}=\frac{I_{oxygen, measured}}{R}$ -- Once the spectra is in real units: compute the density of one of the oxygen lines by integrating underneath one of the peaks (see equation from Slide 39 - bottom). We will give all of the constants that are in this equation (see the "I**ntensity_Calibration_Oxygen_Discharge_Solution.xlsx**") +- Once the spectra is in real units: compute the density of one of the oxygen lines by integrating underneath one of the peaks (see equation from Slide 39 - bottom). We will give all of the constants that are in this equation (see the "Intensity_Calibration_Oxygen_Discharge_Solution.xlsx") """ import numpy as np @@ -118,7 +118,7 @@ I_Ox_measured = df_Ox['I_Plasma Oxygen [a.u.]']-df_Ox['I_Background [a.u.]'] I_Ox_true = R * I_Ox_measured -# Plot Hg intensity-wavelength plot +# Plot Hg spectra [a.u.] plot plt.figure(figsize=(8,5)) plt.plot(wavelength, I_Ox_measured, linestyle='-') plt.xlabel('Wavelength [$nm$]') @@ -128,7 +128,7 @@ plt.title('Wavelength-Intensity ($Ox_{measured}$)') plt.grid(True) plt.show() -# Plot Hg intensity-wavelength plot +# Plot Hg spectra real units plot plt.figure(figsize=(8,5)) plt.plot(wavelength, I_Ox_true, linestyle='-') plt.xlabel('Wavelength [$nm$]') @@ -141,17 +141,24 @@ plt.show() # %% Calculate Dencity of Ox at upper state -from scipy.interpolate import interp1d -from scipy.integrate import quad +from scipy.integrate import simpson -# Create an interpolated callable function -I_Ox_true = interp1d(wavelength, I_Ox_true, kind='linear', - fill_value=0, bounds_error=False) +I_Ox_true = I_Ox_true.to_numpy() -# Now integrate +# Integrate numerator delta = 1 peak = 846.5 bound_lower = peak - delta bound_upper = peak + delta -numerator, err = quad(I_Ox_true, bound_lower, bound_upper) +mask = (wavelength >= bound_lower) & (wavelength <= bound_upper) +wavelength_trimmed = wavelength[mask] +I_Ox_trimmed = I_Ox_true[mask] +numerator = simpson(I_Ox_trimmed, wavelength_trimmed) + +v = c/(peak*10**(-9)) +A = 3.6e6 # 1/s +l = 0.015 # m + +n = numerator / (1/(4*np.pi)*h*v*A*l) + |
