Skip to content

Commit

Permalink
python >= 3.7, to keep up with NEP29 stack, src/ layout
Browse files Browse the repository at this point in the history
  • Loading branch information
scivision committed Feb 10, 2021
1 parent 283de7c commit b24fbe6
Show file tree
Hide file tree
Showing 21 changed files with 38 additions and 168 deletions.
76 changes: 0 additions & 76 deletions .github/CODE_OF_CONDUCT.md

This file was deleted.

4 changes: 0 additions & 4 deletions .github/FUNDING.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- run: pip install .[tests,lint]

- run: flake8
- run: mypy .
- run: mypy

- run: pytest

Expand Down
3 changes: 2 additions & 1 deletion .mypy.ini
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
[mypy]
files = src/

ignore_missing_imports = True
strict_optional = False
allow_redefinition = True
show_error_context = False
show_column_numbers = True
warn_unreachable = False

[mypy-xarray]
follow_imports = skip
19 changes: 0 additions & 19 deletions archive/.appveyor.yml

This file was deleted.

21 changes: 0 additions & 21 deletions archive/.travis.yml

This file was deleted.

2 changes: 0 additions & 2 deletions pytest.ini

This file was deleted.

16 changes: 9 additions & 7 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = astrometry_azel
version = 1.2.7
version = 1.3.0
author = Michael Hirsch, Ph.D.
author_email = [email protected]
description = Register images to az/el using the astrometry.net program
Expand All @@ -15,18 +15,15 @@ classifiers =
Environment :: Console
Intended Audience :: Science/Research
Operating System :: OS Independent
Programming Language :: Python :: 3.6
Programming Language :: Python :: 3.7
Programming Language :: Python :: 3.8
Programming Language :: Python :: 3.9
Programming Language :: Python :: 3
Topic :: Scientific/Engineering :: Atmospheric Science
license_files =
LICENSE.txt
long_description = file: README.md
long_description_content_type = text/markdown

[options]
python_requires = >= 3.6
python_requires = >= 3.7
include_package_data = True
packages = find:
zip_safe = False
Expand All @@ -35,6 +32,11 @@ install_requires =
numpy
astropy
xarray
package_dir=
=src

[options.packages.find]
where=src

[options.extras_require]
tests =
Expand All @@ -44,7 +46,7 @@ lint =
flake8-bugbear
flake8-builtins
flake8-blind-except
mypy
mypy >= 0.800
all =
scikit-image
scipy
Expand Down
10 changes: 7 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
#!/usr/bin/env python
from setuptools import setup
#!/usr/bin/env python3
import site
import setuptools

setup()
# PEP517 workaround
site.ENABLE_USER_SITE = True

setuptools.setup()
File renamed without changes.
6 changes: 3 additions & 3 deletions astrometry_azel/base.py → src/astrometry_azel/base.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
from __future__ import annotations
from pathlib import Path
import subprocess
import shutil
import logging
import warnings
from dateutil.parser import parse
from datetime import datetime
from typing import Tuple
from numpy import meshgrid, column_stack
import xarray
from astropy.io import fits # instead of obsolete pyfits
Expand Down Expand Up @@ -72,7 +72,7 @@ def fits2radec(


def radec2azel(
scale: xarray.Dataset, latlon: Tuple[float, float], time: datetime
scale: xarray.Dataset, latlon: tuple[float, float], time: datetime
) -> xarray.Dataset:

if pymap3d is None:
Expand Down Expand Up @@ -151,7 +151,7 @@ def fits2azel(
fitsfn: Path,
*,
wcsfn: Path = None,
latlon: Tuple[float, float] = None,
latlon: tuple[float, float] = None,
time: datetime = None,
solve: bool = False,
args: str = None,
Expand Down
37 changes: 11 additions & 26 deletions astrometry_azel/io.py → src/astrometry_azel/io.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,4 @@
#!/usr/bin/env python
"""
Astrometry-azel
Copyright (C) 2013-2018 Michael Hirsch, Ph.D.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
--------------------------------------
Image stack -> average -> write FITS
Expand All @@ -30,9 +12,10 @@
PyFits, AstroPy, or ImageMagick is:
IOError: Header missing END card.
"""

from __future__ import annotations
from pathlib import Path
import numpy as np
from typing import Tuple, Optional
from datetime import datetime
from astropy.io import fits
import logging
Expand All @@ -52,8 +35,8 @@


def meanstack(
infn: Path, Navg: int, ut1: Optional[datetime] = None, method: str = "mean"
) -> Tuple[np.ndarray, Optional[datetime]]:
infn: Path, Navg: int, ut1: datetime = None, method: str = "mean"
) -> tuple[np.ndarray, datetime]:

infn = Path(infn).expanduser().resolve(strict=True)
# %% parse indicies to load
Expand Down Expand Up @@ -94,9 +77,7 @@ def meanstack(
return img, ut1


def _h5mean(
fn: Path, ut1: Optional[datetime], key: slice, method: str
) -> Tuple[np.ndarray, Optional[datetime]]:
def _h5mean(fn: Path, ut1: datetime, key: slice, method: str) -> tuple[np.ndarray, datetime]:
with h5py.File(fn, "r") as f:
img = collapsestack(f["/rawimg"], key, method)
# %% time
Expand Down Expand Up @@ -129,7 +110,11 @@ def collapsestack(img: np.ndarray, key: slice, method: str) -> np.ndarray:
else:
raise TypeError(f"unknown method {method}")

return func(img[key, ...], axis=0).astype(img.dtype)
colaps = func(img[key, ...], axis=0).astype(img.dtype)
assert colaps.ndim > 0
assert isinstance(colaps, np.ndarray)

return colaps


def writefits(img: np.ndarray, outfn: Path):
Expand All @@ -144,7 +129,7 @@ def writefits(img: np.ndarray, outfn: Path):
logging.warning(f"did not overwrite existing {outfn}")


def readh5coord(fn: Path) -> Tuple[float, float]:
def readh5coord(fn: Path) -> tuple[float, float]:
if not fn.suffix == ".h5":
return None

Expand Down
2 changes: 1 addition & 1 deletion astrometry_azel/plots.py → src/astrometry_azel/plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def plotimagestack(img: np.ndarray, fn: Path, clim=None):
try:
hc = fg.colorbar(hi)
hc.set_label(f"Data numbers {img.dtype}")
except Exception as e:
except ValueError as e:
logging.warning(f"trouble making picture colorbar {e}")

plotFN = fn.parent / (fn.stem + "_picture.png")
Expand Down
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions astrometry_azel/utils.py → src/astrometry_azel/utils.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from __future__ import annotations
from datetime import datetime, timedelta
import typing


def datetime_range(start: datetime, stop: datetime, step: timedelta) -> typing.List[datetime]:
def datetime_range(start: datetime, stop: datetime, step: timedelta) -> list[datetime]:

"""
Generate range of datetime
Expand Down
4 changes: 2 additions & 2 deletions astrometry_azel/web.py → src/astrometry_azel/web.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
from __future__ import annotations
from pathlib import Path
import typing
import urllib.request
import urllib.error
import socket


def download(odir: Path, source_url: str, irng: typing.Sequence[int]):
def download(odir: Path, source_url: str, irng: list[int]):
"""Download star index files.
The default range was useful for my cameras.
"""
Expand Down

0 comments on commit b24fbe6

Please sign in to comment.