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

Check for Nan in flux and ivar of spectra files #99

Merged
merged 2 commits into from Feb 1, 2018
Merged

Conversation

julienguy
Copy link
Contributor

set flux=0 ivar=0 to Nan or Inf values in spectra files when reading them.
checked it fixes the crash of one simulated spectra file in my sims.
now need to understand where this is coming from on the desispec side.

@julienguy
Copy link
Contributor Author

This fixes issue #98

# for entries with flux==0
for i in np.where(isnan)[0] :
hdata[i][np.isnan(hdata[i])]=0.
hdata[i][np.isinf(hdata[i])]=0.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this could be handled more simply with:

bad = np.isnan(hdata) | np.isinf(hdata) | np.isneginf(hdata)
hdata[bad] = 0.0

I'm more concerned with the assumption downstream that flux=0 data was actually bad data and should be set to ivar=0. Real data will very very rarely be exactly 0, but that seems fragile. Would be better to explicitly make a badflux mask like above, and then use that mask when loading the ivar HDU to set ivar[badmask]=0.

@julienguy
Copy link
Contributor Author

very well, I am redoing this.

@sbailey sbailey merged commit 5a54d31 into master Feb 1, 2018
@sbailey sbailey deleted the nan_proof branch February 1, 2018 23:20
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

Successfully merging this pull request may close these issues.

None yet

2 participants