Issues fitting for TP-AGB parameters
Mslob opened this issue · 4 comments
Hi,
I'm currently trying to fit photometry and spectral data simultaneously while letting dell
be a free parameter. When I try to include this as a free parameter in the fit, the run-time gets extremely long. It now takes over 4 hours to do the optimisation step, whereas without including dell
as a free param it takes about 20 minutes to run the optimisation & MCMC.
Another issue I have is that when I fix dell
to something other than the default in the fit, there is no difference in the resulting fit compared to a fit using the default value. This makes me believe nothing is done with the parameter when creating the models, but then I don't understand why the fitting slows down so much when it is a free parameter.
In terms of settings, I change tpagb_norm_type
to 1 (python-FSPS documentation says dell
only has effect for this case) in the model_params
dictionary, and set dell
as free param with a prior in the model as well. However, when I then inspect the sps.ssp.params.iteritems()
dictionary, both tpagb_norm_type
and dell
are still set to their default values, so I think this might have something to do with my issue, but I'm not sure how to fix this.
Thanks in advance!
Cheers,
Martje
Hi Martje, any of the FSPS parameters that trigger regeneration of the SSPs will increase the runtime by orders of magnitude. Re the lack of change in the ssp parameter values, could you provide a minimum working example? Also, could you let me know which isochrones you are using in (python-)FSPS? (i.e. the output of sps.ssp.libraries) Thanks.
Hi Ben,
Thanks for the explanation, I've found another issue with a strategy to fit for parameters which regenerate SSPs, so I'll try to get that working.
For the parameters not changing in sps, this is a code snippet to just build the model + sps for tpagb_norm_type = 1
instead of the default:
from prospect import prospect_args
def build_model(**extras):
from prospect.models.sedmodel import SedModel
from prospect.models.templates import TemplateLibrary
model_params = TemplateLibrary["parametric_sfh"]
model_params["tpagb_norm_type"] = dict(init=1, isfree=False, N=1)
model = SedModel(model_params)
return model
def build_sps(zcontinuous=1, compute_vega_mags=False, **extras):
from prospect.sources import CSPSpecBasis
sps = CSPSpecBasis(zcontinuous=zcontinuous,
compute_vega_mags=compute_vega_mags, **extras)
return sps
def build_all(**kwargs):
return (build_model(**kwargs),
build_sps(**kwargs))
if __name__ == '__main__':
# - Parser with default arguments -
parser = prospect_args.get_parser()
args = parser.parse_args()
run_params = vars(args)
run_params['tpagb_norm_type'] = 1
model, sps = build_all(**run_params)
which returns the following sps.ssp.params.iteritems()
dictionary: dict_items([('add_agb_dust_model', True), ('add_dust_emission', True), ('add_igm_absorption', False), ('add_neb_emission', False), ('add_neb_continuum', True), ('add_stellar_remnants', True), ('redshift_colors', False), ('compute_light_ages', False), ('nebemlineinspec', True), ('smooth_velocity', True), ('smooth_lsf', False), ('cloudy_dust', False), ('agb_dust', 1.0), ('tpagb_norm_type', 2), ('dell', 0.0), ('delt', 0.0), ('redgb', 1.0), ('agb', 1.0), ('fcstar', 1.0), ('fbhb', 0.0), ('sbss', 0.0), ('pagb', 1.0), ('zred', 0.0), ('zmet', 1), ('logzsol', 0.0), ('pmetals', 2.0), ('imf_type', 2), ('imf_upper_limit', 120), ('imf_lower_limit', 0.08), ('imf1', 1.3), ('imf2', 2.3), ('imf3', 2.3), ('vdmc', 0.08), ('mdave', 0.5), ('evtype', -1), ('use_wr_spectra', 1), ('logt_wmb_hot', 0.0), ('masscut', 150.0), ('sigma_smooth', 0.0), ('min_wave_smooth', 1000.0), ('max_wave_smooth', 10000.0), ('gas_logu', -2), ('gas_logz', 0.0), ('igm_factor', 1.0), ('sfh', 0), ('tau', 1.0), ('const', 0.0), ('sf_start', 0.0), ('sf_trunc', 0.0), ('tage', 0.0), ('dust_tesc', 7.0), ('fburst', 0.0), ('tburst', 11.0), ('sf_slope', 0.0), ('dust_type', 0), ('dust1', 0.0), ('dust2', 0.0), ('dust_clumps', -99.0), ('frac_nodust', 0.0), ('frac_obrun', 0.0), ('dust_index', -0.7), ('dust1_index', -1.0), ('mwr', 3.1), ('uvb', 1.0), ('wgp1', 1), ('wgp2', 1), ('wgp3', 1), ('duste_gamma', 0.01), ('duste_umin', 1.0), ('duste_qpah', 3.5), ('fagn', 0.0), ('agn_tau', 10.0)])
So the tpagb_norm_type
is still set to 2 even though I've set it to 1 for both the run_params
and the model_params
. The same happens when I try to change e.g. the IMF-type this way, so maybe I'm just misunderstanding how to set these parameters.
I'm using the 'mist', 'miles', and 'DL07' isochrones right now.
Thanks!
Cheers,
Martje
Hi Martje, Sorry for the delay, I just got back from vacation. I think the issue is that in the code above the sps object has not interacted with the model object at all yet, so it doesn't know that the parameter should be changed. Try adding the following to your script:
model, sps = build_all(**run_params)
print(sps.ssp.params["tpagb_norm_type"])
obs = dict(wavelength=None, filters=None)
spec, phot, x = model.predict(model.theta, obs=obs, sps=sps)
print(sps.ssp.params["tpagb_norm_type"])
Assuming this is resolved, but please reopen if there are still questions. Thanks!