mcarma 0.1.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- mcarma-0.1.2/CITATION.cff +42 -0
- mcarma-0.1.2/LICENSE +201 -0
- mcarma-0.1.2/MANIFEST.in +19 -0
- mcarma-0.1.2/PKG-INFO +188 -0
- mcarma-0.1.2/README.md +149 -0
- mcarma-0.1.2/examples/README.md +96 -0
- mcarma-0.1.2/examples/cross_band_coherence.py +113 -0
- mcarma-0.1.2/examples/data/1000679 +65 -0
- mcarma-0.1.2/examples/one_band_psd.py +95 -0
- mcarma-0.1.2/examples/sdss_stripe82_demo.py +128 -0
- mcarma-0.1.2/examples/stripe82.py +83 -0
- mcarma-0.1.2/mcarma/__init__.py +54 -0
- mcarma-0.1.2/mcarma/bootstrap.py +178 -0
- mcarma-0.1.2/mcarma/fit.py +2025 -0
- mcarma-0.1.2/mcarma/gic.py +150 -0
- mcarma-0.1.2/mcarma/inference.py +353 -0
- mcarma-0.1.2/mcarma/jax_loglik.py +494 -0
- mcarma-0.1.2/mcarma/jax_transitions.py +151 -0
- mcarma-0.1.2/mcarma/kalman.py +448 -0
- mcarma-0.1.2/mcarma/model_utils.py +468 -0
- mcarma-0.1.2/mcarma/observation.py +73 -0
- mcarma-0.1.2/mcarma/optimizer_utils.py +284 -0
- mcarma-0.1.2/mcarma/parameters.py +277 -0
- mcarma-0.1.2/mcarma/pipeline.py +84 -0
- mcarma-0.1.2/mcarma/preprocess.py +27 -0
- mcarma-0.1.2/mcarma/priors.py +53 -0
- mcarma-0.1.2/mcarma/reporting.py +108 -0
- mcarma-0.1.2/mcarma/rts.py +239 -0
- mcarma-0.1.2/mcarma/simulate.py +227 -0
- mcarma-0.1.2/mcarma/smoother.py +345 -0
- mcarma-0.1.2/mcarma/stage2.py +340 -0
- mcarma-0.1.2/mcarma/statespace.py +260 -0
- mcarma-0.1.2/mcarma.egg-info/PKG-INFO +188 -0
- mcarma-0.1.2/mcarma.egg-info/SOURCES.txt +47 -0
- mcarma-0.1.2/mcarma.egg-info/dependency_links.txt +1 -0
- mcarma-0.1.2/mcarma.egg-info/requires.txt +18 -0
- mcarma-0.1.2/mcarma.egg-info/top_level.txt +1 -0
- mcarma-0.1.2/pyproject.toml +67 -0
- mcarma-0.1.2/setup.cfg +4 -0
- mcarma-0.1.2/tests/test_core_invariants.py +129 -0
- mcarma-0.1.2/tests/test_corr_ridge.py +130 -0
- mcarma-0.1.2/tests/test_diag_load.py +128 -0
- mcarma-0.1.2/tests/test_gic.py +127 -0
- mcarma-0.1.2/tests/test_inference_dispatch.py +153 -0
- mcarma-0.1.2/tests/test_pipeline_fit_and_score.py +131 -0
- mcarma-0.1.2/tests/test_preconditioner.py +247 -0
- mcarma-0.1.2/tests/test_priors_golden.py +165 -0
- mcarma-0.1.2/tests/test_restart_tiers.py +120 -0
- mcarma-0.1.2/tests/test_rts_reconstruction.py +85 -0
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
cff-version: 1.2.0
|
|
2
|
+
message: "If you use this software, please cite both the software and the paper below."
|
|
3
|
+
title: "mcarma: multivariate continuous-time ARMA modeling of astronomical multi-band light curves"
|
|
4
|
+
version: "0.1.2"
|
|
5
|
+
license: Apache-2.0
|
|
6
|
+
type: software
|
|
7
|
+
authors:
|
|
8
|
+
- family-names: Schmidlkofer
|
|
9
|
+
given-names: Izak
|
|
10
|
+
affiliation: "Department of Statistics, Oregon State University"
|
|
11
|
+
email: schmidiz@oregonstate.edu
|
|
12
|
+
- family-names: Hu
|
|
13
|
+
given-names: Zhirui
|
|
14
|
+
affiliation: "Department of Statistics, Oregon State University"
|
|
15
|
+
- family-names: Shi
|
|
16
|
+
given-names: Lishan
|
|
17
|
+
affiliation: "Department of Statistics, Pennsylvania State University"
|
|
18
|
+
- family-names: Yu
|
|
19
|
+
given-names: Weixiang
|
|
20
|
+
affiliation: "The Research Institute of Basic Sciences, Pennsylvania State University"
|
|
21
|
+
- family-names: Tak
|
|
22
|
+
given-names: Hyungsuk
|
|
23
|
+
orcid: "https://orcid.org/0000-0003-0334-8742"
|
|
24
|
+
affiliation: "Department of Statistics, Pennsylvania State University"
|
|
25
|
+
email: tak@psu.edu
|
|
26
|
+
# TODO before submission: fill in journal, year, volume, pages and DOI once the
|
|
27
|
+
# companion papers are accepted, and add a software DOI (Zenodo) here.
|
|
28
|
+
preferred-citation:
|
|
29
|
+
type: article
|
|
30
|
+
title: "Multivariate continuous-time autoregressive moving average modeling of astronomical multi-band time series"
|
|
31
|
+
authors:
|
|
32
|
+
- family-names: Schmidlkofer
|
|
33
|
+
given-names: Izak
|
|
34
|
+
- family-names: Hu
|
|
35
|
+
given-names: Zhirui
|
|
36
|
+
- family-names: Shi
|
|
37
|
+
given-names: Lishan
|
|
38
|
+
- family-names: Yu
|
|
39
|
+
given-names: Weixiang
|
|
40
|
+
- family-names: Tak
|
|
41
|
+
given-names: Hyungsuk
|
|
42
|
+
year: 2026
|
mcarma-0.1.2/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
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 2026 The mcarma authors
|
|
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.
|
mcarma-0.1.2/MANIFEST.in
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
include LICENSE
|
|
2
|
+
include README.md
|
|
3
|
+
include CITATION.cff
|
|
4
|
+
|
|
5
|
+
# The demo light curve and its walkthrough. Without these the documented
|
|
6
|
+
# examples do not run from an installed copy, only from a repo checkout.
|
|
7
|
+
recursive-include examples *.py
|
|
8
|
+
include examples/README.md
|
|
9
|
+
include examples/data/*
|
|
10
|
+
|
|
11
|
+
# The research tree stays out of the distribution. Nothing above sweeps it in
|
|
12
|
+
# today, so these are here to keep a future include from doing it by accident.
|
|
13
|
+
prune docs
|
|
14
|
+
prune memo
|
|
15
|
+
prune fits
|
|
16
|
+
prune data
|
|
17
|
+
prune weixiang
|
|
18
|
+
prune .claude
|
|
19
|
+
prune .github
|
mcarma-0.1.2/PKG-INFO
ADDED
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: mcarma
|
|
3
|
+
Version: 0.1.2
|
|
4
|
+
Summary: Multivariate continuous-time ARMA modeling of irregularly sampled astronomical multi-band light curves
|
|
5
|
+
Author: Izak Schmidlkofer, Zhirui Hu, Lishan Shi, Weixiang Yu, Hyungsuk Tak
|
|
6
|
+
Maintainer-email: Izak Schmidlkofer <schmidiz@oregonstate.edu>
|
|
7
|
+
License-Expression: Apache-2.0
|
|
8
|
+
Project-URL: Homepage, https://github.com/ischmidls/mcarma
|
|
9
|
+
Project-URL: Repository, https://github.com/ischmidls/mcarma
|
|
10
|
+
Project-URL: Issues, https://github.com/ischmidls/mcarma/issues
|
|
11
|
+
Keywords: time series,state space,Kalman filter,CARMA,astronomy,quasars
|
|
12
|
+
Classifier: Development Status :: 4 - Beta
|
|
13
|
+
Classifier: Intended Audience :: Science/Research
|
|
14
|
+
Classifier: Operating System :: OS Independent
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Topic :: Scientific/Engineering :: Astronomy
|
|
20
|
+
Classifier: Topic :: Scientific/Engineering :: Physics
|
|
21
|
+
Requires-Python: >=3.10
|
|
22
|
+
Description-Content-Type: text/markdown
|
|
23
|
+
License-File: LICENSE
|
|
24
|
+
Requires-Dist: numpy>=1.24
|
|
25
|
+
Requires-Dist: scipy>=1.10
|
|
26
|
+
Requires-Dist: jax>=0.4
|
|
27
|
+
Provides-Extra: plots
|
|
28
|
+
Requires-Dist: matplotlib>=3.7; extra == "plots"
|
|
29
|
+
Provides-Extra: numdiff
|
|
30
|
+
Requires-Dist: numdifftools>=0.9; extra == "numdiff"
|
|
31
|
+
Provides-Extra: analysis
|
|
32
|
+
Requires-Dist: pandas>=2.0; extra == "analysis"
|
|
33
|
+
Requires-Dist: statsmodels>=0.14; extra == "analysis"
|
|
34
|
+
Provides-Extra: dev
|
|
35
|
+
Requires-Dist: pytest>=7; extra == "dev"
|
|
36
|
+
Requires-Dist: build>=1.0; extra == "dev"
|
|
37
|
+
Requires-Dist: twine>=5.0; extra == "dev"
|
|
38
|
+
Dynamic: license-file
|
|
39
|
+
|
|
40
|
+
# mcarma
|
|
41
|
+
|
|
42
|
+
Fit multivariate continuous-time autoregressive moving average (MCARMA) models
|
|
43
|
+
jointly to irregularly sampled multi-band astronomical time series.
|
|
44
|
+
|
|
45
|
+
The package extends multivariate damped random walk modeling to higher-order
|
|
46
|
+
stochastic dynamics. Each band can have its own temporal dynamics, while
|
|
47
|
+
dependence across bands is modeled through correlated stochastic drivers. The
|
|
48
|
+
resulting matrix-valued power spectral density characterizes both marginal
|
|
49
|
+
variability within individual bands and dependence across bands.
|
|
50
|
+
|
|
51
|
+
mcarma supports irregular sampling, heteroscedastic measurement errors, and
|
|
52
|
+
partially observed bands, and fits the joint model using penalized maximum
|
|
53
|
+
likelihood and state-space computation.
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
pip install mcarma
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
Not on PyPI until the papers are submitted; until then install from a
|
|
60
|
+
checkout (see Development at the bottom).
|
|
61
|
+
|
|
62
|
+
## Fit one multi-band object
|
|
63
|
+
|
|
64
|
+
```python
|
|
65
|
+
import numpy as np
|
|
66
|
+
from mcarma import ObservationData, fit, compute_aicc, mcarma_psd
|
|
67
|
+
|
|
68
|
+
# One scalar measurement per row: time, magnitude, which band, and the
|
|
69
|
+
# measurement variance. Bands need not be observed together.
|
|
70
|
+
data = ObservationData(t_obs=t, y_obs=y, band=band, R=err**2, d=5)
|
|
71
|
+
|
|
72
|
+
res = fit(data, p=2, q=1, n_restarts=4, use_jax_grad=True)
|
|
73
|
+
|
|
74
|
+
k = 5 * 2 + 5 * 1 + 5 * 6 // 2 + 5 # AR + MA + chol(Sigma) + mu
|
|
75
|
+
aicc = compute_aicc(res["loglik_pure"], k, data.n)
|
|
76
|
+
|
|
77
|
+
freqs = np.logspace(-3.5, -0.7, 400) # cycles per day
|
|
78
|
+
psd = mcarma_psd(res["F"], res["G"], res["H"], res["Sigma"], freqs)
|
|
79
|
+
psd[:, 2, 2] # the r band's own spectrum
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
Each band is centered internally, so pass raw magnitudes. `res["theta"]` is the
|
|
83
|
+
fitted parameter vector, `res["loglik"]` the penalized value and
|
|
84
|
+
`res["loglik_pure"]` the plain one, which is what AICc must be scored on.
|
|
85
|
+
`res["hess_inv"]` carries the inverse Hessian when the optimizer produced one.
|
|
86
|
+
|
|
87
|
+
## Examples
|
|
88
|
+
|
|
89
|
+
Three runnable examples are included using an SDSS Stripe 82 quasar light curve
|
|
90
|
+
distributed with the package. The examples require no external data downloads
|
|
91
|
+
and can be run on a standard computer.
|
|
92
|
+
|
|
93
|
+
| script | what it does | roughly how long |
|
|
94
|
+
| --- | --- | --- |
|
|
95
|
+
| `one_band_psd.py` | fits one filter, prints the variability timescale and the spectrum around its break | 10 seconds |
|
|
96
|
+
| `cross_band_coherence.py` | jointly fits all five filters and estimates cross-band coherence and marginal PSDs | 1 minute |
|
|
97
|
+
| `sdss_stripe82_demo.py` | the full walkthrough: the (1,0)/(2,0)/(2,1) order ladder, AICc selection, light curve and PSD figure | several minutes |
|
|
98
|
+
|
|
99
|
+
```bash
|
|
100
|
+
pip install mcarma[plots]
|
|
101
|
+
|
|
102
|
+
python examples/one_band_psd.py # r band, prints only
|
|
103
|
+
python examples/one_band_psd.py --band g
|
|
104
|
+
python examples/cross_band_coherence.py # writes cross_band_coherence.png
|
|
105
|
+
python examples/sdss_stripe82_demo.py --quick # (1,0) only
|
|
106
|
+
python examples/sdss_stripe82_demo.py # the whole ladder
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
`one_band_psd.py` prints its results and needs no plotting library. The other
|
|
110
|
+
two write a PNG, so they need matplotlib, which is the `plots` extra above.
|
|
111
|
+
Every script takes `--obj PATH` to point at a different Stripe 82 file, and the
|
|
112
|
+
examples directory carries a longer walkthrough of what each one shows.
|
|
113
|
+
|
|
114
|
+
## Model
|
|
115
|
+
|
|
116
|
+
mcarma represents a $d$-band astronomical time series as a joint
|
|
117
|
+
continuous-time stochastic process. Band-specific ARMA dynamics determine the
|
|
118
|
+
marginal temporal behavior, while correlated Wiener drivers introduce
|
|
119
|
+
dependence across bands.
|
|
120
|
+
|
|
121
|
+
$$dZ(t)=F Z(t)dt + G\,dB(t),\ \mathrm{Cov}(dB)=\Sigma dt;\quad
|
|
122
|
+
Y_k = C_k(\mu + H Z_k) + \varepsilon_k,\ \varepsilon_k\sim N(0,R_k).$$
|
|
123
|
+
|
|
124
|
+
$F$ is built from AR Jones factors, $H$ from MA Jones factors. Under the
|
|
125
|
+
structured MCARMA formulation implemented here, cross-band dependence is
|
|
126
|
+
introduced through the covariance matrix $\Sigma$ of the Wiener drivers.
|
|
127
|
+
|
|
128
|
+
Parameter vector:
|
|
129
|
+
|
|
130
|
+
```
|
|
131
|
+
theta = [ AR | MA | chol(Sigma) | mu ], dim = d*p + d*q + d(d+1)/2 + d
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
AR/MA factor coefficients are stored in log space (positive roots). An MA linear
|
|
135
|
+
factor `b` places a zero at frequency `1/b`, so to put a zero in the observable
|
|
136
|
+
band you set `b = 1/omega_z`. That convention matters.
|
|
137
|
+
|
|
138
|
+
The likelihood is the Kalman prediction-error decomposition
|
|
139
|
+
(`mcarma/kalman.py`) with exact irregular-gap transitions
|
|
140
|
+
(`mcarma/statespace.py`, Lyapunov `Qd`). The analytic
|
|
141
|
+
gradient and Hessian-vector products are in
|
|
142
|
+
`mcarma/jax_loglik.py` and are what `use_jax_grad=True`
|
|
143
|
+
selects. Production fits use regularization to improve numerical stability and
|
|
144
|
+
discourage poorly identified parameter configurations; model comparison is
|
|
145
|
+
based on the ordinary, unpenalized likelihood. Standard errors are taken from
|
|
146
|
+
the penalized Hessian.
|
|
147
|
+
|
|
148
|
+
## Dependencies
|
|
149
|
+
|
|
150
|
+
numpy, scipy and jax. matplotlib, numdifftools, and pandas with statsmodels are
|
|
151
|
+
extras (`plots`, `numdiff`, `analysis`) used by the figures, the fallback
|
|
152
|
+
Hessian, and the analysis scripts.
|
|
153
|
+
|
|
154
|
+
Importing `mcarma` does not import jax. The analytic-gradient objective
|
|
155
|
+
(`mcarma.jax_loglik`), the transition helpers (`mcarma.jax_transitions`), the
|
|
156
|
+
RTS smoother (`mcarma.smoother`) and the reconstruction helpers (`mcarma.rts`)
|
|
157
|
+
import it at module load, so import those explicitly when you need them. On a
|
|
158
|
+
shared cluster that means importing them inside a job rather than on a login
|
|
159
|
+
node, where jax cannot start its thread pool.
|
|
160
|
+
|
|
161
|
+
The library logs its fit progress through the standard `logging` module and
|
|
162
|
+
attaches no handler, so it is silent until an application configures one:
|
|
163
|
+
|
|
164
|
+
```python
|
|
165
|
+
import logging
|
|
166
|
+
logging.basicConfig(level=logging.INFO, format="%(message)s")
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
## References
|
|
170
|
+
|
|
171
|
+
- Kelly, B. C. et al. (2014), CARMA for stochastic variability.
|
|
172
|
+
- Hu, Z. et al. (2020), multiband damped random walk.
|
|
173
|
+
- Jones & Ackerson (1990); Cox & Snell (1968); Cordeiro & Klein (1994);
|
|
174
|
+
Politis, Romano & Wolf (1999).
|
|
175
|
+
|
|
176
|
+
---
|
|
177
|
+
|
|
178
|
+
## Development
|
|
179
|
+
|
|
180
|
+
```bash
|
|
181
|
+
git clone https://github.com/ischmidls/mcarma
|
|
182
|
+
cd mcarma
|
|
183
|
+
pip install -e ".[plots,numdiff,analysis,dev]"
|
|
184
|
+
pytest tests/
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
The research behind the package, the simulation study and the SDSS Stripe 82
|
|
188
|
+
pipeline the papers report, lives in a separate repository.
|
mcarma-0.1.2/README.md
ADDED
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
# mcarma
|
|
2
|
+
|
|
3
|
+
Fit multivariate continuous-time autoregressive moving average (MCARMA) models
|
|
4
|
+
jointly to irregularly sampled multi-band astronomical time series.
|
|
5
|
+
|
|
6
|
+
The package extends multivariate damped random walk modeling to higher-order
|
|
7
|
+
stochastic dynamics. Each band can have its own temporal dynamics, while
|
|
8
|
+
dependence across bands is modeled through correlated stochastic drivers. The
|
|
9
|
+
resulting matrix-valued power spectral density characterizes both marginal
|
|
10
|
+
variability within individual bands and dependence across bands.
|
|
11
|
+
|
|
12
|
+
mcarma supports irregular sampling, heteroscedastic measurement errors, and
|
|
13
|
+
partially observed bands, and fits the joint model using penalized maximum
|
|
14
|
+
likelihood and state-space computation.
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
pip install mcarma
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Not on PyPI until the papers are submitted; until then install from a
|
|
21
|
+
checkout (see Development at the bottom).
|
|
22
|
+
|
|
23
|
+
## Fit one multi-band object
|
|
24
|
+
|
|
25
|
+
```python
|
|
26
|
+
import numpy as np
|
|
27
|
+
from mcarma import ObservationData, fit, compute_aicc, mcarma_psd
|
|
28
|
+
|
|
29
|
+
# One scalar measurement per row: time, magnitude, which band, and the
|
|
30
|
+
# measurement variance. Bands need not be observed together.
|
|
31
|
+
data = ObservationData(t_obs=t, y_obs=y, band=band, R=err**2, d=5)
|
|
32
|
+
|
|
33
|
+
res = fit(data, p=2, q=1, n_restarts=4, use_jax_grad=True)
|
|
34
|
+
|
|
35
|
+
k = 5 * 2 + 5 * 1 + 5 * 6 // 2 + 5 # AR + MA + chol(Sigma) + mu
|
|
36
|
+
aicc = compute_aicc(res["loglik_pure"], k, data.n)
|
|
37
|
+
|
|
38
|
+
freqs = np.logspace(-3.5, -0.7, 400) # cycles per day
|
|
39
|
+
psd = mcarma_psd(res["F"], res["G"], res["H"], res["Sigma"], freqs)
|
|
40
|
+
psd[:, 2, 2] # the r band's own spectrum
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Each band is centered internally, so pass raw magnitudes. `res["theta"]` is the
|
|
44
|
+
fitted parameter vector, `res["loglik"]` the penalized value and
|
|
45
|
+
`res["loglik_pure"]` the plain one, which is what AICc must be scored on.
|
|
46
|
+
`res["hess_inv"]` carries the inverse Hessian when the optimizer produced one.
|
|
47
|
+
|
|
48
|
+
## Examples
|
|
49
|
+
|
|
50
|
+
Three runnable examples are included using an SDSS Stripe 82 quasar light curve
|
|
51
|
+
distributed with the package. The examples require no external data downloads
|
|
52
|
+
and can be run on a standard computer.
|
|
53
|
+
|
|
54
|
+
| script | what it does | roughly how long |
|
|
55
|
+
| --- | --- | --- |
|
|
56
|
+
| `one_band_psd.py` | fits one filter, prints the variability timescale and the spectrum around its break | 10 seconds |
|
|
57
|
+
| `cross_band_coherence.py` | jointly fits all five filters and estimates cross-band coherence and marginal PSDs | 1 minute |
|
|
58
|
+
| `sdss_stripe82_demo.py` | the full walkthrough: the (1,0)/(2,0)/(2,1) order ladder, AICc selection, light curve and PSD figure | several minutes |
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
pip install mcarma[plots]
|
|
62
|
+
|
|
63
|
+
python examples/one_band_psd.py # r band, prints only
|
|
64
|
+
python examples/one_band_psd.py --band g
|
|
65
|
+
python examples/cross_band_coherence.py # writes cross_band_coherence.png
|
|
66
|
+
python examples/sdss_stripe82_demo.py --quick # (1,0) only
|
|
67
|
+
python examples/sdss_stripe82_demo.py # the whole ladder
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
`one_band_psd.py` prints its results and needs no plotting library. The other
|
|
71
|
+
two write a PNG, so they need matplotlib, which is the `plots` extra above.
|
|
72
|
+
Every script takes `--obj PATH` to point at a different Stripe 82 file, and the
|
|
73
|
+
examples directory carries a longer walkthrough of what each one shows.
|
|
74
|
+
|
|
75
|
+
## Model
|
|
76
|
+
|
|
77
|
+
mcarma represents a $d$-band astronomical time series as a joint
|
|
78
|
+
continuous-time stochastic process. Band-specific ARMA dynamics determine the
|
|
79
|
+
marginal temporal behavior, while correlated Wiener drivers introduce
|
|
80
|
+
dependence across bands.
|
|
81
|
+
|
|
82
|
+
$$dZ(t)=F Z(t)dt + G\,dB(t),\ \mathrm{Cov}(dB)=\Sigma dt;\quad
|
|
83
|
+
Y_k = C_k(\mu + H Z_k) + \varepsilon_k,\ \varepsilon_k\sim N(0,R_k).$$
|
|
84
|
+
|
|
85
|
+
$F$ is built from AR Jones factors, $H$ from MA Jones factors. Under the
|
|
86
|
+
structured MCARMA formulation implemented here, cross-band dependence is
|
|
87
|
+
introduced through the covariance matrix $\Sigma$ of the Wiener drivers.
|
|
88
|
+
|
|
89
|
+
Parameter vector:
|
|
90
|
+
|
|
91
|
+
```
|
|
92
|
+
theta = [ AR | MA | chol(Sigma) | mu ], dim = d*p + d*q + d(d+1)/2 + d
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
AR/MA factor coefficients are stored in log space (positive roots). An MA linear
|
|
96
|
+
factor `b` places a zero at frequency `1/b`, so to put a zero in the observable
|
|
97
|
+
band you set `b = 1/omega_z`. That convention matters.
|
|
98
|
+
|
|
99
|
+
The likelihood is the Kalman prediction-error decomposition
|
|
100
|
+
(`mcarma/kalman.py`) with exact irregular-gap transitions
|
|
101
|
+
(`mcarma/statespace.py`, Lyapunov `Qd`). The analytic
|
|
102
|
+
gradient and Hessian-vector products are in
|
|
103
|
+
`mcarma/jax_loglik.py` and are what `use_jax_grad=True`
|
|
104
|
+
selects. Production fits use regularization to improve numerical stability and
|
|
105
|
+
discourage poorly identified parameter configurations; model comparison is
|
|
106
|
+
based on the ordinary, unpenalized likelihood. Standard errors are taken from
|
|
107
|
+
the penalized Hessian.
|
|
108
|
+
|
|
109
|
+
## Dependencies
|
|
110
|
+
|
|
111
|
+
numpy, scipy and jax. matplotlib, numdifftools, and pandas with statsmodels are
|
|
112
|
+
extras (`plots`, `numdiff`, `analysis`) used by the figures, the fallback
|
|
113
|
+
Hessian, and the analysis scripts.
|
|
114
|
+
|
|
115
|
+
Importing `mcarma` does not import jax. The analytic-gradient objective
|
|
116
|
+
(`mcarma.jax_loglik`), the transition helpers (`mcarma.jax_transitions`), the
|
|
117
|
+
RTS smoother (`mcarma.smoother`) and the reconstruction helpers (`mcarma.rts`)
|
|
118
|
+
import it at module load, so import those explicitly when you need them. On a
|
|
119
|
+
shared cluster that means importing them inside a job rather than on a login
|
|
120
|
+
node, where jax cannot start its thread pool.
|
|
121
|
+
|
|
122
|
+
The library logs its fit progress through the standard `logging` module and
|
|
123
|
+
attaches no handler, so it is silent until an application configures one:
|
|
124
|
+
|
|
125
|
+
```python
|
|
126
|
+
import logging
|
|
127
|
+
logging.basicConfig(level=logging.INFO, format="%(message)s")
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
## References
|
|
131
|
+
|
|
132
|
+
- Kelly, B. C. et al. (2014), CARMA for stochastic variability.
|
|
133
|
+
- Hu, Z. et al. (2020), multiband damped random walk.
|
|
134
|
+
- Jones & Ackerson (1990); Cox & Snell (1968); Cordeiro & Klein (1994);
|
|
135
|
+
Politis, Romano & Wolf (1999).
|
|
136
|
+
|
|
137
|
+
---
|
|
138
|
+
|
|
139
|
+
## Development
|
|
140
|
+
|
|
141
|
+
```bash
|
|
142
|
+
git clone https://github.com/ischmidls/mcarma
|
|
143
|
+
cd mcarma
|
|
144
|
+
pip install -e ".[plots,numdiff,analysis,dev]"
|
|
145
|
+
pytest tests/
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
The research behind the package, the simulation study and the SDSS Stripe 82
|
|
149
|
+
pipeline the papers report, lives in a separate repository.
|