Skip to content

Commit

Permalink
more style clean-up
Browse files Browse the repository at this point in the history
  • Loading branch information
weaverba137 committed Dec 16, 2023
1 parent 3fffc03 commit 2c91979
Show file tree
Hide file tree
Showing 29 changed files with 290 additions and 314 deletions.
38 changes: 14 additions & 24 deletions pydl/__init__.py
Expand Up @@ -12,25 +12,13 @@
.. _`IDL®`: https://www.nv5geospatialsoftware.com/Products/IDL
"""
import os
from astropy.tests.runner import TestRunner

# Packages may add whatever they like to this file, but
# should keep this content at the top.
# ----------------------------------------------------------------------------
from ._astropy_init import * # noqa
# ----------------------------------------------------------------------------

# Enforce Python version check during package import.
# This is the same check as the one at the top of setup.py
import sys

__minimum_python_version__ = "3.5"

class UnsupportedPythonError(Exception):
pass

if sys.version_info < tuple((int(val) for val in __minimum_python_version__.split('.'))):
raise UnsupportedPythonError("packagename does not support Python < {}".format(__minimum_python_version__))

try:
from .version import version as __version__
except ImportError:
__version__ = ''

from .file_lines import file_lines
from .median import median
Expand All @@ -40,18 +28,20 @@ class UnsupportedPythonError(Exception):
from .uniq import uniq


# Workaround: Numpy 1.14.x changes the way arrays are printed.
# try:
# from numpy import set_printoptions
# set_printoptions(legacy='1.13')
# except Exception:
# pass
# Create the test function for self test
test = TestRunner.make_test_runner_in(os.path.dirname(__file__))
test.__test__ = False


class PydlException(Exception):
"""Base class for exceptions raised in PyDL functions.
"""
pass


__all__ = ['file_lines', 'median', 'pcomp', 'rebin', 'smooth', 'uniq',
'PydlException']

# Clean up namespace
del os
del TestRunner
13 changes: 0 additions & 13 deletions pydl/_astropy_init.py

This file was deleted.

2 changes: 1 addition & 1 deletion pydl/goddard/astro.py
Expand Up @@ -110,7 +110,7 @@ def gcirc(ra1, dec1, ra2, dec2, units=2):
deldec2 = (dcrad2-dcrad1)/2.0
delra2 = (rarad2-rarad1)/2.0
sindis = np.sqrt(np.sin(deldec2)*np.sin(deldec2) +
np.cos(dcrad1)*np.cos(dcrad2)*np.sin(delra2)*np.sin(delra2))
np.cos(dcrad1)*np.cos(dcrad2)*np.sin(delra2)*np.sin(delra2))
dis = 2.0*np.arcsin(sindis)
if units == 0:
return dis
Expand Down
28 changes: 12 additions & 16 deletions pydl/photoop/sdssio.py
Expand Up @@ -31,8 +31,7 @@
'reObjGlobal': "{ftype}-{run:06d}-{camcol:1d}-{field:04d}.fits",
'reObjRun': "{ftype}-{run:06d}-{camcol:1d}-{field:04d}.fits",
'reObjTmp': "{ftype}-{run:06d}-{camcol:1d}-{field:04d}.fits",
'tsField': "{ftype}-{run:06d}-{camcol:1d}-{rerun}-{field:04d}.fit",
}
'tsField': "{ftype}-{run:06d}-{camcol:1d}-{rerun}-{field:04d}.fit"}


_path_formats = {
Expand All @@ -57,8 +56,7 @@
'reObjGlobal': "{resolve}/{rerun}/{run:d}/resolve/{camcol:1d}",
'reObjRun': "{redux}/{rerun}/{run:d}/resolve/{camcol:1d}",
'reObjTmp': "{resolve}/{rerun}/{run:d}/resolve/{camcol:1d}",
'tsField': "{redux}/{rerun}/{run:d}/calibChunks/{camcol:1d}",
}
'tsField': "{redux}/{rerun}/{run:d}/calibChunks/{camcol:1d}"}


def filtername(f):
Expand Down Expand Up @@ -219,18 +217,16 @@ def sdss_path(ftype, run, camcol=0, rerun=''):
If the file type is unknown.
"""
indict = {
'run': run,
'camcol': camcol,
'rerun': rerun,
'calib': os.getenv('PHOTO_CALIB'),
'data': os.getenv('PHOTO_DATA'),
'photoobj': os.getenv('BOSS_PHOTOOBJ'),
'redux': os.getenv('PHOTO_REDUX'),
'resolve': os.getenv('PHOTO_RESOLVE'),
'sky': os.getenv('PHOTO_SKY'),
'sweep': os.getenv('PHOTO_SWEEP'),
}
indict = {'run': run,
'camcol': camcol,
'rerun': rerun,
'calib': os.getenv('PHOTO_CALIB'),
'data': os.getenv('PHOTO_DATA'),
'photoobj': os.getenv('BOSS_PHOTOOBJ'),
'redux': os.getenv('PHOTO_REDUX'),
'resolve': os.getenv('PHOTO_RESOLVE'),
'sky': os.getenv('PHOTO_SKY'),
'sweep': os.getenv('PHOTO_SWEEP')}
try:
datadir = _path_formats[ftype].format(**indict)
except KeyError:
Expand Down
10 changes: 4 additions & 6 deletions pydl/photoop/tests/test_sdssio.py
Expand Up @@ -31,8 +31,7 @@
'reObjGlobal': "/PHOTO_RESOLVE/301/137/resolve/4",
'reObjRun': "/PHOTO_REDUX/301/137/resolve/4",
'reObjTmp': "/PHOTO_RESOLVE/301/137/resolve/4",
'tsField': "/PHOTO_REDUX/301/137/calibChunks/4",
}
'tsField': "/PHOTO_REDUX/301/137/calibChunks/4"}


