Skip to content

Commit

Permalink
Merge pull request #240 from deepskies/dev
Browse files Browse the repository at this point in the history
final pre-JOSS merge including docs
  • Loading branch information
bnord authored Oct 18, 2024
2 parents 4019acc + 9c7c55c commit 2080777
Show file tree
Hide file tree
Showing 12 changed files with 298 additions and 41 deletions.
4 changes: 2 additions & 2 deletions deepszsim/io_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def update_val(self, attr, new_val):
print("not a valid attribute")


def write_params_yaml_new()
def write_params_yaml_new():
"""
write updated yaml file to disk
incorporate run id
Expand All @@ -92,7 +92,7 @@ def write_params_yaml_new()
yaml_file.write( dump )


def _generate_run_id(random_digits=6):
def _generate_run_id(random_digits=6):
'''
'''

Expand Down
72 changes: 37 additions & 35 deletions deepszsim/simclusters.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,48 +9,50 @@
from datetime import datetime as dt

class simulate_clusters:
"""
class for simulating a distribution of clusters
Parameters
----------
M200: float or array-like of float
the mass contained within R200 in solar masses (same length as z_dist)
redshift_z: float or array-like of float
the redshift of the cluster (unitless) (same length as M200_dist)
num_halos: None or int
number of halos to simulate if none supplied
halo_params_dict: None or dict
parameters from which to sample halos if `num_halos` specified,
must contain `zmin`, `zmax`, `m200min_SM`, `m200max_SM`
R200_Mpc: None or float or np.ndarray(float)
if None, will calculate the R200 values corresponding to a given set of
M200 and redshift_z values for the specified cosmology
profile: str
Name of profile, currently only supports "Battaglia2012"
image_size_pixels: None or int
image size in pixels (should be odd; if even, will return images whose
sides are `image_size_pixels+1` in length)
image_size_arcmin: None or float
image size in arcmin
pixel_size_arcmin: None or float
pixel size in arcmin
alpha: float
fixed to equal 1.0 in Battaglia 2012
gamma: float
fixed to equal -0.3 in Battaglia 2012
load_vars_yaml: None or str
path to yaml file with params; if `None`, must explicitly include image specifications
seed: None or int
random seed value to sample with
tqverb: bool
whether or not to display tqdm progress bar while making T maps
"""
def __init__(self, M200 = None, redshift_z = None, num_halos = None, halo_params_dict = None,
R200_Mpc = None, profile = "Battaglia2012",
image_size_pixels = None, image_size_arcmin = None, pixel_size_arcmin = None,
alpha = 1.0, gamma = -0.3,
load_vars_yaml = os.path.join(os.path.dirname(__file__), 'Settings', 'config_simACTDR5.yaml'),
seed = None, tqverb = False
):
"""
Parameters
----------
M200: float or array-like of float
the mass contained within R200 in solar masses (same length as z_dist)
redshift_z: float or array-like of float
the redshift of the cluster (unitless) (same length as M200_dist)
num_halos: None or int
number of halos to simulate if none supplied
halo_params_dict: None or dict
parameters from which to sample halos if `num_halos` specified,
must contain `zmin`, `zmax`, `m200min_SM`, `m200max_SM`
R200_Mpc: None or float or np.ndarray(float)
if None, will calculate the R200 values corresponding to a given set of
M200 and redshift_z values for the specified cosmology
profile: str
Name of profile, currently only supports "Battaglia2012"
image_size_pixels: None or int
image size in pixels (should be odd; if even, will return images whose
sides are `image_size_pixels+1` in length)
image_size_arcmin: None or float
image size in arcmin
pixel_size_arcmin: None or float
pixel size in arcmin
alpha: float
fixed to equal 1.0 in Battaglia 2012
gamma: float
fixed to equal -0.3 in Battaglia 2012
load_vars_yaml: None or str
path to yaml file with params; if `None`, must explicitly include image specifications
seed: None or int
random seed value to sample with
tqverb: bool
whether or not to display tqdm progress bar while making T maps
"""

if (M200 is not None) and (redshift_z is not None):
self.M200, self.redshift_z = M200, redshift_z
Expand Down
20 changes: 20 additions & 0 deletions docs/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Minimal makefile for Sphinx documentation
#

# You can set these variables from the command line, and also
# from the environment for the first two.
SPHINXOPTS ?=
SPHINXBUILD ?= sphinx-build
SOURCEDIR = source
BUILDDIR = build

# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

.PHONY: help Makefile

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
35 changes: 35 additions & 0 deletions docs/make.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
@ECHO OFF

pushd %~dp0

REM Command file for Sphinx documentation

if "%SPHINXBUILD%" == "" (
set SPHINXBUILD=sphinx-build
)
set SOURCEDIR=source
set BUILDDIR=build

if "%1" == "" goto help

%SPHINXBUILD% >NUL 2>NUL
if errorlevel 9009 (
echo.
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
echo.installed, then set the SPHINXBUILD environment variable to point
echo.to the full path of the 'sphinx-build' executable. Alternatively you
echo.may add the Sphinx directory to PATH.
echo.
echo.If you don't have Sphinx installed, grab it from
echo.http://sphinx-doc.org/
exit /b 1
)

%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
goto end

:help
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%

:end
popd
11 changes: 11 additions & 0 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
sphinx==7.1.2
sphinx-rtd-theme==1.3.0rc1
numpy
camb
h5py
astropy
colossus
tqdm
pixell
pandas
scipy
8 changes: 8 additions & 0 deletions docs/source/api.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
API
===

.. autosummary::
:toctree::
:maxdepth: 2

deepszsim
39 changes: 39 additions & 0 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Configuration file for the Sphinx documentation builder.
import os
import sys
sys.path.insert(0, os.path.abspath('../../'))

# -- Project information

project = 'DeepSZSim'
copyright = '2024, DeepSkies'
author = 'DeepSkies'

release = '0.1'
version = '0.1.0'

# -- General configuration

extensions = [
'sphinx.ext.duration',
'sphinx.ext.doctest',
'sphinx.ext.autodoc',
'sphinx.ext.autosummary',
'sphinx.ext.intersphinx',
# 'autoapi.extension',
]

intersphinx_mapping = {
'python': ('https://docs.python.org/3/', None),
'sphinx': ('https://www.sphinx-doc.org/en/master/', None),
}
intersphinx_disabled_domains = ['std']

templates_path = ['_templates']

# -- Options for HTML output

html_theme = 'sphinx_rtd_theme'

# -- Options for EPUB output
epub_show_urls = 'footnote'
106 changes: 106 additions & 0 deletions docs/source/deepszsim.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
deepszsim package
=================

Documentation for `DeepSZSim <https://www.github.com/DeepSkies/DeepSZSim/>`_.

To create a simulation of two SZ clusters as quickly as possible, run
``tc = deepszsim.simulate_clusters(num_halos=2).get_T_maps()``, which will return a dictionary with two entries, accessed by ``tc.clusters``. Each of these entries includes a ``params`` subdirectory and a ``maps`` subdirectory.

Submodules
----------

deepszsim.dm\_halo\_dist module
-------------------------------

.. automodule:: deepszsim.dm_halo_dist
:members:
:undoc-members:
:show-inheritance:

deepszsim.filters module
------------------------

.. automodule:: deepszsim.filters
:members:
:undoc-members:
:show-inheritance:

deepszsim.io\_params module
---------------------------

.. automodule:: deepszsim.io_params
:members:
:undoc-members:
:show-inheritance:

deepszsim.load\_vars module
---------------------------

.. automodule:: deepszsim.load_vars
:members:
:undoc-members:
:show-inheritance:

deepszsim.make\_sz\_cluster module
----------------------------------

.. automodule:: deepszsim.make_sz_cluster
:members:
:undoc-members:
:show-inheritance:

deepszsim.noise module
----------------------

.. automodule:: deepszsim.noise
:members:
:undoc-members:
:show-inheritance:

deepszsim.read\_yaml module
---------------------------

.. automodule:: deepszsim.read_yaml
:members:
:undoc-members:
:show-inheritance:

deepszsim.simclusters module
----------------------------

.. automodule:: deepszsim.simclusters
:members:
:undoc-members:
:show-inheritance:

deepszsim.simtools module
-------------------------

.. automodule:: deepszsim.simtools
:members:
:undoc-members:
:show-inheritance:

deepszsim.utils module
----------------------

.. automodule:: deepszsim.utils
:members:
:undoc-members:
:show-inheritance:

deepszsim.visualization module
------------------------------

.. automodule:: deepszsim.visualization
:members:
:undoc-members:
:show-inheritance:

Module contents
---------------

.. automodule:: deepszsim
:members:
:undoc-members:
:show-inheritance:
12 changes: 12 additions & 0 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Welcome to DeepSZSim's documentation!
=====================================

**DeepSZSim** offers fast simulation of clusters observed via the Sunyaev-Zel'dovich effect in the CMB.

Check out the `github <https://www.github.com/DeepSkies/DeepSZSim/>`_ for installation and usage examples.

.. toctree::
:maxdepth: 3
:caption: Contents:

deepszsim
7 changes: 7 additions & 0 deletions docs/source/modules.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
deepszsim
=========

.. toctree::
:maxdepth: 3

deepszsim
12 changes: 8 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ build-backend = "setuptools.build_meta"

[project]
name = "deepszsim"
version = "0.1.0"
version = "0.1.1"
description = "code for fast simulations of galaxy clusters"
authors = [{name = "Eve Vavagiakis", email = "[email protected]"}]
license = {text="LICENSE.txt"}
requires-python = ">= 3.9, <3.12"
dependencies = [
"camb >= 1.4.0",
"h5py >= 3.8.0",
"numpy >= 1.24.3",
"numpy >= 1.24.3, <2",
"astropy >= 6.0",
"colossus >= 1.3.0",
"tqdm >= 4.66.0",
Expand All @@ -23,5 +23,9 @@ dependencies = [
pytest = "^7.3.1"
pytest-cov = "^4.0.0"

[tool.setuptools.packages.find]
namespaces = false
[tool.setuptools]
packages = ["deepszsim"]
include-package-data = true

[tool.setuptools.package-data]
"deepszsim" = ["Settings/*.yaml"]
13 changes: 13 additions & 0 deletions readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
version: "2"

build:
os: "ubuntu-22.04"
tools:
python: "3.11"

python:
install:
- requirements: docs/requirements.txt

sphinx:
configuration: docs/source/conf.py

0 comments on commit 2080777

Please sign in to comment.