EP-FXT Science Data Center / Users Guide v2.0 · 2026-11-04

FXTSoft v2.0 documentation

fxtspecmerge help

Command help for fxtspecmerge in the FXTSoft v2.0 release.

← Back to Command Reference

NAME

fxtspecmerge -- Merge compatible EP/FXT PHA spectra and optional responses

USAGE

fxtspecmerge infiles=@spectra.lst outfile=merged.pha
fxtspecmerge infiles=@spectra.lst outfile=merged.pha sumtype=AREA
fxtspecmerge infiles=@spectra.lst outfile=merged.pha backfiles=% arffiles=% rmffiles=%
fxtspecmerge infiles=@spectra.lst outfile=merged.pha backfiles=@bkg.lst arffiles=@arf.lst rmffiles=@rmf.lst clobber=yes
fxtspecmerge infiles=@instrument_bkg.lst outfile=instrument_bkg_merged.pha sumtype=TIME backfiles=NONE arffiles=NONE rmffiles=NONE

DESCRIPTION

fxtspecmerge combines compatible OGIP PHA spectra on the same CHANNEL grid. It is intended for source spectra, FSA count spectra, and the floating-point background spectra produced by fxtbkggen. Input files are never changed. The output retains floating-point COUNTS; explicit STAT_ERR columns are propagated using independent-input variance addition. Shared template, calibration, and other cross-channel covariance is not represented by the marginal STAT_ERR column and is recorded in HISTORY rather than claimed to be removed. The OGIP POISSERR=T, STAT_ERR=0 keyword-only placeholder is accepted; a true STAT_ERR column or nonzero error keyword with POISSERR=T is rejected.

The inputs must agree on telescope, filter (by default), data mode, grade/selection, channel grid, and compatible BACKSCAL/AREASCAL conventions. Conflicting values other than an explicitly disabled FILTER cross-input check, or missing selection information, are errors; the task does not guess missing metadata. The merged date envelope uses the earliest DATE-OBS/TSTART and latest DATE-END/TSTOP. Common grade and selection keywords are retained, and each input is listed in MERGE_INPUTS provenance. The output PHA deliberately clears RESPFILE, ANCRFILE, and BACKFILE unless the corresponding response/background product is generated by this invocation. Both TIME and AREA accept FXTA+FXTB: each input must match its own background and response files. Conflicting detector cards are removed from the combined headers; the original identities remain in provenance. Declared response GRADE/DATAMODE, including CALDB boundary descriptors, are checked against the corresponding PHA. Missing response selection cards are not invented.

checkfilter=yes is the default and requires matching FILTER values across input spectra and their associated products. Set checkfilter=no to permit differing or partially missing FILTER values across inputs. All other compatibility checks remain active, including the FILTER match of each PHA with its own background and response files. For a complete mixed-filter set, the merged PHA and any merged ARF/RMF carry FILTER=MULTIPLE. The original input records remain in MERGE_INPUTS; its FILTER_INPUTS provenance column records each leaf FILTER and observation origin so that a later merge can reconstruct the composition. A partially missing input FILTER is never invented: the merged FILTER remains missing and its provenance is incomplete. CHKFILT plus HISTORY record the selected policy. FILTER=MULTIPLE is a provenance marker, not a wildcard, and does not establish that different-filter photon responses or calibration periods are equivalent. An existing MULTIPLE marker requires complete provenance even with checkfilter=no; malformed provenance is an error during both validation and merging. Generate backgrounds per observation before merging when particle rates or calibration periods differ.

When infiles is a standalone list of precomputed particle-model PHAs from fxtbkggen, use backfiles=NONE and provide no paired response products unless they are explicitly wanted. The generic command does not infer a source aperture or validate a particle-template area convention; callers must ensure compatible detector, mode, channel grid, calibration, and BKGREF/BKGPIXA/BKGUNIT metadata. The fxtobsmerge particle-model stage performs those compatibility checks before its dedicated merge, sums counts and exposure in double precision, exposure-weights scalar BACKSCAL, propagates STAT_ERR in quadrature with POISSERR=F, and emits a full effective IMG template area product. That product is not an automatic source-aperture background.

The fxtobsmerge normmethod=imghe path uses a dedicated monitor coaddition rather than this generic raw-PHA sum. It extracts one source-free IMG monitor per observation. The monitor area uses the selected non-vignetted exposure-map pixels (VIGNAPP=False): A_i=sum(selected exposure-map pixels) * pixel solid angle / event EXPOSURE, with no photon-vignetting correction. It then maps each monitor to a common physical particle area and the corresponding FSA exposure with f_i=(A_0/A_i)(T_FSA,i/T_IMG,i), and writes img_monitor_merged.pha with fractional counts, propagated STAT_ERR, and POISSERR=F. It then calls fxtbkggen once with the merged FSA PHA. Do not replace that stage with an unscaled fxtspecmerge sumtype=TIME of raw IMG monitors when their areas or exposures differ: the generic exposure-weighted BACKSCAL then describes an area-weighted sum and does not enforce the IMGHE monitor contract. Use the fxtobsmerge outputs and their MERGE_INPUTS/MERGE_GTIS provenance.

