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

data fitting isssue #9

Closed LejayChen closed 3 years ago

LejayChen commented 3 years ago

Hi,

I am using data from observation in CFHT-Megacam-u and Subaru-HSC-g,r,i,z,y filters, and the fitting-instruction is exactly as in exmaple3. I got the filter curves from the telescopes' website.

fit = pipes.fit(galaxy, fit_instructions)
fit.fit(verbose=False)

The photometry I put in was

[[0.00000000e+00 9.90000000e+09]
 [1.70897492e-02 2.27727314e-05]
 [0.00000000e+00 9.90000000e+09]
 [9.51965070e-02 1.26848239e-04]
 [5.59863376e-02 7.46010968e-05]
 [3.17779369e-01 4.23541465e-04]]

I had the following error:

Bagpipes: fitting object 10054340010916

Bagpipes: lnlike was nan, replaced with zero probability.
Bagpipes: lnlike was nan, replaced with zero probability.
Bagpipes: lnlike was nan, replaced with zero probability.
.....
.....
Bagpipes: lnlike was nan, replaced with zero probability.

Completed in 1.2 seconds.

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-69-ce2f1f757289> in <module>()
      1 fit = pipes.fit(galaxy, fit_instructions)
----> 2 fit.fit(verbose=False)

~/anaconda3/lib/python3.6/site-packages/bagpipes/fitting/fit.py in fit(self, verbose, n_live, mpi_off)
    141 
    142             # Load MultiNest outputs and save basic quantities to file.
--> 143             samples2d = np.loadtxt(self.fname + "post_equal_weights.dat")
    144             lnz_line = open(self.fname + "stats.dat").readline().split()
    145 

~/anaconda3/lib/python3.6/site-packages/numpy/lib/npyio.py in loadtxt(fname, dtype, comments, delimiter, converters, skiprows, usecols, unpack, ndmin, encoding)
   1090         # converting the data
   1091         X = None
-> 1092         for x in read_data(_loadtxt_chunksize):
   1093             if X is None:
   1094                 X = np.array(x, dtype)

~/anaconda3/lib/python3.6/site-packages/numpy/lib/npyio.py in read_data(chunk_size)
   1017 
   1018             # Convert each value according to its column and store
-> 1019             items = [conv(val) for (conv, val) in zip(converters, vals)]
   1020 
   1021             # Then pack it according to the dtype's nesting

~/anaconda3/lib/python3.6/site-packages/numpy/lib/npyio.py in <listcomp>(.0)
   1017 
   1018             # Convert each value according to its column and store
-> 1019             items = [conv(val) for (conv, val) in zip(converters, vals)]
   1020 
   1021             # Then pack it according to the dtype's nesting

~/anaconda3/lib/python3.6/site-packages/numpy/lib/npyio.py in floatconv(x)
    736         if '0x' in x:
    737             return float.fromhex(x)
--> 738         return float(x)
    739 
    740     typ = dtype.type

ValueError: could not convert string to float: '-0.999000000000000022+100'

it seems that this error is associated with one of the posterior files as it said that the errneous figure is in a "...post_equal_weights.dat". file. Does this have to do with previous warnings of "lnlike was nan" and how do I solve this?

Thanks!

LejayChen commented 3 years ago

It seems that the filter cuve is the issue, the default u-band filter on CFHT website is in nanometer not Angstorm. Replacing it with the filters from SVO fixed this issue.

ACCarnall commented 3 years ago

Sorry I was away on holiday when you submitted this, glad you managed to find the solution!

markliuchina commented 1 year ago

Thanks! I was encountered with the same issue. Your solution does work!