Starfish icon indicating copy to clipboard operation
Starfish copied to clipboard

air=True in grid_tools causing weird wavelength bug

Open iancze opened this issue 9 years ago • 3 comments

Steps to reproduce:

import numpy as np
import Starfish
from Starfish.grid_tools import PHOENIXGridInterfaceNoAlpha

grid = PHOENIXGridInterfaceNoAlpha(wl_range=[900, 50000], air=False)
wl = grid.wl

print("Air is {}: Maximum change in wavelength {:.3f} AA".format(False, np.max(np.diff(wl))))
print("Air is {}: Minimum change in wavelength {:.3f} AA".format(False, np.min(np.diff(wl))))
print()

grid = PHOENIXGridInterfaceNoAlpha(wl_range=[900, 50000], air=True)
wl = grid.wl

print("Air is {}: Maximum change in wavelength {:.3f} AA".format(True, np.max(np.diff(wl))))
print("Air is {}: Minimum change in wavelength {:.3f} AA".format(True, np.min(np.diff(wl))))

Output

Air is False: Maximum change in wavelength 0.225 AA
Air is False: Minimum change in wavelength 0.006 AA

Air is True: Maximum change in wavelength 743.863 AA
Air is True: Minimum change in wavelength -1293.716 AA

Obviously, the wavelength grid should be monotonic. I'm not really sure what's causing this, but it seems to be related to applying the vacuum_to_air method to a larger range of wavelengths than just the optical.

iancze avatar Apr 14 '16 15:04 iancze

It seems like there's a resonance feature that reorders the wavelengths at one index location:

vac_air_demo

Not sure how to handle this, though these are exceptionally short wavelengths, so it's unlikely that you have data there. Still it's problematic if you're trying to integrate the function or something.

gully avatar Mar 02 '17 19:03 gully

Ah, your plot makes the issue clearer. I think the problem is that the vacuum to air conversion we are using is not valid outside of optical wavelengths.

iancze avatar Mar 02 '17 19:03 iancze

The Ciddor 1996 formula used is valid for the wavelength range between 0.23 and 1.7μm. Found in the conclusion here as the actual paper is behind a paywall.

jason-neal avatar May 19 '17 15:05 jason-neal