Skip to content

Commit

Permalink
Merge pull request #226 from Ciela-Institute/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
ConnorStoneAstro authored Jun 28, 2024
2 parents 25fd218 + c19621b commit 9b53c57
Show file tree
Hide file tree
Showing 68 changed files with 3,387 additions and 488 deletions.
1 change: 1 addition & 0 deletions .codespell-whitelist
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ sie
childs
dout
din
tht
4 changes: 2 additions & 2 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ jobs:
ls -ltrh
ls -ltrh dist
- name: Publish to Test PyPI
uses: pypa/gh-action-pypi-publish@v1.8.14
uses: pypa/gh-action-pypi-publish@v1.9.0
with:
repository-url: https://test.pypi.org/legacy/
verbose: true
Expand Down Expand Up @@ -95,5 +95,5 @@ jobs:
name: artifact
path: dist

- uses: pypa/gh-action-pypi-publish@v1.8.14
- uses: pypa/gh-action-pypi-publish@v1.9.0
if: startsWith(github.ref, 'refs/tags')
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,7 +9,7 @@ ci:

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

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.1"
rev: "v0.4.10"
hooks:
- id: ruff
args: ["--fix", "--show-fixes"]

- repo: https://github.com/pre-commit/mirrors-mypy
rev: "v1.9.0"
rev: "v1.10.0"
hooks:
- id: mypy
files: src
Expand All @@ -65,16 +66,25 @@ repos:
- pytest

- repo: https://github.com/codespell-project/codespell
rev: "v2.2.6"
rev: "v2.3.0"
hooks:
- 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
2 changes: 1 addition & 1 deletion CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
We as members, contributors, and leaders pledge to make participation in our
community a harassment-free experience for everyone, regardless of age, body
size, visible or invisible disability, ethnicity, sex characteristics, gender
identity and expression, level of experience, education, socio-economic status,
identity and expression, level of experience, education, socioeconomic status,
nationality, personal appearance, race, caste, color, religion, or sexual
identity and orientation.

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
8 changes: 7 additions & 1 deletion docs/source/_toc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@ chapters:
- file: websim
- file: tutorials/index
sections:
- file: tutorials/BasicIntroduction
- file: tutorials/Introduction
- file: interfaceindex
sections:
- file: tutorials/InterfaceIntroduction_yaml
- file: tutorials/InterfaceIntroduction_oop
- file: tutorials/InterfaceIntroduction_func
- file: tutorials/LensZoo
- file: tutorials/VisualizeCaustics
- file: tutorials/MultiplaneDemo
Expand All @@ -23,6 +28,7 @@ chapters:
- file: examples/Example_ImageFit_NUTS
- file: examples/Example_QSOLensFit
- file: contributing
- file: frequently_asked_questions
- file: citation
- file: license
- file: modules
Expand Down
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
10 changes: 10 additions & 0 deletions docs/source/frequently_asked_questions.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FAQs - Frequently asked questions
=================================
| **Q:** How do I know what order to put the parameter values in the pytorch tensor which gets passed to the simulator?
| **A:** If you are using a simulator, then you can get the parameters using ``your_simulator.state_dict()``. The parameters whose values are set dynamically will say "None", while the static parameters will have their values shown. The order of the dynamical parameters corresponds to the order you should use in your parameter value tensor.
|
| **Q:** Why can I put the lens redshift at higher values than the source redshift or to negative values for some parametric models?
| **A:** We can calculate everything for those profiles with reduced deflection angles where the redshifts do not actually play into the calculation. If you use a profile defined by the lens mass, like a NFW lens, or a Multiplane lens then it does matter that the redshifts make sense and you will very likely get errors for those. Similarly, if you call the ``lens.physical_deflection_angle`` you will encounter errors.
|
| **Q:** I do (multiplane-)lensing with pixelated convergence using the pixelated kappa map of a parametric profile. The lensing effect differs from directly using the parametric lens. Why is the lensing effect different?
| **A:** Since you do pixelated convergence your mass is binned in pixels in a finite field of view (FOV) so you are missing some mass. At the limit of infinite resolution and infinite FOV the pixelated profile gives you the parametric profile. If the difference is above your error tolerance then you have to increase the resolution and/or FOV of your pixelated convergence map. Especially for SIE or EPL profiles (which go to infinity density in the center, and have infinite mass outside any FOV) you will miss infinite mass when pixelating.
10 changes: 10 additions & 0 deletions docs/source/interfaceindex.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
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.
They provide progressively more freedom and power, but also require more knowledge of the underlying system.

1. Configuration File: :doc:`tutorials/BasicIntroduction_yaml`
2. Object-Oriented: :doc:`tutorials/BasicIntroduction_oop`
3. Functional: :doc:`tutorials/BasicIntroduction_func`
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
Loading

0 comments on commit 9b53c57

Please sign in to comment.