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

change usage of deprecated np.int to int #148

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
36 changes: 18 additions & 18 deletions jwst_reffiles/bad_pixel_mask/badpix_from_flats.py
Original file line number Diff line number Diff line change
Expand Up @@ -373,8 +373,8 @@ def combine_individual_maps(bad_maps, do_not_use_flags):

# Convert each type of bad pixel input to have the proper value,
# and add to the final map
do_not_use_map = np.zeros((bad_maps['DEAD'].shape)).astype(np.int)
use_map = np.zeros((bad_maps['DEAD'].shape)).astype(np.int)
do_not_use_map = np.zeros((bad_maps['DEAD'].shape)).astype(int)
use_map = np.zeros((bad_maps['DEAD'].shape)).astype(int)
for pix_type in do_not_use_flags:
if pix_type in dq_defs.keys():
if pix_type in bad_maps.keys():
Expand Down Expand Up @@ -564,8 +564,8 @@ def dead_pixels_sigma_rate(rate_image, mean_rate, stdev_rate, sigma=5.):
dead_pix_map : numpy.ndarray
2D map showing DEAD pixels. Good pixels have a value of 0.
"""
dead_pix_map = (rate_image < (mean_rate - sigma * stdev_rate)).astype(np.int)
return dead_pix_map.astype(np.int)
dead_pix_map = (rate_image < (mean_rate - sigma * stdev_rate)).astype(int)
return dead_pix_map.astype(int)


def dead_pixels_absolute_rate(rate_image, max_dead_signal=0.05):
Expand All @@ -586,8 +586,8 @@ def dead_pixels_absolute_rate(rate_image, max_dead_signal=0.05):
dead_pix_map : numpy.ndarray
2D map showing DEAD pixels. Good pixels have a value of 0.
"""
dead_pix_map = (rate_image < max_dead_signal).astype(np.int)
return dead_pix_map.astype(np.int)
dead_pix_map = (rate_image < max_dead_signal).astype(int)
return dead_pix_map.astype(int)


def dead_pixels_flux_check(dead_pix_map, ave_group, flux_check):
Expand Down Expand Up @@ -620,12 +620,12 @@ def dead_pixels_flux_check(dead_pix_map, ave_group, flux_check):

ibad = len(index[0])

updated_pix_map = np.logical_and(dead_pix_map == 1, final_ave_group < flux_check).astype(np.int)
updated_pix_map = np.logical_and(dead_pix_map == 1, final_ave_group < flux_check).astype(int)
index = np.where(updated_pix_map == 1)

iupdated = len(index[0])
print('Number of pixels removed from dead pixel mask after flux check', ibad - iupdated)
return updated_pix_map.astype(np.int)
return updated_pix_map.astype(int)


