Skip to content

Commit a1908d8

Browse files
committed
Docs: Add a Getting Started page.
1 parent ef68129 commit a1908d8

File tree

2 files changed

+101
-0
lines changed

2 files changed

+101
-0
lines changed

docs/source/getting-started.rst

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
Getting Started
2+
===============
3+
4+
Written Mar 16, 2021
5+
6+
Environment
7+
-----------
8+
9+
Previous UNITY documentation use non-``conda`` environments. The scientific community is standardizing on ``conda`` and so should UNITY.
10+
11+
Create a UNITY ``conda`` environment by use unity.yml (found in the root directory of the UNITY project): ``conda env create -f unity.yaml``.
12+
13+
Activate the environnement, then add the UNITY cli, by running ``pip install .`` in repo's top level directory.
14+
15+
16+
Test that things are working
17+
----------------------------
18+
19+
To ensure things are working correctly. Run ``simple_test_dataset.py`` (again found in ``docs/source/``) to create the ``test_simple_300_obs.pkl`` test data set. Run this through the UNITY cli with ``unity run --model=stan_code_simple_debug.txt --steps=100 --max_cores=1 ./path-to/test_simple_300_obs.pkl``.
20+
21+
22+
Your data
23+
---------
24+
25+
I recommend adapting ``./simple_test_dataset.py`` to read in your SALT2 fits and redshifts. A more complete description of each parameter of the data pickle file can be found at ./docs_input_data.rst.

docs/source/simple_test_dataset.py

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
"""simple_test_dataset.py -- Create a simple data set to test installation.
2+
3+
Basic SALT/Tripp standardization.
4+
"""
5+
import pickle
6+
7+
import numpy as np
8+
9+
np.random.seed(13048293)
10+
11+
DATA_NAME = "simple" # default
12+
N_SNE = 300
13+
# Tripp Coefficients
14+
COFF = [
15+
-0.14, # alpha, note negative sign
16+
3, # beta
17+
]
18+
19+
20+
# TRUE VALUES
21+
c_true = np.random.randn(N_SNE) * 0.1
22+
x1_true = np.random.randn(N_SNE)
23+
mb_true = COFF[0] * x1_true + COFF[1] * c_true - 20
24+
25+
26+
# OBSERVATIONAL
27+
x1_obs = x1_true + np.random.randn(N_SNE) * 0.3
28+
c_obs = c_true + np.random.randn(N_SNE) * 0.04
29+
mb_obs = mb_true + np.random.randn(N_SNE) * 0.10
30+
31+
# Don't use non-Gaussian parameters
32+
age_gaus_mean = np.zeros((0, N_SNE, 0))
33+
age_gaus_std = np.zeros((0, N_SNE, 0))
34+
age_gaus_A = np.zeros((0, N_SNE, 0))
35+
36+
37+
pickle.dump(
38+
dict( # general properties
39+
n_sne=N_SNE,
40+
n_props=3,
41+
n_non_gaus_props=0,
42+
n_sn_set=1,
43+
sn_set_inds=[0] * N_SNE,
44+
# redshifts
45+
z_helio=[0.1] * N_SNE,
46+
z_CMB=[0.1] * N_SNE,
47+
# Gaussian defined properties
48+
obs_mBx1c=[[mb_obs[i], x1_obs[i], c_obs[i]] for i in range(N_SNE)],
49+
obs_mBx1c_cov=[
50+
np.diag(
51+
[
52+
0.05 ** 2,
53+
0.3 ** 2,
54+
0.04 ** 2,
55+
]
56+
)
57+
]
58+
* N_SNE,
59+
# Non-Gaussian properties, skip
60+
n_age_mix=0,
61+
age_gaus_mean=age_gaus_mean,
62+
age_gaus_std=age_gaus_std,
63+
age_gaus_A=age_gaus_A,
64+
# Other stuff that does not really need to change
65+
do_fullDint=0,
66+
outl_frac_prior_lnmean=-4.6,
67+
outl_frac_prior_lnwidth=1,
68+
lognormal_intr_prior=0,
69+
allow_alpha_S_N=0,
70+
),
71+
open(f"test_{DATA_NAME}_{N_SNE}_obs.pkl", "wb"),
72+
)
73+
pickle.dump(
74+
{"x1": x1_true, "c": c_true, "mass": mass_true, "age": age_true, "mb": mb_true},
75+
open(f"test_{DATA_NAME}_{N_SNE}_true.pkl", "wb"),
76+
)

0 commit comments

Comments
 (0)