Fixed bad-pix files generation
This commit is contained in:
parent
fa640ad707
commit
07cfdab953
@ -235,7 +235,7 @@ class Observation:
|
|||||||
resized_coeff = (coeff).reshape(2, 2).repeat(180, 0).repeat(180, 1)
|
resized_coeff = (coeff).reshape(2, 2).repeat(180, 0).repeat(180, 1)
|
||||||
return resized_coeff
|
return resized_coeff
|
||||||
|
|
||||||
def get_data(self, file, E_borders=[3, 20]):
|
def get_data(self, file, E_borders=[3, 20], generate_mask=True):
|
||||||
"""
|
"""
|
||||||
Returns masked array with DET1 image data for given energy band.
|
Returns masked array with DET1 image data for given energy band.
|
||||||
Mask is created from observations badpix tables and to mask the border and gaps.
|
Mask is created from observations badpix tables and to mask the border and gaps.
|
||||||
@ -248,10 +248,12 @@ class Observation:
|
|||||||
data_mask = data[np.logical_not(idx_mask)]
|
data_mask = data[np.logical_not(idx_mask)]
|
||||||
build_hist = lambda array: np.histogram2d(array['DET1Y'], array['DET1X'], 360, [[0, 360], [0, 360]])[0]
|
build_hist = lambda array: np.histogram2d(array['DET1Y'], array['DET1X'], 360, [[0, 360], [0, 360]])[0]
|
||||||
output = build_hist(data_output)
|
output = build_hist(data_output)
|
||||||
|
if generate_mask:
|
||||||
mask = build_hist(data_mask)
|
mask = build_hist(data_mask)
|
||||||
mask = np.logical_or(mask, add_borders(output))
|
mask = np.logical_or(mask, add_borders(output))
|
||||||
mask = np.logical_or(mask, self.get_bad_pix(file))
|
mask = np.logical_or(mask, self.get_bad_pix(file))
|
||||||
return output, mask
|
return output, mask
|
||||||
|
return output
|
||||||
|
|
||||||
def get_bad_pix(self, file, threshold=0.9):
|
def get_bad_pix(self, file, threshold=0.9):
|
||||||
"""
|
"""
|
||||||
@ -330,7 +332,7 @@ class Observation:
|
|||||||
"""
|
"""
|
||||||
Returns a hdu_list with positions of masked pixels in RAW coordinates.
|
Returns a hdu_list with positions of masked pixels in RAW coordinates.
|
||||||
"""
|
"""
|
||||||
x_region, y_region = np.where(region)
|
y_region, x_region = np.where(region)
|
||||||
hdus = []
|
hdus = []
|
||||||
for i in range(4):
|
for i in range(4):
|
||||||
current_dir = os.path.dirname(__file__)
|
current_dir = os.path.dirname(__file__)
|
||||||
@ -411,12 +413,12 @@ def process(obs_path, thresh):
|
|||||||
rem_region = np.logical_and(region, np.logical_not(obs.data.mask))
|
rem_region = np.logical_and(region, np.logical_not(obs.data.mask))
|
||||||
masked_obs = np.ma.masked_array(obs.data, mask=region)
|
masked_obs = np.ma.masked_array(obs.data, mask=region)
|
||||||
good_lvl = np.zeros(bin_num, dtype=bool)
|
good_lvl = np.zeros(bin_num, dtype=bool)
|
||||||
good_idx = 0
|
|
||||||
if obs.exposure > 1000:
|
if obs.exposure > 1000:
|
||||||
wav_obs = obs.wavdecomp('atrous', thresh, occ_coeff=True)
|
wav_obs = obs.wavdecomp('atrous', thresh, occ_coeff=True)
|
||||||
wav_sum = wav_obs[2:-1].sum(0)
|
wav_sum = wav_obs[2:-1].sum(0)
|
||||||
occ_coeff = obs.get_coeff()
|
occ_coeff = obs.get_coeff()
|
||||||
binary_arr = binary_array(bin_num)
|
binary_arr = binary_array(bin_num)
|
||||||
|
good_idx = len(binary_arr) - 1
|
||||||
|
|
||||||
for idx, lvl in enumerate(binary_arr):
|
for idx, lvl in enumerate(binary_arr):
|
||||||
try:
|
try:
|
||||||
@ -434,12 +436,9 @@ def process(obs_path, thresh):
|
|||||||
rms[idx] = np.sqrt(((masked_obs-masked_obs.mean())**2).mean())
|
rms[idx] = np.sqrt(((masked_obs-masked_obs.mean())**2).mean())
|
||||||
|
|
||||||
for idx in range(len(poiss_comp)):
|
for idx in range(len(poiss_comp)):
|
||||||
if ((poiss_comp[idx] < poiss_comp[good_idx]) and
|
if ((poiss_comp[idx] < poiss_comp[-1] + 0.05) and
|
||||||
(poiss_comp[idx] < poiss_comp[-1] + 0.05) and
|
(rem_area[idx] > rem_area[good_idx])):
|
||||||
(rem_area[idx] > rem_area[-1])):
|
|
||||||
good_idx = idx
|
good_idx = idx
|
||||||
if good_idx == 0:
|
|
||||||
good_idx = len(binary_arr) - 1
|
|
||||||
good_lvl = binary_arr[good_idx]
|
good_lvl = binary_arr[good_idx]
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user