Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 6 additions & 27 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,39 +1,18 @@
include README.rst
include CHANGES.rst

include ah_bootstrap.py
include setup.cfg
include pyproject.toml
include requirements.txt
include environment.yml
include contributors.md
include popsycle/tests/coveragerc

recursive-include popsycle *.pyx *.c *.pxd
recursive-include popsycle *.py *.npz *.yaml *.rst
recursive-include docs *
recursive-include licenses *
recursive-include cextern *
recursive-include scripts *

prune build
prune dist
prune docs/_build
prune docs/api


# the next few stanzas are for astropy_helpers. It's derived from the
# astropy_helpers/MANIFEST.in, but requires additional includes for the actual
# package directory and egg-info.

include astropy_helpers/README.rst
include astropy_helpers/CHANGES.rst
include astropy_helpers/LICENSE.rst
recursive-include astropy_helpers/licenses *

include astropy_helpers/ah_bootstrap.py

recursive-include astropy_helpers/astropy_helpers *.py *.pyx *.c *.h *.rst
recursive-include astropy_helpers/astropy_helpers.egg-info *
# include the sphinx stuff with "*" because there are css/html/rst/etc.
recursive-include astropy_helpers/astropy_helpers/sphinx *

prune astropy_helpers/build
prune astropy_helpers/astropy_helpers/tests


global-exclude *.pyc *.o
63 changes: 59 additions & 4 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,68 @@ found at our galaxia GitHub repo: https://github.com/jluastro/galaxia.
Installation
------------

To install PopSyCLE, clone the GitHub repository and add the repository's
path to your `PYTHONPATH`. For example:
PopSyCLE is packaged and can be installed directly with either conda or pip.
For the full pipeline, use **Python 3.11**. This is the compatible overlap for
the current SPISEA and BAGLE dependency stack.

Conda installation
^^^^^^^^^^^^^^^^^^

The repository ships with an ``environment.yml`` that installs the Python
dependencies and installs PopSyCLE in editable mode.

.. code-block:: bash

git clone https://github.com/MovingUniverseLab/PopSyCLE.git
cd PopSyCLE
conda env create -f environment.yml
conda activate popsycle

Pip installation
^^^^^^^^^^^^^^^^

If you prefer virtual environments or already manage Python outside conda,
install PopSyCLE directly with pip:

.. code-block:: bash

git clone git@github.com:jluastro/PopSyCLE.git
echo "export PYTHONPATH=$PWD/PopSyCLE:$PYTHONPATH" >> ~/.bashrc
git clone https://github.com/MovingUniverseLab/PopSyCLE.git
cd PopSyCLE
python3.11 -m venv .venv
source .venv/bin/activate
python -m pip install --upgrade pip
python -m pip install -e .

SPISEA
^^^^^^

SPISEA is still distributed upstream as a source checkout rather than a normal
PyPI package, so install it separately after creating the PopSyCLE environment.
Follow the SPISEA repository instructions and make sure it is importable in the
same environment before running the PopSyCLE pipeline.

.. code-block:: bash

git clone https://github.com/astropy/SPISEA.git
export PYTHONPATH=$PWD/SPISEA:$PYTHONPATH

Command line entry point
^^^^^^^^^^^^^^^^^^^^^^^^

After installation, the pipeline CLI is available as:

.. code-block:: bash

popsycle --help

Galaxia
^^^^^^^

Galaxia is still a separate external dependency and must be installed manually.
PopSyCLE checks for the custom ``galaxia`` executable in ``$PATH`` and requires
version ``0.7.2.1`` from the PopSyCLE-compatible Galaxia fork. Follow the
Galaxia instructions in the documentation before running the synthesis
pipeline.

Running PopSyCLE
----------------
Expand Down
36 changes: 32 additions & 4 deletions docs/source/popsycle_docs.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ Documentation
1 Installation
==============

For a full-featured installation, use Python 3.11. That is the supported
overlap for the current SPISEA and BAGLE dependency stack.

1.1 Installing Galaxia
-----------------------

Expand Down Expand Up @@ -82,17 +85,43 @@ Documentation
1.2 Installing SPISEA
----------------------

SPISEA can be installed by cloning the repository from `<https://github.com/astropy/SPISEA>`_ and following the instructions.
SPISEA still needs to be installed separately from source. Use the
repository at `<https://github.com/astropy/SPISEA>`_ and make sure it is
importable in the same Python environment as PopSyCLE before running the
full pipeline.

1.3 Installing BAGLE
----------------------

BAGLE can be installed by cloning the repository from `<https://github.com/MovingUniverseLab/BAGLE_Microlensing>`_ and following the instructions.
BAGLE is installed automatically as part of the packaged PopSyCLE install
methods below. If you need to install it separately, see
`<https://github.com/MovingUniverseLab/BAGLE_Microlensing>`_.

1.4 Installing Python libraries
--------------------------------

We recommend the Anaconda distribution. See `requirements.txt <https://github.com/jluastro/PopSyCLE/blob/main/requirements.txt>`_ for details.
We recommend one of the following installation flows from the repository
root.

Conda:

.. code-block:: bash

conda env create -f environment.yml
conda activate popsycle

Pip:

.. code-block:: bash

python3.11 -m venv .venv
source .venv/bin/activate
python -m pip install --upgrade pip
python -m pip install -e .

SPISEA still needs to be installed separately from its source repository
and made importable in the same environment. After PopSyCLE and SPISEA are
installed, the PopSyCLE CLI is available as ``popsycle``.

