Skip to content

Commit

Permalink
more debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
weaverba137 committed Sep 4, 2024
1 parent 91be4c8 commit 29ad83c
Showing 1 changed file with 23 additions and 22 deletions.
45 changes: 23 additions & 22 deletions py/specprodDB/patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ def patch_exposures(src_exposures, dst_exposures, first_night=None):
(~joined_exposures['DST_INDEX'].mask)]['SRC_INDEX']
dst_exposures_index = joined_exposures[(~joined_exposures['SRC_INDEX'].mask) &
(~joined_exposures['DST_INDEX'].mask)]['DST_INDEX']
dst_exposures_bad_coord = ((dst_exposures['TILERA'][dst_exposures_index] == 0) &
(dst_exposures['TILEDEC'][dst_exposures_index] == 0))
#
# Apply patches from src_exposures.
#
Expand Down Expand Up @@ -141,8 +143,6 @@ def patch_exposures(src_exposures, dst_exposures, first_night=None):
src_exposures_matched = src_exposures[column][src_exposures_index]
dst_exposures_matched = dst_exposures_patched[column][dst_exposures_index]
dst_exposures_mask_matched = np.zeros((len(dst_exposures_matched), ), dtype=bool)
dst_exposures_bad_coord = ((dst_exposures_patched['TILERA'][dst_exposures_index] == 0) &
(dst_exposures_patched['TILEDEC'][dst_exposures_index] == 0))
if hasattr(dst_exposures_patched[column], 'mask'):
if np.any(dst_exposures_patched[column].mask[dst_exposures_index]):
dst_exposures_mask_matched = dst_exposures_patched[column].mask[dst_exposures_index]
Expand Down Expand Up @@ -229,24 +229,6 @@ def patch_tiles(src_tiles, dst_tiles):
assert (np.unique(src_tiles['TILEID']) == sorted(src_tiles['TILEID'])).all()
assert (np.unique(dst_tiles['TILEID']) == sorted(dst_tiles['TILEID'])).all()
#
# Patch SURVEY and PROGRAM.
#
dst_tiles_patched = dst_tiles.copy()
dst_tiles_patched['PROGRAM'] = faflavor2program(dst_tiles_patched['FAFLAVOR'])
oddball_survey = np.where((dst_tiles_patched['SURVEY'] != 'cmx') &
(dst_tiles_patched['SURVEY'] != 'sv1') &
(dst_tiles_patched['SURVEY'] != 'sv2') &
(dst_tiles_patched['SURVEY'] != 'sv3') &
(dst_tiles_patched['SURVEY'] != 'main') &
(dst_tiles_patched['SURVEY'] != 'special'))[0]
oddball_program = np.where((dst_tiles_patched['PROGRAM'] != 'backup') &
(dst_tiles_patched['PROGRAM'] != 'bright') &
(dst_tiles_patched['PROGRAM'] != 'dark') &
(dst_tiles_patched['PROGRAM'] != 'other'))[0]
assert (dst_tiles_patched['SURVEY'][oddball_survey] == 'unknown').all()
assert len(oddball_program) == 0
dst_tiles_patched['SURVEY'][oddball_survey] = 'cmx'
#
# Patch TILERA, TILEDEC.
#
src_tiles_join = Table()
Expand All @@ -260,16 +242,35 @@ def patch_tiles(src_tiles, dst_tiles):
(~joined_tiles['DST_INDEX'].mask)]['SRC_INDEX']
dst_tiles_index = joined_tiles[(~joined_tiles['SRC_INDEX'].mask) &
(~joined_tiles['DST_INDEX'].mask)]['DST_INDEX']
dst_tiles_mask_matched = ((dst_tiles['TILERA'][dst_tiles_index] == 0) &
(dst_tiles['TILEDEC'][dst_tiles_index] == 0))
dst_tiles_patched = dst_tiles.copy()
for column in ('TILERA', 'TILEDEC'):
src_tiles_matched = src_tiles[column][src_tiles_index]
dst_tiles_matched = dst_tiles_patched[column][dst_tiles_index]
dst_tiles_mask_matched = ((dst_tiles_patched['TILERA'][dst_tiles_index] == 0) &
(dst_tiles_patched['TILEDEC'][dst_tiles_index] == 0))
if np.any(dst_tiles_mask_matched):
log.info("Patching %d rows in dst_tiles column %s.",
np.sum(dst_tiles_mask_matched), column)
dst_tiles_matched[dst_tiles_mask_matched] = src_tiles_matched[dst_tiles_mask_matched]
dst_tiles_patched[column][dst_tiles_index] = dst_tiles_matched
assert not (dst_tiles_patched[column] == dst_tiles[column]).all()
#
# Patch SURVEY and PROGRAM.
#
dst_tiles_patched['PROGRAM'] = faflavor2program(dst_tiles_patched['FAFLAVOR'])
oddball_survey = np.where((dst_tiles_patched['SURVEY'] != 'cmx') &
(dst_tiles_patched['SURVEY'] != 'sv1') &
(dst_tiles_patched['SURVEY'] != 'sv2') &
(dst_tiles_patched['SURVEY'] != 'sv3') &
(dst_tiles_patched['SURVEY'] != 'main') &
(dst_tiles_patched['SURVEY'] != 'special'))[0]
oddball_program = np.where((dst_tiles_patched['PROGRAM'] != 'backup') &
(dst_tiles_patched['PROGRAM'] != 'bright') &
(dst_tiles_patched['PROGRAM'] != 'dark') &
(dst_tiles_patched['PROGRAM'] != 'other'))[0]
assert (dst_tiles_patched['SURVEY'][oddball_survey] == 'unknown').all()
assert len(oddball_program) == 0
dst_tiles_patched['SURVEY'][oddball_survey] = 'cmx'
return dst_tiles_patched


Expand Down

0 comments on commit 29ad83c

Please sign in to comment.