Skip to content

Commit

Permalink
Merge pull request #44 from bourque/package-install
Browse files Browse the repository at this point in the history
Package install
  • Loading branch information
bourque authored Mar 16, 2018
2 parents 9b19a6c + c135267 commit 8c94153
Show file tree
Hide file tree
Showing 9 changed files with 62 additions and 23 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
*.pyc
*.fits
*.ipynb_checkpoints/
utils/config.json
utils/config.json
build/
dist/
jwql.egg-info/
10 changes: 10 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
include README.md
include LICENSE
include environment.yml
include setup.py

recursive-include notebooks *
recursive-include style_guide *
recursive-include typing_demo *

exclude *.pyc
2 changes: 1 addition & 1 deletion environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ channels:
- defaults
- http://ssb.stsci.edu/astroconda-dev
dependencies:
- astropy=2.0.3
- astropy=3.0
- django=1.11.8
- jwst=0.7.8rc9
- matplotlib=2.1.1
Expand Down
Empty file added jwql/__init__.py
Empty file.
Empty file added jwql/preview_image/__init__.py
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
Create a preview image from a fits file containing an observation.
This module creates and saves a "preview image" from a fits file
that contains a JWST observation. Data from the user-supplied
that contains a JWST observation. Data from the user-supplied
`extension` of the file are read in, along with the `PIXELDQ`
extension if present. For each integration in the exposure, the
first group is subtracted from the final group in order to create
a difference image. The lower and upper limits to be displayed are
defined as the `clip_percent` and (1. - `clip_percent') percentile
signals. Matplotlib is then used to display a linear- or log-stretched
version of the image, with accompanying colorbar. The image is then
version of the image, with accompanying colorbar. The image is then
saved.
Authors:
Expand All @@ -24,8 +24,8 @@
This module can be imported as such:
>>> from preview_image import Image
im = Image(my_file, "SCI")
>>> from jwql.preview_image.preview_image import PreviewImage
im = PreviewImage(my_file, "SCI")
im.clip_percent = 0.01
im.scaling = 'log'
im.output_format = 'jpg'
Expand All @@ -42,11 +42,11 @@

from jwst.datamodels import dqflags

class Image():
class PreviewImage():

def __init__(self, filename, extension):
"""Initialize the class.
Parameters
----------
filename : str
Expand All @@ -61,7 +61,7 @@ def __init__(self, filename, extension):

# Read in file
self.data, self.dq = self.get_data(self.file, extension)

def diff_img(self, data):
"""
Create a difference image from the data. Use last
Expand Down Expand Up @@ -92,8 +92,8 @@ def diff_img(self, data):

def find_limits(self, data, pixmap, clipperc):
"""
Find the minimum and maximum signal levels after
clipping the top and bottom x% of the pixels.
Find the minimum and maximum signal levels after
clipping the top and bottom x% of the pixels.
Parameters:
----------
Expand All @@ -102,9 +102,9 @@ def find_limits(self, data, pixmap, clipperc):
pixmap : obj
2D numpy ndarray boolean array of science pixel locations
(True for science pixels, False for non-science pix)
clipperc : float
Fraction of top and bottom signal levels to clip
(e.g. 0.01 means to clip brightest and dimmest 1%
clipperc : float
Fraction of top and bottom signal levels to clip
(e.g. 0.01 means to clip brightest and dimmest 1%
of pixels)
Returns:
Expand Down Expand Up @@ -163,7 +163,7 @@ def get_data(self, filename, ext):
raise FileNotFoundError(("WARNING: {} does not exist!"
.format(filename)))
return data, dq

def make_figure(self, image, integration_number, min_value, max_value,
scale, maxsize = 8):
"""
Expand All @@ -173,7 +173,7 @@ def make_figure(self, image, integration_number, min_value, max_value,
----------
image : obj
2D numpy ndarray of floats
integration_number : int
integration_number : int
Integration number within exposure
min_value : float
Minimum value for display
Expand All @@ -191,7 +191,7 @@ def make_figure(self, image, integration_number, min_value, max_value,
if scale not in ['linear','log']:
raise ValueError(("WARNING: scaling option {} not supported."
.format(scale)))

# Set the figure size
yd, xd = image.shape
ratio = yd / xd
Expand All @@ -202,7 +202,7 @@ def make_figure(self, image, integration_number, min_value, max_value,
ysize = maxsize
xsize = maxsize / ratio
fig, ax = plt.subplots(figsize=(xsize, ysize))

if scale == 'log':
# Shift data so everything is positive
shiftdata = image - min_value + 1
Expand All @@ -213,7 +213,7 @@ def make_figure(self, image, integration_number, min_value, max_value,
cax = ax.imshow(shiftdata,
norm=colors.LogNorm(vmin=shiftmin, vmax=shiftmax),
cmap='gray')

# Add colorbar, with original data values
tickvals = np.logspace(np.log10(shiftmin), np.log10(shiftmax), 5)
tlabelflt = tickvals + min_value - 1
Expand All @@ -228,7 +228,7 @@ def make_figure(self, image, integration_number, min_value, max_value,
cax = ax.imshow(image, clim=(min_value, max_value), cmap='gray')
cbar = fig.colorbar(cax)
ax.set_xlabel('Pixels')
ax.set_ylabel('Pixels')
ax.set_ylabel('Pixels')

ax.set_title(self.file + ' Int: {}'.format(np.int(integration_number)))
return fig
Expand All @@ -246,10 +246,10 @@ def make_image(self):
if ndim == 2:
diff_img = np.expand_dims(diff_img, axis=0)
nint, ny, nx = diff_img.shape

for i in range(nint):
frame = diff_img[i, :, :]

# Find signal limits for the display
minval, maxval = self.find_limits(frame, self.dq,
self.clip_percent)
Expand Down
Empty file added jwql/utils/__init__.py
Empty file.
File renamed without changes.
26 changes: 26 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import numpy as np
from setuptools import setup
from setuptools import find_packages

VERSION = '0.4.0'

AUTHORS = 'Matthew Bourque, Sara Ogaz, Joe Filippazzo, Bryan Hilbert, Misty Cracraft, Graham Kanarek'
AUTHORS += 'Johannes Sahlmann, Lauren Chambers, Catherine Martlin'

REQUIRES = ['astropy', 'django', 'matplotlib', 'numpy', 'python-dateutil', 'sphinx', 'sphinx-automodapi', 'sqlalchemy']

setup(
name = 'jwql',
version = VERSION,
description = 'The JWST Quicklook Project',
url = 'https://github.com/spacetelescope/jwql.git',
author = AUTHORS,
author_email='[email protected]',
license='BSD',
keywords = ['astronomy', 'python'],
classifiers = ['Programming Language :: Python'],
packages = find_packages(),
install_requires = REQUIRES,
include_package_data=True,
include_dirs = [np.get_include()],
)

0 comments on commit 8c94153

Please sign in to comment.