bd-j / prospector

Python code for Stellar Population Inference from Spectra and SEDs
http://prospect.readthedocs.io
MIT License
153 stars 71 forks source link

dimension mismatch of arrays in polynomial regularization? #296

Closed wangbingjie closed 7 months ago

wangbingjie commented 10 months ago

When using the polynomial regularization, I had to modify the following codes in the function spec_calibration in sedmodel.py:

order = self.params['polyorder'] --> order = self.params['polyorder'][0]

ATA += reg**2 * np.eye(order) --> ATA += reg**2 * np.eye(order+1)

The first change is to make order an integer, so that it can be passed to np.eye(), whereas the second is to match the dimensions of the arrays. I am not sure if this is a real bug or is something related my setup, so I am raising an issue here.

code versions: python 3.8, numpy 1.24.4

bd-j commented 7 months ago

Hi Sorry, I missed this issue. Do you recall if this was with SedModel or SpecModel? The latter issue seems like a mismatch between the length of the regularization vector and polyorder, note that in SedModel the zero term is treated as an explicit separate parameter (spec_norm) but this entire class will be deprecated.

The other is a real bug.

bd-j commented 7 months ago

I've pushed a fix for the polyorder -> scalar bug

wangbingjie commented 7 months ago

I think it was SpecModel (I don't remember using SedModel). Thanks for taking care of it!

wangbingjie commented 7 months ago

oops I just realized that you only fixed the polyorder -> scalar bug. sorry.. reopening this issue.

bd-j commented 7 months ago

pushed a fix for the other bug, caused by mistranslation from PolySedModel.

bd-j commented 7 months ago

Thanks @wangbingjie for noticing these issues!