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

FXTSoft v2.0 documentation

fxtbkggen help

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

← Back to Command Reference

NAME

fxtbkggen -- generate background spectrum in the IMG area

USAGE

fxtbkggen infile=FSA_PHA outfile=OUT_PHA [normmethod=fsa|imghe ...]

DESCRIPTION

For normmethod=imghe, first choose a source-free monitor region from the cleaned IMG events and extract an ungrouped, unsubtracted PI COUNTS PHA. Supply that spectrum with imgspecfile. Prefer a large valid region within DETX=3:382, DETY=3:382, excluding detected sources and bad/hot pixels or columns. The monitor region need not be the scientific source-extraction region. Do not select the lowest-count patch in the high-energy image. Ensure residual source/sky counts are negligible in the chosen band, including hard-source wings or diffuse emission. The PHA area metadata must describe the region actually retained after masks and detector-edge exclusions.

fxtbkggen estimates the particle-background spectrum for the FXT pnCCD image area. The default normmethod=fsa preserves the established FSA normalization: the required infile is a cleaned frame-store-area (FSA) PHA, produced from fxtchain with datatype=fsaevt and the default selection ELV>5&&COR>6&&SAA==0&&DYE_ELV>30. A manually prepared FSA input must represent the complete calibrated selection: grade 0:12, DETX=3:382, DETY=3:382, with bad or hot pixels and columns excluded. When fxtobsmerge prepares its own monitor, it additionally applies the clean event GTI and requires STATUS all bits zero and complete FSA event data; it does not use a user source or sky-region crop.

An FSA monitor prepared by fxtobsmerge preserves the input frame EXPOSURE. Its integer monitor counts use POISSERR=T and BACKSCAL=1 as an internal full-FSA convention; fxtbkggen uses the counts and exposure for FSA normalization and does not treat that monitor BACKSCAL as an IMG area factor. Null, non-finite and out-of-range PI values are excluded and counted in HISTORY; fractional PI values are rejected.

infile remains the matching FSA spectrum for both normalization methods. normmethod=fsa is the default and is the required cross-check for the experimental image high-energy method; there is no hybrid mode. The output model retains the FSA EXPOSURE and preserves the particle-template BACKSCAL and, when known, its BKGREF/BKGPIXA/BKGUNIT reference-area metadata. Unknown template conventions remain warnings; see the reference-area rules below. The model never reuses the FSA monitor area or applies a bad-pixel ratio a second time. It therefore represents the full effective IMG template area, not an arbitrary science source aperture.

normmethod=imghe uses a cleaned FF image-area monitor PHA from imgspecfile. The monitor has its own EXPOSURE and must have the same detector and filter composition, DATAMODE=FF, grade 0:12, and other selection metadata as infile. A differing TIMESYS or OBS_ID is an error when that keyword is present in both inputs. DATE-OBS/DATE-END and GTI endpoints are compared with a 0.051 s tolerance (one 50 ms FF frame plus timestamp rounding), recorded in HETTOL; invalid dates or GTI intervals remain errors. Differences beyond the tolerance produce a warning, continue with the IMG monitor's own count rate, and set HETIME=MISMATCH with TIME_MISMATCH in HEQUAL. A missing GTI still sets NO_GTI, which may be combined with TIME_MISMATCH. The output retains the FSA EXPOSURE. The IMG monitor should represent the scientific filtering: scaling by exposure does not remove a time-variable background difference, and the FSA comparison can sample a different background level. The default E2PI normalization band is [9,10) keV, with ELOW <= E < EHIGH endpoint semantics. Interface bounds require finite 0.5 <= hemin < hemax; the input E2PI table sets the effective upper edge. For the formal table (PI 0..1023, with PI 1023 ending at 12 keV), hemax=12 is allowed and selects at most PI 1022 because the highest real-energy row can contain events clipped from above the table.

For multiple observations, use fxtobsmerge normmethod=imghe to construct the two matching inputs before calling this task: fsa_merged.pha and img_monitor_merged.pha. The heregion monitor area comes from the matching non-vignetted exposure map: A_i=sum(selected exposure-map pixels) * pixel solid angle / event EXPOSURE, with no photon-vignetting correction. The merged IMG monitor is then put on a common physical particle-area reference and the corresponding FSA exposure, using f_i=(A_0/A_i)(T_FSA,i/T_IMG,i); it may therefore contain fractional COUNTS with propagated STAT_ERR and POISSERR=F. Its BACKSCAL identifies the common monitor reference area. Do not replace it with an unscaled generic sum when monitor areas or exposures differ. The final output BACKSCAL still comes from the particle template, and the FSA amplitude is retained only as an IMG/FSA diagnostic; this is not a hybrid estimator.

