Skip to content

Commit

Permalink
Merge pull request #21 from Autostronomy/versionreqs
Browse files Browse the repository at this point in the history
Refactor for better version control
  • Loading branch information
ConnorStoneAstro authored Aug 15, 2024
2 parents 4e11bbe + 66580fc commit 82035d3
Show file tree
Hide file tree
Showing 18 changed files with 565 additions and 93 deletions.
100 changes: 100 additions & 0 deletions .github/workflows/cd.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
name: CD

on:
workflow_dispatch:
push:
branches:
- main
- dev
release:
types:
- published

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

env:
FORCE_COLOR: 3

jobs:
dist:
name: Distribution build
runs-on: ubuntu-latest

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

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

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

- name: Check products
run: pipx run twine check dist/*

test-built-dist:
needs: [dist]
name: Test built distribution
runs-on: ubuntu-latest
environment: deploy-testpypi
permissions:
id-token: write
steps:
- uses: actions/setup-python@v5
name: Install Python
with:
python-version: "3.10"
- uses: actions/download-artifact@v4
with:
name: artifact
path: dist
- name: List contents of built dist
run: |
ls -ltrh
ls -ltrh dist
- name: Publish to Test PyPI
uses: pypa/gh-action-pypi-publish@v1.9.0
with:
repository-url: https://test.pypi.org/legacy/
verbose: true
skip-existing: true
- name: Check test pypi packages
run: |
sleep 3
python -m pip install --upgrade pip
echo "=== Testing wheel file ==="
# Install wheel to get dependencies and check import
python -m pip install --extra-index-url https://test.pypi.org/simple --upgrade --pre autoprof
python -c "import autoprof; print(autoprof.__version__)"
echo "=== Done testing wheel file ==="
echo "=== Testing source tar file ==="
# Install tar gz and check import
python -m pip uninstall --yes autoprof
python -m pip install --extra-index-url https://test.pypi.org/simple --upgrade --pre --no-binary=:all: autoprof
python -c "import autoprof; print(autoprof.__version__)"
echo "=== Done testing source tar file ==="
publish:
needs: [dist, test-built-dist]
name: Publish to PyPI
environment: deploy-pypi
permissions:
id-token: write
runs-on: ubuntu-latest
if: github.event_name == 'release' && github.event.action == 'published'

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

- uses: pypa/gh-action-pypi-publish@v1.9.0
if: startsWith(github.ref, 'refs/tags')
51 changes: 51 additions & 0 deletions .github/workflows/testing.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Unit Tests

on:
push:
branches:
- main
pull_request:
branches:
- main
- dev
workflow_dispatch:

jobs:
build:
runs-on: ${{matrix.os}}
strategy:
matrix:
python-version: ["3.9", "3.10", "3.11"]
os: [ubuntu-latest, windows-latest, macOS-latest]
steps:
- uses: actions/checkout@master
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Record State
run: |
pwd
echo github.ref is: ${{ github.ref }}
echo GITHUB_SHA is: $GITHUB_SHA
echo github.event_name is: ${{ github.event_name }}
pip --version
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pytest
pip install wheel
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
shell: bash
- name: Install AutoProf
run: |
cd $GITHUB_WORKSPACE/
pip install .
pip show AutoProf
shell: bash
- name: Test with pytest
run: |
cd $GITHUB_WORKSPACE/tests/
pwd
pytest -s
shell: bash
16 changes: 13 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,25 @@ and [Jean-Charles Cuillandre](https://www.cfht.hawaii.edu/~jcc/).
pip install autoprof
```

Please use python version 3.9 or greater.

# Documentation

See our [documentation](https://autoprof.readthedocs.io/en/latest/) for a full description of AutoProf's capabilities
See our [documentation](https://autoprof.readthedocs.io) for a full description
of AutoProf's capabilities

# Citation

Please see the [ADS Bibliographic Record](https://ui.adsabs.harvard.edu/abs/2021MNRAS.508.1870S/abstract) of the AutoProf paper for proper citation.
Please see the [ADS Bibliographic
Record](https://ui.adsabs.harvard.edu/abs/2021MNRAS.508.1870S/abstract) of the
AutoProf paper for proper citation.

# Notice

This is the AutoProf isophotal code, it works great in its domain which is wherever one would use isophotal fitting. Thus it is suitable for mostly isolated, mostly resolved, objects. If you are limited by the PSF, crowding, or want to model multi-band/epoch data you may want to consider "AstroPhot" a full forward modelling code. Just [follow this link](https://github.com/Autostronomy/AstroPhot) to check it out!
This is the AutoProf isophotal code, it works great in its domain which is
wherever one would use isophotal fitting. Thus it is suitable for mostly
isolated, mostly resolved, objects. If you are limited by the PSF, crowding, or
want to model multi-band/epoch data you may want to consider "AstroPhot" a full
forward modelling code. Just [follow this
link](https://github.com/Autostronomy/AstroPhot) to check it out!

14 changes: 13 additions & 1 deletion autoprof/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,16 @@

from . import autoprofutils, Pipeline, pipeline_steps

__version__ = "1.2.1"
try:
from ._version import version as __version__ # noqa
except ModuleNotFoundError:
__version__ = "0.0.0"
import warnings

warnings.warn(
"WARNING: AutoProf version number not found. This is likely because you are running Autoprof from a source directory."
)

__author__ = "Connor Stone"
__email__ = "connorstone628@gmail.com"

Expand All @@ -16,6 +25,9 @@ def run_from_terminal():

config_file = sys.argv[1]

if config_file.strip().lower() == "--version":
print(__version__)
return
try:
if ".log" == sys.argv[2][-4:]:
logfile = sys.argv[2]
Expand Down
20 changes: 3 additions & 17 deletions autoprof/autoprofutils/Diagnostic_Plots.py
Original file line number Diff line number Diff line change
@@ -1,31 +1,18 @@
import numpy as np
from astropy.visualization import SqrtStretch, LogStretch
from astropy.visualization import LogStretch
from astropy.visualization.mpl_normalize import ImageNormalize
import matplotlib.pyplot as plt
from matplotlib.patches import Ellipse, Wedge
import matplotlib.cm as cm
import matplotlib
from itertools import compress
import sys
import os

from .SharedFunctions import (
_x_to_pa,
_x_to_eps,
_inv_x_to_eps,
_inv_x_to_pa,
LSBImage,
AddScale,
AddLogo,
_average,
_scatter,
flux_to_sb,
flux_to_mag,
PA_shift_convention,
autocolours,
autocmap,
fluxdens_to_fluxsum_errorprop,
mag_to_flux,
parametric_SuperEllipse,
Rotate_Cartesian,
)
Expand Down Expand Up @@ -647,7 +634,7 @@ def Plot_Radial_Profiles(dat, R, sb, sbE, pa, nwedges, wedgeangles, wedgewidth,
],
]

cmap = cm.get_cmap("hsv")
cmap = matplotlib.colormaps["hsv"]
colorind = (np.linspace(0, 1 - 1 / nwedges, nwedges) + 0.1) % 1.0
for sa_i in range(len(wedgeangles)):
CHOOSE = np.logical_and(np.array(sb[sa_i]) < 99, np.array(sbE[sa_i]) < 1)
Expand Down Expand Up @@ -767,7 +754,6 @@ def Plot_Axial_Profiles(dat, R, sb, sbE, pa, results, options):
for rd in [1, -1]:
for ang in [1, -1]:
key = (rd, ang)
# cmap = matplotlib.cm.get_cmap('viridis_r')
norm = matplotlib.colors.Normalize(vmin=0, vmax=R[-1] * options["ap_pixscale"])
for pi, pR in enumerate(R):
if pi % 3 != 0:
Expand Down Expand Up @@ -858,7 +844,7 @@ def Plot_Axial_Profiles(dat, R, sb, sbE, pa, results, options):
)
AddScale(plt.gca(), (ranges[0][1] - ranges[0][0]) * options["ap_pixscale"])
count = 0
cmap = matplotlib.cm.get_cmap("hsv")
cmap = matplotlib.colormaps["hsv"]
colorind = (np.linspace(0, 1 - 1 / 4, 4) + 0.1) % 1
colours = list(cmap(c) for c in colorind)
for rd in [1, -1]:
Expand Down
7 changes: 4 additions & 3 deletions docs/getting_started.rst
Original file line number Diff line number Diff line change
Expand Up @@ -136,14 +136,14 @@ Here is the forced photometry file just make sure to save it as a ``.py`` file::

ap_process_mode = "forced image"
ap_image_file = "test_ESO479-G1_r.fits"
ap_image_file = "ESO479-G1_r.fits"
ap_name = "testforcedimage"
ap_pixscale = 0.262
ap_doplot = True
ap_isoclip = True
ap_forcing_profile = "testimage.prof"


To try out this pipeline, download the `test file <https://github.com/Autostronomy/AutoProf/raw/main/tests/ESO479-G1_r.fits>`_.

Batch Forced Photometry
-----------------------
Expand All @@ -162,7 +162,7 @@ It's possible to incorporate descision trees into the AutoProf pipeline. This is

ap_process_mode = "image"

ap_image_file = "test_ESO479-G1_r.fits"
ap_image_file = "ESO479-G1_r.fits"
ap_pixscale = 0.262
ap_name = "testtreeimage"
ap_doplot = True
Expand Down Expand Up @@ -251,3 +251,4 @@ It's possible to incorporate descision trees into the AutoProf pipeline. This is
],
}

To try out this pipeline, download the `test file <https://github.com/Autostronomy/AutoProf/raw/main/tests/ESO479-G1_r.fits>`_.
Loading

0 comments on commit 82035d3

Please sign in to comment.