name_data = {
Expand All @@ -57,8 +56,7 @@
'reObjGlobal': "reObjGlobal-000137-4-0042.fits",
'reObjRun': "reObjRun-000137-4-0042.fits",
'reObjTmp': "reObjTmp-000137-4-0042.fits",
'tsField': "tsField-000137-4-301-0042.fit",
}
'tsField': "tsField-000137-4-301-0042.fit"}


@pytest.fixture
Expand Down Expand Up @@ -109,7 +107,7 @@ def test_sdss_name(sdss_env):
# Bad ftype
#
with pytest.raises(KeyError):
p = sdss_name('fooBar', 137, 4, 42)
_ = sdss_name('fooBar', 137, 4, 42)
for ftype in name_data:
assert sdss_name(ftype, 137, 4, 42, '301', 'r',
no_path=True) == name_data[ftype]
Expand All @@ -131,7 +129,7 @@ def test_sdss_name_reObj(sdss_env):

def test_sdss_path(sdss_env):
with pytest.raises(KeyError):
p = sdss_path('fooBar', 137)
_ = sdss_path('fooBar', 137)
for ftype in path_data:
assert sdss_path(ftype, 137, 4, '301') == path_data[ftype]

Expand Down
4 changes: 3 additions & 1 deletion pydl/photoop/tests/test_window.py
Expand Up @@ -6,7 +6,7 @@
import pytest
import numpy as np
from .. import PhotoopException
from ..window import sdss_score, window_read, window_score
from ..window import window_read, window_score
from ...pydlutils.mangle import FITS_polygon


Expand All @@ -32,9 +32,11 @@ def fits_open(request):
def table_read(request):
data_size = 10
m = request.getfixturevalue("mocker")

class fake_table(dict):
def __len__(self):
return data_size

hh = fake_table()
hh['SCORE'] = np.zeros((data_size,), dtype=np.int16)
hh['IPRIMARY'] = np.zeros((data_size,), dtype=np.int16)
Expand Down
17 changes: 11 additions & 6 deletions pydl/photoop/window.py
Expand Up @@ -12,13 +12,15 @@
from astropy.table import Table
from . import PhotoopException
from .sdssio import sdss_name, sdss_calib
from ..pydlutils.mangle import FITS_polygon #, PolygonList, ManglePolygon, set_use_caps
from ..pydlutils.mangle import FITS_polygon
from ..pydlutils.sdss import sdss_flagval


def sdss_score(flist, silent=True):
def sdss_score(flist, silent=True, **kwargs):
"""Score a list of imaging fields from zero to one.
Additional keyword arguments are passed to :func:`~pydl.photoop.sdssio.sdss_calib`.
Parameters
----------
flist : :class:`~astropy.io.fits.HDUList`
Expand All @@ -31,10 +33,13 @@ def sdss_score(flist, silent=True):
:class:`numpy.ndarray`
A vector of scores, one for each row of the FITS file.
"""
lat = 32.780361
lng = 360.0 - 105.820417
tzone = 7
scores = 1
#
# Not sure why these were defined.
#
# lat = 32.780361
# lng = 360.0 - 105.820417
# tzone = 7
# scores = 1
#
# Read the PHOTO status bits
#
Expand Down

0 comments on commit 2c91979

Please sign in to comment.