For merged spectra, the FSA and IMG source compositions recorded in MERGE_INPUTS/FILTER_INPUTS must match, including same-filter merges. When OBS_ID is present, every OBS_ID-to-FILTER pairing must agree; the existing date, selection, GTI and area constraints still apply. A FILTER=MULTIPLE card is not a wildcard for the IMG monitor.

For an intentionally mixed 01/02 FSA merge, fxtbkggen resolves the composition from complete leaf provenance in MERGE_INPUTS, including an older r2 merged spectrum whose top-level FILTER is absent; FILTER_INPUTS is retained when present for repeated merges. The existing particle-template selection is preserved, including the 02 to 01 mapping. Missing or corrupt provenance, or any filter outside the supported 01/02 set, is an error. A top-level FILTER=MULTIPLE card is accepted only when the provenance proves that supported composition. This permits background generation but does not make photon responses from different filters or calibration periods equivalent. Across periods or changing particle rates, generate one background per observation before merging.

Let q=heareascal be the effective particle monitor/template area fraction. heareascal=AUTO computes the geometric area ratio only when both PHAs have known physical area references. Use this ratio only when the particle spatial distribution is sufficiently uniform over the selected regions; the software cannot verify that assumption. Otherwise supply an independently calibrated finite positive particle-area ratio. This is a particle-area factor and never a celestial-vignetting correction. With N_H image-monitor counts, M_H template counts, T_img image-monitor exposure, T_model template exposure, and T_fsa FSA exposure, the fixed-template scale is alpha = N_H/(M_H*T_img/T_model*q) and output channel counts are alpha*M_i*T_fsa/T_model.

The FSA calculation uses r_FSA=sum(C_FSA[73:925])/T_FSA, predicts the total IMG rate with the CALDB polynomial, then scales the IMG template to that rate and the FSA exposure. It does not divide by the current FSA pixel count or compensate for an arbitrarily cropped FSA region. Use the full calibrated FSA selection described above. Keep the pipeline exposure convention used to calibrate the coefficients; do not separately double the FSA rate to account for its 25 ms physical integration within the 50 ms frame cycle.

The native FXT SKY image grid is 600*600 pixels. The known 20250509 template PHAs were created with an extractor convention whose BACKSCAL normalization denominator is 601*601=361201; retain this legacy pair when reading those templates. Their effective output areas are 142475 pixels for FXTA and 144350 for FXTB, from BACKSCAL*BKGREF. These already include the template bad-pixel and bad-column exclusions; do not apply another good-pixel fraction or substitute a fixed 380*380. IMG monitor spectra use the native 600*600=360000 reference. For different reference grids or pixel scales, compare BACKSCAL*BKGREF*BKGPIXA in common area units.

Equivalently, first take the FSA output B0, then compute its prediction in the monitor area and exposure: P0_H=sum(B0_H)*T_IMG/T_FSA*q. The correction is k_HE=N_H/P0_H, recorded in HEFSARAT, and B_final=k_HE*B0. Use the already normalized output in this denominator, not the raw template. HENORM instead records the final amplitude relative to the raw template. Both forms give the same result; the FSA amplitude and its amplitude uncertainty cancel. A hybrid estimator is outside this interface and would require independently calibrated FSA predictive scatter and dependence information; COEFF_ERR alone is not that predictive uncertainty.

heregion optionally names an existing DS9 extraction-region file. It is recorded for provenance only and does not filter the spectrum. There is no automatic source exclusion. A hard source or thermal tail can contaminate the monitor, and the nearby Cu Kbeta feature can affect the high-energy band; IMGHE therefore remains experimental. It does not predict a low-energy sky background. Broad scientific acceptance requires held-out closed-wheel validation.

In FSA mode, the output uses POISSERR=F as a FITS logical value and an explicit STAT_ERR column. Errors use first-order propagation of the calibrated polynomial and include the correlation between each template channel and the template normalization sum. Declared input STAT_ERR values are used; otherwise Poisson counts are used (and recorded as an assumption for legacy inputs without POISSERR).

