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

Fix errors in reprocessing #29

Merged
merged 9 commits into from
Sep 1, 2022
2 changes: 1 addition & 1 deletion astromon/cross_match.py
Original file line number Diff line number Diff line change
Expand Up @@ -747,7 +747,7 @@ def simple_cross_match(
matches['dz'] = matches['x_z_angle'] - matches['c_z_angle']
matches['dy'] = matches['x_y_angle'] - matches['c_y_angle']
matches['dr'] = np.sqrt(matches['dy']**2 + matches['dz']**2)
matches['cat_order'] = 200
matches['cat_order'] = np.full(len(matches), 200)
for i, k in enumerate(catalogs):
matches['cat_order'][matches['catalog'] == k] = i

Expand Down
59 changes: 35 additions & 24 deletions astromon/observation.py
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -447,16 +447,19 @@ def make_images(self, evt=None):
clobber='yes',
logging_tag=str(self)
)
self.ciao(
'acis_streak_map',
infile=str(evt).replace('_filtered', ''),
fovfile=fov_file,
bkgroot=outdir / (self.obsid + "_acis_streaks_bkg.fits"),
regfile=outdir / (self.obsid + "_acis_streaks.txt"),
msigma='4',
clobber='yes',
logging_tag=str(self)
)
try:
self.ciao(
'acis_streak_map',
infile=str(evt).replace('_filtered', ''),
fovfile=fov_file,
bkgroot=outdir / (self.obsid + "_acis_streaks_bkg.fits"),
regfile=outdir / (self.obsid + "_acis_streaks.txt"),
msigma='4',
clobber='yes',
logging_tag=str(self)
)
except Exception:
logger.warning(f'{self} acis_streak_map failed')

@logging_call_decorator
def run_wavdetect(self, edition, skip_exist=False, scales="1.4 2 4 8 16 32"):
Expand All @@ -475,19 +478,27 @@ def run_wavdetect(self, edition, skip_exist=False, scales="1.4 2 4 8 16 32"):
if outfile.exists() and skip_exist:
return

self.ciao(
"wavdetect",
infile=imgdir / (self.obsid + "_" + band + "_thresh.img"),
expfile=imgdir / (self.obsid + "_" + band + "_thresh.expmap"), # exposure map
psffile=imgdir / (self.obsid + "_" + band + "_thresh.psfmap"), # PSF
outfile=outfile,
scellfile=detdir / (root + ".cell"),
imagefile=detdir / (root + ".img"),
defnbkgfile=detdir / (root + ".nbkg"),
scales=scales,
clobber='yes',
logging_tag=str(self)
)
scales = scales.split()
# if wavdetect fails, it tries again removing the largest two scales
for i in range(2):
try:
self.ciao(
"wavdetect",
infile=imgdir / (self.obsid + "_" + band + "_thresh.img"),
expfile=imgdir / (self.obsid + "_" + band + "_thresh.expmap"), # exposure map
psffile=imgdir / (self.obsid + "_" + band + "_thresh.psfmap"), # PSF
outfile=outfile,
scellfile=detdir / (root + ".cell"),
imagefile=detdir / (root + ".img"),
defnbkgfile=detdir / (root + ".nbkg"),
scales=' '.join(scales),
clobber='yes',
logging_tag=str(self)
)
except Exception:
scales = scales[:-1]
if len(scales) < 3:
raise

@logging_call_decorator
def run_celldetect(self, snr=3):
Expand Down Expand Up @@ -520,7 +531,7 @@ def filter_events(self, radius=180, psfratio=1): # radius in arcsec
try:
evt = list((self.workdir / 'primary').glob('*evt2.fits*'))[0]
except Exception:
raise Exception(f'evt2 file not found ') from None
raise SkippedWithWarning(f'evt2 file not found') from None

evt2 = str(evt).replace('evt2', 'evt2_filtered')

Expand Down
2 changes: 2 additions & 0 deletions astromon/scripts/get_cat_obs_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,8 @@ def process(obsid, workdir, log_level, archive_dir):
}

(observation.workdir / 'results').mkdir(exist_ok=True)
# this is because of unicode characters in observer names and other fields
result['astromon_obs'].convert_unicode_to_bytestring()
for name in ['astromon_obs', 'astromon_xray_src', 'astromon_cat_src', 'astromon_xcorr']:
fn = observation.workdir / 'results' / f'{name}.fits'
fn.unlink(missing_ok=True)
Expand Down