Skip to content

Commit 5ae9448

Browse files
committed
Merge branch 'develop'
Release v0.9
2 parents 1a05947 + e681d9e commit 5ae9448

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

84 files changed

+4937
-805
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,7 @@ devnotes*
2323
*.cb
2424
*.cb2
2525
.*.lb
26+
27+
# docs
28+
docs/build
29+
docs/source/**/generated/

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2022 Nolan Dickson
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 11 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -2,62 +2,17 @@
22

33
## Fitting of static equilibrium globular cluster models
44

5-
Python package enabling the generalized fitting of globular cluster
6-
observations to distribution function based lowered isothermal
7-
([LIMEPY](https://github.com/mgieles/limepy)) models to various observational
8-
data products, via a parallelized [MCMC](https://github.com/dfm/emcee/) suite.
5+
Python package enabling the generalized fitting of distribution function based
6+
lowered isothermal ([LIMEPY](https://github.com/mgieles/limepy)) models to
7+
various observational Globular Cluster data products, via a parallelized
8+
sampling suite.
99

10-
## Installation
10+
## Documentation
11+
All documentation, including installation instructions and examples, can be
12+
found [here](https://GCfit.readthedocs.io).
1113

12-
The `fitter` package can be easily installed from this repository using pip.
13-
A fork of the `ssptools` library must be installed seperately, as below. All
14-
other requisite packages will be installed automatically.
14+
## Attribution
1515

16-
```
17-
pip install git+ssh://git@github.com/nmdickson/ssptools.git
18-
pip install git+ssh://git@github.com/nmdickson/GCfit.git
19-
```
20-
21-
or this repo can be cloned locally and installed with pip.
22-
23-
## Usage
24-
25-
GCfit has two main functionalities; to fit globular cluster models, and to
26-
explore the results of those fitting runs.
27-
28-
### Fitting
29-
30-
Fitting of the clusters is done through the `fit` function of `fitter`.
31-
For ease of use, a command-line script is provided in `GCfitter`, which should
32-
be automatically placed in your path upon installation.
33-
34-
`GCfitter` takes the name of the cluster you wish to fit, as well as a
35-
number of sampler directives. See `GCfitter -h` for a full list of arguments.
36-
37-
#### Examples
38-
39-
Fitting cluster "NGC0104" (also known as 47 Tucanae) for 2000 iterations of 100
40-
MCMC walkers, parallelized locally over 2 CPUs (default). Sampler output is
41-
saved to `~/.GCfit/47Tuc_sampler.hdf` (default).
42-
```
43-
GCfitter 47Tuc -N 2000 --Nwalkers 100 --verbose
44-
```
45-
46-
Fitting cluster "NGC6397" for 1850 iterations of 150 walkers (default), using
47-
MPI. MPI parameters and allocations must be handled by your job
48-
script/scheduler separately. Output and debug info is saved to a local `results`
49-
folder.
50-
```
51-
srun GCfitter NGC6397 -N 1850 --mpi --savedir ./results --debug
52-
```
53-
54-
Fitting cluster "NGC0104" for 2000 iterations of 150 walkers, with custom prior
55-
bounds specified in the file `alt_bounds`, parallelized locally with 4 CPUs.
56-
```
57-
echo '{"a3": [">=", "a2"], "delta": [0.45, 0.5]}' > alt_bounds.json
58-
GCfitter NGC104 -N 2000 --Ncpu 4 --bounds alt_bounds.json --debug
59-
```
60-
61-
### Investigating Fitting Results
62-
63-
TODO
16+
If you find this package useful in your research, please see the
17+
[documentation](https://GCfit.readthedocs.io/en/latest/citations.html) for
18+
information on what you should cite.

bin/GCfitter

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -74,14 +74,9 @@ if __name__ == '__main__':
7474
help='Likelihood components to '
7575
'exclude from posteriors')
7676

77-
shared_parser.add_argument('--no-hyperparams', dest='hyperparams',
78-
action='store_false',
79-
help="Don't use Bayesian hyperparams")
80-
81-
shared_parser.add_argument('--strict', nargs='+',
82-
metavar=('[STRICT]', 'LIKELIHOOD'),
83-
help="A (numeric) strictness factor to be "
84-
"applied to each specified likelihood")
77+
shared_parser.add_argument('--hyperparams', dest='hyperparams',
78+
action='store_true',
79+
help="Use Bayesian hyperparams")
8580

8681
shared_parser.add_argument('--verbose', action='store_true')
8782
shared_parser.add_argument('--debug', action='store_true')
@@ -134,6 +129,13 @@ if __name__ == '__main__':
134129
help='Posterior weighting fraction f_p')
135130
parser_nest.add_argument('--dlogz', default=0.25, type=float,
136131
help='Δln(Z) tolerance initial stopping condition')
132+
parser_nest.add_argument('--maxfrac', default=0.8, type=float,
133+
help='The fractional threshold, relative to the '
134+
'peak weight, used to determine likelihood '
135+
'bounds for dynamic sampling. Default to 0.8')
136+
parser_nest.add_argument('--eff-samples', default=5000, type=pos_int,
137+
help='Number of effective posterior samples '
138+
'stopping condition')
137139
parser_nest.add_argument('--maxiter', default=None, type=pos_int,
138140
help='Maximum number of iterations allowed. May '
139141
'end sampling before the stopping conditions '
@@ -184,16 +186,6 @@ if __name__ == '__main__':
184186
else:
185187
parser.error(f"Cannot access '{bnd_file}': No such file")
186188

187-
# TODO could also be a way here for setting `err_on_fail` in the priors
188-
if args.strict is not None:
189-
try:
190-
args.strict[0] = float(args.strict[0])
191-
except (ValueError, TypeError):
192-
args.strict = [1.] + args.strict
193-
194-
if len(args.strict) == 1:
195-
args.strict.append('*')
196-
197189
pathlib.Path(args.savedir).mkdir(exist_ok=True)
198190

199191
# ----------------------------------------------------------------------

bin/file_creator.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
'''
2+
1) Create a Clusterfile
3+
2) Add metadata to created Clusterfile
4+
3) Create a bunch of Datasets
5+
- Add them to created Clusterfile
6+
'''

docs/CLUSTER_DPC_V2.pdf

-120 KB
Binary file not shown.

docs/Makefile

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Minimal makefile for Sphinx documentation
2+
#
3+
4+
# You can set these variables from the command line, and also
5+
# from the environment for the first two.
6+
SPHINXOPTS ?=
7+
SPHINXBUILD ?= sphinx-build
8+
SOURCEDIR = source
9+
BUILDDIR = build
10+
11+
# Put it first so that "make" without argument is like "make help".
12+
help:
13+
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
14+
15+
.PHONY: help Makefile
16+
17+
# Catch-all target: route all unknown targets to Sphinx using the new
18+
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
19+
%: Makefile
20+
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

docs/make.bat

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
@ECHO OFF
2+
3+
pushd %~dp0
4+
5+
REM Command file for Sphinx documentation
6+
7+
if "%SPHINXBUILD%" == "" (
8+
set SPHINXBUILD=sphinx-build
9+
)
10+
set SOURCEDIR=source
11+
set BUILDDIR=build
12+
13+
if "%1" == "" goto help
14+
15+
%SPHINXBUILD% >NUL 2>NUL
16+
if errorlevel 9009 (
17+
echo.
18+
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
19+
echo.installed, then set the SPHINXBUILD environment variable to point
20+
echo.to the full path of the 'sphinx-build' executable. Alternatively you
21+
echo.may add the Sphinx directory to PATH.
22+
echo.
23+
echo.If you don't have Sphinx installed, grab it from
24+
echo.https://www.sphinx-doc.org/
25+
exit /b 1
26+
)
27+
28+
%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
29+
goto end
30+
31+
:help
32+
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
33+
34+
:end
35+
popd

docs/source/_static/DPC.pdf

141 KB
Binary file not shown.

docs/source/citations.rst

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
=========
2+
Citations
3+
=========
4+
5+
If you find this package useful in your research, please consider citing the
6+
relevant papers below:
7+
8+
Observational Data
9+
==================
10+
11+
Each observational dataset should come with it's own ``source`` metadata,
12+
typically in the form of a
13+
`bibcode <https://adsabs.harvard.edu/help/actions/bibcode>`_ identifier.
14+
15+
While these can be accessed directly through the metadata attribute of each
16+
``Dataset``:
17+
18+
.. code-block:: python
19+
20+
>>> dset = obs['proper_motion/gedr3']
21+
>>> dset.mdata['source']
22+
'2021MNRAS.505.5978V'
23+
24+
``GCfit`` also comes equipped with some utility functions to automatically
25+
convert bibcodes to useful formats, like bibtex. This functionality requires
26+
the `ads <https://github.com/andycasey/ads>`_ package to be installed correctly,
27+
with a valid ``ADS_DEV_KEY`` set.
28+
29+
The ``Observations`` and ``Dataset`` objects can provide some of the available
30+
formats directly:
31+
32+
.. code-block:: python
33+
34+
>>> sources = obs.get_sources()
35+
>>> print(sources['proper_motion/gedr3'])
36+
@ARTICLE{2021MNRAS.505.5978V,
37+
author = {{Vasiliev}, Eugene and {Baumgardt}, Holger},
38+
...
39+
adsnote = {Provided by the SAO/NASA Astrophysics Data System}
40+
}
41+
>>> dset.cite()
42+
'Vasiliev & Baumgardt (2021)'
43+
44+
Or the utility methods can be used directly:
45+
46+
.. code-block:: python
47+
48+
>>> print(fitter.util.bibcode2bibtex(dset.mdata['source']))
49+
@ARTICLE{2021MNRAS.505.5978V,
50+
author = {{Vasiliev}, Eugene and {Baumgardt}, Holger},
51+
...
52+
adsnote = {Provided by the SAO/NASA Astrophysics Data System}
53+
}
54+
>>> fitter.util.bibcode2cite(dset.mdata['source'])
55+
'Vasiliev & Baumgardt (2021)'
56+
57+
58+
Models
59+
======
60+
61+
The equilibrium models used should be cited from the ``limepy`` paper:
62+
`2015MNRAS.454..576G <https://adsabs.harvard.edu/abs/2015MNRAS.454..576G>`_.
63+
64+
65+
Samplers
66+
========
67+
68+
If you are using the MCMC fitter (``MCMC_fit``), the sampler source software
69+
should be cited as the ``emcee`` paper:
70+
`2013PASP..125..306F <https://adsabs.harvard.edu/abs/2013PASP..125..306F>`_.
71+
Specific proposal algorithm citations can be found within.
72+
73+
Nested sampling fits (``nested_fit``) should cite the ``dynesty`` paper:
74+
`2020MNRAS.493.3132S <https://adsabs.harvard.edu/abs/2020MNRAS.493.3132S>`_.
75+
For specific bound and sampler algorithm sources, see the
76+
`dynesty documentation <https://dynesty.readthedocs.io/en/latest/references.html>`_.
77+
78+
Other
79+
=====
80+
81+
If Bayesian hyperparameters are used (``hyperparams=True`` in any fitting),
82+
the source paper
83+
`2002MNRAS.335..377H <https://adsabs.harvard.edu/abs/2002MNRAS.335..377H>`_
84+
can be cited.
85+
86+
``GCfit`` makes extensive use of the
87+
`numpy <https://adsabs.harvard.edu/abs/2020Natur.585..357H>`_,
88+
`scipy <https://adsabs.harvard.edu/abs/2020NatMe..17..261V>`_ and
89+
`astropy <https://adsabs.harvard.edu/abs/2018AJ....156..123A>`_
90+
libraries. All plotting functionality is enabled by the
91+
`matplotlib <https://adsabs.harvard.edu/abs/2007CSE.....9...90H>`_ library.
92+
Parallelization pools are handled by the
93+
`schwimmbad <https://adsabs.harvard.edu/abs/2017JOSS....2..357P>`_ library

0 commit comments

Comments
 (0)