The calibration supplies coefficient standard errors without a full covariance matrix. The current STAT_ERR is a marginal, independent-input propagation; shared template and calibration contributions may be correlated across channels, but the full covariance is not encoded. These assumptions are recorded in FITS HISTORY and do not certify the low-count approximation. The estimated background counts are unchanged by this error-propagation correction.

The output records the selected method in NORMMETH. In IMGHE mode diagnostics record the normalization and error (HENORM/HENERR), high-energy monitor counts and error (HECOUNTS/HECERR), effective monitor counts (HEEFFN=N_H^2/Var(N_H)), unscaled template monitor expectation (HEMODEL), effective area fraction (HEAREA), template, monitor, and E2PI calibration hashes (BKGSHA/HESHA/HEE2SHA), and the IMG/FSA ratio/significance (HEFSARAT/HEFSASIG). A ratio discrepancy at or above 3 sigma is warned. Half-band hardness (HEHARDZ) is reported only when both halves have at least 20 effective monitor counts; otherwise HEHSTAT=LOWSTAT. Fewer than 100 effective high-energy counts (HEEFFN) is warned, and a zero-count required normalization band is an error. For an unweighted raw Poisson monitor, effective counts equal raw counts; for an area/exposure-weighted monitor, all thresholds use N^2/Var(N) rather than the fractional COUNTS sum. HEQUAL records diagnostic flags and HEVALID=EXPERIMENTAL records the scientific status.

With normmethod=imghe, nonzero low counts or diagnostic discrepancies produce warnings but still apply the high-energy normalization. There is no automatic fallback to FSA and no 400-count acceptance threshold. To produce the FSA-normalized result, run normmethod=fsa with a separate output filename. HENERR is the error of the raw-template amplitude HENORM; a separate uncertainty for the FSA-relative correction HEFSARAT is not currently stored.

IMGHE STAT_ERR is marginal and first-order: it includes template numerator/sum covariance and the correlated shared normalization, so channels or scientific regions must not be treated as all independent. Area scaling, template-shape, source/sky contamination, and other systematics are not included in STAT_ERR. The output adds a HE_MONITOR extension copied from the input monitor spectrum. If monitor region HDUs are present, they are copied under HE_ names; a supplied heregion adds a HE_REGION extension containing the raw region bytes and SHA256 provenance. Monitor GTIs are copied as HE_GTI* extensions with HDUCLAS1=PROVENANCE; they document the monitor selection and are not used as output GTIs. HEOVREJ=T records that the E2PI highest row was excluded from IMGHE to avoid clipped above-table events. The region is never used to filter events.

HEASoft ftaddspec can remove DATE-OBS, DATE-END, and the grade selection from a merged spectrum; addspec can also remove DATAMODE. The dateobs, dateend, grade, and datamode parameters provide explicit values for missing header keywords. AUTO reads the input spectrum. An explicit value only fills a missing keyword; if the input already contains a different value, fxtbkggen stops with an error. Values used to fill missing cards are recorded in the output HISTORY, and the input file is never modified.

For a merged spectrum, dateobs and dateend must be the actual earliest start and latest end of the merged inputs. Do not derive dates from EXPOSURE: exposure is a duration and does not define an absolute epoch. The original spectra must have grade 0:12 and DATAMODE=FF; these parameters repair missing metadata only. Across calibration periods or changing particle-background rates, run fxtbkggen per observation before merging. The fxtobsmerge workflow already follows this boundary.

When the particle template has a supported reference-area convention, the output spectrum carries the effective detector-area information needed by fxtbkgmap AUTO normalization. Its BACKSCAL is retained from the particle-background template, while BKGREF records the BACKSCAL normalization denominator in reference pixels. It may be the legacy 361201 template convention or the native IMG-monitor value 360000; it is not necessarily the dimensions of the actual SKY image. BKGPIXA records the reference pixel area, BKGUNIT=deg2 identifies the area unit, and BKGASRC records the source of the reference-area metadata. This allows a map to use the physical area BACKSCAL * BKGREF * BKGPIXA without applying the bad-pixel or bad-column correction a second time. An unknown template convention is reported as a warning and leaves these reference keywords absent; the spectrum remains usable, but fxtbkgmap AUTO then fails explicitly and a positive numeric bkgimgpixels is required. A partial or invalid declared reference-area set is an error and stops fxtbkggen, preventing an output spectrum with unreliable area metadata.

