Skip to content

Commit

Permalink
v0.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
bd-j committed Apr 23, 2019
1 parent 7903e8c commit cd4f1eb
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 50 deletions.
66 changes: 33 additions & 33 deletions demo/InteractiveDemo.ipynb

Large diffs are not rendered by default.

26 changes: 13 additions & 13 deletions demo/tutorial.rst
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ including any custom arguments that you might add.
In this example we have added several command line arguments that control how the data is read and how the
The supplied command line arguments are then parsed and placed in a dictionary.
This dictionary is passed to all the ingredient building methods (described below), which return the data dictionary and necessary model objects.
The data dictionary and model objects are passed to a function that runs the prospector fit (:py:method:`fit_model`).
The data dictionary and model objects are passed to a function that runs the prospector fit (:py:function:`fit_model`).
Finally, the fit results are written to an output file.


Expand All @@ -51,7 +51,7 @@ can therefore be used to control the behaviour of the ingredient building functi
For example, a custom command line argument can be used to control the type of model that is fit,
or how or from where the data is loaded.

First, the :py:method:`build_model` function is where the model that we will fit will be constructed.
First, the :py:func:`build_model` function is where the model that we will fit will be constructed.
The specific model that you choose to construct depends on your data and your scientific question.

We have to specify a dictionary or list of model parameter specifications (see :doc:`models`).
Expand All @@ -77,18 +77,18 @@ You'll see that this model has 5 free parameters.
Any parameter with ``"isfree": True`` in its specification will be varied during the fit.
We have set priors on these parameters, visible as e.g. ``model_params["mass"]["prior"]``.
You may wish to change the default priors for your particular science case,
using the prior objects in the :py:module:`models.priors` module.
An example of adjusting the priors for several parameters is given in the :py:method:`build_model` method in ``demo_params.py``.
using the prior objects in the :py:mod:`models.priors` module.
An example of adjusting the priors for several parameters is given in the :py:func:`build_model` method in ``demo_params.py``.
Any free parameter *must* have an associated prior.
Other parameters have their value set to the value of the ``"init"`` key, but do not vary during the fit.
They can be made to vary by setting ``"isfree": True`` and specifying a prior.
Parameters not listed here will be set to their default values.
Typically this means default values in the ``fsps.StellarPopulation()`` object;
Typically this means default values in the :py:class:`fsps.StellarPopulation` object;
see `python-fsps <http://dan.iel.fm/python-fsps/current/>`_ for details.
Once you get a set of parameters from the :py:class:`TemplateLibrary` you can modify or add parameter specifications.
Since ``model_params`` is a dictionary (of dictionaries), you can update it with other parameter set dictionaries from the :py:class:`TemplateLibrary`.

Finally, the :py:method:`build_model` function takes the ``model_params`` dictionary or list that you build and
Finally, the :py:func:`build_model` function takes the ``model_params`` dictionary or list that you build and
uses it to instantiate a :py:class:`SedModel` object.

.. code-block:: python
Expand All @@ -103,7 +103,7 @@ uses it to instantiate a :py:class:`SedModel` object.
If you wanted to change the specification of the model using custom command line arguments,
you could do it in :py:method:`build_model` by allowing this function to take keyword arguments
you could do it in :py:func:`build_model` by allowing this function to take keyword arguments
with the same name as the custom command line argument.
This can be useful for example to set the initial value of the redshift ``"zred"`` on an object-by-object basis.
Such an example is shown in ``demo_params.py``,
Expand All @@ -112,33 +112,33 @@ which also uses command line arguments to control whether nebular and/or dust em

**Building the fit ingredients: build_obs**

The next thing to look at is the :py:method:`build_obs` function.
The next thing to look at is the :py:func:`build_obs` function.
This is where you take the data from whatever format you have and
put it into the dictionary format required by |Codename| for a single object.
This means you will have to modify this function heavily for your own use.
But it also means you can use your existing data formats.

Right now, the :py:method:`build_obs` function just reads ascii data from a file,
Right now, the :py:func:`build_obs` function just reads ascii data from a file,
picks out a row (corresponding to the photometry of a single galaxy),
and then makes a dictionary using data in that row.
You'll note that both the datafile name and the object number are keyword arguments to this function.
That means they can be set at execution time on the command line,
by also including those variables in the ``run_params`` dictionary.
We'll see an example later.

When you write your own :py:method:`build_obs` function, you can add all sorts of keyword arguments that control its output
When you write your own :py:func:`build_obs` function, you can add all sorts of keyword arguments that control its output
(for example, an object name or ID number that can be used to choose or find a single object in your data file).
You can also import helper functions and modules.
These can be either things like astropy, h5py, and sqlite or your own project specific modules and functions.
As long as the output dictionary is in the right format (see dataformat.rst), the body of this function can do anything.

**Building the fit ingredients: the rest**

Ok, now we go to the :py:method:`build_sps` function.
Ok, now we go to the :py:func:`build_sps` function.
This one is pretty straightforward, it simply instantiates our :py:class:`sources.CSPSpecBasis` object.
For nonparameteric fits one would use the :py:class:`sources.FastStepBasis` object.
These objects hold all the spectral libraries and produce an SED given a set of parameters.
After that is :py:method:`build_noise`, which is for complexifying the noise model -- ignore that for now.
After that is :py:func:`build_noise`, which is for complexifying the noise model -- ignore that for now.


Running a fit
Expand Down Expand Up @@ -254,7 +254,7 @@ that can be done as follows
for i in range(model.ndim)]
If necessary, one can regenerate models at any position in the posterior chain.
This requires that we have the sps object used in the fitting to generate models, which we can regenerate using the :py:method:`read_results.get_sps` method.
This requires that we have the sps object used in the fitting to generate models, which we can regenerate using the :py:func:`read_results.get_sps` method.

.. code-block:: python
Expand Down
2 changes: 1 addition & 1 deletion doc/dataformat.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Data Formats
===========
The :py:meth:`build_obs()` function
The :py:meth:`build_obs` function
---------------------------------------

The :py:meth:`build_obs` function in the parameter file is written by the user.
Expand Down
2 changes: 1 addition & 1 deletion doc/output.rst
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ The results dictionary contains the information needed to regenerate the *sps* o

.. code-block:: python
sps = pread.get_sps(res)
sps = reader.get_sps(res)
Pickles
Expand Down
2 changes: 1 addition & 1 deletion doc/usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ You can inspect the default set of arguments and their default values as follows
parser.print_help()
In the typical **parameter file** the arguments are converted to a dictionary and passed as keyword arguments
to all of the :py:method:`build_*` methods described below.
to all of the :py:func:`build_*` methods described below.

A user can add custom arguments that will further control the behavior of the model and data building methods.
This is done by adding arguments to the parser in the executable part of the **parameter file**.
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
setup

#githash = subprocess.check_output(["git", "log", "--format=%h"], universal_newlines=True).split('\n')[0]
vers = "0.2.1"
vers = "0.3.0"
githash = ""
with open('prospect/_version.py', "w") as f:
f.write('__version__ = "{}"\n'.format(vers))
Expand Down

0 comments on commit cd4f1eb

Please sign in to comment.