sumtype=TIME sums exposure and source counts. sumtype=AREA also sums source counts, records the mean exposure, and multiplies the combined effective area by the number of inputs. Both conventions preserve the sum of predicted model counts. Source BACKSCAL is always exposure-weighted from its inputs. Background normalization follows bkgmethod below. This command does not promise bitwise or exact numerical parity with HEASoft ftaddspec.

BACKGROUND COMBINATION AND STATISTICS

bkgmethod selects the paired-background arithmetic independently of sumtype when backfiles are supplied. The TIME, ASCA and COUNTS choices follow the algorithms documented for CIAO combine_spectra. The default is ASCA, matching CIAO. Explicit AUTO selects TIME for measured Poisson backgrounds, COUNTS for effective-Poisson inputs, and WEIGHTED when any input is non-Poisson. No method cancels merging because channels have few or zero counts.

bkgmethodBackground outputStatistical interpretation
AUTOTIME for measured Poisson inputs, COUNTS for existing EFFPOISS inputs, WEIGHTED if any input is non-PoissonRecords the resolved method in BKGMETH
TIMEUnscaled count sum; background BACKSCAL weighted by its own exposuresIndependent measured Poisson counts remain Poisson, including empty channels
ASCA (default)Exposure/area-scaled counts with an equivalent background BACKSCALNon-unit weights produce non-Poisson counts and propagated STAT_ERR
COUNTSEffective counts and channel-dependent BACKSCAL matching the scaled first and second momentsEffective Poisson approximation: POISSERR=T, STATPOL=EFFPOISS; requires Poisson or effective-Poisson backgrounds
WEIGHTEDScaled count/error sum; source and background keep their own exposure-weighted BACKSCALPreserves the summed background subtraction and propagated variance; intended for model backgrounds

Let a_i = (t_src,i/t_bkg,i)(BS_src,i/BS_bkg,i)(AS_src,i/AS_bkg,i), and K = (T_src/T_bkg) BS_src,out (AS_src,out/AS_bkg,out), where BS and AS denote BACKSCAL and AREASCAL. The output scaling is a_out = K/BS_bkg,out. The formulae apply per channel when an input BACKSCAL is a column.

  • TIME sums raw background counts and exposure-weights each BACKSCAL independently.
  • ASCA uses a_out = sum(t_bkg,i a_i)/sum(t_bkg,i), BS_bkg,out = K/a_out, and sums counts scaled by a_i/a_out.
  • COUNTS forms M = sum(a_i B_i) and V = sum(a_i^2 B_i), then stores B_eff = M^2/V and BS_bkg,out = K M/V. If all contributions to a channel are zero, it stores zero counts and BACKSCAL=1, following CIAO. It never rounds effective counts into artificial events.
  • WEIGHTED retains the exposure-weighted background BACKSCAL and scales each input by a_i/a_out; variances are multiplied by the squared factors.

For unit AREASCAL these reproduce the CIAO numerical normalizations. TIME and ASCA retain the source BACKSCAL instead of setting it to one, with the matching background normalization preserving the same source/background ratio. CIAO's COUNTS method already retains the source BACKSCAL. Non-unit AREASCAL ratios are included explicitly. A per-channel BACKSCAL is written as a Type-I column and can be read back by this task. Original input scales and applied scalar or per-channel factors are retained in MERGE_INPUTS.

TIME with different input scaling factors uses an approximate combined normalization; it does not preserve every realization of the separately scaled background subtraction. Large differences in background rates or extraction areas can bias a combined fit. COUNTS matches moments, not the full original likelihood; its noninteger effective counts remain an approximation even though POISSERR=T selects a Poisson treatment in fitting software. Shared-model covariances are not represented. Separate joint fitting remains an optional analysis choice; the requested merge is still performed.

Unscaled measured counts use STATPOL=POISSON. Propagated non-Poisson errors use POISSERR=F, STATPOL=PROPVAR, and STAT_ERR. The floating model backgrounds produced by fxtbkggen are never relabeled as measured Poisson events. XSPEC statistics must be selected explicitly: CSTAT does not automatically become PGSTAT when POISSERR=F. PGSTAT is appropriate only if a Gaussian approximation to the background errors is justified. WSTAT can also be sensitive to very sparse background channels. BKGMETH, STATPOL and HISTORY make these assumptions visible.

ASSOCIATED FILES

backfiles, arffiles, and rmffiles are optional ordered lists. Each list accepts a single path, comma- or whitespace-separated paths, or an @listfile. NONE skips that product. A percent entry (%) reads the corresponding PHA header keyword: BACKFILE, ANCRFILE, or RESPFILE. For example, backfiles=% uses each input PHA's background pointer; the common full-header lookup is backfiles=% arffiles=% rmffiles=%. Percent entries may be mixed with explicit paths in one ordered list. If a percent lookup is missing or invalid, the error identifies the affected PHA and the associated parameter so that an explicit per-input fallback path can be supplied; no response is invented.

