├── .DS_Store
├── .gitignore
├── .idea
├── encodings.xml
├── libraries
│ └── R_User_Library.xml
├── misc.xml
├── modules.xml
├── pycecream.iml
├── vcs.xml
└── workspace.xml
├── CONTRIBUTING.md
├── LICENSE
├── README.md
├── README_dream.md
├── build
└── lib
│ └── pycecream
│ ├── __init__.py
│ ├── cream_f90.f90
│ └── creaminpar.par
├── dist
└── pycecream-1.5.5.tar.gz
├── docs
├── _build
│ ├── pydocmd
│ │ ├── index.md
│ │ └── pycecream.md
│ └── site
│ │ ├── 404.html
│ │ ├── css
│ │ ├── theme.css
│ │ └── theme_extra.css
│ │ ├── fonts
│ │ ├── Lato
│ │ │ ├── lato-bold.eot
│ │ │ ├── lato-bold.ttf
│ │ │ ├── lato-bold.woff
│ │ │ ├── lato-bold.woff2
│ │ │ ├── lato-bolditalic.eot
│ │ │ ├── lato-bolditalic.ttf
│ │ │ ├── lato-bolditalic.woff
│ │ │ ├── lato-bolditalic.woff2
│ │ │ ├── lato-italic.eot
│ │ │ ├── lato-italic.ttf
│ │ │ ├── lato-italic.woff
│ │ │ ├── lato-italic.woff2
│ │ │ ├── lato-regular.eot
│ │ │ ├── lato-regular.ttf
│ │ │ ├── lato-regular.woff
│ │ │ └── lato-regular.woff2
│ │ ├── RobotoSlab
│ │ │ ├── roboto-slab-v7-bold.eot
│ │ │ ├── roboto-slab-v7-bold.ttf
│ │ │ ├── roboto-slab-v7-bold.woff
│ │ │ ├── roboto-slab-v7-bold.woff2
│ │ │ ├── roboto-slab-v7-regular.eot
│ │ │ ├── roboto-slab-v7-regular.ttf
│ │ │ ├── roboto-slab-v7-regular.woff
│ │ │ ├── roboto-slab-v7-regular.woff2
│ │ │ └── roboto-slab.eot
│ │ ├── fontawesome-webfont.eot
│ │ ├── fontawesome-webfont.svg
│ │ ├── fontawesome-webfont.ttf
│ │ ├── fontawesome-webfont.woff
│ │ └── fontawesome-webfont.woff2
│ │ ├── img
│ │ └── favicon.ico
│ │ ├── index.html
│ │ ├── js
│ │ ├── jquery-2.1.1.min.js
│ │ ├── modernizr-2.8.3.min.js
│ │ └── theme.js
│ │ ├── pycecream
│ │ └── index.html
│ │ ├── search.html
│ │ ├── search
│ │ ├── lunr.js
│ │ ├── main.js
│ │ ├── search_index.json
│ │ └── worker.js
│ │ ├── sitemap.xml
│ │ └── sitemap.xml.gz
├── autogen.py
├── build_docs.sh
├── deploy_docs.sh
├── examples
│ └── pyceream_test.py
├── pydocmd.yml
└── serve_docs.sh
├── examples
├── .ipynb_checkpoints
│ ├── test_pycecream-checkpoint.ipynb
│ └── test_pycecream_tophat_0lag-checkpoint.ipynb
├── fitinfo_fit_figures__1.pdf
├── fluxflux.pdf
├── page_0_lcplot_fit_figures__1.pdf
├── page_1_lcplot_fit_figures__1.pdf
├── resamp_
├── test_pycecream.ipynb
├── test_pycecream.py
├── test_pycecream_background_polynomials.py
├── test_pycecream_files
│ ├── test_pycecream_12_0.png
│ ├── test_pycecream_6_3.png
│ ├── test_pycecream_6_4.png
│ ├── test_pycecream_6_6.png
│ └── test_pycecream_6_8.png
├── test_pycecream_tophat_0lag.ipynb
├── test_pycecream_tophat_0lag.md
└── test_pycecream_tophat_0lag_files
│ ├── test_pycecream_tophat_0lag_6_1.png
│ ├── test_pycecream_tophat_0lag_6_2.png
│ ├── test_pycecream_tophat_0lag_6_4.png
│ └── test_pycecream_tophat_0lag_6_6.png
├── misc
├── merge_test.py
├── run_lc.py
├── test_parallel.py
└── test_pycecream.py
├── pycecream.egg-info
├── PKG-INFO
├── SOURCES.txt
├── dependency_links.txt
├── not-zip-safe
├── requires.txt
└── top_level.txt
├── pycecream
├── .DS_Store
├── __init__.py
├── __init__.pyc
├── cream_f90.f90
├── creaminpar.par
├── creammod.mod
└── modules
│ ├── cream_lcplot.py
│ ├── cream_plotlibrary.py
│ ├── myconvolve.py
│ ├── mydisksim.py
│ ├── myedlum.py
│ ├── myfake.py
│ ├── myfake_amp.py
│ ├── mylcgen.py
│ ├── myplank.py
│ ├── myrandom.py
│ ├── myresample.py
│ ├── mytemp0.py
│ └── mytfb_quick.py
├── requirements.txt
└── setup.py
/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/drds1/pycecream/1716da359b611ad37f1f645f247e15d59796fb56/.DS_Store
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | pycecream/.DS_Store
3 | pycecream_test/.DS_Store
4 | .idea
5 | .idea/
6 | .ipynb_checkpoints
7 | .ipynb_checkpoints/
8 | .idea/workspace
9 | *venv*
10 | *scratch_*
11 | *simulation_files*
12 | *output_2020*
13 | *.pickle
14 | *simulation_dir*
15 | *.pdf
16 | __pycache__/
--------------------------------------------------------------------------------
/.idea/encodings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/.idea/libraries/R_User_Library.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/.idea/pycecream.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/workspace.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 | $USER_HOME$/.subversion
41 |
42 |
43 |
44 |
45 | 1560762203620
46 |
47 |
48 | 1560762203620
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | # Contributing to Pycecream
2 |
3 |
4 | ## Suggesting new features / Reporting An Issue
5 |
6 | First, check to see if there's an existing issue/pull request for the
7 | bug/feature. All issues are at https://github.com/dstarkey23/pycecream/issues and pull reqs are at
8 | https://github.com/dstarkey23/pycecream/pull.
9 |
10 | If there isn't an existing issue there, please file an issue. The
11 | ideal report includes:
12 |
13 | - A description of the problem/suggestion.
14 | - How to recreate the bug (including the version on your python interpreter).
15 | - If possible, create a pull request with a (failing) test case
16 | demonstrating what's wrong. This makes the process for fixing bugs
17 | quicker & gets issues resolved sooner.
18 |
19 | ## Setting up your environment
20 |
21 | First, clone the repo, then `cd` into the repo.
22 |
23 | ```bash
24 | $ git@github.com:dstarkey23/pycecream.git
25 | $ cd pycecream
26 | ```
27 |
28 | create a new virtual environment
29 | ```bash
30 | $ python3.7 -m venv venv
31 | ```
32 |
33 | activate your environment
34 | ```bash
35 | $ . venv/bin/activate
36 | ```
37 |
38 | install the required dependencies
39 | ```
40 | $ pip install -e .[tests]
41 | ```
42 |
43 | run tests
44 | ```
45 | $ python setup.py test
46 | ```
47 |
48 | serve documentation
49 | ```bash
50 | $ ./docs/serve_docs.sh
51 | ```
52 | …and view the docs at http://localhost:8000 in your web browser.
53 |
54 |
55 | :tada: Now you're ready to create a new branch, add a feature or fix a bug, then send us a pull request! :tada:
56 |
57 | ## Contributing Code
58 |
59 | A good pull request:
60 | - Is clear.
61 | - Follows the existing style of the code base (PEP-8).
62 | - Has comments included as needed.
63 | - A test case that demonstrates the previous flaw that now passes with
64 | the included patch, or demonstrates the newly added feature.
65 |
66 |
67 |
68 | ## Style guide
69 |
70 | #### Commit message formatting
71 | We adopt the [Conventional Commits](https://www.conventionalcommits.org) convention to format commit messages.
72 |
73 |
74 | #### Documentation
75 | We're using [Pydocmd](https://github.com/NiklasRosenstein/pydoc-markdown)
76 | to automatically generate docs.
77 |
78 | Documentation should follow the [Google Documentation Style Guide](https://developers.google.com/style/api-reference-comments)
79 |
80 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
178 | APPENDIX: How to apply the Apache License to your work.
179 |
180 | To apply the Apache License to your work, attach the following
181 | boilerplate notice, with the fields enclosed by brackets "[]"
182 | replaced with your own identifying information. (Don't include
183 | the brackets!) The text should be enclosed in the appropriate
184 | comment syntax for the file format. We also recommend that a
185 | file or class name and description of purpose be included on the
186 | same "printed page" as the copyright notice for easier
187 | identification within third-party archives.
188 |
189 | Copyright [yyyy] [name of copyright owner]
190 |
191 | Licensed under the Apache License, Version 2.0 (the "License");
192 | you may not use this file except in compliance with the License.
193 | You may obtain a copy of the License at
194 |
195 | http://www.apache.org/licenses/LICENSE-2.0
196 |
197 | Unless required by applicable law or agreed to in writing, software
198 | distributed under the License is distributed on an "AS IS" BASIS,
199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 | See the License for the specific language governing permissions and
201 | limitations under the License.
202 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # PyceCREAM
2 |
3 | Here is a python implementation of my accretion disc and emission line lightcurve-fitting code (previously CREAM). This guide briefly covers generating synthetic data and calling a new pycecream object to ingest and fit the accretion disc model (or emission line model) to a set of input light curves. I also demonstrate how to access the output of the pycecream fit. The output includes the fitted light curves, any new light curve data points after merging, fitted response functions and parameter MCMC chain histories for the disc and/or tophat response parameters.
4 |
5 |
6 | The following documentation details the use of pycecream for either ...
7 |
8 | 1) Continuum Reverberation Mapping: Fitting the AGN lamppost model to continuum light curves for continuum reverberation mapping.
9 |
10 | 2) Line Reverberation Mapping: Fitting a tophat lag function to line light curves for line reverberation mapping
11 |
12 | 3) [Multi-telescope lightcurve merging](https://github.com/dstarkey23/pycecream/blob/master/README_dream.md): Another application of this code merges light curves taken from multiple telescopes, models the calibration differences between these light curves and produces a single combined light curve. This implementation is known as DREAM. Please see [here](https://github.com/dstarkey23/pycecream/blob/master/README_dream.md) for DREAM merging instructions.
13 |
14 |
15 |
16 | Most of these features are used in some form or another from a previous f90 version of this code (CREAM) in the following literature
17 |
18 | * Grier et al in prep
19 | * Grier et al 2018 https://iopscience.iop.org/article/10.3847/1538-4357/aa98dc/pdf
20 | * Starkey et al 2017 https://ui.adsabs.harvard.edu/#abs/arXiv:1611.06051
21 | * Starkey et al 2016 https://ui.adsabs.harvard.edu/#abs/arXiv:1511.06162
22 |
23 | Please send questions to ds207@st-andrews.ac.uk.
24 |
25 | #### Docs available [here](https://dstarkey23.github.io/pycecream/)
26 |
27 |
28 | ## Requirements & Installation
29 |
30 | #### Install Fortran compiler (see macports / wget)
31 | I use Gfortran. If you have an alternate (e.g ifort),
32 | please indicate the standard command used to call
33 | the fortran compiler using the ```fortran_caller``` argument
34 | (default ```fortran_caller = gfortran```).
35 |
36 | #### Install Pycecream
37 | ```
38 | pip install pycecream
39 | ```
40 |
41 |
42 | ## Section 1 (Optional): Generate test synthetic light curves
43 |
44 | In this example we generate 4 disk light curves and 2 emission-line light curves modelled as a top-hat with a 20-day lag. The code below generates a list where each index contains an Nx3 numpy array for each light curve. The 3 vertical axis for each light curve are the time, flux and noise respectively (query synthetic_data['echo lightcurves'][0] for an example of the format required when inputting your own light curve data).
45 |
46 | The example below combines continuum and line light curves and illustrates a case in which you may have two of the same emission line (and so want to fit with the same response function model) but observed from different telescopes that require seperate noise models.
47 |
48 |
49 | ```python
50 | import astropy_stark.myfake as mf
51 | import matplotlib.pylab as plt
52 |
53 | '''
54 | mf.myfake arguments are
55 |
56 | wavelengths: enter the wavelengths (-1 indicates an emission line light curve modelled with a top-hat response),
57 |
58 | snr: set the signal-to-noise relative to light curve rms
59 |
60 | cadence:set the mean cadence
61 |
62 | top hat centroid: set the centroid for the top-hat (I think thats what this does but the line lag
63 | thing is still newish so Im used to just making continuum light curve)
64 | '''
65 |
66 |
67 | synthetic_data = mf.myfake(
68 | [4000.0,5000.0,5000.0,7000.0,-1.0,-1.0],
69 | [50.0,50.0,10.0,50.0,50,10.],
70 | [1.0,1.0,2.0,1.0,1.0,3.0],
71 | thcent = 20.0
72 | )
73 |
74 | '''This recovers the synthetic data'''
75 | dat = synthetic_data['echo light curves']
76 | ```
77 |
78 | ## Section 2: Set-up and run PyceCREAM
79 |
80 |
81 |
82 |
83 | ```python
84 | import pycecream
85 |
86 | #instantiate a pycecream object
87 | a = pycecream.pycecream()
88 |
89 | '''
90 | If you use a fortran compiler other than gfortran please indicate here.
91 | I just re-enter gfortran here for demonstration purposes even though
92 | this is unecassary as gfortran is the default argument.
93 | '''
94 | a.fortran_caller = 'gfortran'
95 |
96 |
97 |
98 | '''Choose an output directory in which to save the results.
99 | This will be a new directory that you have not previously created (pycecream will make it automatically).
100 |
101 | NOTE: Each new cream simulation must have a new name for "output_directory argument below
102 | otherwise an excpetion is raised. This is to prevent accidentally overwriting previous simulations.
103 | I might change this in a future version
104 | '''
105 | a.project_folder = 'fit_synthetic_lightcurves'
106 |
107 |
108 |
109 | '''
110 | Add the light curves to be modeled. Inputs should be a 3 column numpy
111 | array of `time`, `flux`, `error`.
112 | In this case we are using the "dat" output
113 | from the synthetic data above.
114 | '''
115 | a.add_lc(dat[0], name = 'continuum 4000')
116 | a.add_lc(dat[1], name = 'continuum 5000')
117 | a.add_lc(dat[2], name = 'continuum 5000 (b)')
118 | a.add_lc(dat[3], name = 'continuum 7000')
119 |
120 | #If adding a line light curve, must indicate using the "kind" argument
121 | a.add_lc(dat[4],name='test line 1',kind='line')
122 |
123 | #If we want the same line response function model, set "share_previous_lag"=True
124 | a.add_lc(dat[5],name='test line 1 (shared)',kind='line',share_previous_lag=True)
125 |
126 |
127 |
128 | '''
129 | specify the numnber of MCMC iterations. Normally at least several thousand are necessary but shorter numbers
130 | can be used just to check everything is working is done here.
131 | '''
132 | a.N_iterations=40
133 |
134 | '''
135 | specify the step sizes for the fit parameters.
136 | Here we are setting the accretion rate step size to vary by ~ 0.1 solar masses per year.
137 | '''
138 | a.p_accretion_rate_step = 0.1
139 |
140 | '''
141 | Check the input settings are ok prior to running
142 | '''
143 | print(a.lightcurve_input_params)
144 |
145 | '''
146 | RUN! specify ncores (default = 1) to parallelise with 1 chain per core
147 | '''
148 | a.run(ncores = 4)
149 | ```
150 |
151 | ## Section 3: Outputs
152 |
153 | The main outputs are stored in two dataframes.
154 |
155 | ### 1) output_lightcurves = a.get_light_curve_fits():
156 | This a dictionary of 3 data frames.
157 |
158 | 1.1) output_lightcurves['model']: standard time, model, error envelope for each file
159 |
160 | 1.2) output_lightcurves['merged model'] AS above but with the error bars, vertical and horrizontal scalings applied relative to the reference model. Not sure but I think the reference model defaults to the first occurence of a particular wavelength in the order that it was added in self.add_lc
161 |
162 | 1.3) output_lightcurves['merged data'] DICTIONARY (since the input data light curves can be different sizes) The same transformations but applied to the input light curve data. useful if using cream only to merge the orriginal light curves from different telescopes to a new scale for further study elsewhere
163 |
164 | ### 2) output_chains = a.get_MCMC_chains():
165 | These are the MCMC chains for each parameter.
166 |
167 |
168 |
169 | ```python
170 | '''
171 | Get the mcmc chains and output fits.
172 | Each of these arguments come with a "location" argument where you can point to a
173 | previous simulation and recover the outputs.
174 | If this is left blank we default to the current simulation
175 | '''
176 | output_chains = a.get_MCMC_chains(location = None)
177 | output_lightcurves = a.get_light_curve_fits(location = None)
178 |
179 |
180 | '''
181 | NEW: 11/12/2019 Now the fourier chains are available as a pandas
182 | dataframe.
183 | Stats on the sine and cosine parameters are also available for each
184 | freuqency accessible in the `fourier_stats` dictionary element of this
185 | `get_MCMC_fourier_chains` function.
186 | '''
187 | output_fourier_chains = a.get_MCMC_fourier_chains(location=None)
188 | fourier_chains = output_fourier_chains['fourier_chains']
189 | fourier_stats = output_fourier_chains['fourier_stats']
190 |
191 |
192 | '''
193 | make figures of the fit, posterior, light curves etc. file prefix tells the code where you want to save the output.
194 | The figure plotting is somewhat primitive and is a relic of when I still used cream. You may prefer to use your own
195 | output figures with the output of the "get_MCMC_chains" and "get_light_curve_fits" functions above.
196 | '''
197 | a.plot_results(file_prefix='fit_figures')
198 |
199 |
200 |
201 |
202 | '''
203 | figures can also be made on an indivdual basis with axes objects returned from python plotting functions
204 | '''
205 | #plot the fitted light curves.
206 | a.plot_lightcurves()
207 | plt.show()
208 |
209 |
210 | #plot the driving light curve
211 | a.plot_driver()
212 | plt.show()
213 |
214 |
215 | #plot the parameter trace plots
216 | a.plot_trace()
217 | plt.show()
218 |
219 |
220 | #plot the covariance parameter plot for the disc parameters
221 | a.plot_posterior()
222 | plt.show()
223 |
224 |
225 | ```
226 |
227 |
228 |
229 |
--------------------------------------------------------------------------------
/README_dream.md:
--------------------------------------------------------------------------------
1 | # PyceCREAM - DREAM
2 |
3 |
4 | Reverberation Mapping requires telescope images to be converted to light curves. These images are often taken
5 | from multiple telescopes over several months with unique calibration anomalies between the telescopes.
6 | These calibration anomalies are often visible in the final combined light curve.
7 |
8 | ##Example Figure showing lighcurves with calibration problem
9 |
10 | Often the individual light curves are rescaled to a reference mean and standard deviation
11 | prior to merging.
12 |
13 | Here Pycecream is used to combine light curves in a more sophisticated way by rescaling each light curve
14 | to pycecreams random walk model fit. In addition to correcting the calibration fluxes,
15 | dream also modifies the input error bars with a multiplicative (f) and additive (V) parameter.
16 |
17 |
18 | \sigma^{2} = \left ( f \sigma_0 \right )^{2} + V
19 |
20 |
21 | ## Installation (requires Python 3)
22 |
23 | `pip install pycecream`
24 |
25 |
26 | ## g-band merging example
27 |
28 | The example below shows how to use dream to merge example g-band light curves
29 | from 5 telescopes and access the merged output.
30 |
31 | ```python
32 | import pycecream as pc
33 | import pickle
34 |
35 | #initialise dream instance
36 | dream = pc.dream(Niterations = 200)
37 |
38 | #add each light curve ('dat' should be a N x 3 array of time, flux, errorbar)
39 | #errorbar_variance, errorbar_rescale should be True to optimise the 'f' and 'V' error bar parameters
40 | dream.add_lc(dat1, 'g-band 1', errorbar_variance=True, errorbar_rescale=True)
41 | dream.add_lc(dat2, 'g-band 2', errorbar_variance=True, errorbar_rescale=True)
42 | dream.add_lc(dat3, 'g-band 3', errorbar_variance=True, errorbar_rescale=True)
43 | dream.add_lc(dat4, 'g-band 4', errorbar_variance=True, errorbar_rescale=True)
44 | dream.add_lc(dat5, 'g-band 5', errorbar_variance=True, errorbar_rescale=True)
45 |
46 |
47 |
48 | #run the simulation
49 | dream.run()
50 |
51 |
52 | #access the input lightcurves
53 | input = dream.lcinput
54 |
55 | #access the combined merged light curve
56 | merged_combined = dream.lc_combined
57 |
58 | #access the individual (but rescaled light curves)
59 | merged_individual = dream.lc_merged_individual
60 |
61 |
62 |
63 | #OPTIONAL: Save the output for later
64 | os.system('rm ' + picklefile)
65 | pickle_out = open(picklefile, "wb")
66 | pickle.dump(dream, pickle_out)
67 | pickle_out.close()
68 |
69 | ```
70 |
71 |
72 |
--------------------------------------------------------------------------------
/build/lib/pycecream/creaminpar.par:
--------------------------------------------------------------------------------
1 | ./hermine_lc
2 | !!! path to main folder (dirpath) folder string subfolders of agn with the light curves !! set to ./fake/ to generate fake data
3 | F F !!! save the BOF and pspec plots as separate files and save big parameter file (takes lots of space)
4 | !!! save plot frequency (if -ve, display plots to screen and backs up every -value iterations)
5 | 20
6 | 4 !! how many backups to keep
7 |
8 | -0.01,-0.007,0.0 !!! (flo,df,start0) (0.02, -0.007, 1.0 pre 14/apr/16 values) Enter lowest and frequency spacing in cycles/day (if -ve, code decides for df uses flo by default), start0 = 1 if you want fourier amplitudes to start at 0
9 | -20 !!!(NW) number of Fourier frequencies (if -ve program choses), (if 1 start fourier amplitudes at 0 else code guesses)
10 | 0.5 !!! (whi) Enter highest frequency in cycles/day (if NW -ve above then this determines NW. If both -ve, program chooses)
11 | 100 !!! (nits) Default number of iterations (nits) (code cuts off when converged)
12 | 2 !!! (AT) NUmber of acceptances before doubling stepsizes
13 | 5 !!! (RT) Number of rejections before halving step sizes
14 | -10.0 50.0 !!! (min and maxtau) lag limits
15 | 0.2 !!! (dtaugrid) if -ve, automatically determined, but may want to control manually if having resolution problems
16 |
17 | !!!!!!! Fourier scaling
18 | 0.00001 !! starting fourier scaling (default0.001) if -ve, code uses power law slope to scale terms
19 |
20 | !!!!!!! Error bar expansion
21 | F !! sigexpand (Set true to allow error bars to expand)
22 | 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 !! Default expansion factor sigexpandparm (NLC +1 f xray data)
23 | 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 !! default logarithmic stepsize in error bar expansion (sigexpandsteplog)
24 |
25 | !!!!!!! Delay parameters
26 | 0.1 !!! black hole efficiency (eta)
27 | 0.0 !!! disk albedo (alb)
28 | 0.0 !!! height profile constant of proportionality (konst)
29 | 0.0 !!! power index f height proportionality (alpha)
30 | 3.0 !!! innner radius (rs)
31 | 1.0 !!! lamppost height (rs)
32 | 1.0 !!! black hole accretion rate (umdot)
33 | 1.12e8 !!! black hole mmdot (umbh)
34 | -6.0 -0.1 !!! prior on mmdot (mean and sd of gaussian (in log 10 units, set sd -ve to exclude prior)
35 | 0.01 !!! black hole mdot scaling [log10scaling]
36 |
37 | !! Inclination parameters
38 | 0.0 !!! starting inclination (degrees) 60 degrees
39 | 0.0 !!! scaling cos(theta)
40 | -50.0 20.0 !!! Enter deginc0 and a for inclination prior - takes form (1 / (1+(cosinc/cosinc0)^a)) set deginc0 -ve to exclude
41 |
42 | !!!!!!! PSPEC PRIOR PARMS
43 | F !! implement break in power spectrum (T or F)
44 | -0.001 !!! (p0mean) mean value of p0
45 | 0.0 !!!was -1before 26/10/2014 (siglogp0) uncertainty in logp0 (for prior prior is not yet logarithmic make sigp0=p0mean*siglogp0) (14th may set to 0.001)
46 | 0.00 !!! (p0steplog) logarithmic stepsize of p0
47 | 0.1 !!! (meanf0) mean value of f0 (cycles / day)
48 | 0.0000000 !!! (siglogw0) uncertainty in log w0 ( for prior set -ve to not include prior)
49 | 0.00 !!! (w0steplog) logarithmic step size of w0
50 | 2.0 !!! (meanalpha) mean (-ve) value of alpha (meanalpha)
51 | 0.0 !!! (sigalpha) uncertainty in alpha (sigalph) for the prior (set -ve to not include prior)
52 | 0.0 !!! (alphascale) scaling of alpha parameter
53 | 2.0 !!! (meanbeta) mean (-ve) value of beta (meanbeta)
54 | 0.0 !!! (sigbeta) uncertainty in beta (sigbeta) for the prior (set -ve to not include prior)
55 | 0.0 !!! (betascale) scaling of beta parameter
56 |
57 | !!!!!!! Stretch and offset parms (starting values inside code just the sclaings here)
58 | 0.0 !!! (stretchscale)
59 | 10.0 10.0 10.0 10.0 10.0 10.0 10.0 10.0 10.0 10.0 10.0 10.0 10.0 10.0 10.0 10.0 10.0 10.0 10.0 10.0 10.0 10.0 10.0 10.0 10.0 10.0 10.0 10.0 10.0 10.0 10.0 10.0 !!! (gal flux real array containing the steady state host component
60 | 0.1 !!! (galscale) !! log10
61 |
62 | !!!!!! luminosity distance and scaling (version 2 only)
63 | 0.0, 0.3, 0.7 !!! redshift of target, omega_m, omega_l
64 | 500.0 !!! Luminosity distance (MPC)
65 | 0.01 !!! dlscale (in log10 units)
66 | 0.0168 !!! MW extinction parameter in ra and dec of target
67 | 1.0 !!! Default AGN extinction parameter E(B-V)
68 | 1.0 !!! default logarithmic stepping ebmvagnsteplog
69 |
70 | !!!!!! temperature radius parms, scaling (log10) (version 3 only)
71 | 0.75 !!!!! viscous tr parameter (P(NPtridx))
72 | 0.75 !!!!! irradiation tr parameter
73 | 0.0 !!!!! logarithmic scaling of tv
74 | 0.0 !!!!! logarithmic scaling of ta parms
75 | -5.0 !!!!! UR0 (rs) if negative then in light days
76 | 0.1 !!!!! logarithmic scaling of ur0
77 | 0.1 !!!!! offset scale (mjy)
78 |
79 | F !!!!! Skip convolve (Only set this to Y if you are running a test to fit just a driving light curve (for estimating power spectrum properties) then not interested in convolution or echo lightcurves)
80 |
--------------------------------------------------------------------------------
/dist/pycecream-1.5.5.tar.gz:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/drds1/pycecream/1716da359b611ad37f1f645f247e15d59796fb56/dist/pycecream-1.5.5.tar.gz
--------------------------------------------------------------------------------
/docs/_build/pydocmd/index.md:
--------------------------------------------------------------------------------
1 | # PyceCREAM
2 |
3 | Here is a python implementation of my accretion disc and emission line lightcurve-fitting code (previously CREAM). This guide briefly covers generating synthetic data and calling a new pycecream object to ingest and fit the accretion disc model (or emission line model) to a set of input light curves. I also demonstrate how to access the output of the pycecream fit. The output includes the fitted light curves, any new light curve data points after merging, fitted response functions and parameter MCMC chain histories for the disc and/or tophat response parameters.
4 |
5 | Most of these features are used in some form or another from a previous f90 version of this code (CREAM) in the following literature
6 |
7 | * Grier et al in prep
8 | * Grier et al 2018 https://iopscience.iop.org/article/10.3847/1538-4357/aa98dc/pdf
9 | * Starkey et al 2017 https://ui.adsabs.harvard.edu/#abs/arXiv:1611.06051
10 | * Starkey et al 2016 https://ui.adsabs.harvard.edu/#abs/arXiv:1511.06162
11 |
12 | Please send questions to ds207@st-andrews.ac.uk.
13 |
14 | #### Docs available [here](https://dstarkey23.github.io/pycecream/)
15 |
16 |
17 | ## Requirements & Installation
18 |
19 | #### Install Fortran compiler (see macports / wget)
20 | I use Gfortran. If you have an alternate (e.g ifort),
21 | please indicate the standard command used to call
22 | the fortran compiler using the ```fortran_caller``` argument
23 | (default ```fortran_caller = gfortran```).
24 |
25 | #### Install Pycecream
26 | ```
27 | pip install pycecream
28 | ```
29 |
30 |
31 | ## Section 1 (Optional): Generate test synthetic light curves
32 |
33 | In this example we generate 4 disk light curves and 2 emission-line light curves modelled as a top-hat with a 20-day lag. The code below generates a list where each index contains an Nx3 numpy array for each light curve. The 3 vertical axis for each light curve are the time, flux and noise respectively (query synthetic_data['echo lightcurves'][0] for an example of the format required when inputting your own light curve data).
34 |
35 | The example below combines continuum and line light curves and illustrates a case in which you may have two of the same emission line (and so want to fit with the same response function model) but observed from different telescopes that require seperate noise models.
36 |
37 |
38 | ```python
39 | import astropy_stark.myfake as mf
40 | import matplotlib.pylab as plt
41 |
42 | '''
43 | mf.myfake arguments are
44 |
45 | wavelengths: enter the wavelengths (-1 indicates an emission line light curve modelled with a top-hat response),
46 |
47 | snr: set the signal-to-noise relative to light curve rms
48 |
49 | cadence:set the mean cadence
50 |
51 | top hat centroid: set the centroid for the top-hat (I think thats what this does but the line lag
52 | thing is still newish so Im used to just making continuum light curve)
53 | '''
54 |
55 |
56 | synthetic_data = mf.myfake(
57 | [4000.0,5000.0,5000.0,7000.0,-1.0,-1.0],
58 | [50.0,50.0,10.0,50.0,50,10.],
59 | [1.0,1.0,2.0,1.0,1.0,3.0],
60 | thcent = 20.0
61 | )
62 |
63 | '''This recovers the synthetic data'''
64 | dat = synthetic_data['echo light curves']
65 | ```
66 |
67 | ## Section 2: Set-up and run PyceCREAM
68 |
69 |
70 |
71 |
72 | ```python
73 | import pycecream
74 |
75 | #instantiate a pycecream object
76 | a = pycecream.pycecream()
77 |
78 | '''
79 | If you use a fortran compiler other than gfortran please indicate here.
80 | I just re-enter gfortran here for demonstration purposes even though
81 | this is unecassary as gfortran is the default argument.
82 | '''
83 | a.fortran_caller = 'gfortran'
84 |
85 |
86 |
87 | '''Choose an output directory in which to save the results.
88 | This will be a new directory that you have not previously created (pycecream will make it automatically).
89 |
90 | NOTE: Each new cream simulation must have a new name for "output_directory argument below
91 | otherwise an excpetion is raised. This is to prevent accidentally overwriting previous simulations.
92 | I might change this in a future version
93 | '''
94 | a.project_folder = 'fit_synthetic_lightcurves'
95 |
96 |
97 |
98 | '''
99 | Add the light curves to be modeled. Inputs should be a 3 column numpy
100 | array of `time`, `flux`, `error`.
101 | In this case we are using the "dat" output
102 | from the synthetic data above.
103 | '''
104 | a.add_lc(dat[0], name = 'continuum 4000')
105 | a.add_lc(dat[1], name = 'continuum 5000')
106 | a.add_lc(dat[2], name = 'continuum 5000 (b)')
107 | a.add_lc(dat[3], name = 'continuum 7000')
108 |
109 | #If adding a line light curve, must indicate using the "kind" argument
110 | a.add_lc(dat[4],name='test line 1',kind='line')
111 |
112 | #If we want the same line response function model, set "share_previous_lag"=True
113 | a.add_lc(dat[5],name='test line 1 (shared)',kind='line',share_previous_lag=True)
114 |
115 |
116 |
117 | '''
118 | specify the numnber of MCMC iterations. Normally at least several thousand are necessary but shorter numbers
119 | can be used just to check everything is working is done here.
120 | '''
121 | a.N_iterations=40
122 |
123 | '''
124 | specify the step sizes for the fit parameters.
125 | Here we are setting the accretion rate step size to vary by ~ 0.1 solar masses per year.
126 | '''
127 | a.p_accretion_rate_step = 0.1
128 |
129 | '''
130 | Check the input settings are ok prior to running
131 | '''
132 | print(a.lightcurve_input_params)
133 |
134 | '''
135 | RUN! specify ncores (default = 1) to parallelise with 1 chain per core
136 | '''
137 | a.run(ncores = 4)
138 | ```
139 |
140 | ## Section 3: Outputs
141 |
142 | The main outputs are stored in two dataframes.
143 |
144 | ### 1) output_lightcurves = a.get_light_curve_fits():
145 | This a dictionary of 3 data frames.
146 |
147 | 1.1) output_lightcurves['model']: standard time, model, error envelope for each file
148 |
149 | 1.2) output_lightcurves['merged model'] AS above but with the error bars, vertical and horrizontal scalings applied relative to the reference model. Not sure but I think the reference model defaults to the first occurence of a particular wavelength in the order that it was added in self.add_lc
150 |
151 | 1.3) output_lightcurves['merged data'] DICTIONARY (since the input data light curves can be different sizes) The same transformations but applied to the input light curve data. useful if using cream only to merge the orriginal light curves from different telescopes to a new scale for further study elsewhere
152 |
153 | ### 2) output_chains = a.get_MCMC_chains():
154 | These are the MCMC chains for each parameter.
155 |
156 |
157 |
158 | ```python
159 | '''
160 | Get the mcmc chains and output fits.
161 | Each of these arguments come with a "location" argument where you can point to a
162 | previous simulation and recover the outputs.
163 | If this is left blank we default to the current simulation
164 | '''
165 | output_chains = a.get_MCMC_chains(location = None)
166 | output_lightcurves = a.get_light_curve_fits(location = None)
167 |
168 |
169 | '''
170 | NEW: 11/12/2019 Now the fourier chains are available as a pandas
171 | dataframe.
172 | Stats on the sine and cosine parameters are also available for each
173 | freuqency accessible in the `fourier_stats` dictionary element of this
174 | `get_MCMC_fourier_chains` function.
175 | '''
176 | output_fourier_chains = a.get_MCMC_fourier_chains(location=None)
177 | fourier_chains = output_fourier_chains['fourier_chains']
178 | fourier_stats = output_fourier_chains['fourier_stats']
179 |
180 |
181 | '''
182 | make figures of the fit, posterior, light curves etc. file prefix tells the code where you want to save the output.
183 | The figure plotting is somewhat primitive and is a relic of when I still used cream. You may prefer to use your own
184 | output figures with the output of the "get_MCMC_chains" and "get_light_curve_fits" functions above.
185 | '''
186 | a.plot_results(file_prefix='fit_figures')
187 |
188 |
189 |
190 |
191 | '''
192 | figures can also be made on an indivdual basis with axes objects returned from python plotting functions
193 | '''
194 | #plot the fitted light curves.
195 | a.plot_lightcurves()
196 | plt.show()
197 |
198 |
199 | #plot the driving light curve
200 | a.plot_driver()
201 | plt.show()
202 |
203 |
204 | #plot the parameter trace plots
205 | a.plot_trace()
206 | plt.show()
207 |
208 |
209 | #plot the covariance parameter plot for the disc parameters
210 | a.plot_posterior()
211 | plt.show()
212 |
213 |
214 | ```
215 |
216 |
217 |
218 |
--------------------------------------------------------------------------------
/docs/_build/pydocmd/pycecream.md:
--------------------------------------------------------------------------------
1 |
Here is a python implementation of my accretion disc and emission line lightcurve-fitting code (previously CREAM). This guide briefly covers generating synthetic data and calling a new pycecream object to ingest and fit the accretion disc model (or emission line model) to a set of input light curves. I also demonstrate how to access the output of the pycecream fit. The output includes the fitted light curves, any new light curve data points after merging, fitted response functions and parameter MCMC chain histories for the disc and/or tophat response parameters.
119 |
Most of these features are used in some form or another from a previous f90 version of this code (CREAM) in the following literature
120 |
121 |
Grier et al in prep
122 |
Grier et al 2018 https://iopscience.iop.org/article/10.3847/1538-4357/aa98dc/pdf
123 |
Starkey et al 2017 https://ui.adsabs.harvard.edu/#abs/arXiv:1611.06051
124 |
Starkey et al 2016 https://ui.adsabs.harvard.edu/#abs/arXiv:1511.06162
I use Gfortran. If you have an alternate (e.g ifort),
131 | please indicate the standard command used to call
132 | the fortran compiler using the fortran_caller argument
133 | (default fortran_caller = gfortran).
134 |
Install Pycecream
135 |
pip install pycecream
136 |
137 |
138 |
Section 1 (Optional): Generate test synthetic light curves
139 |
In this example we generate 4 disk light curves and 2 emission-line light curves modelled as a top-hat with a 20-day lag. The code below generates a list where each index contains an Nx3 numpy array for each light curve. The 3 vertical axis for each light curve are the time, flux and noise respectively (query synthetic_data['echo lightcurves'][0] for an example of the format required when inputting your own light curve data).
140 |
The example below combines continuum and line light curves and illustrates a case in which you may have two of the same emission line (and so want to fit with the same response function model) but observed from different telescopes that require seperate noise models.
141 |
import astropy_stark.myfake as mf
142 | import matplotlib.pylab as plt
143 |
144 | '''
145 | mf.myfake arguments are
146 |
147 | wavelengths: enter the wavelengths (-1 indicates an emission line light curve modelled with a top-hat response),
148 |
149 | snr: set the signal-to-noise relative to light curve rms
150 |
151 | cadence:set the mean cadence
152 |
153 | top hat centroid: set the centroid for the top-hat (I think thats what this does but the line lag
154 | thing is still newish so Im used to just making continuum light curve)
155 | '''
156 |
157 |
158 | synthetic_data = mf.myfake(
159 | [4000.0,5000.0,5000.0,7000.0,-1.0,-1.0],
160 | [50.0,50.0,10.0,50.0,50,10.],
161 | [1.0,1.0,2.0,1.0,1.0,3.0],
162 | thcent = 20.0
163 | )
164 |
165 | '''This recovers the synthetic data'''
166 | dat = synthetic_data['echo light curves']
167 |
168 |
169 |
Section 2: Set-up and run PyceCREAM
170 |
import pycecream
171 |
172 | #instantiate a pycecream object
173 | a = pycecream.pycecream()
174 |
175 | '''
176 | If you use a fortran compiler other than gfortran please indicate here.
177 | I just re-enter gfortran here for demonstration purposes even though
178 | this is unecassary as gfortran is the default argument.
179 | '''
180 | a.fortran_caller = 'gfortran'
181 |
182 |
183 |
184 | '''Choose an output directory in which to save the results.
185 | This will be a new directory that you have not previously created (pycecream will make it automatically).
186 |
187 | NOTE: Each new cream simulation must have a new name for "output_directory argument below
188 | otherwise an excpetion is raised. This is to prevent accidentally overwriting previous simulations.
189 | I might change this in a future version
190 | '''
191 | a.project_folder = 'fit_synthetic_lightcurves'
192 |
193 |
194 |
195 | '''
196 | Add the light curves to be modeled. Inputs should be a 3 column numpy
197 | array of `time`, `flux`, `error`.
198 | In this case we are using the "dat" output
199 | from the synthetic data above.
200 | '''
201 | a.add_lc(dat[0], name = 'continuum 4000')
202 | a.add_lc(dat[1], name = 'continuum 5000')
203 | a.add_lc(dat[2], name = 'continuum 5000 (b)')
204 | a.add_lc(dat[3], name = 'continuum 7000')
205 |
206 | #If adding a line light curve, must indicate using the "kind" argument
207 | a.add_lc(dat[4],name='test line 1',kind='line')
208 |
209 | #If we want the same line response function model, set "share_previous_lag"=True
210 | a.add_lc(dat[5],name='test line 1 (shared)',kind='line',share_previous_lag=True)
211 |
212 |
213 |
214 | '''
215 | specify the numnber of MCMC iterations. Normally at least several thousand are necessary but shorter numbers
216 | can be used just to check everything is working is done here.
217 | '''
218 | a.N_iterations=40
219 |
220 | '''
221 | specify the step sizes for the fit parameters.
222 | Here we are setting the accretion rate step size to vary by ~ 0.1 solar masses per year.
223 | '''
224 | a.p_accretion_rate_step = 0.1
225 |
226 | '''
227 | Check the input settings are ok prior to running
228 | '''
229 | print(a.lightcurve_input_params)
230 |
231 | '''
232 | RUN! specify ncores (default = 1) to parallelise with 1 chain per core
233 | '''
234 | a.run(ncores = 4)
235 |
236 |
237 |
Section 3: Outputs
238 |
The main outputs are stored in two dataframes.
239 |
1) output_lightcurves = a.get_light_curve_fits():
240 |
This a dictionary of 3 data frames.
241 |
1.1) output_lightcurves['model']: standard time, model, error envelope for each file
242 |
243 | 1.2) output_lightcurves['merged model'] AS above but with the error bars, vertical and horrizontal scalings applied relative to the reference model. Not sure but I think the reference model defaults to the first occurence of a particular wavelength in the order that it was added in self.add_lc
244 |
245 | 1.3) output_lightcurves['merged data'] DICTIONARY (since the input data light curves can be different sizes) The same transformations but applied to the input light curve data. useful if using cream only to merge the orriginal light curves from different telescopes to a new scale for further study elsewhere
246 |
247 |
2) output_chains = a.get_MCMC_chains():
248 |
These are the MCMC chains for each parameter.
249 |
'''
250 | Get the mcmc chains and output fits.
251 | Each of these arguments come with a "location" argument where you can point to a
252 | previous simulation and recover the outputs.
253 | If this is left blank we default to the current simulation
254 | '''
255 | output_chains = a.get_MCMC_chains(location = None)
256 | output_lightcurves = a.get_light_curve_fits(location = None)
257 |
258 |
259 | '''
260 | NEW: 11/12/2019 Now the fourier chains are available as a pandas
261 | dataframe.
262 | Stats on the sine and cosine parameters are also available for each
263 | freuqency accessible in the `fourier_stats` dictionary element of this
264 | `get_MCMC_fourier_chains` function.
265 | '''
266 | output_fourier_chains = a.get_MCMC_fourier_chains(location=None)
267 | fourier_chains = output_fourier_chains['fourier_chains']
268 | fourier_stats = output_fourier_chains['fourier_stats']
269 |
270 |
271 | '''
272 | make figures of the fit, posterior, light curves etc. file prefix tells the code where you want to save the output.
273 | The figure plotting is somewhat primitive and is a relic of when I still used cream. You may prefer to use your own
274 | output figures with the output of the "get_MCMC_chains" and "get_light_curve_fits" functions above.
275 | '''
276 | a.plot_results(file_prefix='fit_figures')
277 |
278 |
279 |
280 |
281 | '''
282 | figures can also be made on an indivdual basis with axes objects returned from python plotting functions
283 | '''
284 | #plot the fitted light curves.
285 | a.plot_lightcurves()
286 | plt.show()
287 |
288 |
289 | #plot the driving light curve
290 | a.plot_driver()
291 | plt.show()
292 |
293 |
294 | #plot the parameter trace plots
295 | a.plot_trace()
296 | plt.show()
297 |
298 |
299 | #plot the covariance parameter plot for the disc parameters
300 | a.plot_posterior()
301 | plt.show()
302 |
303 |
304 |