Skip to content
Open

Dev #267

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
210 commits
Select commit Hold shift + click to select a range
c09b784
spec dependencies python
ConnorStoneAstro Jul 16, 2024
d160b69
Add plotting unit tests
ConnorStoneAstro Jul 16, 2024
ba8613f
Remove parse config in favour of config scripts
ConnorStoneAstro Jul 16, 2024
2599435
Add isophote ellipse tests
ConnorStoneAstro Jul 16, 2024
d868a27
Merge branch 'dev' into scipyspec
ConnorStoneAstro Jul 16, 2024
e34e173
remove config import
ConnorStoneAstro Jul 16, 2024
4e5835e
remove oldlm import
ConnorStoneAstro Jul 16, 2024
d463e31
fix ellip test
ConnorStoneAstro Jul 16, 2024
4f31a01
Merge branch 'dev' into scipyspec
ConnorStoneAstro Aug 7, 2024
00baeb5
Merge branch 'dev' into scipyspec
ConnorStoneAstro Sep 11, 2024
eee6b78
Merge branch 'dev' into scipyspec
ConnorStoneAstro Dec 23, 2024
004a48b
update colormaps
ConnorStoneAstro Dec 26, 2024
c387056
change params passing
ConnorStoneAstro Jan 13, 2025
5f8873d
Fix forced setting of target for group models
ConnorStoneAstro Mar 17, 2025
520eb7a
Merge branch 'main' into dev
ConnorStoneAstro Apr 10, 2025
664c06a
fix: Plot target wasnt working for pure noise image, also added total…
ConnorStoneAstro Apr 10, 2025
a16f975
still moving to caskade
ConnorStoneAstro Apr 15, 2025
9a20d08
working on caskade wcs
ConnorStoneAstro May 22, 2025
916efb2
Image object in semi ready state
ConnorStoneAstro Jun 9, 2025
a630bd9
getting other image types online
ConnorStoneAstro Jun 10, 2025
efa9b2b
getting model sampler online
ConnorStoneAstro Jun 11, 2025
f709246
fill out model template
ConnorStoneAstro Jun 12, 2025
51c6bc9
mixins simplify a lot of model construction
ConnorStoneAstro Jun 13, 2025
657a68d
handle windows, start optimizers
ConnorStoneAstro Jun 13, 2025
870af0f
starting on LM
ConnorStoneAstro Jun 16, 2025
59d759f
basic sample now online for sersic
ConnorStoneAstro Jun 18, 2025
ec6f7cd
working to get LM online
ConnorStoneAstro Jun 18, 2025
578a175
Lm now online
ConnorStoneAstro Jun 19, 2025
79df025
window system online and fitting
ConnorStoneAstro Jun 19, 2025
102c9e1
first tutorial online
ConnorStoneAstro Jun 20, 2025
4229764
PSF models getting online
ConnorStoneAstro Jun 20, 2025
2f6734a
adding models back in
ConnorStoneAstro Jun 21, 2025
de6e6cc
getting all models back online
ConnorStoneAstro Jun 23, 2025
d5c71c4
refine mixins for wedge ray warg etc
ConnorStoneAstro Jun 23, 2025
66d1c23
getting all models to run
ConnorStoneAstro Jun 24, 2025
3b45244
group model starting to come online
ConnorStoneAstro Jun 24, 2025
ef7002d
get group models online
ConnorStoneAstro Jun 25, 2025
13c027b
psf advanced tutorial online
ConnorStoneAstro Jun 25, 2025
24daa07
getting psf convolution settled
ConnorStoneAstro Jun 27, 2025
dbfe1f1
tuning group fitting
ConnorStoneAstro Jun 27, 2025
9e1f920
add ferrer and king profiles
ConnorStoneAstro Jun 27, 2025
ccbc15f
add softening start docstrings
ConnorStoneAstro Jun 27, 2025
f6e51fd
fix softening bug, more robust initialize
ConnorStoneAstro Jul 2, 2025
64517ed
cleanup
ConnorStoneAstro Jul 2, 2025
18bf037
working on joint model tutorial
ConnorStoneAstro Jul 3, 2025
e8534ac
sersic now with logIe
ConnorStoneAstro Jul 3, 2025
e9032f0
valid is the problem for joint models
ConnorStoneAstro Jul 3, 2025
7ab7457
its the valid context
ConnorStoneAstro Jul 4, 2025
e17b501
finally works logit is more stable
ConnorStoneAstro Jul 6, 2025
599f0dd
convert crpix and data to non-params
ConnorStoneAstro Jul 6, 2025
11d6384
starting to add sip
ConnorStoneAstro Jul 7, 2025
7930e65
remove automatic uncertainty better point model
ConnorStoneAstro Jul 8, 2025
c8909a9
deleting unneeded utils files
ConnorStoneAstro Jul 8, 2025
fcdf36e
log space definitions for core models
ConnorStoneAstro Jul 8, 2025
a2b3c6a
SIP target basic functions now run
ConnorStoneAstro Jul 9, 2025
112b22f
sip target now works in fitting
ConnorStoneAstro Jul 10, 2025
c0c668a
add scipy fit update LM
ConnorStoneAstro Jul 10, 2025
83ef9a4
change to coordinate indexing for image data
ConnorStoneAstro Jul 10, 2025
969af31
getting tests online pixelscale to CD
ConnorStoneAstro Jul 11, 2025
110bc73
add gaussian ellipsoid
ConnorStoneAstro Jul 12, 2025
d859480
getting model test to run
ConnorStoneAstro Jul 12, 2025
4abf746
modified ferrer to ferrer and empirical king to king
ConnorStoneAstro Jul 13, 2025
198af2f
test models now runs
ConnorStoneAstro Jul 13, 2025
1946aab
Use valid for intensity rather than overlaod param
ConnorStoneAstro Jul 15, 2025
ead3c20
basis model online with zernike
ConnorStoneAstro Jul 17, 2025
9a0f3de
switch to bright integrate
ConnorStoneAstro Jul 18, 2025
29a174f
all tests now run
ConnorStoneAstro Jul 18, 2025
d589e2a
Merge branch 'dev' into getcaskade
ConnorStoneAstro Jul 18, 2025
c07de9f
fix profile test
ConnorStoneAstro Jul 18, 2025
97d6025
build docstrings for primary models
ConnorStoneAstro Jul 20, 2025
b649b2b
add image alignment tutorial
ConnorStoneAstro Jul 20, 2025
e09ddf8
add gravitational lensing tutorial
ConnorStoneAstro Jul 21, 2025
e2706b1
more stable LM hess fix
ConnorStoneAstro Jul 21, 2025
1490e8d
more unit tests
ConnorStoneAstro Jul 21, 2025
3493239
more fitters tested. Add notebook test
ConnorStoneAstro Jul 21, 2025
802b38d
nbval in correct requirements
ConnorStoneAstro Jul 21, 2025
12e66df
add dev option
ConnorStoneAstro Jul 21, 2025
441b461
add nbconvert package
ConnorStoneAstro Jul 21, 2025
649d012
adding more control and packages for notebooks
ConnorStoneAstro Jul 21, 2025
92ff20c
fitter test errors fixed
ConnorStoneAstro Jul 21, 2025
3a426a8
add emcee requirement for dev
ConnorStoneAstro Jul 21, 2025
10138b0
more test coverage
ConnorStoneAstro Jul 21, 2025
6230a3a
add group model tests
ConnorStoneAstro Jul 21, 2025
a0dde51
better test notebooks
ConnorStoneAstro Jul 21, 2025
b4f1218
fix sip save load, add tests
ConnorStoneAstro Jul 22, 2025
631c73d
add tests
ConnorStoneAstro Jul 22, 2025
9486eae
increase socket timeout to help python 3.11
ConnorStoneAstro Jul 22, 2025
6daa698
more tests for sip
ConnorStoneAstro Jul 22, 2025
0af5903
fix sip image reduce and crop
ConnorStoneAstro Jul 22, 2025
286d271
fix test
ConnorStoneAstro Jul 22, 2025
ab15b71
transposing docs to new astrophot
ConnorStoneAstro Jul 23, 2025
5101c09
change AP_config to just config
ConnorStoneAstro Jul 23, 2025
b804a24
fix notebook test directory
ConnorStoneAstro Jul 23, 2025
1fa7798
now vmap compatible, get MALA online
ConnorStoneAstro Jul 24, 2025
0b3edf8
adjustments to fitters
ConnorStoneAstro Jul 24, 2025
626290f
fix group psf normlaization
ConnorStoneAstro Jul 24, 2025
54bcd00
Merge pull request #265 from Autostronomy/getcaskade
ConnorStoneAstro Jul 24, 2025
4679756
Merge branch 'main' into dev
ConnorStoneAstro Jul 24, 2025
e225e20
remove temp file
ConnorStoneAstro Jul 25, 2025
751690e
automatic sip backwards coefficients
ConnorStoneAstro Jul 25, 2025
94595f7
tweaking LM performance
ConnorStoneAstro Jul 26, 2025
a69d7c7
model test passes now
ConnorStoneAstro Jul 26, 2025
09a340e
add emcee to docs requirements
ConnorStoneAstro Jul 26, 2025
1e2a23b
add new gradient descent optimizer
ConnorStoneAstro Jul 27, 2025
ffc56d2
tweaks to tutorials
ConnorStoneAstro Jul 27, 2025
615b5b9
add cmos image
ConnorStoneAstro Jul 27, 2025
b8c63b6
change threshold to curvature, all go by pixel fraction now
ConnorStoneAstro Jul 27, 2025
df31b5c
clear unused, test module
ConnorStoneAstro Jul 28, 2025
cfc7e8c
Add alternate image types tutorial
ConnorStoneAstro Jul 28, 2025
8731a69
add poisson noise tutorial and lm fitter
ConnorStoneAstro Jul 29, 2025
2a25791
working on docs
ConnorStoneAstro Jul 29, 2025
e35ffed
still working on docs display
ConnorStoneAstro Jul 29, 2025
a381ae8
add all and docstrings
ConnorStoneAstro Jul 30, 2025
e11aab7
improving docstrings
ConnorStoneAstro Jul 30, 2025
3640e4a
more work on docstrings, auto build notebook docs
ConnorStoneAstro Jul 31, 2025
d7c9220
Cleanup docs for fit and plot
ConnorStoneAstro Jul 31, 2025
e01fcfd
fix docs for image objects
ConnorStoneAstro Jul 31, 2025
cfa8c40
fix utils docs
ConnorStoneAstro Jul 31, 2025
f9d0f66
fix util docs
ConnorStoneAstro Jul 31, 2025
3c6b1d0
fix import
ConnorStoneAstro Jul 31, 2025
a59b525
increase download times
ConnorStoneAstro Jul 31, 2025
6d00062
fix minor issues with iter and model_image
ConnorStoneAstro Jul 31, 2025
4996602
change scipy fitting example
ConnorStoneAstro Aug 1, 2025
7f93880
Merge pull request #268 from Autostronomy/getcaskade
ConnorStoneAstro Aug 1, 2025
5599dcd
fix caskade import
ConnorStoneAstro Aug 1, 2025
9b7d77c
remove test cell in getting started tutorial
ConnorStoneAstro Aug 1, 2025
74d25ac
making jax backend for AstroPhot
ConnorStoneAstro Aug 12, 2025
383c311
making more jax backend for AstroPhot
ConnorStoneAstro Aug 13, 2025
b2718d7
first set of backend replacements complete
ConnorStoneAstro Aug 13, 2025
eeffeba
jax working on first tests
ConnorStoneAstro Aug 14, 2025
44ab619
updating unit tests to backend
ConnorStoneAstro Aug 14, 2025
c4497df
now passing plenty of tests
ConnorStoneAstro Aug 14, 2025
c5a92b0
most tests working a few tricky things left
ConnorStoneAstro Aug 15, 2025
ad18c2f
run jax tests in CI
ConnorStoneAstro Aug 17, 2025
1f01200
Get pytorch tests to pass
ConnorStoneAstro Aug 17, 2025
8247609
Bump actions/checkout from 4 to 5
dependabot[bot] Aug 18, 2025
1246882
ensure jax requirement
ConnorStoneAstro Aug 18, 2025
2ec24f5
ensure backend is torch after notebooks
ConnorStoneAstro Aug 18, 2025
7a91434
Merge pull request #273 from Autostronomy/dependabot/github_actions/d…
ConnorStoneAstro Aug 18, 2025
368f3d5
Bump actions/download-artifact from 4 to 5 (#271)
dependabot[bot] Aug 18, 2025
748baf1
skip notebook tests skip random model tests
ConnorStoneAstro Aug 18, 2025
868a0a3
Merge branch 'dev' into jaxbackend
ConnorStoneAstro Aug 18, 2025
04fdb26
better coverage
ConnorStoneAstro Aug 18, 2025
b65bc2a
stronger config based device maangement
ConnorStoneAstro Aug 18, 2025
4c66d51
read the docs now use python 3.12
ConnorStoneAstro Aug 18, 2025
4080894
fixing coverage notebook tests
ConnorStoneAstro Aug 18, 2025
7bfbaec
Merge pull request #272 from Autostronomy/jaxbackend
ConnorStoneAstro Aug 18, 2025
7d335e9
build(deps): bump pypa/gh-action-pypi-publish from 1.12.4 to 1.13.0
dependabot[bot] Sep 8, 2025
6fc57a4
build(deps): bump actions/setup-python from 5 to 6
dependabot[bot] Sep 8, 2025
a011c9f
iter param fitter online
ConnorStoneAstro Sep 16, 2025
9c0ea86
add dynamic params array index function
ConnorStoneAstro Sep 18, 2025
0e1bb4f
quick fix
ConnorStoneAstro Oct 22, 2025
977248a
fix radial median profile
ConnorStoneAstro Oct 23, 2025
1e9f985
remove unneeded comment
ConnorStoneAstro Oct 23, 2025
b08905a
build(deps): bump actions/download-artifact from 5 to 6
dependabot[bot] Oct 27, 2025
8079f93
changing data transpose to be invisible to user
ConnorStoneAstro Oct 29, 2025
0c433d0
Adding deblending and segmentation
ConnorStoneAstro Nov 11, 2025
2dd0b89
add nodejs dependency
ConnorStoneAstro Nov 11, 2025
f72f93f
add npm dependency for jupyter book
ConnorStoneAstro Nov 11, 2025
01bfa22
fix nodejs requirement version
ConnorStoneAstro Nov 11, 2025
5e7fe86
explicit downgrade to jupyter-book version 1
ConnorStoneAstro Nov 11, 2025
5e75b83
simplify deblend data call
ConnorStoneAstro Nov 11, 2025
1de6d4a
Merge pull request #280 from Autostronomy/segmentation
ConnorStoneAstro Nov 11, 2025
ffc7aaf
Merge branch 'dev' into dependabot/github_actions/dev/actions/downloa…
ConnorStoneAstro Nov 11, 2025
c55c3fc
Merge pull request #278 from Autostronomy/dependabot/github_actions/d…
ConnorStoneAstro Nov 11, 2025
abc9610
Merge branch 'dev' into dependabot/github_actions/dev/actions/setup-p…
ConnorStoneAstro Nov 11, 2025
0207d17
Merge pull request #275 from Autostronomy/dependabot/github_actions/d…
ConnorStoneAstro Nov 11, 2025
0aa9591
Merge branch 'dev' into dependabot/github_actions/dev/pypa/gh-action-…
ConnorStoneAstro Nov 11, 2025
2392ee9
build(deps): bump actions/upload-artifact from 4 to 5
dependabot[bot] Nov 11, 2025
d23d605
Merge pull request #274 from Autostronomy/dependabot/github_actions/d…
ConnorStoneAstro Nov 11, 2025
2d53b70
Merge branch 'dev' into dependabot/github_actions/dev/actions/upload-…
ConnorStoneAstro Nov 11, 2025
860f1fc
Merge pull request #279 from Autostronomy/dependabot/github_actions/d…
ConnorStoneAstro Nov 11, 2025
9c07eb0
Made functional fitting tutorial
ConnorStoneAstro Nov 12, 2025
2138ff4
remove unused import
ConnorStoneAstro Nov 12, 2025
9101f81
Merge branch 'dev' into iterlm
ConnorStoneAstro Nov 12, 2025
ea29974
remove has_mask and has_variance, now always have those
ConnorStoneAstro Nov 12, 2025
b74c973
remove unused import
ConnorStoneAstro Nov 12, 2025
454c327
getting most tests to run
ConnorStoneAstro Nov 12, 2025
480f1a5
typo
ConnorStoneAstro Nov 14, 2025
caea6f6
get sip tests working
ConnorStoneAstro Nov 14, 2025
9569aac
add corner dependency for dev version
ConnorStoneAstro Nov 14, 2025
2333d4d
More tests, better coverage for fitters
ConnorStoneAstro Nov 17, 2025
aa5821b
fix test bug
ConnorStoneAstro Nov 17, 2025
d9c7788
more unit tests for better coverage of iterparam
ConnorStoneAstro Nov 17, 2025
772e15b
Merge pull request #282 from Autostronomy/iterlm
ConnorStoneAstro Nov 17, 2025
6c5f778
Merge branch 'dev' into fullfunc
ConnorStoneAstro Nov 17, 2025
9a7bd59
Nicer MALA example in fitting tutorial
ConnorStoneAstro Nov 17, 2025
1d77f4c
mala set params based on best params found
ConnorStoneAstro Nov 17, 2025
ef68821
smaller random number initialization for rng in mala because windows
ConnorStoneAstro Nov 17, 2025
bc80061
fix mala interface in functional example
ConnorStoneAstro Nov 17, 2025
b966913
add func path in fit all
ConnorStoneAstro Nov 17, 2025
767114f
Merge pull request #281 from Autostronomy/fullfunc
ConnorStoneAstro Nov 17, 2025
7ba94f8
Merge branch 'main' into dev
ConnorStoneAstro Nov 18, 2025
3b64d5c
set jax requirement
ConnorStoneAstro Nov 18, 2025
ba6747f
fix gaussian ellipsoid
ConnorStoneAstro Nov 18, 2025
b536fcb
set jax limit in toml file too
ConnorStoneAstro Nov 18, 2025
4585c49
hard fix jax version see if that works
ConnorStoneAstro Nov 18, 2025
7b2665d
my bad
ConnorStoneAstro Nov 18, 2025
fad3feb
set max jax version 0.7.0 as 0.7.2 has breaking change
ConnorStoneAstro Nov 19, 2025
00a3f85
fix segmap auto init
ConnorStoneAstro Nov 19, 2025
507564b
add function to collect legacy survey cutouts
ConnorStoneAstro Nov 19, 2025
ac7b90a
add pyvo requirement
ConnorStoneAstro Nov 19, 2025
743820e
Merge pull request #284 from Autostronomy/devbugs
ConnorStoneAstro Nov 19, 2025
e7c2575
update to new version of caskade
ConnorStoneAstro Dec 2, 2025
e7dfd40
fix is valid test
ConnorStoneAstro Dec 3, 2025
f088b30
handle new caskade static none capability
ConnorStoneAstro Dec 4, 2025
5c75c8f
ensure dynamic for some params
ConnorStoneAstro Dec 4, 2025
551b2ad
updates for caskade v0140
ConnorStoneAstro Dec 5, 2025
91233bc
slight change to fourier ellipse model to align with previous iteration
ConnorStoneAstro Dec 9, 2025
63704d4
build(deps): bump actions/checkout from 5 to 6 (#285)
dependabot[bot] Dec 9, 2025
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
14 changes: 7 additions & 7 deletions .github/workflows/cd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6
with:
fetch-depth: 0

- name: Build sdist and wheel
run: pipx run build

- uses: actions/upload-artifact@v4
- uses: actions/upload-artifact@v5
with:
path: dist

Expand All @@ -45,11 +45,11 @@ jobs:
permissions:
id-token: write
steps:
- uses: actions/setup-python@v5
- uses: actions/setup-python@v6
name: Install Python
with:
python-version: "3.10"
- uses: actions/download-artifact@v4
- uses: actions/download-artifact@v6
with:
name: artifact
path: dist
Expand All @@ -58,7 +58,7 @@ jobs:
ls -ltrh
ls -ltrh dist
- name: Publish to Test PyPI
uses: pypa/gh-action-pypi-publish@v1.12.4
uses: pypa/gh-action-pypi-publish@v1.13.0
with:
repository-url: https://test.pypi.org/legacy/
verbose: true
Expand Down Expand Up @@ -91,10 +91,10 @@ jobs:
if: github.event_name == 'release' && github.event.action == 'published'

steps:
- uses: actions/download-artifact@v4
- uses: actions/download-artifact@v6
with:
name: artifact
path: dist

- uses: pypa/gh-action-pypi-publish@v1.12.4
- uses: pypa/gh-action-pypi-publish@v1.13.0
if: startsWith(github.ref, 'refs/tags')
19 changes: 15 additions & 4 deletions .github/workflows/coverage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
steps:
- uses: actions/checkout@master
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
uses: actions/setup-python@v6
with:
python-version: "3.10"
- name: Record State
Expand All @@ -44,12 +44,23 @@ jobs:
python -m pip install pytest-github-actions-annotate-failures
- name: Install AstroPhot
run: |
pip install -e .
pip install -e ".[dev]"
pip show ${{ env.PROJECT_NAME }}
shell: bash
- name: Test with pytest
- name: Test with pytest [torch]
run: |
pytest -vvv --cov=${{ env.PROJECT_NAME }} --cov-report=xml --cov-report=term tests/
coverage run --source=${{ env.PROJECT_NAME }} -m pytest tests/
shell: bash
env:
CASKADE_BACKEND: torch
- name: Extra coverage report for jax checks
run: |
echo "Running extra coverage report for jax checks"
coverage run --append --source=${{ env.PROJECT_NAME }} -m pytest tests/
shell: bash
env:
JAX_ENABLE_X64: True
CASKADE_BACKEND: jax

- name: Upload coverage reports to Codecov with GitHub Action
uses: codecov/codecov-action@v5
Expand Down
7 changes: 4 additions & 3 deletions .github/workflows/testing.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ jobs:
runs-on: ${{matrix.os}}
strategy:
matrix:
python-version: ["3.9", "3.10"]
python-version: ["3.10", "3.11", "3.12"]
os: [ubuntu-latest, windows-latest, macOS-latest]
steps:
- uses: actions/checkout@master
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}
- name: Record State
Expand All @@ -35,12 +35,13 @@ jobs:
python -m pip install --upgrade pip
pip install pytest
pip install wheel
pip install jax
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
shell: bash
- name: Install AstroPhot
run: |
cd $GITHUB_WORKSPACE/
pip install .
pip install .[dev]
pip show astrophot
shell: bash
- name: Test with pytest
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ tests/*.yaml
docs/source/tutorials/*.fits
docs/source/tutorials/*.yaml
docs/source/tutorials/*.jpg
docs/autophot.*rst
docs/source/astrophotdocs/*.ipynb
docs/modules.rst
pip_cheatsheet.txt
.gitpod.yml
Expand Down
5 changes: 4 additions & 1 deletion .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,14 @@ sphinx:
build:
os: "ubuntu-20.04"
tools:
python: "3.9"
python: "3.12"
apt_packages:
- pandoc # Specify pandoc to be installed via apt-get
- graphviz
jobs:
pre_build:
# Build docstring jupyter notebooks
- "python make_docs.py"
# Generate the Sphinx configuration for this Jupyter Book so it builds.
- "jupyter-book config sphinx docs/source/"
# Create font cache ahead of jupyter book
Expand Down
170 changes: 98 additions & 72 deletions astrophot/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,28 @@
import argparse
import requests
import torch
from .parse_config import galfit_config, basic_config
from . import models, image, plots, utils, fit, param, AP_config
from . import config, models, plots, utils, fit, image, errors
from .param import forward, Param, Module

from .image import (
Image,
ImageList,
TargetImage,
TargetImageList,
SIPModelImage,
SIPTargetImage,
CMOSModelImage,
CMOSTargetImage,
JacobianImage,
JacobianImageList,
PSFImage,
ModelImage,
ModelImageList,
Window,
WindowList,
)
from .models import Model
from .backend_obj import backend, ArrayLike

try:
from ._version import version as VERSION # noqa
Expand All @@ -21,32 +41,10 @@

def run_from_terminal() -> None:
"""
Execute AstroPhot from the command line with various options.

This function uses the `argparse` module to parse command line arguments and execute the appropriate functionality.
It accepts the following arguments:

- `filename`: the path to the configuration file. Or just 'tutorial' to download tutorials.
- `--config`: the type of configuration file being provided. One of: astrophot, galfit.
- `-v`, `--version`: print the current AstroPhot version to screen.
- `--log`: set the log file name for AstroPhot. Use 'none' to suppress the log file.
- `-q`: quiet flag to stop command line output, only print to log file.
- `--dtype`: set the float point precision. Must be one of: float64, float32.
- `--device`: set the device for AstroPhot to use for computations. Must be one of: cpu, gpu.

If the `filename` argument is not provided, it raises a `RuntimeError`.
If the `filename` argument is `tutorial` or `tutorials`,
it downloads tutorials from various URLs and saves them locally.

This function logs messages using the `AP_config` module,
which sets the logging output based on the `--log` and `-q` arguments.
The `dtype` and `device` of AstroPhot can also be set using the `--dtype` and `--device` arguments, respectively.

Returns:
None
Running from terminal no longer supported. This is only used for convenience to download the tutorials.

"""
AP_config.ap_logger.debug("running from the terminal, not sure if it will catch me.")
config.logger.debug("running from the terminal, not sure if it will catch me.")
parser = argparse.ArgumentParser(
prog="astrophot",
description="Fast and flexible astronomical image photometry package. For the documentation go to: https://astrophot.readthedocs.io",
Expand All @@ -58,60 +56,60 @@ def run_from_terminal() -> None:
metavar="configfile",
help="the path to the configuration file. Or just 'tutorial' to download tutorials.",
)
parser.add_argument(
"--config",
type=str,
default="astrophot",
choices=["astrophot", "galfit"],
metavar="format",
help="The type of configuration file being being provided. One of: astrophot, galfit.",
)
# parser.add_argument(
# "--config",
# type=str,
# default="astrophot",
# choices=["astrophot", "galfit"],
# metavar="format",
# help="The type of configuration file being being provided. One of: astrophot, galfit.",
# )
parser.add_argument(
"-v",
"--version",
action="version",
version=f"%(prog)s {__version__}",
help="print the current AstroPhot version to screen",
)
parser.add_argument(
"--log",
type=str,
metavar="logfile.log",
help="set the log file name for AstroPhot. use 'none' to suppress the log file.",
)
parser.add_argument(
"-q",
action="store_true",
help="quiet flag to stop command line output, only print to log file",
)
parser.add_argument(
"--dtype",
type=str,
choices=["float64", "float32"],
metavar="datatype",
help="set the float point precision. Must be one of: float64, float32",
)
parser.add_argument(
"--device",
type=str,
choices=["cpu", "gpu"],
metavar="device",
help="set the device for AstroPhot to use for computations. Must be one of: cpu, gpu",
)
# parser.add_argument(
# "--log",
# type=str,
# metavar="logfile.log",
# help="set the log file name for AstroPhot. use 'none' to suppress the log file.",
# )
# parser.add_argument(
# "-q",
# action="store_true",
# help="quiet flag to stop command line output, only print to log file",
# )
# parser.add_argument(
# "--dtype",
# type=str,
# choices=["float64", "float32"],
# metavar="datatype",
# help="set the float point precision. Must be one of: float64, float32",
# )
# parser.add_argument(
# "--device",
# type=str,
# choices=["cpu", "gpu"],
# metavar="device",
# help="set the device for AstroPhot to use for computations. Must be one of: cpu, gpu",
# )

args = parser.parse_args()

if args.log is not None:
AP_config.set_logging_output(
config.set_logging_output(
stdout=not args.q, filename=None if args.log == "none" else args.log
)
elif args.q:
AP_config.set_logging_output(stdout=not args.q, filename="AstroPhot.log")
config.set_logging_output(stdout=not args.q, filename="AstroPhot.log")

if args.dtype is not None:
AP_config.dtype = torch.float64 if args.dtype == "float64" else torch.float32
config.DTYPE = torch.float64 if args.dtype == "float64" else torch.float32
if args.device is not None:
AP_config.device = "cpu" if args.device == "cpu" else "cuda:0"
config.DEVICE = "cpu" if args.device == "cpu" else "cuda:0"

if args.filename is None:
raise RuntimeError(
Expand All @@ -128,7 +126,6 @@ def run_from_terminal() -> None:
"https://raw.github.com/Autostronomy/AstroPhot/main/docs/source/tutorials/BasicPSFModels.ipynb",
"https://raw.github.com/Autostronomy/AstroPhot/main/docs/source/tutorials/AdvancedPSFModels.ipynb",
"https://raw.github.com/Autostronomy/AstroPhot/main/docs/source/tutorials/ConstrainedModels.ipynb",
"https://raw.github.com/Autostronomy/AstroPhot-tutorials/main/docs/tutorials/simple_config.py",
]
for url in tutorials:
try:
Expand All @@ -140,12 +137,41 @@ def run_from_terminal() -> None:
f"WARNING: couldn't find tutorial: {url[url.rfind('/')+1:]} check internet connection"
)

AP_config.ap_logger.info("collected the tutorials")
elif args.config == "astrophot":
basic_config(args.filename)
elif args.config == "galfit":
galfit_config(args.filename)
config.logger.info("collected the tutorials")
else:
raise ValueError(
f"Unrecognized configuration file format {args.config}. Should be one of: astrophot, galfit"
)
raise ValueError(f"Unrecognized request")


__all__ = (
"models",
"image",
"Model",
"Image",
"ImageList",
"TargetImage",
"TargetImageList",
"SIPModelImage",
"SIPTargetImage",
"CMOSModelImage",
"CMOSTargetImage",
"JacobianImage",
"JacobianImageList",
"PSFImage",
"ModelImage",
"ModelImageList",
"Window",
"WindowList",
"plots",
"utils",
"fit",
"forward",
"Param",
"errors",
"Module",
"config",
"backend",
"run_from_terminal",
"__version__",
"__author__",
"__email__",
)
Loading
Loading