Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated imports and use of datamodels #7

Merged
merged 2 commits into from
Jun 9, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions jwst/background/background_step.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#! /usr/bin/env python

from jwst.stpipe import Step
from jwst import datamodels
from .. import datamodels
from . import background_sub

class BackgroundStep(Step):
Expand Down Expand Up @@ -35,7 +35,7 @@ def process(self, input, bkg_list):
"""

# Load the input data model
with models.open(input) as input_model:
with datamodels.open(input) as input_model:

# Do the background subtraction
result = background_sub.background_sub(input_model, bkg_list)
Expand Down
6 changes: 3 additions & 3 deletions jwst/background/background_sub.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from __future__ import division

from jwst import datamodels
from .. import datamodels
from . import subtract_images

import numpy as np
Expand Down Expand Up @@ -71,11 +71,11 @@ def average_background(bkg_list):
# Loop over the images to be used as background
for bkg_file in bkg_list:
log.debug(' Accumulate bkg from %s', bkg_file)
bkg_model = models.ImageModel(bkg_file)
bkg_model = datamodels.ImageModel(bkg_file)

# Initialize the avg_bkg model, if necessary
if avg_bkg is None:
avg_bkg = models.ImageModel(bkg_model.data.shape)
avg_bkg = datamodels.ImageModel(bkg_model.data.shape)

# Accumulate the data from this background image
avg_bkg.data += bkg_model.data
Expand Down
2 changes: 1 addition & 1 deletion jwst/background/subtract_images.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from __future__ import division

from jwst import datamodels
from .. import datamodels
import numpy as np

import logging
Expand Down
20 changes: 10 additions & 10 deletions jwst/background/subtract_images_step.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#! /usr/bin/env python

from jwst.stpipe import Step
from jwst import datamodels
from .. import datamodels
from jwst.background import subtract_images

class SubtractImagesStep(Step):
Expand Down Expand Up @@ -36,25 +36,25 @@ def process(self, input1, input2):
"""

# First, determine what kind of input model has been provided
model1 = models.open(input1)
model1 = datamodels.open(input1)

if isinstance(model1, models.CubeModel):
if isinstance(model1, datamodels.CubeModel):
self.log.debug('Input is a CubeModel')
model1.close()
model1 = models.CubeModel(input1)
elif isinstance(model1, models.ImageModel):
model1 = datamodels.CubeModel(input1)
elif isinstance(model1, datamodels.ImageModel):
self.log.debug('Input is an ImageModel')
model1.close()
model1 = models.ImageModel(input1)
elif isinstance(model1, models.DataModel):
model1 = datamodels.ImageModel(input1)
elif isinstance(model1, datamodels.DataModel):
self.log.debug('Input is a MultiSlitModel')
model1.close()
model1 = models.MultiSlitModel(input1)
model1 = datamodels.MultiSlitModel(input1)

# Assume that the second input model is always Image or MultiSlit with
# a single image, which is safe to open as MultiSlit for either case
#model2 = models.MultiSlitModel(input2)
model2 = models.ImageModel(input2)
#model2 = datamodels.MultiSlitModel(input2)
model2 = datamodels.ImageModel(input2)

# Call the subtraction routine
result = subtract_images.subtract(model1, model2)
Expand Down