- SciPy - Home
- SciPy - Introduction
- SciPy - Environment Setup
- SciPy - Basic Functionality
- SciPy - Relationship with NumPy
- SciPy Clusters
- SciPy - Clusters
- SciPy - Hierarchical Clustering
- SciPy - K-means Clustering
- SciPy - Distance Metrics
- SciPy Constants
- SciPy - Constants
- SciPy - Mathematical Constants
- SciPy - Physical Constants
- SciPy - Unit Conversion
- SciPy - Astronomical Constants
- SciPy - Fourier Transforms
- SciPy - FFTpack
- SciPy - Discrete Fourier Transform (DFT)
- SciPy - Fast Fourier Transform (FFT)
- SciPy Integration Equations
- SciPy - Integrate Module
- SciPy - Single Integration
- SciPy - Double Integration
- SciPy - Triple Integration
- SciPy - Multiple Integration
- SciPy Differential Equations
- SciPy - Differential Equations
- SciPy - Integration of Stochastic Differential Equations
- SciPy - Integration of Ordinary Differential Equations
- SciPy - Discontinuous Functions
- SciPy - Oscillatory Functions
- SciPy - Partial Differential Equations
- SciPy Interpolation
- SciPy - Interpolate
- SciPy - Linear 1-D Interpolation
- SciPy - Polynomial 1-D Interpolation
- SciPy - Spline 1-D Interpolation
- SciPy - Grid Data Multi-Dimensional Interpolation
- SciPy - RBF Multi-Dimensional Interpolation
- SciPy - Polynomial & Spline Interpolation
- SciPy Curve Fitting
- SciPy - Curve Fitting
- SciPy - Linear Curve Fitting
- SciPy - Non-Linear Curve Fitting
- SciPy - Input & Output
- SciPy - Input & Output
- SciPy - Reading & Writing Files
- SciPy - Working with Different File Formats
- SciPy - Efficient Data Storage with HDF5
- SciPy - Data Serialization
- SciPy Linear Algebra
- SciPy - Linalg
- SciPy - Matrix Creation & Basic Operations
- SciPy - Matrix LU Decomposition
- SciPy - Matrix QU Decomposition
- SciPy - Singular Value Decomposition
- SciPy - Cholesky Decomposition
- SciPy - Solving Linear Systems
- SciPy - Eigenvalues & Eigenvectors
- SciPy Image Processing
- SciPy - Ndimage
- SciPy - Reading & Writing Images
- SciPy - Image Transformation
- SciPy - Filtering & Edge Detection
- SciPy - Top Hat Filters
- SciPy - Morphological Filters
- SciPy - Low Pass Filters
- SciPy - High Pass Filters
- SciPy - Bilateral Filter
- SciPy - Median Filter
- SciPy - Non - Linear Filters in Image Processing
- SciPy - High Boost Filter
- SciPy - Laplacian Filter
- SciPy - Morphological Operations
- SciPy - Image Segmentation
- SciPy - Thresholding in Image Segmentation
- SciPy - Region-Based Segmentation
- SciPy - Connected Component Labeling
- SciPy Optimize
- SciPy - Optimize
- SciPy - Special Matrices & Functions
- SciPy - Unconstrained Optimization
- SciPy - Constrained Optimization
- SciPy - Matrix Norms
- SciPy - Sparse Matrix
- SciPy - Frobenius Norm
- SciPy - Spectral Norm
- SciPy Condition Numbers
- SciPy - Condition Numbers
- SciPy - Linear Least Squares
- SciPy - Non-Linear Least Squares
- SciPy - Finding Roots of Scalar Functions
- SciPy - Finding Roots of Multivariate Functions
- SciPy - Signal Processing
- SciPy - Signal Filtering & Smoothing
- SciPy - Short-Time Fourier Transform
- SciPy - Wavelet Transform
- SciPy - Continuous Wavelet Transform
- SciPy - Discrete Wavelet Transform
- SciPy - Wavelet Packet Transform
- SciPy - Multi-Resolution Analysis
- SciPy - Stationary Wavelet Transform
- SciPy - Statistical Functions
- SciPy - Stats
- SciPy - Descriptive Statistics
- SciPy - Continuous Probability Distributions
- SciPy - Discrete Probability Distributions
- SciPy - Statistical Tests & Inference
- SciPy - Generating Random Samples
- SciPy - Kaplan-Meier Estimator Survival Analysis
- SciPy - Cox Proportional Hazards Model Survival Analysis
- SciPy Spatial Data
- SciPy - Spatial
- SciPy - Special Functions
- SciPy - Special Package
- SciPy Advanced Topics
- SciPy - CSGraph
- SciPy - ODR
- SciPy Useful Resources
- SciPy - Reference
- SciPy - Quick Guide
- SciPy - Cheatsheet
- SciPy - Useful Resources
- SciPy - Discussion
SciPy - lambda2nu() Method
The SciPy lambda2nu() method is used to convert the wavelength into optical frequency.
A wavelength() represents the distance between two peaks of wave whereas, optical frequency () is measured by number of times the light wave vibrates in a given time period.
In statistics term, we say these are shape(numerical) parameters which determine the relationship of two quantities with respect to speed of light.
The wavelength is measured in meters and the frequency is measured using hertz(Hz). The speed of light in a vacuum is similar to 3 108 m/s. To obtain the following formula −
Speed of light(c) = wavelength().frequency().
Syntax
Following is the syntax of the SciPy lambda2nu() method −
lambda2nu(lambda_)
Parameters
This method accepts only a single parameter which is −
- lambda_− This parameter based on either integer or float values.
Return value
This function returns the float value or an array of float values.
Example 1
Following is the basic SciPy lambda2nu() method that illustrates the conversion of wavelength into frequency.
def lambda2nu(lambda_):
# c is speed of light(m/s)
c = 3e8
# Convert wavelength (in meters) to frequency (in Hz)
nu = c / lambda_
return nu
# w is wavelength(m)
w = 500e-9
f = lambda2nu(w)
print(f"Frequency: {f} Hz")
Output
On execution of above code, we get the following result −
Frequency: 600000000000000.0 Hz
Example 2
Here, the program illustrates how to build an object for the class, and with the help of the lamda2nu() method, it converts wavelengths in different units to frequency.
from scipy.constants import c, nano, micro, milli
class WavelengthConverter:
UNIT_DICT = {'m': 1, 'nm': nano, 'um': micro, 'mm': milli}
@staticmethod
def lambda2nu(lambda_, unit='m'):
if unit not in WavelengthConverter.UNIT_DICT:
raise ValueError("Unsupported unit")
lambda_in_meters = lambda_ * WavelengthConverter.UNIT_DICT[unit]
if lambda_in_meters <= 0:
raise ValueError("Wavelength must be positive.")
return c / lambda_in_meters
# show the result
converter = WavelengthConverter()
print("Frequency in Hz for 500 nm wavelength", converter.lambda2nu(500, 'nm'))
print("Frequency in Hz for 0.5 m wavelength", converter.lambda2nu(0.5, 'um'))
Output
After executing the above code, we get the following result −
Frequency in Hz for 500 nm wavelength 599584915999999.9 Frequency in Hz for 0.5 m wavelength 599584916000000.0
Example 3
Below the program define an array() which associate to numpy object and accept two parameter float_val and speed_of_light to generate the result.
from scipy.constants import lambda2nu, speed_of_light import numpy as np result = lambda2nu(np.array((3.8, speed_of_light))) print(result)
Output
The above code produces the following result −
[7.88927521e+07 1.00000000e+00]