PARAMETER SUMMARY

This table is synchronized with the installed HEASoft parameter file. Mode letters follow the standard PFILES convention.

ParameterTypeModeDefault / rangePurpose
infilesqrequiredinput the spectral file extracted from the cleaned frame store area events
outfilesqrequiredoutput file name of the instrumental background spectrum
clobberbhyesOverwrite existing output file (yes/no)
dateobsshAUTOMissing DATE-OBS fallback (YYYY-MM-DDThh:mm:ss); AUTO reads the spectrum
dateendshAUTOMissing DATE-END fallback (YYYY-MM-DDThh:mm:ss); AUTO reads the spectrum
gradeshAUTOMissing grade selection fallback (0:12); AUTO reads the spectrum
datamodeshAUTOMissing DATAMODE fallback (FF); AUTO reads the spectrum
normmethodshfsa; choices fsa | imgheParticle normalization method; hidden parameter, with FSA as the default
imgspecfileshNONEPHA from a source-free cleaned FF IMG region, or an area/exposure-normalized merged monitor from fxtobsmerge; active only when normmethod=imghe
heminrh9.0; minimum 0.5IMGHE E2PI lower endpoint in keV; active only when normmethod=imghe
hemaxrh10.0; minimum 0.5IMGHE E2PI upper endpoint in keV (exclusive); limited by the input E2PI table; active only when normmethod=imghe
heareascalshAUTOEffective particle monitor/template area fraction or explicit positive ratio; active only when normmethod=imghe
heregionshNONEExisting DS9 extraction region for provenance only; it does not filter data
verboseih1; range 0 .. 2Logging verbosity
modeshqlQuery/learn mode

PARAMETERS

infile [file name]
Name of the input frame-store area spectrum FITS file.

outfile [file name]
Name of output particle background spectrum file.
clobber [yes/no]
Overwrite an existing output file. Default: yes.
dateobs [YYYY-MM-DDThh:mm:ss or AUTO]
Fallback for a missing DATE-OBS. Default: AUTO, which reads the input spectrum. An explicit value must be an ISO timestamp and only fills a missing keyword; it must agree with any existing value.
dateend [YYYY-MM-DDThh:mm:ss or AUTO]
Fallback for a missing DATE-END. Default: AUTO, which reads the input spectrum. An explicit value must be an ISO timestamp and only fills a missing keyword; it must agree with any existing value.
grade [0:12 or AUTO]
Fallback for a missing DSVAL1 grade selection. Default: AUTO, which reads the input spectrum. The only explicit grade accepted by fxtbkggen is 0:12; a different existing selection is an error.
datamode [FF or AUTO]
Fallback for a missing DATAMODE. Default: AUTO, which reads the input spectrum. The only explicit mode accepted by fxtbkggen is FF; a different existing mode is an error.
normmethod [fsa or imghe]
Particle normalization method. Default: fsa, which preserves the established FSA method. imghe is an experimental fixed-template high-energy image-monitor method; there is no hybrid mode.
imgspecfile [file name or NONE]
PHA extracted by the user from a source-free region of cleaned FF IMG events, or the area/exposure-normalized img_monitor_merged.pha made by fxtobsmerge, for normmethod=imghe. It must contain ungrouped, unsubtracted COUNTS with AREASCAL=1; RATE-only spectra are not supported. A merged monitor may have fractional counts and must carry its propagated STAT_ERR with POISSERR=F. Default: NONE. The monitor has its own exposure and must match the FSA detector and filter composition, FF mode, grade and selection metadata. For merged spectra, leaf FILTER values and any OBS_ID-to-FILTER pairings must agree. Matching observation times and GTIs are preferred; differences beyond 0.051 s warn and are recorded as TIME_MISMATCH, while a missing GTI is recorded as NO_GTI. This hidden parameter is inactive for normmethod=fsa.
hemin [keV]
Lower endpoint of the IMGHE E2PI normalization band. Default: 9.0 keV. The interface requires finite 0.5 <= hemin < hemax; the input E2PI table supplies the effective upper edge and the lower endpoint is included.
hemax [keV]
Exclusive upper endpoint of the IMGHE E2PI normalization band. Default: 10.0 keV. The default band is [9,10) keV. For the formal 0..1023 table, hemax=12 is valid but excludes PI 1023, whose real-energy row can also contain events clipped from above the table. Set hemin and hemax explicitly to use another interval; these values are learned by PFILES. This default is a candidate band for validation, not a guarantee that source contamination is negligible.
heareascal [AUTO or positive ratio]
Effective particle monitor/template area fraction q. Default: AUTO, allowed only when both PHAs have validated physical area references. Otherwise supply an explicit finite positive ratio. No celestial vignetting correction is applied.
heregion [DS9 file name or NONE]
Optional existing DS9 IMG extraction-region file. Default: NONE. It is recorded for provenance only and does not filter the spectrum; this hidden parameter is inactive for normmethod=fsa.
verbose
Logging verbosity: 0=warning/error, 1=normal info, 2=debug. Default: 1.