===============
2 Reading Files
Expand Down Expand Up @@ -1325,4 +1354,3 @@ Note: be careful with the branch of arctangent. Practically, use ``numpy.arctan2
:align: center

Diagram of Heliocentric and Galactic coordinate systems. The red dot is the sun.

26 changes: 26 additions & 0 deletions environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: popsycle
channels:
- conda-forge
dependencies:
- python=3.11
- pip
- numpy>=1.24.3
- matplotlib>=3.7.1
- astropy>=5.3
- h5py>=3.8.0
- scipy>=1.10.1
- pyyaml>=6.0
- pandas>=1.5.2
- pysynphot>=2.0.0
- synphot>=1.7.0
- stsynphot>=1.5.1
- scikit-learn
- celerite
- jplephem
- ephem
- pytest>=7.2.0
- numpydoc>=1.5
- sphinx_rtd_theme
- pip:
- --editable .
# Install SPISEA separately in this environment after creation.
54 changes: 44 additions & 10 deletions popsycle/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,49 @@
import sys
import time
import glob
from popsycle import synthetic
from popsycle import utils
from popsycle.synthetic import _check_run_galaxia
from popsycle.synthetic import _check_perform_pop_syn
from popsycle.synthetic import _check_calc_events
from popsycle.synthetic import _check_refine_events
from popsycle.synthetic import _check_refine_binary_events
from popsycle.synthetic import multiplicity_list
from popsycle import binary_utils
from popsycle import phot_utils

synthetic = None
utils = None
binary_utils = None
phot_utils = None
_check_run_galaxia = None
_check_perform_pop_syn = None
_check_calc_events = None
_check_refine_events = None
_check_refine_binary_events = None
multiplicity_list = None


def _load_runtime_dependencies():
global synthetic
global utils
global binary_utils
global phot_utils
global _check_run_galaxia
global _check_perform_pop_syn
global _check_calc_events
global _check_refine_events
global _check_refine_binary_events
global multiplicity_list

if synthetic is not None:
return

from popsycle import synthetic as synthetic_mod
from popsycle import utils as utils_mod
from popsycle import binary_utils as binary_utils_mod
from popsycle import phot_utils as phot_utils_mod

synthetic = synthetic_mod
utils = utils_mod
binary_utils = binary_utils_mod
phot_utils = phot_utils_mod
_check_run_galaxia = synthetic_mod._check_run_galaxia
_check_perform_pop_syn = synthetic_mod._check_perform_pop_syn
_check_calc_events = synthetic_mod._check_calc_events
_check_refine_events = synthetic_mod._check_refine_events
_check_refine_binary_events = synthetic_mod._check_refine_binary_events
multiplicity_list = synthetic_mod.multiplicity_list


def _return_filename_dict(output_root, filter_dict, red_law, multiplicity = None):
Expand Down Expand Up @@ -1356,6 +1389,7 @@ def main():
help="Skip running refine_binary_events.",
action='store_true')
args = parser.parse_args()
_load_runtime_dependencies()

run(output_root=args.output_root,
field_config_filename=args.field_config_filename,
Expand Down
7 changes: 5 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
[build-system]

requires = ["setuptools",
"setuptools_scm",
requires = ["setuptools>=64",
"setuptools_scm[toml]>=8",
"wheel"]

build-backend = 'setuptools.build_meta'

[tool.setuptools_scm]
write_to = "popsycle/version.py"
3 changes: 3 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,11 @@ pandas~=1.5.2
numpydoc~=1.5
sphinx_rtd_theme
pysynphot
synphot
stsynphot
scikit-learn
# The following are needed for BAGLE
celerite
jplephem
ephem
bagle>=1.0.5
47 changes: 41 additions & 6 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,65 @@ author = Casey Lam and Jessica Lu
author_email = jlu.astro@berkeley.edu
license = BSD 3-Clause
license_file = licenses/LICENSE.rst
url = https://github.com/jluastro/PopSyCLE
url = https://github.com/MovingUniverseLab/PopSyCLE
description = Population Synthesis for Compact-object Lensing Events
long_description = file: README.rst
long_description_content_type = text/x-rst
edit_on_github = False
github_project = jluastro/PopSyCLE
github_project = MovingUniverseLab/PopSyCLE

[options]
zip_safe = False
packages = find:
python_requires = >=3.6
setup_requires = setuptools_scm
include_package_data = True
python_requires = >=3.11,<3.12
install_requires =
astropy
numpy>=1.24.3
matplotlib>=3.7.1
astropy>=5.3
h5py>=3.8.0
scipy>=1.10.1
pyyaml>=6.0
pandas>=1.5.2
pysynphot>=2.0.0
synphot>=1.7.0
stsynphot>=1.5.1
scikit-learn
celerite
jplephem
ephem
bagle>=1.0.5


[options.extras_require]
test =
pytest>=7.2.0
pytest-astropy
docs =
numpydoc>=1.5
sphinx_rtd_theme
sphinx-astropy
dev =
build
wheel
twine

[options.entry_points]
console_scripts =
popsycle = popsycle.run:main

[options.package_data]
popsycle = data/*
popsycle =
data/*
tests/data_correct/*
tests/data_test/*

[options.packages.find]
namespaces = False
exclude =
popsycle.data
popsycle.tests.data_correct
popsycle.tests.data_test

[tool:pytest]
testpaths = "popsycle" "docs"
Expand Down
Loading