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

Something about the photometry data and the fitting results #39

Closed markliuchina closed 1 year ago

markliuchina commented 1 year ago

Dear Adam, Hello! I am now learning your code and want to make an "imitation" of your published paper (Carnall et al. 2020). Primarily, I performed fitting on the GOODS-S objects in your sample. But my results are all with a huge chi^2 (about ~20 and even higher). I call the chi^2 in this way:

print(np.percentile(fit.posterior.samples["chisq_phot"], (16, 50, 84)))
[18.76193059 21.48623753 25.45852246]

The photometry data was processed carefully and the fitting model was set as described in your paper.

dblplaw = {}                        
dblplaw["tau"] = (0.1, 15.)
dblplaw["tau_prior"] = "uniform"

dblplaw["alpha"] = (0.01, 1000.)
dblplaw["beta"] = (0.01, 1000.)
dblplaw["alpha_prior"] = "log_10"
dblplaw["beta_prior"] = "log_10"

dblplaw["massformed"] = (0.00001, 13.)         #因为无法把这个质量下限的log_10取0,所以近似取0.00001,防止kernel崩溃。
dblplaw["metallicity"] = (0.1, 2.5)            #对数空间下的取值应该是-1到0.4之间,对应就是0.1到2.5
dblplaw["massformed_prior"] = "log_10"
dblplaw["metallicity_prior"] = "log_10"

dust = {}                           
dust["type"] = "Calzetti"
dust["delta"] = (-0.3, 0.3)
dust["delta_prior"] = "Gaussian"
dust["delta_prior_mu"] = 0.
dust["delta_prior_sigma"] = 0.1

dust["B"] = (0., 5.)
dust["B_prior"] = "uniform"

dust["Av"] = (0., 8.)
dust["Av_prior"] = "uniform"
dust["qpah"] = 2.
dust["umin"] = 1.
dust["gamma"] = 0.01

nebular = {}
nebular["logU"] = -3.

fit_instructions = {}
fit_instructions["redshift"] = (0., 10)
fit_instructions["redshift_prior"] = "uniform"
fit_instructions["dblplaw"] = dblplaw
fit_instructions["dust"] = dust
fit_instructions["nebular"] = nebular

(I use the full photometry catalog with 17 bands provided by CANDELS) When loading the observed photometry data using:

galaxy = pipes.galaxy("22", load_goodss, spectrum_exists = False, filt_list = goodss_filt_list, spec_units = "mujy")
fig1 = galaxy.plot()

And I got a figure of the observed photometry, but there exist some photometry point with value = 0 & error = ∞. I know the reasons, cause the loading function is defined as:

def load_goodss(ID):
    cat = np.loadtxt('./photometry_catalog/staa1535_SED_input_catalog_goodss.txt', 
                 usecols = (3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35,   
                            4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36))
    row = int(ID) - 1
    fluxes = cat[row, :17]
    fluxerrs = cat[row, 17:]
    photometry = np.c_[fluxes, fluxerrs]

    for i in range(len(photometry)):
        if (photometry[i, 0] == 0.) or (photometry[i, 1] <= 0):
            photometry[i,:] = [0., 9.9*10**99.]

    for i in range(len(photometry)):
        if i <= 12:
            max_snr = 20.
        elif i <= 14:
            max_snr = 10.
        else:
            max_snr = 5.

        if photometry[i, 0]/photometry[i, 1] > max_snr:
            photometry[i, 1] = photometry[i, 0]/max_snr

    return photometry

I know how this script works and its effects. After checking the original data, my most concern is: Whether those photometry points with 0 values and infinite errors get involved in the fitting process? Anyway, is the chisq_phot in the advanced quantities exactly the "minimum reduced chi-squred values"? I am a postgraduate student (now my 1st year) and do not know much about the SED fitting process (I am now learning it). Maybe this is a simple and humble question to professional scientists like you. Please forgive my interruption! I am sorry to disturb you for such reasons. Anything from you will be appreciated! Thanks you again for providing such a wonderful code!

Best wishes.

Mingfeng Liu Department of Theoretical Physics Nanjing Normal University Wenyuan Road 1, Qixia District Nanjing City, Jiangsu Province, PRC 2023.3.4

markliuchina commented 1 year ago

I'm sorry Adam! I did not think carefully before opening an issue. I found the solutions and closed the issue (I didn't know exactly the differences between ‘Close as Completed’ and 'Close as not planned') I have misunderstanding in 'Close as not planned', I used to deem it as 'cancel and delete the issue as if not opened ever before'. Anyway, I was going to delete it at that time. Please forgive me! I promise I will think twice before opening an issue Best.

Mingfeng Liu