Skip to content

Commit

Permalink
Merge branch 'pre-commit-ci-update-config' of github.com:Ciela-Instit…
Browse files Browse the repository at this point in the history
…ute/caustics into pre-commit-ci-update-config
  • Loading branch information
ConnorStoneAstro committed Aug 7, 2024
2 parents d66b9fc + 3c67f46 commit d4eff65
Show file tree
Hide file tree
Showing 75 changed files with 2,393 additions and 402 deletions.
8 changes: 8 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,12 @@ jobs:
pytest -vvv --cov=${{ env.PROJECT_NAME }} --cov-report=xml --cov-report=term tests/
- name: Upload coverage reports to Codecov with GitHub Action
if:
${{ matrix.python-version == '3.10' && matrix.os == 'ubuntu-latest'}}
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage.xml
flags: unittests
name: codecov-umbrella
fail_ci_if_error: true
2 changes: 1 addition & 1 deletion .github/workflows/image_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ jobs:
uses: docker/setup-buildx-action@v3

- name: Build and export to Docker
uses: docker/build-push-action@v5
uses: docker/build-push-action@v6
with:
context: .
file: ./resources/docker/Dockerfile
Expand Down
26 changes: 18 additions & 8 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ ci:

repos:
- repo: https://github.com/psf/black
rev: "24.4.2"
rev: "24.8.0"
hooks:
- id: black-jupyter

- repo: https://github.com/asottile/blacken-docs
rev: "1.16.0"
rev: "1.18.0"
hooks:
- id: blacken-docs
additional_dependencies: [black==23.7.0]
Expand All @@ -23,6 +23,7 @@ repos:
rev: "v4.6.0"
hooks:
- id: check-added-large-files
args: ["--maxkb=1000"]
- id: check-case-conflict
- id: check-merge-conflict
- id: check-symlinks
Expand Down Expand Up @@ -50,13 +51,13 @@ repos:
args: [--prose-wrap=always]

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: "v0.4.10"
rev: "v0.5.6"
hooks:
- id: ruff
args: ["--fix", "--show-fixes"]

- repo: https://github.com/pre-commit/mirrors-mypy
rev: "v1.10.0"
rev: "v1.11.1"
hooks:
- id: mypy
files: src
Expand All @@ -70,11 +71,20 @@ repos:
- id: codespell
args: ["--write-changes", "--ignore-words", ".codespell-whitelist"]

- repo: https://github.com/kynan/nbstripout
rev: 0.7.1
#- repo: https://github.com/kynan/nbstripout
#rev: 0.7.1
#hooks:
#- id: nbstripout
#args: [--extra-keys=metadata.kernelspec metadata.language_info.version]

- repo: local
hooks:
- id: nbstripout
args: [--extra-keys=metadata.kernelspec metadata.language_info.version]
- id: strip-output-keep-html
name: Strip Jupyter Notebook output but keep HTML
entry: python strip_output_keep_html.py
language: python
additional_dependencies: [nbformat]
files: \.ipynb$

