result output changed
This commit is contained in:
parent
a58a1f612e
commit
fd708d8170
@ -278,7 +278,7 @@ class Observation:
|
|||||||
correction_poiss = np.random.poisson(corr*array, corr.shape)
|
correction_poiss = np.random.poisson(corr*array, corr.shape)
|
||||||
return array + correction_poiss
|
return array + correction_poiss
|
||||||
|
|
||||||
def wavdecomp(self, mode='gauss', thresh=False, occ_coeff=False):
|
def wavdecomp(self, mode='gauss', thresh=0, occ_coeff=False):
|
||||||
"""
|
"""
|
||||||
Performs a wavelet decomposition of image.
|
Performs a wavelet decomposition of image.
|
||||||
"""
|
"""
|
||||||
@ -392,7 +392,6 @@ def process(obs_path, thresh):
|
|||||||
Arguments: path to the file of interest and threshold,
|
Arguments: path to the file of interest and threshold,
|
||||||
e.g. process('D:\\Data\\obs_cl.evt', (3, 2))
|
e.g. process('D:\\Data\\obs_cl.evt', (3, 2))
|
||||||
"""
|
"""
|
||||||
bin_num = 6
|
|
||||||
|
|
||||||
table = {
|
table = {
|
||||||
'obs_id': [], 'detector': [], 'ra': [], 'dec': [],
|
'obs_id': [], 'detector': [], 'ra': [], 'dec': [],
|
||||||
@ -407,17 +406,18 @@ def process(obs_path, thresh):
|
|||||||
dec=obs.dec*u.deg,
|
dec=obs.dec*u.deg,
|
||||||
frame='fk5').transform_to('galactic')
|
frame='fk5').transform_to('galactic')
|
||||||
lon, lat = sky_coord.l.value, sky_coord.b.value
|
lon, lat = sky_coord.l.value, sky_coord.b.value
|
||||||
rem_signal, rem_area, poiss_comp, rms = np.zeros((4, 2**bin_num))
|
useful_bin_num = 6
|
||||||
|
rem_signal, rem_area, poiss_comp, rms = np.zeros((4, 2**useful_bin_num))
|
||||||
region = np.zeros(obs.data.shape, dtype=bool)
|
region = np.zeros(obs.data.shape, dtype=bool)
|
||||||
region_raw = -1
|
region_raw = -1
|
||||||
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(useful_bin_num, dtype=bool)
|
||||||
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(useful_bin_num)
|
||||||
good_idx = len(binary_arr) - 1
|
good_idx = len(binary_arr) - 1
|
||||||
|
|
||||||
for idx, lvl in enumerate(binary_arr):
|
for idx, lvl in enumerate(binary_arr):
|
||||||
@ -482,7 +482,7 @@ def process(obs_path, thresh):
|
|||||||
]
|
]
|
||||||
|
|
||||||
for key, value in zip(table.keys(), to_table):
|
for key, value in zip(table.keys(), to_table):
|
||||||
table[key] = [value]
|
table[key] = value
|
||||||
return table, region.astype(int), region_raw, wav_sum
|
return table, region.astype(int), region_raw, wav_sum
|
||||||
except TypeError:
|
except TypeError:
|
||||||
return obs_path, -1, -1, -1
|
return obs_path, -1, -1, -1
|
||||||
@ -603,14 +603,14 @@ def process_folder(input_folder=None, start_new_file=None, fits_folder=None,
|
|||||||
num += 1
|
num += 1
|
||||||
continue
|
continue
|
||||||
|
|
||||||
obs_name = str(result['obs_id'][0])+result['detector'][0]
|
obs_name = str(result['obs_id'])+result['detector']
|
||||||
if result['exposure'][0] < 1000:
|
if result['exposure'] < 1000:
|
||||||
print(f'{num:>3} {obs_name} is skipped. Exposure < 1000')
|
print(f'{num:>3} {obs_name} is skipped. Exposure < 1000')
|
||||||
DataFrame(result).to_csv(os.path.join(fits_folder, 'overview_skipped.csv'), mode='a', header=False)
|
DataFrame(result, index=[0]).to_csv(os.path.join(fits_folder, 'overview_skipped.csv'), mode='a', header=False)
|
||||||
num += 1
|
num += 1
|
||||||
continue
|
continue
|
||||||
|
|
||||||
DataFrame(result).to_csv(os.path.join(fits_folder, 'overview.csv'), mode='a', header=False)
|
DataFrame(result, index=[0]).to_csv(os.path.join(fits_folder, 'overview.csv'), mode='a', header=False)
|
||||||
save_region(region, os.path.join(region_folder, f'{obs_name}_region.fits'), overwrite=True)
|
save_region(region, os.path.join(region_folder, f'{obs_name}_region.fits'), overwrite=True)
|
||||||
region_raw.writeto(os.path.join(region_raw_folder, f'{obs_name}_reg_raw.fits'), overwrite=True)
|
region_raw.writeto(os.path.join(region_raw_folder, f'{obs_name}_reg_raw.fits'), overwrite=True)
|
||||||
fits.writeto(os.path.join(wav_sum_folder, f'{obs_name}_wav_sum.fits'), wav_sum, overwrite=True)
|
fits.writeto(os.path.join(wav_sum_folder, f'{obs_name}_wav_sum.fits'), wav_sum, overwrite=True)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user