ACCarnall / bagpipes

Bagpipes is a state of the art code for generating realistic model galaxy spectra and fitting these to spectroscopic and photometric observations. Users should install with pip, not by cloning the repository.
http://bagpipes.readthedocs.io
GNU General Public License v3.0
71 stars 37 forks source link

Plotting spectrum fails when y_scale lower than -20 #34

Closed ThomasHerard closed 1 year ago

ThomasHerard commented 1 year ago

I encountered this issue when plotting spectra with small fluxes in the order of 10**(-20). Once y_scale <= -20, the arrays' dtype becomes object and the following error is raised:

TypeError: ufunc 'isfinite' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''

Quick fix would be to cast y_scale to float before plotting, I will open a pull request where I found the issue but it might be found elsewhere as well.

ACCarnall commented 1 year ago

Hi Thomas,

I'm not convinced this is related to any specific values of y_scale. I've had this kind of error before when the spectrum that's been provided to the code contains significantly higher flux values than the associated photometry. Might this be what's going on in your case? As I often tell people, I see the plotting functions as kind of an add-on to the code rather than core functionality. If they work, great, but I can't guarantee they will in all situations. I'd always encourage people to make their own plots to check their outputs.

Cheers, Adam

ThomasHerard commented 1 year ago

It does depend on the y_scale value but seems system dependant as explained here on stackoverflow, I have had the switch to object type at 10^20 or 10^(-20) on two machines, which for latter can be inconvenient as those fluxes scales are common.

However, I understand your policy on the plotting functions and have not opened a pull request, thanks for the reply anyway!

Cheers, Thomas

ACCarnall commented 1 year ago

Ah ok that's interesting, thanks. Feel free to open a pull request to fix this if you'd like, no pressure though.

ACCarnall commented 1 year ago

I believe this should now be fixed in v1.0.2