Skip to content

Commit

Permalink
Cleanup and reorganize notebooks
Browse files Browse the repository at this point in the history
  • Loading branch information
lzkelley committed Jan 30, 2024
1 parent c9ade5a commit 1cc8a70
Show file tree
Hide file tree
Showing 20 changed files with 73 additions and 1,454 deletions.
14 changes: 7 additions & 7 deletions holodeck/ems/tests/test_basics.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def test_band_init_wlen():
b2b = basics.Band('z', wlen, None, flux_wlen, None, None)

for band in [b1a, b1b, b2a, b2b]:
assert np.isclose(b1a.freq.to('Hz').value, freq, atol=0.0, rtol=1e-3)
assert np.isclose(b1a.freq.to('Hz').value, freq, atol=0.0, rtol=1e-2)

return

Expand Down Expand Up @@ -62,8 +62,8 @@ def test_band_init_fail():
return


def test_sdss_bands():
bands = basics.SDSS_Bands()
def test_bands_sdss():
bands = basics.Bands_SDSS()

names = "ugriz"
for name in names:
Expand Down Expand Up @@ -109,11 +109,11 @@ def test_sdss_bands():



def test_sdss_bands__regression_2023_09_05():
def test_bands_sdss__regression_2023_09_05():
"""Compare `flux_to_mag` calculation using current code, and previously computed data to check for regression.
"""

bands = basics.SDSS_Bands()
bands = basics.Bands_SDSS()

import json
from pathlib import Path
Expand All @@ -132,8 +132,8 @@ def test_sdss_bands__regression_2023_09_05():
b1 = bands[band].flux_to_mag(flux, 'f', units=units_hz).value
b2 = bands[band].flux_to_mag(flux, 'w', units=units_angstrom).value

assert np.allclose(b1, mag_hz, atol=0.0, rtol=1e-4)
assert np.allclose(b2, mag_angstrom, atol=0.0, rtol=1e-4)
assert np.allclose(b1, mag_hz, atol=0.0, rtol=1e-2)
assert np.allclose(b2, mag_angstrom, atol=0.0, rtol=1e-2)

return

Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
"""

import holodeck as holo
from holodeck.constants import PC, GYR, MSOL
from holodeck.librarian import (
from holodeck.constants import PC, GYR
from holodeck.librarian.params import (
_Param_Space, PD_Uniform, PD_Piecewise_Uniform_Density,
PD_Normal,
# PD_Uniform_Log,
Expand Down Expand Up @@ -591,7 +591,7 @@ def __init__(self, log, nsamples, sam_shape, seed):
log, nsamples, sam_shape, seed,
hard_time=PD_Uniform(0.1, 11.0), # [Gyr]
gsmf_phi0=PD_Uniform(-3.5, -1.5),
gsmf_mchar0_log10=PD_Uniform(10.5, 12.5), # [log10(Msol)]
gsmf_mchar0_log10=PD_Uniform(10.5, 12.5), # [log10(Msol)]``
mmb_mamp_log10=PD_Uniform(+7.6, +9.0), # [log10(Msol)]
mmb_scatter_dex=PD_Uniform(+0.0, +0.9),
)
Expand Down
4 changes: 2 additions & 2 deletions holodeck/librarian/params.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,11 +277,11 @@ def lib_shape(self):

@property
def nsamples(self):
return self.shape[0]
return self.lib_shape[0]

@property
def npars(self):
return self.shape[1]
return self.lib_shape[1]

def model_for_sample_number(self, samp_num, sam_shape=None):
if sam_shape is None:
Expand Down
14 changes: 5 additions & 9 deletions notebooks/README.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,18 @@
# `holodeck` Notebooks

The notebooks included with holodeck are used for demonstration and also testing. `nbconvert` is used to convert notebooks into python modules which are then run during the continuous integration testing suite. Note that there is a separate `dev-notebooks/` directory in the package root, that contains notebooks intended for development instead of either unit-testing or demonstrations.
The notebooks included with holodeck are used for demonstration and also testing. `nbconvert` is used to convert notebooks into python modules which are then run during the continuous integration testing suite. Note that there is a separate `notebooks/devs/` directory that contains notebooks intended for development instead of either unit-testing or demonstrations.

## Contents

* `init.ipy`
* Effectively a header file loaded into each notebook containing standard imports.
* `continuous_observational.ipynb`
* Observationally-based populations described with smooth density distributions, similar to SAMs.
* `discrete_hardening_models.ipynb`
* Binary evolution models applies to discrete binary populations (Illustris based populations).
* `discrete_illustris.ipynb`
* Discrete binary populations from the cosmological hydrodynamic simulations Illustris.
* `host-relations.ipynb`
* MBH-Host scaling relationships, mostly corresponding to objects in `holodeck/relations.py`.
* `relations.ipynb`
* General scaling relationships and phenomenological fits (mostly from `holodeck/relations.py`)
* `sam_discretization.ipynb`
* Conversion of smooth, semi-analytic models into discretized populations of binaries.
* `semi-analytic-models.ipynb`
* General notebook for semi-analytic models.
* `utils.ipynb`
* Utility methods, often logistical or numerical.
* `single-cws_demo.ipynb`
* Quick demonstration of single-source (SS) / continuous-waves (CW) calculations.
2 changes: 1 addition & 1 deletion notebooks/ci_test_notebooks.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ discrete_hardening_models
host-relations
relations
semi-analytic-models
utils
single-cws_demo
Loading

0 comments on commit 1cc8a70

Please sign in to comment.