from scipy import constants
import numpy as np
g = constants.g
sigma = constants.Stefan_Boltzmann
R = constants.R
print(f"g = {g} m/s²")
print(f"σ = {sigma} W/m²/K⁴")
print(f"R = {R} J/mol/K")
F = 1361 / 4
T_earth = (F / sigma) ** 0.25
print(f"\nEarth's blackbody temperature: {T_earth:.1f} K ({T_earth-273.15:.1f}°C)")Scientific Computing with SciPy
What is SciPy?
SciPy builds on NumPy to provide a comprehensive ecosystem for scientific computing. It’s organized into submodules, each addressing specific scientific domains:
- scipy.constants- Physical and mathematical constants
- scipy.integrate- Integration and differential equations
- scipy.interpolate- Data interpolation
- scipy.optimize- Optimization and root finding
- scipy.signal- Signal processing
- scipy.spatial- Spatial algorithms and data structures
- scipy.stats- Statistical functions
- scipy.linalg- Linear algebra (extends NumPy)
- scipy.fft- Fast Fourier transforms
- scipy.ndimage- N-dimensional image processing
Physical Constants
The scipy.constants module provides precise physical constants:
You can search for constants:
Interpolation
Interpolation fills in values between known data points. This is crucial for working with scattered or sparse data.
2D Interpolation
For gridded data:
Optimization
Find minima, maxima, and zeros of functions:
Finding Roots
Integration
Numerical integration for definite integrals:
Double Integrals
Statistics
The scipy.stats module provides probability distributions and statistical tests:
Statistical Tests
Signal Processing with FFT
Fast Fourier Transform for frequency analysis:
Summary
SciPy provides essential scientific computing tools:
- Constants - Physical and mathematical values
- Interpolation - Fill in missing data points
- Optimization - Find minima/maxima and roots
- Integration - Numerical integration
- Statistics - Distributions and hypothesis tests
- Signal processing - FFT and filtering
SciPy builds on NumPy to provide the algorithms that power scientific Python!
