Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error in normalize.integrate_flux #18

Open
dirkscholte opened this issue Apr 18, 2023 · 1 comment
Open

Error in normalize.integrate_flux #18

dirkscholte opened this issue Apr 18, 2023 · 1 comment

Comments

@dirkscholte
Copy link
Member

dirkscholte commented Apr 18, 2023

@biprateep I encountered an error in the integrate_flux function when the value at the start or the end of a flux window is masked. In that case the interpolation function bounds are shorter than the flux window and an error is returned.

I managed to reproduce the error with this simple example:

wave = np.linspace(0,10,11)
flux = np.linspace(0,10,11)
ivar = flux = np.linspace(0,10,11)
mask = np.ones_like(wave, dtype='bool')
mask[7:9] = False
print(wave[mask])
integrate_flux(wave[mask], flux[mask], ivar[mask], 3., 7.)

Returns: ValueError: A value in x_new is above the interpolation range.

I can 'fix' the issue by setting bounds_error=False, fill_value='extrapolate' in the interpolation of this function but that might be a bit risky (I guess the most extreme extrapolation issues will already be avoided as a max of 20% of the pixels can be masked for the interpolation to even happen).

Do you have any thoughts on what might be a better solution?

@dirkscholte
Copy link
Member Author

I also encountered the issue that when one spectrum can not be normalised the stacking crashes. which is understandable but we might want to include some functionality that filters out those rare spectra with >20% masked within the flux window and then continues stacking with the spectra that can be normalised.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant