Skip to content

Commit

Permalink
Merge branch 'astropy-conversion-megabranch' into 'master'
Browse files Browse the repository at this point in the history
Convert backend from PyEphem to Astropy

See merge request ska-telescope/katpoint!11
  • Loading branch information
ludwigschwardt committed Oct 2, 2020
2 parents d696dc4 + 6ed4ef4 commit 099af4b
Show file tree
Hide file tree
Showing 49 changed files with 2,942 additions and 3,350 deletions.
32 changes: 16 additions & 16 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,12 @@
*.so
*.so.dSYM

# Packages
*.egg
*.egg-info
dist
# Packages / virtual envs
build
eggs
.eggs
parts
bin
var
sdist
develop-eggs
.installed.cfg
lib
lib64
dist
*.eggs
*.egg-info
.cache
__pycache__

# Installer logs
Expand All @@ -27,11 +18,20 @@ pip-log.txt
# Unit test / coverage reports
.coverage
.tox
nosetests.xml
htmlcov
coverage.xml
.pytest_cache

# Documentation
docs/_build
docs/apidocs

# Developer tools
# Developer tools / IDEs
*~
.ropeproject
.idea
.eclipse
.vscode

# Downloaded AIPS source files
katpoint/test/aips_projection/*.F
Expand Down
71 changes: 71 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
image: nexus.engageska-portugal.pt/ska-docker/ska-python-buildenv:latest

before_script:
- python3 -m pip install -r gitlab-ci-requirements.txt

stages:
- test
- linting
- deploy

test:
stage: test
script:
- pytest --cov katpoint --cov-branch --cov-report term --cov-report html --cov-report xml:./build/reports/code-coverage.xml --junitxml=./build/reports/unit-tests.xml
artifacts:
paths:
- ./build
- htmlcov

list_dependencies:
stage: test
script:
- pipdeptree --json >> pip_deps.json
- pipdeptree >> pip_deps.txt
- dpkg -l >> system_deps.txt
- awk 'FNR>5 {print $2 ", " $3}' system_deps.txt >> system_deps.csv
- mkdir .public
- cp pip_deps.txt .public/
- cp pip_deps.json .public/
- cp system_deps.txt .public/
- cp system_deps.csv .public/
- mv .public public
artifacts:
paths:
- public

linting:
stage: linting
script:
- pylint --exit-zero --output-format=pylint_junit.JUnitReporter katpoint > ./build/reports/linting.xml
- pylint --exit-zero --output-format=parseable katpoint
when: always
artifacts:
paths:
- ./build

pages:
stage: deploy
dependencies:
- test
script:
- ls -la
- mkdir .public
- cp -r htmlcov/* .public
- rm -rf htmlcov
- mv .public public
artifacts:
paths:
- public
expire_in: 30 days

create ci metrics:
stage: .post
when: always
script:
# Gitlab CI badges creation: START
- curl -s https://gitlab.com/ska-telescope/ci-metrics-utilities/raw/master/scripts/ci-badges-func.sh | sh
# Gitlab CI badges creation: END
artifacts:
paths:
- ./build
2 changes: 1 addition & 1 deletion LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2009-2019, National Research Foundation (Square Kilometre Array)
Copyright (c) 2009-2020, National Research Foundation (SARAO)
All rights reserved.

Redistribution and use in source and binary forms, with or without modification,
Expand Down
18 changes: 18 additions & 0 deletions gitlab-ci-requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
astropy>=4.1rc1
docutils
markupsafe
numpy
pipdeptree
pygments
pylint
pylint-junit
pytest
pytest-cov
pytest-pylint
python-dotenv>=0.5.1
setuptools
sgp4>=2.7
sphinx
sphinx-autobuild
sphinx-rtd-theme
sphinxcontrib-websupport
24 changes: 11 additions & 13 deletions katpoint/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,16 @@
and CASA.
"""
from __future__ import print_function, division, absolute_import

import logging as _logging
import warnings as _warnings

import future.utils
import numpy as _np

from .target import Target, construct_azel_target, construct_radec_target, NonAsciiError
from .antenna import Antenna
from .timestamp import Timestamp
from .flux import FluxDensityModel, FluxError
from .catalogue import Catalogue, specials
from .ephem_extra import lightspeed, rad2deg, deg2rad, wrap_angle, is_iterable
from .conversion import (lla_to_ecef, ecef_to_lla, enu_to_ecef, ecef_to_enu,
azel_to_enu, enu_to_azel, hadec_to_enu, enu_to_xyz)
from .projection import sphere_to_plane, plane_to_sphere
Expand All @@ -46,6 +43,15 @@
from .refraction import RefractionCorrection
from .delay import DelayModel, DelayCorrection


def wrap_angle(angle, period=2.0 * _np.pi):
"""Wrap angle into interval centred on zero.
This wraps the *angle* into the interval -*period* / 2 ... *period* / 2.
"""
return (angle + 0.5 * period) % period - 0.5 * period


# Hide submodules in module namespace, to avoid confusion with corresponding class names
# If the module is reloaded, this will fail - ignore the resulting NameError
try:
Expand All @@ -62,6 +68,7 @@
# Setup library logger and add a print-like handler used when no logging is configured
class _NoConfigFilter(_logging.Filter):
"""Filter which only allows event if top-level logging is not configured."""

def filter(self, record):
return 1 if not _logging.root.handlers else 0

Expand All @@ -72,14 +79,6 @@ def filter(self, record):
logger = _logging.getLogger(__name__)
logger.addHandler(_no_config_handler)

if future.utils.PY2:
_PY2_WARNING = (
"Python 2 has reached End-of-Life, and a future version of katpoint "
"will remove support for it. Please update your scripts to Python 3 "
"as soon as possible."
)
_warnings.warn(_PY2_WARNING, FutureWarning)

# BEGIN VERSION CHECK
# Get package version when locally imported from repo or via -e develop install
try:
Expand All @@ -90,4 +89,3 @@ def filter(self, record):
else:
__version__ = _katversion.get_version(__path__[0])
# END VERSION CHECK

Loading

0 comments on commit 099af4b

Please sign in to comment.