ASSESS QUALITY: To apply information per channel FOR EACH spectrum file: totalexposure = totalexposure + EXPOSURE IF withspeccombine FOR EACH spectrum channel: IF ( acceptable QUALITY ) channelexp = EXPOSURE * AREASCAL OR IF SPECTRUM == NET staterrquad = squared(STAT_ERR) backscalexp = EXPOSURE * BACKSCAL totalcounts = totalcounts + COUNTS Then: Accumulate counts, backscalexp and channelexp or staterrquad ELSE do not add counts Call rgsrmfgen, creating temporary response onto which the channel quality criterion is applied FOR EACH response bin (rows): FOR EACH response channel (columns) AND IF ( acceptable QUALITY for channel): IF ( corresponding spectrum channel not discarded ) newresponse = newresponse + MATRIX * EXPOSURE * AREASCAL FOR EACH spectrum channel: IF (all quality flag 1 over all spectra files) Set final quality flag to 1 IF (all quality flag 2 over all spectra files) Set final quality flag to 2 ELSE Set final quality flag to 0 IF spectrum == TOTAL Finalareascal = channelexp / totalexposure ELSE Finalstaterr = square-root(staterrquad) Finalbackscal = backscalexp / totalexposure Finalresponse = newresponse / Finalareascal Write to file Add attributes for DATE-OBS, DATE-END, applicable to observation list