Skip to content

Commit

Permalink
drop sci asns when not with paired bkgd
Browse files Browse the repository at this point in the history
  • Loading branch information
tapastro committed Jan 27, 2025
1 parent 760c113 commit 6330761
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
26 changes: 23 additions & 3 deletions jwst/associations/generator/generate_per_candidate.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@


def generate_per_candidate(pool, rule_defs, candidate_ids=None, all_candidates=True, discover=False,
version_id=None, finalize=True, merge=False, ignore_default=False):
version_id=None, finalize=True, merge=False, ignore_default=False,
DMS_enabled=False):
"""Generate associations in the pool according to the rules.
Parameters
Expand Down Expand Up @@ -48,6 +49,9 @@ def generate_per_candidate(pool, rule_defs, candidate_ids=None, all_candidates=T
ignore_default : bool
Ignore the default rules. Use only the user-specified ones.
DMS_enabled : bool
Flag for DMS processing, true if command-line argument '--DMS' was used.
Returns
-------
associations : [Association[,...]]
Expand Down Expand Up @@ -86,7 +90,8 @@ def generate_per_candidate(pool, rule_defs, candidate_ids=None, all_candidates=T
pool,
rule_defs,
version_id=version_id,
ignore_default=ignore_default
ignore_default=ignore_default,
DMS_enabled=DMS_enabled
)

# Add to the list
Expand Down Expand Up @@ -136,7 +141,8 @@ def generate_per_candidate(pool, rule_defs, candidate_ids=None, all_candidates=T
return finalized_asns


def generate_on_candidate(cid_ctype, pool, rule_defs, version_id=None, ignore_default=False):
def generate_on_candidate(cid_ctype, pool, rule_defs, version_id=None, ignore_default=False,
DMS_enabled=False):
"""Generate associations based on a candidate ID
Parameters
Expand All @@ -159,6 +165,9 @@ def generate_on_candidate(cid_ctype, pool, rule_defs, version_id=None, ignore_de
ignore_default : bool
Ignore the default rules. Use only the user-specified ones.
DMS_enabled : bool
Flag for DMS processing, true if command-line argument '--DMS' was used.
Returns
-------
associations : [Association[,...]]
Expand All @@ -169,6 +178,17 @@ def generate_on_candidate(cid_ctype, pool, rule_defs, version_id=None, ignore_de

# Get the pool
pool_cid = pool_from_candidate(pool, cid)

# DMS processing excludes generation of o-type candidates for science exposures
# with linked backgrounds, i.e. without the background member present, as it
# would be for c-type background association candidates.
if DMS_enabled and 'observation' in ctype:
skip_rows = []
for i, row in enumerate(pool_cid):
if 'background' in row['asn_candidate'] and row['bkgdtarg'] == 'f':
skip_rows.append(i)

Check warning on line 189 in jwst/associations/generator/generate_per_candidate.py

View check run for this annotation

Codecov / codecov/patch

jwst/associations/generator/generate_per_candidate.py#L189

Added line #L189 was not covered by tests
pool_cid.remove_rows(skip_rows)

pool_cid['asn_candidate'] = [f"[('{cid}', '{ctype}')]"] * len(pool_cid)
logger.info(f'Length of pool for {cid}: {len(pool_cid)}')

Expand Down
3 changes: 2 additions & 1 deletion jwst/associations/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,8 @@ def generate(self):
version_id=parsed.version_id,
finalize=not parsed.no_finalize,
merge=parsed.merge,
ignore_default=parsed.ignore_default
ignore_default=parsed.ignore_default,
DMS_enabled=parsed.DMS_enabled
)


Expand Down

0 comments on commit 6330761

Please sign in to comment.