Refractive index of air and wave length conversion

Refractive index of air

The Python module ref_index has functions for calculating the refractive index of air. It also has functions for converting between wave length of light in vacuum and that in air.

The equations used in this module are taken from the documentation for the NIST online refractive index of air calculator.


In the following examples, wave lengths are in nano-meters, pressure in Pascal, temperature in degree Celsius, and relative humidity is a number between 0 and 100.

Converting wave length of light from vacuum to that in air

>>> ref_index.vac2air(633.0)

>>> ref_index.vac2air(np.array([633.0, 550.0, 400.0]))
array([ 632.82500477,  549.84723175,  399.88692724])

Default calculation is carried out at a temperature of 15 degree Celsius, pressure of 101325Pa, relative humidity of 0, and a CO2 concentration of 450micro-mole/mole. These can be changed by passing appropriate parameters to the function.

>>> ref_index.vac2air(wave=633.0, t=20, p=101325, rh=50)

Converting wave length of light from air to that in vacuum

The equations need wave length in vacuum, but I use the wave lengths in air as an approximation. The full conversion from vacuum to air and back agrees to ~1e-5nm, as shown below.

>>> x = ref_index.vac2air(np.array([633.0, 550.0, 400.0]))

>>> ref_index.air2vac(x)
array([ 633.0000014 ,  550.00000164,  400.00000243])

Refractive index

Refractive index can be calculated using two different equations: one due to Edlen and another due to Ciddor. The wave length conversion functions, vac2air() and air2vac() both use the Ciddor formula.

>>> ref_index.ciddor(wave=633.0, t=20, p=101325, rh=20)
>>> ref_index.edlen(wave=633.0, t=20, p=101325, rh=20)

>>> ref_index.edlen(wave=633.0, t=20, p=101325, rh=80)
>>> ref_index.ciddor(wave=633.0, t=20, p=101325, rh=80)

>>> ref_index.edlen(wave=633.0, t=60, p=101325, rh=80)
>>> ref_index.ciddor(wave=633.0, t=60, p=101325, rh=80)



The module can be installed using pip and easy_install.

$ pip install ref_index


$ easy_install ref_index

The code repository is at Github:


The following comments are based on the discussions presented in the NIST documentation. It is intended as a brief overview. See, for detailed discussions.

Refractive index of air can be calculated using two different algorithms: one due to Edlen (updated by Birch and Down), and one due to Ciddor. The latter has been adopted by the International Association of Geodesy (IAG) as the reference equation for calculating refractive index of air. Functions for calculating refractive index using either of these are defined in this module.

The vacuum to air and air to vacuum wave length conversion functions in this module use the Ciddor equation, in the form presented in the NIST documentation.

Uncertainties in refractive index, and hence in wave length conversions, due to uncertainties in measured values of temperature, pressure, and humidity exceeds that due to the intrinsic uncertainty in the equations used.

An uncertainty of 1e-6 in refractive index can result from a combination of:

  • an error of 1 degree Celsius (1.8 degree F) in air temperature
  • an error of 0.4kPa (3mm of Hg) in air pressure
  • an error of 50% in relative humidity at sufficiently high air
    temperatures (near 35 degree Celsius)

Valid range for input parameters for the refractive index calculations
are presented below. The online calculator issues a warning if input
parameters are outside a smaller interval within the maximum
range. Functions in this module do not raise a warning by default. But
they accept a keyword warn, which when set to True will result
in warnings, when the input parameters are outside the accepted range.

  • Wavelength [300nm – 1700nm]

    Warning is issued if value is outside [350nm – 1600nm].

  • Pressure [10kPa – 140kPa]

    Warning is issued if value is outside [60kPa – 120kPa].

  • Temperature [-40 degree C – 100 degree C].

    Warning is issued if value is outside [0 degree C – 40 degree C].

  • Humidity [0 – 100]

    Can be given as relative humidity, dew point, frost point or partial pressure of water vapour. A warning is given if the mole fraction of water vapour exceeds 20% or, equivalently, relative humidity exceeds 85%. A warning is issued if relative humidity is less than 1%.

  • CO2 concentration [0micro-mole/mole – 2000micro-mole/mole]

    The common value to use is 450. Outdoor values are rarely below 300 and indoor can be as high as 600. A difference of 150 will lead to a difference of only ~ 2e-8 in index of refraction.

    A warning is issued if a value other than 450 is used.

Most of these options are probably not relevant for astronomy applications. The defaults should be enough. See the next section for comparison with IDLASTRO IDL code.

Comparison with IDLASTRO code

In astronomy, the convention is to use the refraction correction for wave length greater than 200nm, even though the equations are not strictly valid at wave lengths shorter than 300nm. For example, the popular IDLASTRO IDL code and will accept any wave length greater than 2000 angstrom.

To accommodate this type of usage, instead of limiting the possible input wave lengths, functions in this module will accept any wave length value. It is up to the user to decide if a particular wave length is to be used as an input to the equations.

Comparison with the IDLASTRO and algorithms show that the equivalent functions in this module, vac2air and air2vac, give results that agree to within 1e-4nm, over a range of wavelengths from 200nm to 1700nm. This uncertainty translates to a velocity difference of 150m/s to 17m/s, over the wave length range 1700nm to 200nm.

The IDLASTRO code uses a fixed value of temperature and humidity which is not documented in the IDL code. The above comparison was carried out at a temperature of 15 degree C and a relative humidity of 0.

The IDL code used for testing was downloaded on 2011/10/07. The revision history indicates that the IDL code in and were last modified in March 2011.

See the functions with names starting with the string _test for details on how the tests were performed.

About Prasanth Nair

Prasanth Nair is a freelance software developer with strong interests in STEM education research, especially Physics Education Research.
This entry was posted in Astronomy, Python and tagged , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s