diff --git a/jwst/associations/lib/rules_level2_base.py b/jwst/associations/lib/rules_level2_base.py index a152e1048b..1571e55f10 100644 --- a/jwst/associations/lib/rules_level2_base.py +++ b/jwst/associations/lib/rules_level2_base.py @@ -1003,6 +1003,20 @@ def nod_background_overlap(science_item, background_item): if exptype not in ['nrs_fixedslit', 'nrs_msaspec']: return False + # Check for target ID - if present, + # it must match for either FS or MOS + try: + sci_target_id = str(science_item['targetid']).lower() + bkg_target_id = str(background_item['targetid']).lower() + except KeyError: + sci_target_id = None + bkg_target_id = None + if sci_target_id != bkg_target_id: + # Report overlap - different activities contain + # different sources that may overlap, even if not + # at the same primary nod position. + return True + # Get pattern number values, needed for FS or MOS try: numdthpt = int(science_item['numdthpt']) diff --git a/jwst/associations/lib/rules_level3_base.py b/jwst/associations/lib/rules_level3_base.py index 944bc2b63b..a0569bdeb4 100644 --- a/jwst/associations/lib/rules_level3_base.py +++ b/jwst/associations/lib/rules_level3_base.py @@ -682,6 +682,8 @@ def dms_product_name_nrsfs_sources(asn): product_name : str The product name """ + target = asn._get_target() + instrument = asn._get_instrument() opt_elem = asn._get_opt_element() @@ -690,8 +692,10 @@ def dms_product_name_nrsfs_sources(asn): if subarray: subarray = '-' + subarray + product_name_format = ( 'jw{program}-{acid}' + '_{target}' '_{source_id}' '_{instrument}' '_{opt_elem}-{slit_name}{subarray}' @@ -700,6 +704,7 @@ def dms_product_name_nrsfs_sources(asn): product_name_format, program=asn.data['program'], acid=asn.acid.id, + target=target, instrument=instrument, opt_elem=opt_elem, subarray=subarray,