jacopo-chevallard / BEAGLE-general

Basic information to get started with the galaxy spectral modelling tool Beagle
https://www.iap.fr/beagle/
9 stars 0 forks source link

Likelihood function returns invalid value when fitting equivalent width with upper limit #29

Open mengtaotang opened 8 years ago

mengtaotang commented 8 years ago

I am using BEAGLE to fit both broadband photometry and emission line equivalent width measured from spectra simultaneously. It runs well if equivalent width type ewType is set to be standard or lower. However, when I tried to fit EW whose value is treated as upper limit (upper in ewType), I got problem that the likelihood function returns invalid value:

docker run --rm -it -v /home/mengtao/BEAGLE/BEAGLE-general:/BEAGLE_virtual_workdir --env-file env.list beagletool/beagle:0.7.2 --parameter-file /BEAGLE_virtual_workdir/params/test/fit_egs.param --fit

 Reading Filter File: /BEAGLE_virtual_workdir/filters/FILTERBIN.RES
 271 filters defined, out of 500                                maximum     ...done
 ---> fixed                         sfh_type                                   0
 ---> fitted                        mass                                       0
 ---> fixed                         current_sfr_timescale                      0
 ---> fitted                        redshift                                   0
 ---> dependent                     nebular_Z                                  0
 ---> fixed                         attenuation_type                           0
 ---> fitted                        tauV_eff                                   0
 ---> fixed                         mu                                         0
 ---> fitted                        tau                                        1
 ---> fitted                        metallicity                                1
 ---> fitted                        specific_sfr                               1
 ---> fitted                        nebular_logU                               1
 ---> fitted                        nebular_xi                                 1
 n_fitted:            8
 *****************************************************
 MultiNest v3.9
 Copyright Farhan Feroz & Mike Hobson
 Release Oct 2014

 no. of live points =  150
 dimensionality =    8
 *****************************************************
 Starting MultiNest
 generating live points
 indx, fitted_par_values, likelihood:            2   11.2246170       7.47700024       1.82317889       8.29180145      -1.62558198      -7.74211121      -2.94602299      0.288603872                  NaN
 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
         [ERROR: Likelihood function has returned an invalid value [NaN or Inf]! ]
 [FUNCTION: "likelihood" ]
 [MODULE: "likelihood_function" ]
 [BACKTRACE:   
#0  0x7FACF21C5E08
#1  0x6318FC in print_backtrace at lib_messages.f90:330
#2  0x435FDB in __likelihood_function_MOD_likelihood at likelihood_function.f90:441
#3  0x436DD5 in __likelihood_function_MOD_mc_likelihood at likelihood_function.f90:89 (discriminator 4)
#4  0x4FE2A3 in __nested_sampling_MOD_getloglike at nested_sampling.f90:206 (discriminator 6)
#5  0x52BE90 in __nested_MOD_gen_initial_live at nested.F90:536
#6  0x52D60C in __nested_MOD_nestsample at nested.F90:352
#7  0x52E6A4 in __nested_MOD_nestrun at nested.F90:239
#8  0x4FE67C in __nested_sampling_MOD_run_nested_sampling at nested_sampling.f90:134
#9  0x4F3DD2 in __prosit_MOD_sample_pdf at PROSIT.f90:314
#10  0x406FF9 in MAIN__ at BEAGLE.f90:547
 ]
 [ ***************************************** ]
 [ ----> EXITING FUNCTION / SUBROUTINE <---- ]                                      
 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 [ ***** STOPPING PROGRAM ***** ]
Note: The following floating-point exceptions are signalling: IEEE_INVALID_FLAG IEEE_DIVIDE_BY_ZERO IEEE_UNDERFLOW_FLAG IEEE_DENORMAL

Here is the parameter file that I used:

[main]

# This is a stripped down version of the BEAGLE parameter file for 
# with checking the correct installation of BEAGLE using Docker.
# This file will be used for producing artificial photometry using
# an analytic star formation history.
# Verbose mode: 0 ---> no info
#               1 ----> print only errors
#               2 ---> print errors and warnings
#               3 ----> print errors, warnings and info 
VERBOSE = 1

# Seed for the random number generator
SEED = 994189

#****************************************************************
#******************** COSMOLOGICAL PARAMETERS *******************
#****************************************************************
#
# If left blank, default parameter values will be used.

HUBBLE_0 = 

OMEGA_MATTER =

OMEGA_LAMBDA =

#****************************************************************
# ******************* TEMPLATES  *****************************
#****************************************************************

#TEMPLATES = $BEAGLE_TEMPLATES/bc03/bc03_miles_chab_spectra
TEMPLATES NEBULAR = $BEAGLE_TEMPLATES/ineb_Jan16_C100/cb2013_n2_mup100_N015_O01_deplO70_C100_Jan16
EMISSION LINES CONFIGURATION = $BEAGLE_TEMPLATES/ineb_Jan16_C100/cb2013_n2_mup100_N015_O01_deplO70_C100_Jan16_line_wavelengths_PHOTOMETRY.dat

SHRINK TEMPLATES WL RANGE = 900 60000
REBIN TEMPLATES = 10

#****************************************************************
# ******************* SPECTROSCOPY ***************************
#****************************************************************

SPECTRAL INDICES CONFIGURATION = $BEAGLE_FILTERS/spec_config_RB16.dat