Parameter values are learned through the active PFILES directory. To restore all four metadata fallbacks to AUTO, use explicit dateobs=AUTO dateend=AUTO grade=AUTO datamode=AUTO values or run punlearn fxtbkggen.

EXAMPLES

  1.  >fxtbkggen infile=fsa.pha outfile=imgbkg.pha clobber=yes
        
  2. Supply metadata removed by a merge tool, using the actual merged time span:

     >fxtbkggen infile=merged_fsa.pha outfile=imgbkg.pha dateobs=2024-01-02T03:04:05 dateend=2024-01-03T05:06:07 grade=0:12 datamode=FF
        
  3. For a known mixed 01/02 FSA merge, disable only the cross-input FILTER equality check, then generate the particle background from the merged PHA. This requires complete MERGE_INPUTS leaf provenance; if the output carries FILTER=MULTIPLE, that card is interpreted only through the proven 01/02 composition:

     >fxtspecmerge infiles=@fsa_mixed_filters.lst outfile=fsa_mixed.pha sumtype=TIME checkfilter=no backfiles=NONE arffiles=NONE rmffiles=NONE clobber=yes
     >fxtbkggen infile=fsa_mixed.pha outfile=fsa_mixed_bkg.pha normmethod=fsa dateobs=AUTO dateend=AUTO grade=AUTO datamode=AUTO
        

    This coaddition does not make different-filter photon responses or calibration periods equivalent. When those conditions vary, generate each observation's background before merging. For normmethod=imghe, use the corresponding IMG monitor with matching filter composition and valid heareascal: use AUTO only with validated physical area references, otherwise provide a finite positive ratio.

  4. First select a source-free IMG region and extract img_monitor.pha from its cleaned events, retaining matching detector/filter/mode/grade metadata and correct effective area metadata. Follow the science filtering when possible; small time-selection differences are warnings and are recorded in the output. Run the experimental method with the default E2PI band explicitly selected (overriding learned energy limits):

     >fxtbkggen infile=fsa.pha outfile=imgbkg_imghe.pha normmethod=imghe imgspecfile=img_monitor.pha hemin=9 hemax=10 heareascal=AUTO heregion=img_monitor.reg
        
  5. For a multi-observation merge, use the merged monitors produced by fxtobsmerge. The command has already matched GTIs and standardized monitor area/exposure weights; do not feed raw per-observation IMG PHA sums here:

     >fxtbkggen infile=fsa_merged.pha outfile=particle_bkg_merged.pha normmethod=imghe imgspecfile=img_monitor_merged.pha hemin=9 hemax=10 heareascal=AUTO
        
  6. Choose another normalization band with hemin and hemax. This example selects [8.5,10) keV; it demonstrates the interface and does not establish that this band is free of source or line contamination:

     >fxtbkggen infile=fsa.pha outfile=imgbkg_imghe.pha normmethod=imghe imgspecfile=img_monitor.pha hemin=8.5 hemax=10 heareascal=AUTO heregion=img_monitor.reg
        
  7. Use an explicit positive particle-area ratio when AUTO cannot validate both PHA area references. The value below is illustrative; derive the ratio from the actual effective area and calibrated particle spatial model:

     >fxtbkggen infile=fsa.pha outfile=imgbkg_imghe.pha normmethod=imghe imgspecfile=img_monitor.pha heareascal=0.75
        
  8. Restore learned fallbacks to header-driven behavior:

     >punlearn fxtbkggen
        

BUGS

SEE ALSO

Manual page updated

2026-11-04