diff --git a/deepszsim/io_params.py b/deepszsim/io_params.py index 0a9fa61..b72eeea 100644 --- a/deepszsim/io_params.py +++ b/deepszsim/io_params.py @@ -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 @@ -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): ''' ''' diff --git a/deepszsim/simclusters.py b/deepszsim/simclusters.py index 3a94172..d945798 100644 --- a/deepszsim/simclusters.py +++ b/deepszsim/simclusters.py @@ -9,6 +9,43 @@ 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, @@ -16,41 +53,6 @@ def __init__(self, M200 = None, redshift_z = None, num_halos = None, halo_params 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 diff --git a/docs/Makefile b/docs/Makefile new file mode 100644 index 0000000..d0c3cbf --- /dev/null +++ b/docs/Makefile @@ -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) diff --git a/docs/make.bat b/docs/make.bat new file mode 100644 index 0000000..6247f7e --- /dev/null +++ b/docs/make.bat @@ -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 diff --git a/docs/requirements.txt b/docs/requirements.txt new file mode 100644 index 0000000..fbada6f --- /dev/null +++ b/docs/requirements.txt @@ -0,0 +1,11 @@ +sphinx==7.1.2 +sphinx-rtd-theme==1.3.0rc1 +numpy +camb +h5py +astropy +colossus +tqdm +pixell +pandas +scipy \ No newline at end of file diff --git a/docs/source/api.rst b/docs/source/api.rst new file mode 100644 index 0000000..dc499c5 --- /dev/null +++ b/docs/source/api.rst @@ -0,0 +1,8 @@ +API +=== + +.. autosummary:: + :toctree:: + :maxdepth: 2 + + deepszsim \ No newline at end of file diff --git a/docs/source/conf.py b/docs/source/conf.py new file mode 100644 index 0000000..dc7c2ec --- /dev/null +++ b/docs/source/conf.py @@ -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' \ No newline at end of file diff --git a/docs/source/deepszsim.rst b/docs/source/deepszsim.rst new file mode 100644 index 0000000..b928600 --- /dev/null +++ b/docs/source/deepszsim.rst @@ -0,0 +1,106 @@ +deepszsim package +================= + +Documentation for `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: diff --git a/docs/source/index.rst b/docs/source/index.rst new file mode 100644 index 0000000..cc4698a --- /dev/null +++ b/docs/source/index.rst @@ -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 `_ for installation and usage examples. + +.. toctree:: + :maxdepth: 3 + :caption: Contents: + + deepszsim \ No newline at end of file diff --git a/docs/source/modules.rst b/docs/source/modules.rst new file mode 100644 index 0000000..8b1d906 --- /dev/null +++ b/docs/source/modules.rst @@ -0,0 +1,7 @@ +deepszsim +========= + +.. toctree:: + :maxdepth: 3 + + deepszsim diff --git a/readthedocs.yaml b/readthedocs.yaml new file mode 100644 index 0000000..a02ae4e --- /dev/null +++ b/readthedocs.yaml @@ -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