def extract_10th_group(hdu_list):
Expand Down Expand Up @@ -738,9 +738,9 @@ def find_open_and_low_qe_pixels(rate_image, max_dead_signal=0.05, max_low_qe=0.5
"""
ydim, xdim = rate_image.shape

low_qe_map = np.zeros((ydim, xdim)).astype(np.int)
open_pix_map = np.zeros((ydim, xdim)).astype(np.int)
adj_pix_map = np.zeros((ydim, xdim)).astype(np.int)
low_qe_map = np.zeros((ydim, xdim)).astype(int)
open_pix_map = np.zeros((ydim, xdim)).astype(int)
adj_pix_map = np.zeros((ydim, xdim)).astype(int)
low_sig_y, low_sig_x = np.where((rate_image >= max_dead_signal) & (rate_image < max_low_qe))

for x, y in zip(low_sig_x, low_sig_y):
Expand Down Expand Up @@ -931,7 +931,7 @@ def manual_flags(filename, map_shape, no_use):
tab = ascii.read(filename)

# Create empty mask
mask = np.zeros(map_shape).astype(np.int)
mask = np.zeros(map_shape).astype(int)

# Pixel index columns can have string or integer data.
# If we have strings, convert to integer, watching for
Expand Down Expand Up @@ -1001,7 +1001,7 @@ def miri_bad_columns(dimensions):

print('*************',dimensions)

shorted_map = np.zeros(dimensions).astype(np.int)
shorted_map = np.zeros(dimensions).astype(int)
shorted_map[:, 384:386] = 1
return shorted_map

Expand Down Expand Up @@ -1217,7 +1217,7 @@ def reference_pixel_map(dimensions, instrument_name):

"""
yd, xd = dimensions
ref_map = np.zeros(dimensions).astype(np.int)
ref_map = np.zeros(dimensions).astype(int)

ref_map[:, 0:4] = 1
ref_map[:, xd-4:xd] = 1
Expand Down Expand Up @@ -1249,15 +1249,15 @@ def range_format(table_cell, total_dimension):
The maximum index number to be returned
"""
try:
value = np.int(table_cell)
value = int(table_cell)
vals = [value, value+1]
except ValueError:
vals = table_cell.split(':')
if vals[0] == '':
vals[0] = 0
if vals[1] == '':
vals[1] = total_dimension - 1
vals = [np.int(val) for val in vals]
vals = [int(val) for val in vals]
vals[1] += 1
return vals

Expand Down Expand Up @@ -1468,8 +1468,8 @@ def split_row(line, colname):
a range is given (e.g. 200:210), then values will be [200, 210].
"""
try:
val = np.int(line[colname])
val = int(line[colname])
values = [val]
except ValueError:
values = [np.int(e) for e in line[colname].split(':')]
values = [int(e) for e in line[colname].split(':')]
return values
6 changes: 3 additions & 3 deletions jwst_reffiles/dark_current/dark_reffile.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,15 +132,15 @@ def __init__(self, file_list=[], max_equivalent_groups=60, sigma_threshold=3, pe
pix_per_fullframe_group = x_fullframe_dim * y_fullframe_dim

pix_per_group = self.metadata['SUBSIZE1'] * self.metadata['SUBSIZE2']
pix_ratio = np.int(pix_per_fullframe_group / pix_per_group)
pix_ratio = int(pix_per_fullframe_group / pix_per_group)

# The number of groups that can be read in from each file is the
# user-entered max number of groups, divided by the ratio of the
# number of pixels in a full frame exposure to the number of pixels
# in the input aperture, divided by the number of files, and
# finally divided by 2, since we will also need to read in the
# cosmic ray flags associated with each file
delta_groups = np.int(max_equivalent_groups / pix_ratio / len(self.file_list)) # / 2.)
delta_groups = int(max_equivalent_groups / pix_ratio / len(self.file_list)) # / 2.)
if delta_groups == 0:
raise ValueError(('ERROR: max_equivalent_groups incompatible with the number/size '
'of input files. Even reading just a single group at a time from '
Expand Down Expand Up @@ -373,7 +373,7 @@ def prepare_cr_maps(self):
first_hits = dq_flags.collapse_cr_map(file_cr_map)

print('Temporarily save CR maps for development, into CR_maps.fits')
hh0 = fits.PrimaryHDU(file_cr_map.astype(np.int))
hh0 = fits.PrimaryHDU(file_cr_map.astype(int))
hh1 = fits.ImageHDU(first_hits)
hlist = fits.HDUList([hh0, hh1])
hlist.writeto('CR_maps.fits', overwrite=True)
Expand Down
6 changes: 3 additions & 3 deletions jwst_reffiles/utils/dq_flags.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def collapse_cr_map(dq_map):
nints, ngroups, ny, nx = dq_map.shape

# Create an array containing all group indexes
all_groups = np.zeros((1, ngroups, 1, 1), dtype=np.int)
all_groups = np.zeros((1, ngroups, 1, 1), dtype=int)
all_groups[0, :, 0, 0] = np.arange(ngroups)
intermediate1 = np.repeat(all_groups, nints, axis=0)
intermediate2 = np.repeat(intermediate1, ny, axis=2)
Expand Down Expand Up @@ -165,8 +165,8 @@ def signals_per_group(number_of_good, ngroup):
within each group
"""
nint, ny, nx = number_of_good.shape
good_per_group = np.zeros((ngroup, ny, nx)).astype(np.int)
bad_per_group = np.zeros((ngroup, ny, nx)).astype(np.int)
good_per_group = np.zeros((ngroup, ny, nx)).astype(int)
bad_per_group = np.zeros((ngroup, ny, nx)).astype(int)

for group in range(ngroup):
grp_map = np.sum(group < number_of_good, axis=0)
Expand Down
Loading