SPECTRAL INDICES CATALOGUE = $BEAGLE_DATA/egs_spec.fits

#****************************************************************
# ******************* PHOTOMETRY *****************************
#****************************************************************

FILTERS FILE = $BEAGLE_FILTERS/filters_RB16.dat

PHOTOMETRIC CATALOGUE = $BEAGLE_DATA/egs_phot.fits
PRIORS CATALOGUE = $BEAGLE_DATA/egs_phot.fits

FIT PHOTOMETRY = T
FIT SPECTRUM = T

#****************************************************************
#******************** DUST ATTENUATION AND IGM ABSORPTION *******
#****************************************************************
#
IGM ABSORPTION = Inoue

# File containing set of radiativa transfer (RT) calculations of dust attenuation of starlight
#RT CALCULATIONS = Tuffs_bulge_NEW-28-11.dat Tuffs_thick_NEW-28-11.dat Tuffs_thin_NEW-28-11.dat
#RT COMPONENTS NAMES = bulge thick_disc thin_disc

# **************************************************
# ************** SF BIN #1 **************************
# **************************************************
SF_PARAMETER  = name:sfh_type                 type:fixed  char_value:delayed
#options for analytic SFHs are 'ssp' (for a burst), 'constant', 'exponential', 'delayed', 'rising'

# In log(yr)
SF_PARAMETER  = name:tau                      type:fitted  order_priority:1  prior:distribution:uniform  prior:range:[7.,10.5]

# in log(Z/Z_sun)
SF_PARAMETER  = name:metallicity              type:fitted  order_priority:1  prior:distribution:uniform  prior:range:[-2.2,0.25]

# In log(M/M_sun)
SF_PARAMETER  = name:mass                     type:fitted  order_priority:0  prior:distribution:uniform  prior:range:[5.,12.] 

# **************************************************
# **************  OTHER SF PARAMETERS **************************
# **************************************************

# In log(yr)
SF_PARAMETER  = name:current_sfr_timescale        type:fixed  value:7.

# In log(yr^-1)
SF_PARAMETER  = name:specific_sfr                type:fitted  order_priority:1  prior:distribution:uniform  prior:range:[-14.,-7.]

#****************************************************************
# ******************* PRINTED OUTPUT  *****************************
#****************************************************************

RESULTS DIRECTORY = $BEAGLE_RESULTS/egs/

#MOCK CATALOGUE NAME = 

PRINT PHOTOMETRY = T
PRINT SPECTRUM = F
PRINT SPECTRAL INDICES = T
PRINT SF AND ChE HISTORIES = F

#****************************************************************
# ******************* PARAMETERS HANDLING  *****************************
#****************************************************************

PDF SAMPLER FILE = $BEAGLE_PARAM_DIR/MCMC_example.param

PARAMETER  = name:redshift     type:fitted  order_priority:0    prior:distribution:dirac  prior:colName:spec_z

PARAMETER  = name:nebular_logU type:fitted  order_priority:1  prior:distribution:uniform  prior:range:[-4.,-1.]

PARAMETER  = name:nebular_xi   type:fitted  order_priority:1  prior:distribution:uniform  prior:range:[0.1,0.5]

PARAMETER  = name:nebular_Z    type:dependent 

PARAMETER  = name:attenuation_type  type:fixed  char_value:CF00   
# values can be: CF00, Calzetti, CCWW13_universal, CCWW13_full

PARAMETER  = name:tauV_eff     type:fitted  order_priority:0      prior:distribution:uniform   prior:range:[0.001,5.]

PARAMETER  = name:mu           type:fixed   value:0.4

And spectroscopy & photometry catalogs, spectral indices configuration file & filter file are in the following link: https://www.dropbox.com/s/dvrww6vnmuj65op/beagle.tar?dl=0 The tar file contains: Spectral Indices Catalogue: egs_spec.fits; Photometry Catalogue: egs_phot.fits; Spectral Indices Configuration: spec_config_RB16.data; Filter File: filters_RB16.dat; Parameter File: fit_egs.param. Two EWs are going to be fitted: Ly-alpha EW and CIII] EW. CIII] EW has ewType set as upper, if it is set to be standard, the error message will be removed and BEAGLE will run.

jacopo-chevallard commented 8 years ago

Great, thanks for the accurate report, I'll take a look as soon as I find some time!

lukasfurtak commented 2 years ago

Any update on this? I get the exact same error message with BEAGLE v0.27.2 when trying to fit photometry+spectral indices, though as 'standard' not upper limit.

jacopo-chevallard commented 2 years ago

@lukasfurtak that's quite strange, we use this functionality all the time with no issues, @ImaanBontle which version of Beagle are you using to run your MOSDEF fits of lines + photometry?

ImaanBontle commented 2 years ago

Hi @lukasfurtak I am also using BEAGLE v0.27.2, although I am not currently fitting any equivalent widths for my spectral indices, only fluxes and their errors. It is possible I have not yet run into this error.

lukasfurtak commented 2 years ago

Hi @jacopo-chevallard and @ImaanBontle, I used the same BEAGLE version. So this thing turned out to be a very strange object and Dan Stark's group managed to fit all of the EWs and photometry with some new templates they have after all. So I think in my case this was due to the limitations of the parameters I used to reproduce the weird SED of this galaxy.