A comprehensive tool to analyze and graph data from physics experiments using matplotlib
, numpy
, and pandas
.
This repository includes tools for:
-
Pendulum Experiments:
- Analyze pendulum data to calculate the slope (( A )), intercept (( B )), gravity (( g )), and moment of inertia.
- Generate graphs with regression lines and results.
-
Focal Length Calculation:
- Calculate the focal length of lenses using data from physics experiments.
- Perform graphical analysis to determine the focal length.
- Includes additional comment print statements to display intermediate calculations for better understanding of the exercise.
-
Spring Force Analysis (Siły Sprężyste):
- Method A: Analyze spring length vs. applied mass to determine spring constant using Hooke's law.
- Method B: Study oscillation period vs. suspended mass to calculate spring constant.
- Perform linear regression analysis and calculate uncertainties.
- Generate comparative plots for both methods.
-
Thermocouple Analysis (Termopara):
- Analyze thermocouple temperature measurements for different materials.
- Study cooling curves and temperature dependencies.
- Process data for water and Wood's alloy temperature measurements.
- Generate temperature vs. time plots with analysis.
-
Diode Analysis (Diody):
- Analyze diode characteristics and I-V curves.
- Calculate diode parameters and perform regression analysis.
- Generate characteristic plots for diode behavior analysis.
-
Signal Generator Analysis:
- Analyze signal generator output characteristics.
- Process frequency response and amplitude measurements.
- Generate plots for signal analysis and characterization.
-
Amplifier Analysis (Wzmacniacz):
- Analyze amplifier gain and frequency response.
- Calculate amplification factors and bandwidth characteristics.
- Multiple analysis versions available (standard, clean, improved).
- Generate Bode plots and frequency response curves.
-
Thermal Resistance Analysis (TermOpor):
- Analyze thermal resistance and temperature coefficient measurements.
- Study temperature-dependent resistance characteristics.
- Process thermal response data and generate analysis plots.
-
For Pendulum Experiments:
- Ensure your data is stored in an Excel file (
Pendulum.xlsx
) with the following columns:D
: Distance from the center of weight (in meters).t1
: Start time for 40 oscillations (in seconds).t2
: End time for 40 oscillations (in seconds).
- Ensure your data is stored in an Excel file (
-
For Focal Length Calculation:
- Ensure your data is stored in an Excel file (
focal-length.xlsx
) with two sheets:- Sheet 1 (
pomn
): Data for the reduced image.- Columns:
x1
,x2
,x3
,x4
,x5
(object distances), andy
(image distances).
- Columns:
- Sheet 2 (
pow
): Data for the magnified image.- Columns:
x1
,x2
,x3
,x4
,x5
(object distances), andy
(image distances).
- Columns:
- Sheet 1 (
- Ensure your data is stored in an Excel file (
-
For Spring Force Analysis:
- Ensure your data is stored in an Excel file (
sily_sprezyste.xlsx
) with two sheets:- Sheet 1 (
MetodaA
): Spring length vs. mass data.- Columns:
L_0
(initial length in mm),M
(mass in g),L
(spring length in m).
- Columns:
- Sheet 2 (
MetodaB
): Oscillation period vs. mass data.- Columns:
M
(mass in g),t1
,t2
(time measurements in s),T
(period in s).
- Columns:
- Sheet 1 (
- Ensure your data is stored in an Excel file (
-
For Thermocouple Analysis:
- Ensure your data is stored in an Excel file (
Termopara.xlsx
) with sheets for different materials:- Temperature measurements over time for various substances.
- Data should include time and temperature columns for analysis.
- Ensure your data is stored in an Excel file (
-
For Diode Analysis:
- Ensure your data is stored in an Excel file with voltage and current measurements.
- Data should include columns for applied voltage and measured current for I-V characteristic analysis.
-
For Signal Generator Analysis:
- Ensure your data is stored in an Excel file (
Generator.xlsx
) with frequency and amplitude measurements. - Data should include frequency response and signal characteristics for analysis.
- Ensure your data is stored in an Excel file (
-
For Amplifier Analysis:
- Ensure your data is stored in an Excel file (
Wzmacniacz.xlsx
) with gain and frequency measurements. - Data should include input/output voltage measurements and frequency response data.
- Ensure your data is stored in an Excel file (
-
For Thermal Resistance Analysis:
- Ensure your data is stored in an Excel file (
TermOpor.xlsx
) with temperature and resistance measurements. - Data should include temperature values and corresponding resistance measurements for analysis.
- Ensure your data is stored in an Excel file (
The project requires the following Python libraries:
pyxdf
matplotlib
pyqt6
numpy
scipy
pandas
scikit-learn
openpyxl
pyedflib
Install dependencies with uv:
uv sync
Alternatively, install dependencies manually:
pip install pyxdf matplotlib pyqt6 numpy scipy pandas scikit-learn openpyxl pyedflib
- If you are using
uv
, the virtual environment is automatically managed. - Otherwise, activate the virtual environment manually:
-
Linux/macOS:
source ./.venv/bin/activate
-
Windows:
.\.venv\Scripts\activate
-
-
For Pendulum Experiments:
python src/eeg/Pendulum.py
-
For Focal Length Calculation:
python src/eeg/focal_len.py
-
For Spring Force Analysis:
python src/eeg/sily_sprezyste.py
-
For Thermocouple Analysis:
python src/eeg/termopara.py
-
For Diode Analysis:
python src/eeg/diody.py
-
For Signal Generator Analysis:
python src/eeg/generator.py
-
For Amplifier Analysis:
python src/eeg/wzmacniacz.py
Alternative versions:
python src/eeg/wzmacniacz_clean.py python src/eeg/wzmacniacz_improved.py
-
For Thermal Resistance Analysis:
python src/eeg/termopor.py
-
Pendulum Experiments:
- The script will calculate the slope (( A )), intercept (( B )), gravity (( g )), and moment of inertia with uncertainties.
- It will display the results in the terminal and on a graph.
-
Focal Length Calculation:
- The script will calculate the focal length for both reduced and magnified images.
- It will also perform graphical analysis to determine the focal length and display the results on a graph.
- Additional print statements will show intermediate calculations, such as:
- Average focal lengths for reduced and magnified images.
- Graphically determined focal length and its uncertainty.
-
Spring Force Analysis:
- Method A: Calculates spring constant from spring length vs. mass relationship.
- Method B: Calculates spring constant from oscillation period vs. mass relationship.
- Displays regression statistics, spring constants, and uncertainties.
- Generates plots showing data points, regression lines, and calculated results.
-
Thermocouple Analysis:
- Processes temperature vs. time data for different materials.
- Calculates cooling rates and temperature dependencies.
- Generates temperature curves and analysis plots.
-
Diode Analysis:
- Analyzes I-V characteristics of diodes.
- Calculates diode parameters such as forward voltage and reverse saturation current.
- Generates characteristic curves and regression analysis plots.
-
Signal Generator Analysis:
- Processes frequency response and amplitude characteristics.
- Analyzes signal quality and distortion parameters.
- Generates frequency response plots and signal analysis graphs.
-
Amplifier Analysis:
- Calculates amplification gain and frequency response.
- Analyzes bandwidth and phase characteristics.
- Generates Bode plots and frequency response curves.
- Multiple analysis approaches available for different aspects of amplifier behavior.
-
Thermal Resistance Analysis:
- Analyzes temperature coefficient of resistance.
- Calculates thermal response characteristics.
- Generates temperature vs. resistance plots with regression analysis.
Slope (A): 3.1046 ± 0.1059 s²/m
Intercept (B): 0.3433 ± 0.0073 m·s²
Gravity (g): 12.7161 ± 1.3466 m/s²
Moment of Inertia: 0.0866 ± 0.0035 kg·m²
- The graph will display the data points, regression line, and the results in a text box.
Średnia ogniskowa (obraz pomniejszony): 15.23 cm ± 0.12 cm
Średnia ogniskowa (obraz powiększony): 15.18 cm ± 0.10 cm
Graficznie wyznaczona ogniskowa: 15.20 cm ± 0.11 cm
- The graph will display:
- Data points for reduced and magnified images.
- Fitted regression lines for both datasets.
- The intersection point representing the focal length.
Statystyki regresji:
Nachylenie (a): 0.0098
Przecięcie (b): 0.1420
Niepewność standardowa u(a): 0.0012
Niepewność standardowa u(b): 0.0012
Nachylenie a (m/kg): 0.0098
Stała sprężyny k: 100.15 N/m
Niepewność stałej sprężyny u(k): 12.34 N/m
L_0 = 0.1400 m odpowiada przecięciu y b = 0.1420 ± 0.0036 m
Nachylenie a (s/kg): 0.6234
Średnia arytmetyczna stałej sprężyny k: 98.76 N/kg
Odchylenie standardowe stałej sprężyny: 3.45 N/kg
Niepewność okresu delta_T: 0.0200 s
- Method A: Spring length vs. mass with regression line and spring constant calculation.
- Method B: Oscillation period vs. mass with regression analysis and spring constant determination.
Analiza danych termopary:
Temperatura początkowa wody: 85.2°C
Temperatura końcowa wody: 23.1°C
Szybkość chłodzenia: -0.52°C/min
Temperatura topienia stopu Wooda: 70.5°C ± 1.2°C
Czas stabilizacji temperatury: 15.3 min
- Temperature vs. time curves for water cooling.
- Wood's alloy melting point analysis with plateau identification.
-
Excel File Issues:
- Ensure your Excel file is formatted correctly and contains valid data.
- Verify that the sheet names and column names match the expected format.
- For spring force analysis, ensure
MetodaA
andMetodaB
sheets exist with correct column names. - For thermocouple analysis, verify temperature and time data columns are properly formatted.
-
Unit Conversion Issues:
- Spring force analysis expects specific units: mass in grams, length in meters/millimeters as specified.
- Thermocouple data should have temperature in Celsius and time in appropriate units.
-
Data Format Issues:
- Ensure numerical data doesn't contain text or missing values.
- Check for consistent decimal separators (dots vs. commas) based on your system locale.
-
Dependency Issues:
- Verify that your Python environment is properly set up and all required libraries are installed.
-
Virtual Environment:
- Ensure the virtual environment is activated before running the scripts.
-
Plot Display Issues:
- If plots don't display, ensure you have a GUI backend for matplotlib installed.
- On some systems, you may need to install additional packages for plot display.
The project automatically generates LaTeX reports and plots for each experiment:
Reports/
├── Dioda/ # Diode analysis
│ ├── dioda.pdf # Compiled LaTeX report
│ ├── dioda.tex # LaTeX source
│ ├── Figure_1.png # I-V characteristic plot
│ └── Figure_2.png # Additional analysis plot
├── Generator/ # Signal generator analysis
│ ├── generator.pdf # Compiled LaTeX report
│ ├── generator.tex # LaTeX source
│ └── Generator.png # Generator analysis plot
├── Ogniskowa/ # Focal length analysis
│ ├── ogniskowa.pdf # Compiled LaTeX report
│ ├── ogniskowa.tex # LaTeX source
│ ├── obraz_pom.png # Reduced image plot
│ └── obraz_pow.png # Magnified image plot
├── Pendulum/ # Pendulum experiments
│ ├── reportPendulum.pdf # Compiled report
│ ├── reportPendulum.tex # LaTeX source
│ └── pendulum.png # Pendulum analysis plot
├── sily_sprezyste/ # Spring force analysis
│ ├── sily_sprezyste.pdf # Compiled report
│ ├── sily_sprezyste.tex # LaTeX source
│ ├── MetodaA.png # Method A plot
│ └── MetodaB.png # Method B plot
├── Template/ # LaTeX template files
│ ├── template.pdf # Template document
│ ├── template.tex # LaTeX template source
│ └── logaUR.pdf # University logo
├── Termopara/ # Thermocouple analysis
│ ├── reportTermopara.pdf # Compiled report
│ ├── reportTermopara.tex # LaTeX source
│ ├── woda.png # Water cooling plot
│ └── stopWooda.png # Wood's alloy analysis plot
├── TermOpor/ # Thermal resistance analysis
│ ├── termopor.pdf # Compiled LaTeX report
│ ├── termopor.tex # LaTeX source
│ └── termOpor.png # Thermal resistance plot
└── Wzmacniacz/ # Amplifier analysis
├── wzmacniacz.pdf # Compiled LaTeX report
├── wzmacniacz.tex # LaTeX source
├── wzmacniacz.png # Standard amplifier plot
├── wzmacniaczImpr.png # Improved analysis plot
├── wykresy osobno.png # Separate plots
└── analiza_wyniki.txt # Analysis results text file
All experimental data is stored in the data/
directory:
Pendulum.xlsx
- Pendulum experiment datafocal-length.xlsx
- Lens focal length measurementssily_sprezyste.xlsx
- Spring force analysis data (Methods A & B)Termopara.xlsx
- Thermocouple temperature measurementsGenerator.xlsx
- Signal generator analysis dataWzmacniacz.xlsx
- Amplifier analysis measurementsTermOpor.xlsx
- Thermal resistance measurement data
- This tool is designed for educational purposes and assumes the input data follows the expected format.
- Contributions and suggestions for improvement are welcome!