LSSTDESC / firecrown

DESC Cosmology Likelihood Framework
BSD 3-Clause "New" or "Revised" License
29 stars 7 forks source link

Method for returning a dictionary of required parameters set by a likelihood object #383

Open arthurmloureiro opened 5 months ago

arthurmloureiro commented 5 months ago

Hi Firecrowd,

It would be great to have a way for returning a dictionary of required parameters (keys and values) from a likelihood object. At the moment, I can return a list of required parameter names by:

from firecrown.likelihood.likelihood import load_likelihood_from_module_type
# this is a likelihood from firecrown's examples:
import des_y1_3x2pt_PT 

likelihood, tools = load_likelihood_from_module_type(des_y1_3x2pt_PT, None)

list(likelihood.required_parameters().get_params_names())

which returns me:

['lens0_b_s',
 'ia_a_d',
 'lens0_mag_bias',
 'ia_a_2',
 'src0_delta_z',
 'ia_a_1',
 'lens0_delta_z',
 'lens0_b_2',
 'lens0_bias']

Although these values are set inside the likelihood, I could not find a way of accessing them.

Is this possible?

This would be useful for the blinding infrastructure as it would eliminate requiring the user to provide this dictionary (and avoid the user providing a dictionary that may be discrepant with what's on the likelihood already).

marcpaterno commented 1 month ago

This is closed by PR #420. The Likelihood class method has a method required_parameters that returns a RequiredParameters object containing the names and values of the parameters.

Note that ModelingTools also has a method required_parameters that returns a RequiredParameters object containing all the parameters of the models.

The RequiredParameters class has a method get_default_values that returns a dictionary with the names and default values of the parameters.

We will add a tutorial that includes a demonstration of these features.

@arthurmloureiro does this meet the need?

arthurmloureiro commented 2 weeks ago

Hi @marcpaterno : has this feature been released yet?

marcpaterno commented 2 weeks ago

This feature has been merged into the master branch. It is not yet part of a tagged release, but will become part of Firecrown 1.8.0 (modulo any tweaking in the interface that might occur before the release is cut).