1

For some reason, my data reduction for a fits image has given me -0 values, which I would like to set to 0.

I've attempted to use:

my_array[~numpy.isfinite(my_array)] = 0

All I would like to do is set the -0 values in the corrfact_um2_ext1 array to 0. Just to keep everything in the same format, as I think this may cause a problem in subsequent data reduction steps.

But this just deals with NaN values and sets them to 0. So, I'm halfway there!

3

1 Answer 1

1

Simply adding 0.0 to each floating point number should fix this:

a = np.array([-0.0, 0.0, 1.0, -1.0])
Out[1]: array([-0.,  0.,  1., -1.]

a += 0.0
a
Out[2]: array([ 0.,  0.,  1., -1.])

But note:

np.array(-0.) == np.array(+0.)
Out[3]: True

Does this solve your problem?

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.