Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 0da83f6

Browse files
authoredSep 1, 2022
Merge pull request #29 from sot/fix-errors
Fix errors in reprocessing
2 parents 885abdf + 7cc2303 commit 0da83f6

File tree

3 files changed

+38
-25
lines changed

3 files changed

+38
-25
lines changed
 

‎astromon/cross_match.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -747,7 +747,7 @@ def simple_cross_match(
747747
matches['dz'] = matches['x_z_angle'] - matches['c_z_angle']
748748
matches['dy'] = matches['x_y_angle'] - matches['c_y_angle']
749749
matches['dr'] = np.sqrt(matches['dy']**2 + matches['dz']**2)
750-
matches['cat_order'] = 200
750+
matches['cat_order'] = np.full(len(matches), 200)
751751
for i, k in enumerate(catalogs):
752752
matches['cat_order'][matches['catalog'] == k] = i
753753

‎astromon/observation.py

100755100644
+35-24
Original file line numberDiff line numberDiff line change
@@ -447,16 +447,19 @@ def make_images(self, evt=None):
447447
clobber='yes',
448448
logging_tag=str(self)
449449
)
450-
self.ciao(
451-
'acis_streak_map',
452-
infile=str(evt).replace('_filtered', ''),
453-
fovfile=fov_file,
454-
bkgroot=outdir / (self.obsid + "_acis_streaks_bkg.fits"),
455-
regfile=outdir / (self.obsid + "_acis_streaks.txt"),
456-
msigma='4',
457-
clobber='yes',
458-
logging_tag=str(self)
459-
)
450+
try:
451+
self.ciao(
452+
'acis_streak_map',
453+
infile=str(evt).replace('_filtered', ''),
454+
fovfile=fov_file,
455+
bkgroot=outdir / (self.obsid + "_acis_streaks_bkg.fits"),
456+
regfile=outdir / (self.obsid + "_acis_streaks.txt"),
457+
msigma='4',
458+
clobber='yes',
459+
logging_tag=str(self)
460+
)
461+
except Exception:
462+
logger.warning(f'{self} acis_streak_map failed')
460463

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

478-
self.ciao(
479-
"wavdetect",
480-
infile=imgdir / (self.obsid + "_" + band + "_thresh.img"),
481-
expfile=imgdir / (self.obsid + "_" + band + "_thresh.expmap"), # exposure map
482-
psffile=imgdir / (self.obsid + "_" + band + "_thresh.psfmap"), # PSF
483-
outfile=outfile,
484-
scellfile=detdir / (root + ".cell"),
485-
imagefile=detdir / (root + ".img"),
486-
defnbkgfile=detdir / (root + ".nbkg"),
487-
scales=scales,
488-
clobber='yes',
489-
logging_tag=str(self)
490-
)
481+
scales = scales.split()
482+
# if wavdetect fails, it tries again removing the largest two scales
483+
for i in range(2):
484+
try:
485+
self.ciao(
486+
"wavdetect",
487+
infile=imgdir / (self.obsid + "_" + band + "_thresh.img"),
488+
expfile=imgdir / (self.obsid + "_" + band + "_thresh.expmap"), # exposure map
489+
psffile=imgdir / (self.obsid + "_" + band + "_thresh.psfmap"), # PSF
490+
outfile=outfile,
491+
scellfile=detdir / (root + ".cell"),
492+
imagefile=detdir / (root + ".img"),
493+
defnbkgfile=detdir / (root + ".nbkg"),
494+
scales=' '.join(scales),
495+
clobber='yes',
496+
logging_tag=str(self)
497+
)
498+
except Exception:
499+
scales = scales[:-1]
500+
if len(scales) < 3:
501+
raise
491502

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

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

‎astromon/scripts/get_cat_obs_data.py

+2
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,8 @@ def process(obsid, workdir, log_level, archive_dir):
145145
}
146146

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

0 commit comments

Comments
 (0)
Please sign in to comment.