forked from spacetelescope/jwst
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cube build stage3 - JP-2096 (spacetelescope#6093)
* updates using numba jit * flake 8 fixes * a few numba updates * updates to support internal_cal and numba * fix test - removing unused resolution file * improved blotting speed using numba * added c code for emsm * fixed setup.py to compile match_det_cube * updates to c code * some changes to c python interface * more fixes to c code * added cube_match_internal and pulled common c routines to cube_utils.c * Clean up * remove cube_cloud.py * added weighting=msm as possibility for c extension cube weighting * removed declaration of numba from routine * fix typo * flake8 fix * remove printf from c code * remove print in ifu_cube.py * typo in cube_match_sky.c * changes after review * fix alloc arrays def * Updated change log * remove print statement
- Loading branch information
1 parent
dc266b1
commit d38a0a7
Showing
16 changed files
with
2,661 additions
and
2,116 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
""" Map the detector pixels to the cube coordinate system. | ||
This is where the weight functions are used. | ||
""" | ||
import numpy as np | ||
import logging | ||
log = logging.getLogger(__name__) | ||
log.setLevel(logging.DEBUG) | ||
|
||
|
||
def blot_overlap(ipt, xstart, | ||
xcenter, ycenter, | ||
x_cube, y_cube, | ||
flux_cube, | ||
blot_xsize, | ||
blot_flux, blot_weight): | ||
|
||
""" Blot the median sky image back to the detector | ||
ipt is the median element. | ||
xcenter, ycenter are the detector pixel arrays | ||
xstart is only valid for MIRI and is the start of the x detector value for channel | ||
0 for channels on left and ~512 for channels on right | ||
x_cube, y_cube: median cube IFU mapped backwards to detector | ||
flux_cube: median flux | ||
blot_flux & blot_weight: blotted values of flux_cube to detector | ||
""" | ||
|
||
roi_det = 1.0 # Just large enough that we don't get holes | ||
xdistance = np.absolute(x_cube[ipt] - xcenter) | ||
ydistance = np.absolute(y_cube[ipt] - ycenter) | ||
|
||
index_x = np.where(xdistance <= roi_det) | ||
index_y = np.where(ydistance <= roi_det) | ||
|
||
if len(index_x[0]) > 0 and len(index_y[0]) > 0: | ||
|
||
d1pix = x_cube[ipt] - xcenter[index_x] | ||
d2pix = y_cube[ipt] - ycenter[index_y] | ||
|
||
dxy = [(dx * dx + dy * dy) for dy in d2pix for dx in d1pix] | ||
dxy = np.array(dxy) | ||
dxy = np.sqrt(dxy) | ||
weight_distance = np.exp(-dxy) | ||
weighted_flux = weight_distance * flux_cube[ipt] | ||
|
||
index2d = [iy * blot_xsize + ix for iy in index_y[0] for ix in (index_x[0] + xstart)] | ||
index2d = np.array(index2d) | ||
|
||
blot_flux[index2d] = blot_flux[index2d] + weighted_flux | ||
blot_weight[index2d] = blot_weight[index2d] + weight_distance |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.