- repo: local
hooks:
Expand Down
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
[![Documentation Status](https://readthedocs.org/projects/caustics/badge/?version=latest)](https://caustics.readthedocs.io/en/latest/?badge=latest)
[![PyPI version](https://badge.fury.io/py/caustics.svg)](https://pypi.org/project/caustics/)
[![coverage](https://img.shields.io/codecov/c/github/Ciela-Institute/caustics)](https://app.codecov.io/gh/Ciela-Institute/caustics)
[![DOI](https://zenodo.org/badge/521722463.svg)](https://zenodo.org/doi/10.5281/zenodo.10806382)
[![status](https://joss.theoj.org/papers/995fa98462eb534a32952549ef2244f8/status.svg)](https://joss.theoj.org/papers/995fa98462eb534a32952549ef2244f8)
[![Zenodo](https://zenodo.org/badge/521722463.svg)](https://zenodo.org/doi/10.5281/zenodo.10806382)
[![arXiv](https://img.shields.io/badge/arXiv-2406.15542-b31b1b.svg)](https://arxiv.org/abs/2406.15542)

# caustics

Expand Down Expand Up @@ -45,7 +47,7 @@ x = torch.tensor([
5.0, -0.2, 0.0, 0.8, 0.0, 1., 1.0, 10.0
]) # fmt: skip

minisim = caustics.Lens_Source(
minisim = caustics.LensSource(
lens=sie, source=src, lens_light=lnslt, pixelscale=0.05, pixels_x=100
)
plt.imshow(minisim(x, quad_level=3), origin="lower")
Expand Down
9 changes: 5 additions & 4 deletions docs/source/_toc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@ chapters:
- file: websim
- file: tutorials/index
sections:
- file: basicindex
- file: tutorials/Introduction
- file: interfaceindex
sections:
- file: tutorials/BasicIntroduction_yaml
- file: tutorials/BasicIntroduction_oop
- file: tutorials/BasicIntroduction_func
- file: tutorials/InterfaceIntroduction_yaml
- file: tutorials/InterfaceIntroduction_oop
- file: tutorials/InterfaceIntroduction_func
- file: tutorials/LensZoo
- file: tutorials/VisualizeCaustics
- file: tutorials/MultiplaneDemo
Expand Down
21 changes: 20 additions & 1 deletion docs/source/citation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,23 @@
Citation
========

Paper coming soon! We will put all the citation information here when its ready.
Paper is submitted to JOSS, in the meantime please cite the `arXiv version <https://arxiv.org/abs/2406.15542>`_ of the paper:

.. code-block:: bibtex
@ARTICLE{2024arXiv240615542S,
author = {{Stone}, Connor and {Adam}, Alexandre and {Coogan}, Adam and {Yantovski-Barth}, M.~J. and {Filipp}, Andreas and {Setiawan}, Landung and {Core}, Cordero and {Legin}, Ronan and {Wilson}, Charles and {Missael Barco}, Gabriel and {Hezaveh}, Yashar and {Perreault-Levasseur}, Laurence},
title = "{Caustics: A Python Package for Accelerated Strong Gravitational Lensing Simulations}",
journal = {arXiv e-prints},
keywords = {Astrophysics - Instrumentation and Methods for Astrophysics, Astrophysics - Cosmology and Nongalactic Astrophysics},
year = 2024,
month = jun,
eid = {arXiv:2406.15542},
pages = {arXiv:2406.15542},
doi = {10.48550/arXiv.2406.15542},
archivePrefix = {arXiv},
eprint = {2406.15542},
primaryClass = {astro-ph.IM},
adsurl = {https://ui.adsabs.harvard.edu/abs/2024arXiv240615542S},
adsnote = {Provided by the SAO/NASA Astrophysics Data System}
}
5 changes: 2 additions & 3 deletions docs/source/examples/Example_ImageFit_LM.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,9 @@
"cosmology.to(dtype=torch.float32)\n",
"\n",
"upsample_factor = 1\n",
"thx, thy = caustics.utils.get_meshgrid(\n",
"thx, thy = caustics.utils.meshgrid(\n",
" pixelscale / upsample_factor,\n",
" upsample_factor * numPix,\n",
" upsample_factor * numPix,\n",
" dtype=torch.float32,\n",
")\n",
"z_l = torch.tensor(0.5, dtype=torch.float32)\n",
Expand Down Expand Up @@ -110,7 +109,7 @@
")\n",
"\n",
"# Image plane simulator\n",
"sim = caustics.Lens_Source(\n",
"sim = caustics.LensSource(\n",
" lens=lens_mass_model,\n",
" lens_light=lens_light_model,\n",
" source=source_light_model,\n",
Expand Down
5 changes: 2 additions & 3 deletions docs/source/examples/Example_ImageFit_NUTS.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,9 @@
"cosmology.to(dtype=torch.float32)\n",
"\n",
"upsample_factor = 1\n",
"thx, thy = caustics.utils.get_meshgrid(\n",
"thx, thy = caustics.utils.meshgrid(\n",
" pixelscale / upsample_factor,\n",
" upsample_factor * numPix,\n",
" upsample_factor * numPix,\n",
" dtype=torch.float32,\n",
")\n",
"z_l = torch.tensor(0.5, dtype=torch.float32)\n",
Expand Down Expand Up @@ -115,7 +114,7 @@
")\n",
"\n",
"# Image plane simulator\n",
"sim = caustics.Lens_Source(\n",
"sim = caustics.LensSource(\n",
" lens=lens_mass_model,\n",
" lens_light=lens_light_model,\n",
" source=source_light_model,\n",
Expand Down
3 changes: 1 addition & 2 deletions docs/source/examples/Example_QSOLensFit.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,9 @@
"res = 0.05\n",
"upsample_factor = 1\n",
"fov = res * n_pix\n",
"thx, thy = caustics.utils.get_meshgrid(\n",
"thx, thy = caustics.utils.meshgrid(\n",
" res / upsample_factor,\n",
" upsample_factor * n_pix,\n",
" upsample_factor * n_pix,\n",
" dtype=torch.float32,\n",
")\n",
"\n",
Expand Down
4 changes: 2 additions & 2 deletions docs/source/basicindex.rst → docs/source/interfaceindex.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Basic Introduction
==================
The three interfaces to Caustics
================================

There are three user interfaces to Caustics: configuration file, object-oriented, and functional.
Here we have built the same tutorial three times over so you can see how the three interfaces compare.
Expand Down
2 changes: 1 addition & 1 deletion docs/source/intro.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ x = torch.tensor([
5.0, -0.2, 0.0, 0.8, 0.0, 1., 1.0, 10.0
]) # fmt: skip

minisim = caustics.Lens_Source(
minisim = caustics.LensSource(
lens=sie, source=src, lens_light=lnslt, pixelscale=0.05, pixels_x=100
)
plt.imshow(minisim(x, quad_level=3), origin="lower")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Welcome to Caustics! Functional\n",
"# Caustics Interface: Functional\n",
"\n",
"Caustics is a powerful gravitational lensing simulator that can support users from beginner to highly advanced. In this tutorial we will cover the basics of the caustics functional interface. This one is a bit different from the other two since we are building from the ground up."
]
Expand Down Expand Up @@ -59,7 +59,7 @@
"# First lets define the sampling grid\n",
"npix = 100\n",
"pixelscale = 0.05\n",
"thx, thy = caustics.utils.get_meshgrid(pixelscale, npix, npix)\n",
"thx, thy = caustics.utils.meshgrid(pixelscale, npix, npix)\n",
"gqx, gqy, gqW = caustics.utils.gaussian_quadrature_grid(\n",
" pixelscale, thx, thy, quad_level=3\n",
")"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Welcome to Caustics! Object Oriented\n",
"# Caustics Interface: Object Oriented\n",
"\n",
"Caustics is a powerful gravitational lensing simulator that can support users from beginner to highly advanced. In this tutorial we will cover the basics of the caustics object oriented programming interface."
]
Expand Down Expand Up @@ -128,7 +128,7 @@
"metadata": {},
"outputs": [],
"source": [
"sim = caustics.Lens_Source(\n",
"sim = caustics.LensSource(\n",
" lens=sie, source=src, lens_light=lnslt, pixelscale=0.05, pixels_x=100\n",
")"
]
Expand Down Expand Up @@ -244,7 +244,7 @@
"source": [
"### The Simulator Graph\n",
"\n",
"Here we take a quick look at the simulator graph for the image we have produced. You will learn much more about what this means in the `Simulators` tutorial notebook, but let's cover the basics here. First, note that this is a Directed Acyclic Graph (DAG), this is how all simulator parameters are represented in Caustics. At the top of the graph is the `Lens_Source` object, you can see in brackets it has a name `sim` which is used as the identifier for it's node in the graph. At the next level is the `z_s` parameter for the redshift of the source. Next are the `SIE` lens, `Sersic` source, and `Sersic` lenslight objects which themselves each hold parameters. You will notice that all the parameters are in white boxes right now, this is because they are `dynamic` parameters which need values to be passed, grey boxes are used for parameters with fixed values."
"Here we take a quick look at the simulator graph for the image we have produced. You will learn much more about what this means in the `Simulators` tutorial notebook, but let's cover the basics here. First, note that this is a Directed Acyclic Graph (DAG), this is how all simulator parameters are represented in Caustics. At the top of the graph is the `LensSource` object, you can see in brackets it has a name `sim` which is used as the identifier for it's node in the graph. At the next level is the `z_s` parameter for the redshift of the source. Next are the `SIE` lens, `Sersic` source, and `Sersic` lenslight objects which themselves each hold parameters. You will notice that all the parameters are in white boxes right now, this is because they are `dynamic` parameters which need values to be passed, grey boxes are used for parameters with fixed values."
]
},
{
Expand All @@ -254,7 +254,7 @@
"outputs": [],
"source": [
"# Substitute sim with sim for the yaml method\n",
"sim.get_graph(True, True)"
"sim.graph(True, True)"
]
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Welcome to Caustics! YAML\n",
"# Caustics Interface: YAML\n",
"\n",
"Caustics is a powerful gravitational lensing simulator that can support users from beginner to highly advanced. In this tutorial we will cover the basics of the caustics `yaml` interface."
]
Expand Down Expand Up @@ -181,7 +181,7 @@
"source": [
"### The Simulator Graph\n",
"\n",
"Here we take a quick look at the simulator graph for the image we have produced. You will learn much more about what this means in the `Simulators` tutorial notebook, but let's cover the basics here. First, note that this is a Directed Acyclic Graph (DAG), this is how all simulator parameters are represented in Caustics. At the top of the graph is the `Lens_Source` object, you can see in brackets it has a name `sim` which is used as the identifier for it's node in the graph. At the next level is the `z_s` parameter for the redshift of the source. Next are the `SIE` lens, `Sersic` source, and `Sersic` lenslight objects which themselves each hold parameters. You will notice that all the parameters are in white boxes right now, this is because they are `dynamic` parameters which need values to be passed, grey boxes are used for parameters with fixed values."
"Here we take a quick look at the simulator graph for the image we have produced. You will learn much more about what this means in the `Simulators` tutorial notebook, but let's cover the basics here. First, note that this is a Directed Acyclic Graph (DAG), this is how all simulator parameters are represented in Caustics. At the top of the graph is the `LensSource` object, you can see in brackets it has a name `sim` which is used as the identifier for it's node in the graph. At the next level is the `z_s` parameter for the redshift of the source. Next are the `SIE` lens, `Sersic` source, and `Sersic` lenslight objects which themselves each hold parameters. You will notice that all the parameters are in white boxes right now, this is because they are `dynamic` parameters which need values to be passed, grey boxes are used for parameters with fixed values."
]
},
{
Expand All @@ -191,7 +191,7 @@
"outputs": [],
"source": [
"# The simulator is internally represented as a directed acyclic graph of operations\n",
"sim.get_graph(True, True)"
"sim.graph(True, True)"
]
},
{
Expand Down Expand Up @@ -336,7 +336,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"### Lens_Source Simulator\n",
"### LensSource Simulator\n",
"\n",
"Next we pass our configuration to a `Simulator` in caustics, simulators perform the work of forward modelling various configurations and producing the desired outputs. Here we are interested in a common scenario of producing an image of a background source through a lens distribution. It is possible to make your own simulator to represent all sorts of situations. First, we pass the `lens` model and the `source` model defined above. Next we use `pixelscale` and `pixels_x` to define the grid of pixels that will be sampled. Finally, we pass the `z_s` redshift at which the source (`Sersic`) model should be placed; recall that light models don't use the cosmology model and so aren't aware of their placement in space.\n",
"\n",
Expand All @@ -347,7 +347,7 @@
"```yaml\n",
"simulator:\n",
" name: minisim\n",
" kind: Lens_Source\n",
" kind: LensSource\n",
" init_kwargs:\n",
" lens: *lens\n",
" source: *src\n",
Expand All @@ -359,7 +359,7 @@
"In this section:\n",
"- `simulator:` is the key that starts the definition of the simulator.\n",
"- `name: minisim` sets the name of the simulator to 'minisim'.\n",
"- `kind: Lens_Source` sets the kind of the simulator to 'Lens_Source', which indicates that this simulator will simulate a lens and a source.\n",
"- `kind: LensSource` sets the kind of the simulator to 'LensSource', which indicates that this simulator will simulate a lens and a source.\n",
"- `init_kwargs:` is a key for additional parameters required for the simulator.\n",
"- `lens: *lens` sets the lens for the simulator to the lens defined earlier in the YAML file.\n",
"- `source: *src` sets the source for the simulator to the source defined earlier in the YAML file.\n",
Expand All @@ -369,16 +369,14 @@
"\n",
"This section defines the `simulator` that will be used to perform the simulation. It references the lens, source, and lens light definitions from earlier in the YAML file and sets additional parameters for the simulator."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "caustic",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
Expand All @@ -388,7 +386,8 @@
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3"
"pygments_lexer": "ipython3",
"version": "3.9.18"
}
},
"nbformat": 4,
Expand Down
Loading

0 comments on commit d4eff65

Please sign in to comment.