-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Fix a bug in buildFileListOrig causing crash when updatewcs=True (#1549) * Exception error now reported to include the name of the file being (#1552) processed (e.g., ERROR: Cannot run astrodrizzle on runastrodriz -m -i u482c701r_d0m.fits). * test against pre-built binaries of numpy (#1553) * Protect against using compute_sregion for no valid images (#1547) * Ensure the software does not execute compute_sregion() if no valid images are found for processing and AstroDrizzle is exiting. * Added a note to the buildEmptyDRZ to explain further the need for this empty (only header keywords, no data components) file. Fixed a typo, and changed the filename variable used when computing the sregion. * Added info to CHANGELOG. * Unit test for point kernel (#1542) * Added fixture for test_drizzle and point kernel test I've added a fixture to used for test_zero_input_weight and now a new test called test_point_kernel. I use the same pytest.mark.parameterize kernel parameters (for now). * Working tests using the Get_Grid Class and appropriate dny * Small text changes * Added csv truth files. * Added three additional tests for edge cases. * Added now with the changes made to the test. * Small comment/text change. * New test_setup.py file with Get_Grid Moved truth files to "truth_files" directory. test_drizzle.py is now test_kernel and I've added a new test_cdriz that uses the same test_setup.py. * Added test_cdriz tests. * improved test_zero_input_weight, no setup defaults * Added file creation on failure for non_sym. test * Added other tests + return_pngs cdriz tests * added warren's cdriz_setup, lanczos3 still fails. * Tests working * print statements and altered rtol * temprary new pytest added * added requirements.dev * steve's pytest removed * temporary assert command for test_point_kernel. * test_point_kernel w/ np.testing.assert_array_equal * test_kernel assert without mask * testing test_point_kernel with zero_background * better name for variable. * updated truth files with zero background * removing unused variable * path to saved files added+new truth when missing. * removed new_truth argument * large_sqaure to large_square * spelling corrections * removed duplicated line. * duplicated line removed.. * removed png path * Implemented cdriz_setup.get_output_fullpath * Added docstring to get_output_fullpath * WFPC2: Issue a specific error code and create an empty manifest file for bad data (#1550) * If analysis of a WFPC2 exposure determines the data cannot be processed for some reason, the converted WFPC2 FLT file is currently deleted. The process will now exist with the return code of NO_VIABLE_DATA (65), and an empty manifest file will be created. Also, fixed the option string, added a little documentation, and added a BaseException to handle the sys.exit(). * Updated the changelog. * Fix changelog (#1556) * Corrected the documentation for release candidates (RCs). The documenation for the separate RCs will be combined once the final is ready. * Fixed the Release Candidates(RCs) with dates into their own catagories. When the final release is ready, the separate RCs will be combined. --------- Co-authored-by: Mihai Cara <[email protected]> Co-authored-by: Zach Burnett <[email protected]> Co-authored-by: Steve Goldman <[email protected]>
- Loading branch information
1 parent
bde8d90
commit 1ed7caf
Showing
16 changed files
with
971 additions
and
78 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,157 @@ | ||
import os | ||
import numpy as np | ||
from astropy import wcs | ||
from drizzlepac import cdriz | ||
|
||
|
||
def get_wcs(_grid, pscale=0.04): | ||
w = wcs.WCS() | ||
w.wcs.ctype = ["RA---TAN", "DEC--TAN"] | ||
w.wcs.crpix = [_grid[0] / 2.0, _grid[1] / 2.0] # define as center pixel in array | ||
w.wcs.crval = [10.000, 10.000] # RA/Decl. in decimal degrees | ||
w.wcs.cdelt = [pscale / 3600.0, pscale / 3600.0] | ||
w.wcs.set() | ||
return w | ||
|
||
|
||
class Get_Grid: | ||
"""Sets up inputs to call the python wrapper of the c code: cdriz.tdriz. | ||
The size of the input and ouput grids can be specified in the arguments for | ||
the init(). For an input grid of 4 x 4 and output grid of 5 x 5 you would | ||
use the following call of the class. | ||
Get_Grid(inx=4,iny=4, outx=5, outy=5) | ||
mapping = cdriz.DefaultWCSMapping( | ||
input_wcs, output_wcs, | ||
input_wcs.pixel_shape[0], input_wcs.pixel_shape[1], | ||
stepsize | ||
) | ||
""" | ||
|
||
def __init__(self, inx, iny, outx, outy): | ||
np.random.seed(0) # keep same random across each instance | ||
self.in_grid = (iny, inx) # use numpy indexing order (y,x) | ||
self.out_grid = (outy, outx) # use numpy indexing order (y,x) | ||
self.insci = np.random.randn(self.in_grid[0], self.in_grid[1]).astype("float32") | ||
self.inwht = np.ones(self.in_grid, dtype=np.float32) | ||
self.dny = self.insci.shape[1] # input y_grid | ||
self.outsci = np.zeros(self.out_grid, dtype=np.float32) | ||
self.outwht = np.zeros(self.out_grid, dtype=np.float32) | ||
self.outctx = np.zeros(self.out_grid, dtype=np.int32) | ||
self.w1 = get_wcs(self.in_grid) | ||
self.w2 = get_wcs(self.out_grid) | ||
self.mapping = cdriz.DefaultWCSMapping( | ||
self.w1, self.w2, self.in_grid[0], self.in_grid[1], 1 | ||
) | ||
|
||
def zero_background(self): | ||
super().__init__() | ||
self.insci = np.zeros(self.in_grid, dtype=np.float32) | ||
|
||
|
||
def cdriz_call(_set_kernel_pars, kernel): | ||
""" | ||
parameters explained in c code (arrdrizmodule.c) | ||
_vers, nmiss, nskip = cdriz.tdriz(insci, inwht, outsci, outwht, | ||
outctx, uniqid, ystart, 1, 1, _dny, | ||
pix_ratio, 1.0, 1.0, 'center', pixfrac, | ||
kernel, in_units, expscale, wt_scl, | ||
fillval, nmiss, nskip, 1, mapping) | ||
""" | ||
cdriz.tdriz( | ||
_set_kernel_pars.insci, | ||
_set_kernel_pars.inwht, | ||
_set_kernel_pars.outsci, | ||
_set_kernel_pars.outwht, | ||
_set_kernel_pars.outctx, | ||
1, # uniqid | ||
0, # ystart | ||
1, # xmin pixel to start reading; fits so starts at 1 | ||
1, # ymin pixel to start reading; fits so starts at 1 | ||
_set_kernel_pars.dny, # _dny | ||
1.0, # pix_ratio | ||
1.0, # xscale; plate scale variations | ||
1.0, # yscale; plate scale variations | ||
"corner", # center of pixel is what 0 corresponds to | ||
1.0, # pixfrac | ||
kernel, # kernel | ||
"cps", # units | ||
1.0, # expscale | ||
1.0, # wt_scale | ||
"INDEF", # fillval | ||
0, # nmiss | ||
0, # nskip | ||
1, # vflag; historical value only (not used) | ||
_set_kernel_pars.mapping, | ||
) | ||
|
||
|
||
def get_output_fullpath(relative_path, output_filename): | ||
"""Returns the final output path given a name and relative path. | ||
Parameters | ||
---------- | ||
relative_path : str | ||
relative path from this file to desired path. | ||
output_filename : str | ||
desired name of output file (png or csv). | ||
Returns | ||
------- | ||
output_fullpath: str | ||
final output path | ||
""" | ||
local_path = os.path.dirname(__file__) | ||
output_name = os.path.join(relative_path, output_filename) | ||
output_fullpath = os.path.join(local_path, output_name) | ||
print(f"Output Path: {output_fullpath}") | ||
return output_fullpath | ||
|
||
|
||
def save_array(_data, _name): | ||
np.savetxt( | ||
_name, | ||
X=_data, | ||
fmt="%1.8f", | ||
delimiter=",", | ||
) | ||
|
||
|
||
def generate_png(_set_kernel_pars, _name): | ||
"""Added function for displaying the test results as an image map. | ||
This should show the expected point kernel response. | ||
Parameters | ||
---------- | ||
_set_kernel_pars : Class instance | ||
an instance of the kernel_pars class. | ||
_name : str | ||
The name of the output png file. | ||
""" | ||
# for generating truth files | ||
import matplotlib.pyplot as plt | ||
|
||
fig = plt.figure(figsize=(4, 2)) | ||
ax1 = fig.add_subplot(111, projection=_set_kernel_pars.w1) | ||
ax1.imshow(_set_kernel_pars.outsci, origin="lower", cmap="Greys") | ||
ax1.set_ylabel(" ") | ||
ax1.set_xlabel(" ") | ||
fig.savefig(_name) | ||
|
||
|
||
def error_message(_data, _name): | ||
"""Saves new truth csv file on failure of test. | ||
Parameters | ||
---------- | ||
_data : np.array | ||
data to save to new truth file | ||
_name : str | ||
new name of truth file, should be slightly | ||
different than current truth file | ||
""" | ||
save_array(_data, _name) |
Oops, something went wrong.