ARF and RMF are combined jointly with exposure times the relevant AREASCAL as weights. An RMF-only request accepts a complete RSP or identical redistribution inputs; distinct redistribution without matching ARFs is rejected because a scalar RMF average is not physically defined. Generated products use the output stem: merged.pha produces merged_bg.pha, merged.arf, and merged.rmf when those associated products are requested. Keep these files together; start XSPEC in the output directory so its relative response and background filename lookup finds the associated products.

PARAMETER SUMMARY

ParameterDefault / valuesSummary
infilesrequiredInput PHA files, comma-separated, whitespace-separated, one file, or @listfile
outfilerequiredMerged PHA output; prefix with ! to override clobber
sumtypeTIMETIME exposure sum or AREA effective-area weighted mean
backfilesNONEOrdered background PHA list, % for PHA BACKFILE, or NONE
arffilesNONEOrdered ARF list, % for PHA ANCRFILE, or NONE
rmffilesNONEOrdered RMF/RSP list, % for PHA RESPFILE, or NONE
bkgmethodASCAAUTO, TIME, ASCA, COUNTS, or WEIGHTED for paired backfiles (case-insensitive); standalone model lists use explicit errors
clobbernoOverwrite existing output files (yes/no)
checkfilteryesRequire matching FILTER by default; no permits known mixed FILTER and records FILTER=MULTIPLE plus leaf provenance in MERGE_INPUTS/FILTER_INPUTS
modeqlParameter query and learning mode
verbose1Logging verbosity: 0=warning/error, 1=normal info, 2=debug

PARAMETERS

infiles [string]
Input PHA files. Use one path, comma- or whitespace-separated paths, or an @listfile. The input channel grid and required selection metadata must be compatible.

outfile [file name]
Output PHA path. Prefix the path with ! to force replacement of existing output products regardless of clobber.

(sumtype=TIME) [string]
TIME sums exposure and count spectra. AREA uses effective-area weighting for simultaneous detector combinations.

(backfiles=NONE) [string]
Ordered background PHA paths, or % to resolve each input PHA's BACKFILE. Explicit paths can replace missing header pointers on a per-input basis.

(arffiles=NONE) [string]
Ordered ARF paths, or % to resolve each input PHA's ANCRFILE. ARFs are combined jointly with RMFs when requested.

(rmffiles=NONE) [string]
Ordered RMF/RSP paths, or % to resolve each input PHA's RESPFILE. Distinct redistribution inputs require matching ARFs.

(clobber=no) [boolean]
Overwrite existing products. The ! prefix on outfile is an explicit per-invocation override.

(bkgmethod=ASCA) [string]
Background combination method described above. This does not change the source count sum. It is used only when paired backfiles are supplied; with backfiles=NONE, a standalone list of model-background PHAs is summed with its explicit errors and no paired-background scaling is applied.

(checkfilter=yes) [boolean]
Require matching FILTER values across input spectra and across associated background spectra. Set no to permit differing or partially missing input FILTER values; each PHA must still match its own background and response files. A complete mixed set writes FILTER=MULTIPLE to the merged PHA and generated ARF/RMF, retains the original records in MERGE_INPUTS, and records leaf FILTER/observation origins in the FILTER_INPUTS provenance column. Missing FILTER remains missing rather than being fabricated. The FILTER=MULTIPLE marker is not a wildcard for downstream tasks; CHKFILT and HISTORY record the policy.

EXAMPLES

BACKSCAL conventions must match within each merge and within each source/background pair. Labelled dimensionless fractions require complete BKGREF/BKGPIXA/BKGUNIT reference metadata; BSCALUNI, when present, must be 1. A mixture of labelled and unlabelled spectra, incomplete references, or differing reference tuples is rejected before output. Regenerate or explicitly normalize incompatible inputs first. Entirely unlabelled legacy inputs retain their existing contract: callers remain responsible for verifying a common convention. Common reference metadata is retained in both output header layers.

fxtspecmerge infiles=@pha.lst outfile=merged.pha
fxtspecmerge infiles=@pha.lst outfile=merged.pha sumtype=AREA
fxtspecmerge infiles=@pha.lst outfile=merged.pha backfiles=% arffiles=% rmffiles=%
fxtspecmerge infiles=@pha.lst outfile=merged_counts.pha backfiles=% arffiles=% rmffiles=% bkgmethod=counts
fxtspecmerge infiles=@pha.lst outfile=merged_auto.pha backfiles=% arffiles=% rmffiles=% bkgmethod=auto
fxtspecmerge infiles=@pha.lst outfile=merged_model.pha backfiles=% arffiles=% rmffiles=% bkgmethod=weighted
fxtspecmerge infiles=@pha.lst outfile=!merged.pha clobber=no
fxtspecmerge infiles=@instrument_bkg.lst outfile=instrument_bkg_merged.pha sumtype=TIME backfiles=NONE arffiles=NONE rmffiles=NONE
fxtspecmerge infiles=@fsa_mixed_filters.lst outfile=fsa_mixed.pha sumtype=TIME checkfilter=no backfiles=NONE arffiles=NONE rmffiles=NONE clobber=yes

Manual page updated

2026-11-04