BCFTMW
BCFTMW is the CP-FTMW container exposed by
BCExperiment as exp.ftmw whenever the
experiment folder contains an fid/ subdirectory. It loads
fid/fidparams.csv and fid/processing.csv once at construction
and serves BCFid objects on demand through
get_fid; the per-FID waveform data is read lazily, so opening a
large experiment is cheap.
The ftmw_type attribute carries the FtmwType value from
objectives.csv and gates the API surface that is meaningful for
each acquisition mode. Target_Shots, Target_Duration, and
Forever acquisitions store their cumulative final FID as 0.csv
and intermediate backups as 1.csv, 2.csv, …;
get_differential_fid exposes shots collected between two backup
points by subtracting their raw integer data. LO_Scan, DR_Scan,
and Peak_Up acquisitions store independent segments instead, so
get_differential_fid is rejected for those modes and num_backups
returns zero.
process_sideband performs the same sideband deconvolution that
Blackchirp’s GUI applies to LO-scan acquisitions. Frequency-shifted
copies of every segment’s FT are interpolated onto a common global
grid, the chosen sideband(s) are co-averaged, and the result is
returned in the requested frequency units. The algorithm and the
upper / lower / both options are described in detail on the
CP-FTMW user-guide page under
“Sideband Deconvolution”.
API Reference
- class blackchirp.BCFTMW(path: str, sep: str, ftmw_type: str = '')
Storage object for CP-FTMW data
The
BCFTMWclass loads FID and processing data for CP-FTMW experiments. It provides functions for accessing FIDs and for performing processing tasks that involve analyzing multiple FIDs in a single operation (e.g., sideband deconvolution in an LO Scan experiment).This class is not meant to be initialized directly by the user; it is created automatically by BCExperiment.
- Parameters:
path – Path to fid directory
sep – CSV delimiter
ftmw_type –
FtmwTypevalue fromobjectives.csv. Used to gate the differential-FID API to single-segment acquisitions.
Examples
Loading an experiment and reading a FID (0.csv):
from blackchirp import * exp = BCExperiment('path/to/experiment') # The BCFTMW object is exp.ftmw if the experiment contains CP-FTMW data. fid = exp.ftmw.get_fid()
Performing upper sideband deconvolution, harmonic mean, FT range 0.1-1.0 GHz per segment:
x, y = exp.ftmw.process_sideband(which='upper', avg='harmonic', min_ft_offset=100.0, max_ft_offset=1000.0)
Viewing only the shots collected after the second backup, mirroring Blackchirp’s “differential backup” view:
diff_fid = exp.ftmw.get_differential_fid(start=2) x, y = diff_fid.ft()
- fidparams
Contents of fidparams.csv file
- Type:
DataFrame
- proc
Contents of processing.csv file
- Type:
dict
- numfids
Number of FIDs specified in fidparams.csv
- Type:
int
- ftmw_type
FtmwTypevalue fromobjectives.csv(e.g."Forever","LO_Scan").- Type:
str
- get_differential_fid(start: int = 0, end: int = -1) BCFid
Build a FID from shots collected between two backup points.
Mirrors Blackchirp’s “differential backup” view, with a more general two-bound interface. The returned
BCFidrepresents the shots collected between backupstartand backupend: its raw integer data israw[end] - raw[start]and itsfidparams.shotsisshots[end] - shots[start].- Parameters:
start – Backup index to subtract.
0(default) means do not subtract anything — the differential begins at the start of the experiment. A positive value loadsstart.csvand subtracts it from the upper-bound FID.end – Backup index to use as the upper bound.
-1(default) means the cumulative final FID (0.csv). A positive value loadsend.csv.
- Returns:
A BCFid containing the differential data, with
fidparams.shotsandshotsset to the shot difference.- Raises:
ValueError – If the experiment is multi-segment (
LO_Scan,DR_Scan,Peak_Up— backups do not exist for these modes), ifstartorendis out of range, if the resolved(start, end)pair is not strictly ordered, or if the start and end FIDs have a different number of frames.
- get_fid(num: int = 0) BCFid
Loads a (potentially multi-frame) FID from disk.
For standard acquisition modes (Target Shots, Target Time, and Forever), the complete FID is stored as
0.csvand would correspond tonum=0, the default. Any other CSV files are backups and are accessed by providing the desired backup number fornum.For other acquisition modes that consist of several segments (LO Scan, DR Scan),
numcorresponds to the desired segment.- Parameters:
num – Number of FID file to load.
- Returns:
A BCFid object containing the requested FID
- Raises:
ValueError – If
numis out of range for this experiment.
- is_multi_segment() bool
Indicate whether the FID files represent independent segments.
- Returns:
TrueforLO_Scan,DR_Scan, andPeak_Upacquisitions, where eachN.csvis an independent segment rather than a backup.FalseforTarget_Shots,Target_Duration, andForever, where0.csvis the cumulative final FID and1.csv,2.csv, … are intermediate backups.
- num_backups() int
Return the number of backup FIDs available.
- Returns:
Number of intermediate backup FIDs available (
len(fidparams) - 1for single-segment acquisitions;0for multi-segment acquisitions, which do not have backups).
- process_sideband(which: str = 'both', avg: str = 'harmonic', min_ft_offset: float = None, max_ft_offset: float = None, frame: int = 0, verbose: bool = False, freq_units: str = 'MHz', **proc_kwargs) tuple[numpy.ndarray, numpy.ndarray]
Performs sideband deconvolution on an LO Scan experiment
See Sideband Deconvolution for an explanation of the purpose of the algorithm. The arguments correspond to the options available in the Sideband Processing and FID processing menus in Blackchirp.
- Parameters:
which – {‘both’, ‘upper’, ‘lower’} Sideband to use in deconvolution.
avg – {‘harmonic’, ‘geometric’} Whether to use a harmonic or geometric mean for overlapped segments.
min_ft_offset – Minimum offset frequency for sideband, in MHz. Value is relative to the Downconversion LO frequency. Defaults to 0.0 MHz.
max_ft_offset – Maximum offset frequency for sideband, in MHz. Value is relative to the Downconversion LO frequency. Defaults to the FT bandwidth.
frame – Frame number (indexed from 0). If negative, all frames will be averaged
verbose – If true, print a progress message during the deconvolution.
freq_units – Units for the returned frequency array. One of
"Hz","kHz","MHz"(default),"GHz","THz".min_ft_offsetandmax_ft_offsetare always interpreted in MHz regardless of this choice.**proc_kwargs – FID processing settings passed as **kwargs to BCFid.ft. A
freq_unitsentry here is ignored — the deconvolution is computed in MHz and rescaled at the end via the explicitfreq_unitsargument.
- Returns:
Frequency (in
freq_units) and intensity arrays for the processed spectrum.- Raises:
ValueError – If
whichis not one of'both','upper','lower'; ifavgis not'harmonic'or'geometric'; ifmin_ft_offsetormax_ft_offsetis non-positive; iffreq_unitsis not a recognised frequency-unit string; or if any FID’ssidebandvalue is unrecognised (propagated fromBCFid.is_lower_sideband).