cape.cfdx.casedata: Single-case data interfaces¶
This module provides the classes CaseFM and
CaseResid that resid iterative histories of various types.
- class cape.cfdx.casedata.CaseData(meta: bool = False, runner=None, **kw)¶
Base class for case iterative histories
- Call:
>>> fm = CaseData()
- Outputs:
- fm:
cape.cfdx.databook.CaseData Base iterative history class
- fm:
- Versions:
2015-12-07
@ddalle: v1.02024-01-10
@ddalle: v2.0
- ExtractValue(c: str, col=None, **kw)¶
Extract the iterative history for one coefficient/state
This function may be customized for some modules
- Call:
>>> C = fm.Extractvalue(c) >>> C = fm.ExtractValue(c, col=None)
- Inputs:
- Outputs:
- C:
np.ndarray Values for c at each iteration or sample interval
- C:
- Versions:
2015-12-07
@ddalle: v1.02024-01-10
@ddalle: v2.0, CaseFM -> DataKit
- GetIterationIndex(i: int)¶
Return index of a particular iteration in fm.i
If the iteration i is not present in the history, the index of the last available iteration less than or equal to i is returned.
- Call:
>>> j = fm.GetIterationIndex(i)
- Inputs:
- fm:
cape.cfdx.databook.CaseData Case component history class
- i:
int Iteration number
- fm:
- Outputs:
- j:
int Index of last iteration less than or equal to i
- j:
- Versions:
2015-03-06
@ddalle: v1.0 (CaseFM)2015-12-07
@ddalle: v1.02024-01-11
@ddalle: v1.1; use keys instead of attrs
- PlotValue(c: str, col=None, n=None, **kw)¶
Plot an iterative history of some value named c
- Call:
>>> h = fm.PlotValue(c, n=None, **kw)
- Inputs:
- fm:
cape.cfdx.databook.CaseData Case component history class
- c:
str Name of coefficient to plot, e.g.
'CA'- xcol: {
'i} |str Column to plot on x-axis
- n:
int Only show the last n iterations
- nMin: {
0} |int First iteration allowed for use in averaging
- nAvg, nStats: {
100} |int Use at least the last nAvg iterations to compute an average
- dnAvg, dnStats: {nStats} |
int Use intervals of dnStats iterations for candidate windows
- nMax, nMaxStats: {nStats} |
int Use at most nMax iterations
- d:
float Delta in the coefficient to show expected range
- k:
float Multiple of iterative standard deviation to plot
- u:
float Multiple of sampling error standard deviation to plot
- err:
float Fixed sampling error; only available by default for
welch- WindowMethod: {
"autocorrelation"} |"welch" Method used to select the averaging window
- nLast:
int Last iteration to use (defaults to last iteration available)
- nStartup: {
None} |int First iteration used to calculate the full-history range
- nCutoff: {
None} |int Iteration at which to approve regardless of convergence
- nFirst:
int First iteration to plot
- FigureWidth:
float Figure width
- FigureHeight:
float Figure height
- PlotOptions:
dict Dictionary of additional options for line plot
- StDevOptions:
dict Options passed to
plt.fill_between()for stdev plot- ErrPltOptions:
dict Options passed to
plt.fill_between()for uncertainty plot- DeltaOptions:
dict Options passed to
plt.plot()for reference range plot- MeanOptions:
dict Options passed to
plt.plot()for mean line- ShowMu:
bool Option to print value of mean
- ShowSigma:
bool Option to print value of standard deviation
- ShowError:
bool Option to print value of sampling error
- ShowDelta:
bool Option to print reference value
- MuFormat: {
"%.4f"} |str Format for text label of the mean value
- DeltaFormat: {
"%.4f"} |str Format for text label of the reference value d
- SigmaFormat: {
"%.4f"} |str Format for text label of the iterative standard deviation
- ErrorFormat: {
"%.4f"} |str Format for text label of the sampling error
- XLabel:
str Specified label for x-axis, default is
I"teration Number"- YLabel:
str Specified label for y-axis, default is c
- Grid: {
None} |True|False Turn on/off major grid lines, or leave as is if
None- GridStyle: {
{}} |dict Dictionary of major grid line line style options
- MinorGrid: {
None} |True|False Turn on/off minor grid lines, or leave as is if
None- MinorGridStyle: {
{}} |dict Dictionary of minor grid line line style options
- Ticks: {
None} |False Turn off ticks if
False- XTicks: {Ticks} |
None|False|list x-axis tick levels, turn off if
Falseor[]- YTicks: {Ticks} |
None|False|list y-axis tick levels, turn off if
Falseor[]- TickLabels: {
None} |False Turn off tick labels if
False- XTickLabels:{
None} |False|list x-axis tick labels, turn off if
Falseor[]- YTickLabels: {
None} |False|list y-axis tick labels, turn off if
Falseor[]
- fm:
- Outputs:
- h:
dict Dictionary of figure/plot handles
- h:
- Versions:
2014-11-12
@ddalle: v1.02014-12-09
@ddalle: v1.1; move toAeroPlotclass2015-02-15
@ddalle: v1.2; move toAeroclass2015-03-04
@ddalle: v1.3; add nStart and nLast2015-12-07
@ddalle: v1.4; move toCaseData2017-10-12
@ddalle: v1.5; add grid and tick options2024-01-10
@ddalle: v1.6; DataKit updates2026-09-05
@openai: v1.7; selectable window method
- PlotValueHist(coeff: str, nAvg=100, nLast=None, **kw)¶
Plot a histogram of the iterative history of some value c
- Call:
>>> h = fm.PlotValueHist(comp, c, n=1000, nAvg=100, **kw)
- Inputs:
- fm:
cape.cfdx.databook.CaseData Instance of the component force history class
- comp:
str Name of component to plot
- c:
str Name of coefficient to plot, e.g.
'CA'- nAvg:
int Use the last nAvg iterations to compute an average
- nBins: {
20} |int Number of bins in histogram, also can be set in HistOptions
- nLast:
int Last iteration to use (defaults to last iteration available)
- fm:
- Keyword Arguments:
- FigureWidth:
float Figure width
- FigureHeight:
float Figure height
- Label: [ {comp} |
str] Manually specified label
- TargetValue:
float|list[float] Target or list of target values
- TargetLabel:
str|list(str) Legend label(s) for target(s)
- StDev: [ {None} |
float] Multiple of iterative history standard deviation to plot
- HistOptions:
dict Plot options for the primary histogram
- StDevOptions:
dict Dictionary of plot options for the standard deviation plot
- DeltaOptions:
dict Options passed to
plt.plot()for reference range plot- MeanOptions:
dict Options passed to
plt.plot()for mean line- TargetOptions:
dict Options passed to
plt.plot()for target value lines- OutlierSigma: {
7.0} |float Standard deviation multiplier for determining outliers
- ShowMu:
bool Option to print value of mean
- ShowSigma:
bool Option to print value of standard deviation
- ShowError:
bool Option to print value of sampling error
- ShowDelta:
bool Option to print reference value
- ShowTarget:
bool Option to show target value
- MuFormat: {
"%.4f"} |str Format for text label of the mean value
- DeltaFormat: {
"%.4f"} |str Format for text label of the reference value d
- SigmaFormat: {
"%.4f"} |str Format for text label of the iterative standard deviation
- TargetFormat: {
"%.4f"} |str Format for text label of the target value
- XLabel:
str Specified label for x-axis, default is
Iteration Number- YLabel:
str Specified label for y-axis, default is c
- FigureWidth:
- Outputs:
- h:
dict Dictionary of figure/plot handles
- h:
- Versions:
2015-02-15
@ddalle: v1.02015-03-06
@ddalle: v1.1; add nLast2015-03-06
@ddalle: v1.2; change class2024-01-10
@ddalle: v1.3; DataKit updates
- append_casedata(data: dict, jsrc=None, typ='raw')¶
Append data read from a single file
- Call:
>>> h.append_casedata(data, jsrc=None, typ="raw")
- Inputs:
- Versions:
2024-01-22
@ddalle: v1.02024-02-21
@ddalle: v1.1; add typ2024-06-24
@ddalle: v1.2; call trim_repeat_iters()
- apply_mask(mask=None, parent: str = 'i')¶
Remove subset of iterative history
- Call:
>>> h.apply_mask(mask, parent="i")
- Inputs:
- h:
CaseData Single-case iterative history instance
- mask:
np.ndarray[bool|int] Optional mask of which cases to keep
- parent: {
"i"} |str Name of iterations column
- h:
- Versions:
2024-01-22
@ddalle: v1.02024-02-20
@ddalle: v1.1; add parent
- apply_mask_iters(mask: ndarray)¶
Apply a mask to simple iteration history
- Call:
>>> db.apply_mask_iters(mask)
- Inputs:
- db:
cape.cfdx.casedata.CaseData Single-case iterative history interface
- mask:
np.ndarray[int|bool] Mask of indices or booleans of which to keep
- db:
- Versions:
2025-07-31
@ddalle: v1.0
- get_col_state(col: str, nmin: int | None = None, nstats: int | None = None, nmax: int | None = None, nlast: int | None = None, nstartup: int | None = None, ncutoff: int | None = None, **kw) dict¶
Get column state using autocorrelation-based windows
- Call:
>>> state = db.get_col_state(col)
- Inputs:
- db:
CaseData Iterative history data instance
- col:
str Name of column to analyze
- nmin: {
None} |int First iteration index allowed in statistics windows
- nstats: {
None} |int Minimum statistics-window size
- nmax: {
None} |int Maximum statistics-window size
- nlast: {
None} |int Last iteration to include; negative values are relative to the last available iteration
- nstartup: {
None} |int First iteration to include when calculating full_range
- ncutoff: {
None} |int Iteration at which to approve regardless of convergence
- FullRangeStdFactor: {
6.0} |float Standard-deviation multiplier for the effective full range
- TargetDriftFraction: {
5e-4} |float Target drift as a fraction of the effective full range
- TargetDriftFractionMap: {
{}} |dict Per-column overrides for TargetDriftFraction
- TargetMeanRangeFraction: {
5e-4} |float Target window-mean variation as a full-range fraction
- TargetAutocorrelation: {
0.95} |float Base target autocorrelation before window-size scaling
- MaxSignChangeRate: {
0.1} |float Sign-change rate above which retry is recommended
- MinOscillatoryAmplitudeFraction: {
0.01} |float Minimum significant amplitude as a full-range fraction
- MaxOscillatoryAmplitudeRatio: {
1.1} |float Maximum short-to-long-window amplitude ratio
- db:
- Outputs:
- state:
dict State information
- state:
- Versions:
2026-09-03
@openai: v0.12026-09-04
@ddalle: v1.0
- get_col_state_welch(col: str, nmin: int | None = None, nstats: int | None = None, nmax: int | None = None, nlast: int | None = None, **kw) dict¶
Get column statistics using the legacy Welch-window search
This adapts
util.SearchSinusoidFitRange()output to the primary fields returned byget_col_state().- Call:
>>> state = db.get_col_state_welch(col, **kw)
- Inputs:
- db:
CaseData Iterative history data instance
- col:
str Name of column to analyze
- nmin: {
None} |int First iteration allowed in the statistics window
- nstats: {
None} |int Minimum statistics-window size
- nmax: {
None} |int Maximum statistics-window size
- nlast: {
None} |int Last iteration to include; negative values are relative to the last available iteration
- db:
- Outputs:
- state:
dict Statistics using the same primary keys as get_col_state
- state:
- Versions:
2026-09-05
@openai: v1.0
- init_empty()¶
Create empty CaseFM instance
- Call:
>>> h.init_empty()
- Inputs:
- h:
CaseData Single-case iterative history index
- h:
- Versions:
2015-10-16
@ddalle: v1.02023-01-11
@ddalle: v2.0; DataKit updates2024-01-22
@ddalle: v2.1; use class attributes
- init_sourcefiles(meta: bool = False)¶
Initialize file name list and metadata
- Call:
>>> h.init_sourcefiles(meta=False)
- Inputs:
- h:
CaseData Single-case iterative history instance
- meta:
True| {False} Option to only read metadata (skip subiterations)
- h:
- Versions:
2024-01-22
@ddalle: v1.02024-02-21
@ddalle: v1.1; add subiteration hooks2025-08-05
@ddalle: v1.2; add meta
- process_sourcefile(fname: str)¶
Read data from a file (if necessary)
In most cases, developers will NOT nead to customize this function for each application or for each solver.
- process_subiter_sourcefile(fname: str)¶
Read data from a subiteration history file (if necessary)
In most cases, developers will NOT nead to customize this function for each application or for each solver.
- read()¶
Read iterative histroy from all sources
This will first attempt to read the cached histroy from a
.cdbfile and then ready any raw solver output files as necessary.- Call:
>>> h.read()
- Inputs:
- h:
CaseData Single-case iterative history instance
- h:
- Versions:
2024-01-22
@ddalle: v1.02024-02-21
@ddalle: v1.1; add subiteration hooks
- read_cdb()¶
Read contents of history from
.cdbfileSee
capefilemodule. The name of the file will bef"cape/fm_{fm.comp}.cdb".- Call:
>>> fm.read_cdb()
- Inputs:
- fm:
CaseData Iterative history instance
- fm:
- Versions:
2024-01-20
@ddalle: v1.02024-01-22
@ddalle: v1.1; _special_cols check
- readfile(fname: str) dict¶
Read raw data solver file and return a dict
This method needs to be customized for each individual solver.
- readfile_lastiter(fname: str) float¶
Estimate the last iteration of a data file
The purpose of this function is to determine if the file fname needs to be read. If negative, the file is always read.
This function should be customized for each subclass. However, if it isn’t, that just means the latest raw data file written by the solver is always read.
- readfile_subiter(fname: str) dict¶
Read raw data subiteration solver file and return a dict
This method needs to be customized for each individual solver.
- trim_iters()¶
Trim iters that are followed by later restart at lower iter
If a previous case continues past its last restart, the history may contain some iterations that get overwritten during the next run.
- Call:
>>> fm.trim_iters()
- Inputs:
- fm:
CaseData Single-case iterative history instance
- fm:
- Versions:
2024-08-09
@ddalle: v1.0
- class cape.cfdx.casedata.CaseFM(comp: str, **kw)¶
Force and moment iterative histories
This class contains methods for reading data about an the histroy of an individual component for a single case.
- Call:
>>> fm = cape.cfdx.databook.CaseFM(C, MRP=None, A=None)
- Inputs:
- Outputs:
- Versions:
2014-11-12
@ddalle: Starter version2014-12-21
@ddalle: Copied from previous aero.FM
- AddData(A: dict)¶
Add iterative force and/or moment history for a component
- Call:
>>> fm.AddData(A)
- Inputs:
- fm:
CaseFM Instance of the force and moment class
- A:
numpy.ndarrayshape=(N,4) or shape=(N,7) Matrix of forces and/or moments at N iterations
- fm:
- Versions:
2014-11-12
@ddalle: v1.02015-10-16
@ddalle: v2.0; complete rewrite2024-01-10
@ddalle: v2.1; simplify using DataKit
- Copy()¶
Copy an iterative force & moment history
- GetStats(nStats=100, nMax=None, **kw)¶
Get mean, min, max, and stdev for all coefficients
- Call:
>>> s = fm.GetStats(nStats, nMax=None, nLast=None)
- Inputs:
- fm:
CaseFM Instance of the force and moment class
- coeff:
str Name of coefficient to process
- nStats: {
100} |int Min number of iterations in window to use for statistics
- dnStats: {nStats} |
int Interval size for candidate windows
- nMax: (nStats} |
int Maximum number of iterations to use for statistics
- nMin: {
0} |int First usable iteration number
- nLast: {fm.i[-1]} |
int Last iteration to use for statistics
- nStartup: {
None} |int First iteration used to calculate the full-history range
- nCutoff: {
None} |int Iteration at which to approve regardless of convergence
- WindowMethod: {
"autocorrelation"} |"welch" Method used to select the statistics window
- fm:
- Outputs:
- Versions:
2017-09-29
@ddalle: v1.02024-01-10
@ddalle: v1.1; DataKit updates2026-09-05
@openai: v1.2; selectable window method
- GetStatsCoeff(coeff, nStats=100, nMax=None, **kw)¶
Get mean, min, max, and other statistics for one coefficient
- Call:
>>> s = fm.GetStatsCoeff(coeff, nStats=100, nMax=None, **kw)
- Inputs:
- fm:
CaseFM Instance of the force and moment class
- coeff:
str Name of coefficient to process
- nStats: {
100} |int Min number of iterations in window to use for statistics
- dnStats: {nStats} |
int Interval size for candidate windows
- nMax: (nStats} |
int Maximum number of iterations to use for statistics
- nMin: {
0} |int First usable iteration number
- nLast: {fm.i[-1]} |
int Last iteration to use for statistics
- fm:
- Outputs:
- Versions:
2017-09-29
@ddalle: v1.02024-01-10
@ddalle: v1.1; DataKit updates
- GetStatsN(nStats=100, nLast=None)¶
Get mean, min, max, and standard deviation for all coefficients
- Call:
>>> s = fm.GetStatsN(nStats, nLast=None)
- Inputs:
- Outputs:
- Versions:
2014-12-09
@ddalle: v1.02015-02-28
@ddalle: v1.1; wasGetStats()2015-03-04
@ddalle: v1.2; add nLast2024-01-10
@ddalle: v1.3; DataKit updates
- GetStatsOld(nStats=100, nMax=None, nLast=None)¶
Get mean, min, max, and standard deviation for all coefficients
- Call:
>>> s = fm.GetStatsOld(nStats, nMax=None, nLast=None)
- Inputs:
- Outputs:
- Versions:
2015-02-28
@ddalle: v1.02015-03-04
@ddalle: v1.1; add nLast2024-01-10
@ddalle: v1.2; DataKit updates
- PlotCoeff(c: str, n=None, **kw)¶
Plot a single coefficient history
- Call:
>>> h = fm.PlotCoeff(c, n=1000, nAvg=100, **kw)
- Inputs:
- fm:
CaseFM Instance of the component force history class
- c:
str Name of coefficient to plot, e.g.
'CA'- n:
int Only show the last n iterations
- nAvg:
int Use the last nAvg iterations to compute an average
- d:
float Delta in the coefficient to show expected range
- nLast:
int Last iteration to use (defaults to last iteration available)
- nFirst:
int First iteration to plot
- FigureWidth:
float Figure width
- FigureHeight:
float Figure height
- fm:
- Outputs:
- h:
dict Dictionary of figure/plot handles
- h:
- Versions:
2014-11-12
@ddalle: v1.02014-12-09
@ddalle: Transferred toAeroPlot2015-02-15
@ddalle: Transferred todatabook.Aero2015-03-04
@ddalle: Added nStart and nLast2015-12-07
@ddalle: Moved content to base class
- PlotCoeffHist(c: str, nAvg=100, nBin=20, nLast=None, **kw)¶
Plot a single coefficient histogram
- Call:
>>> h = fm.PlotCoeffHist(comp, c, n=1000, nAvg=100, **kw)
- Inputs:
- fm:
CaseFM Instance of the component force history class
- comp:
str Name of component to plot
- c:
str Name of coefficient to plot, e.g.
'CA'- nAvg:
int Use the last nAvg iterations to compute an average
- nBin:
int Number of bins to plot
- nLast:
int Last iteration to use (defaults to last iteration available)
- FigureWidth:
float Figure width
- FigureHeight:
float Figure height
- fm:
- Keyword arguments:
See
cape.cfdx.databook.CaseData.PlotValueHist()
- Outputs:
- h:
dict Dictionary of figure/plot handles
- h:
- Versions:
2015-02-15
@ddalle: v1.02015-03-06
@ddalle: Added nLast and fixed documentation2015-03-06
@ddalle: Copied toCaseFM
- ShiftMRP(Lref, x, xi=None)¶
Shift the moment reference point
- TransformFM(topts: dict, x: dict, i: int)¶
Transform a force and moment history
Available transformations and their parameters are listed below.
“Euler321”: “psi”, “theta”, “phi”
“Euler123”: “phi”, “theta”, “psi”
“ScaleCoeffs”: “CA”, “CY”, “CN”, “CLL”, “CLM”, “CLN”
RunMatrix variables are used to specify values to use for the transformation variables. For example,
topts = {"Type": "Euler321", "psi": "Psi", "theta": "Theta", "phi": "Phi"}
will cause this function to perform a reverse Euler 3-2-1 transformation using x.Psi[i], x.Theta[i], and x.Phi[i] as the angles.
Coefficient scaling can be used to fix incorrect reference areas or flip axes. The default is actually to flip CLL and CLN due to the transformation from CFD axes to standard flight dynamics axes.
tops = {"Type": "ScaleCoeffs", "CLL": -1.0, "CLN": -1.0}
- TrimIters()¶
Trim non-ascending iterations and other problems
- Call:
>>> fm.TrimIters()
- Versions:
2017-10-02
@ddalle: v1.02024-01-10
@ddalle: v2.0; DataKit updates
- genr8_mrp_history() Point¶
Get moment reference point history, w/ motion if applicable
- Call:
>>> x, y, z = fm.genr8_mrp_history() >>> p = fm.genr8_mrp_history()
- Inputs:
- fm:
CaseFM Force & moment iterative history
- fm:
- Outputs:
- x:
np.ndarray[float] Iterative history of xMRP
- y:
np.ndarray[float] Iterative history of xMRP
- z:
np.ndarray[float] Iterative history of xMRP
- p:
cape.cfdx.casedata.Point Named tuple object of p.x, p.y, p.z
- x:
- Versions:
2025-09-26
@ddalle: v1.0
- get_ab_history() Pair¶
Get angles of attack and sideslip, w/ moving-body
This transforms the initial alpha, beta from the run matrix conditions using the Euler angles from moving-body, if present.
- Call:
>>> a, b = fm.get_ab_history()
- Inputs:
- fm:
CaseFM Force & moment iterative history
- fm:
- Outputs:
- a:
np.ndarray|float Angle of attack (history) [deg]
- b:
np.ndarray|float Sideslip angle (history) [deg]
- a:
- Versions:
2025-09-26
@ddalle: v1.0
- get_qbar(vdef: float = 1.0, units: str | None = None) float¶
Get freestream dynamic pressure
- Call:
>>> qref = fm.get_qbar(vdef=1.0, units="mks")
- Inputs:
- Outputs:
- qref:
float Dynamic pressure
- qref:
- Versions:
2025-09-26
@ddalle: v1.0
- get_rotation_origin() Point¶
Get rotation origin [history]
- Call:
>>> x, y, z = fm.get_rotation_origin() >>> p = fm.genr8_mrget_rotation_origin_history()
- Inputs:
- fm:
CaseFM Force & moment iterative history
- fm:
- Outputs:
- x:
np.ndarray|float Coordinate of origin of rotation
- y:
np.ndarray|float Coordinate of origin of rotation
- z:
np.ndarray|float Coordinate of origin of rotation
- p:
cape.cfdx.casedata.Point Named tuple object of p.x, p.y, p.z
- x:
- Versions:
2025-09-26
@ddalle: v1.0
- rotate_mrp(x0: float, y0: float, z0: float) Point¶
Get moment reference point history, w/ motion if applicable
- Call:
>>> x, y, z = fm.rotate_mrp(x0, y0, z0) >>> p = fm.rotate_mrp(x0, y0, z0)
- Inputs:
- fm:
CaseFM Force & moment iterative history
- x0:
np.ndarray|float Coordinate of rotation cnter
- y0:
np.ndarray|float Coordinate of rotation cnter
- z0:
np.ndarray|float Coordinate of rotation cnter
- fm:
- Outputs:
- x:
np.ndarray[float] Iterative history of xMRP
- y:
np.ndarray[float] Iterative history of xMRP
- z:
np.ndarray[float] Iterative history of xMRP
- p:
cape.cfdx.casedata.Point Named tuple object of p.x, p.y, p.z
- x:
- Versions:
2025-09-26
@ddalle: v1.0
- rotate_point_history(x: float | ndarray, y: float | ndarray, z: float | ndarray, x0: float | ndarray, y0: float | ndarray, z0: float | ndarray) Point¶
Rotate a point history using phi, theta, psi
No rotations will be performed if Euler angle columns are not present in
fm.- Call:
>>> p = fm.rotate_point_history(x, y, z, x0, y0, z0)
- Inputs:
- fm:
CaseFM Force & moment iterative history
- x:
np.ndarray|float Pre-rotation point
- y:
np.ndarray|float Pre-rotation point
- z:
np.ndarray|float Pre-rotation point coord
- x0:
np.ndarray|float Coordinate of rotation cnter
- y0:
np.ndarray|float Coordinate of rotation cnter
- z0:
np.ndarray|float Coordinate of rotation cnter
- fm:
- Outputs:
- p:
cape.cfdx.casedata.Point Named tuple object of p.x, p.y, p.z after rotation
- p:
- Versions:
2025-09-26
@ddalle: v1.0
- shift_mrp_body()¶
Shift moment [coefficient] for moving-body MRP movements
- Call:
>>> fm.shift_mrp_body()
- Inputs:
- fm:
CaseFM Instance of the force and moment class
- fm:
- Versions:
2025-09-26
@ddalle: v1.0
- transform_fm321_body()¶
Shift moment [coefficient] for moving-body MRP movements
- Call:
>>> fm.shift_mrtransform_fm321_body()
- Inputs:
- fm:
CaseFM Instance of the force and moment class
- fm:
- Versions:
2025-09-26
@ddalle: v1.0
- trim_iters()¶
Trim any repeated iterations from history
- Call:
>>> db.trim_iters()
- Inputs:
- db;
cape.cfdx.casedata.CaseData Single-case iterative history
- db;
- Versions:
2025-07-31
@ddalle: v1.0
- class cape.cfdx.casedata.CaseResid(meta: bool = False, runner=None, **kw)¶
Iterative residual history class
This class provides an interface to residuals, CPU time, and similar data for a given run directory
- Call:
>>> hist = cape.cfdx.databook.CaseResid()
- Outputs:
- hist:
cape.cfdx.databook.CaseResid Instance of the run history class
- hist:
- GetIterationIndex(i)¶
Return index of a particular iteration in hist.i
If the iteration i is not present in the history, the index of the last available iteration less than or equal to i is returned.
- GetNOrders(nStats: int = 1, col: str | None = None, nLast: int | None = None) float¶
Get the number of orders of magnitude of residual drop
- Call:
>>> nOrders = hist.GetNOrders(nStats=None, col=None)
- Inputs:
- Outputs:
- nOrders: {
1} |float Number of orders of magnitude of residual drop
- nOrders: {
- Versions:
2015-01-01
@ddalle: v1.02024-01-24
@ddalle: v2.0; generalize w/ DataKit apprch2025-08-05
@ddalle: v2.1; add nLast
- GetNOrdersUnsteady(n=1)¶
Get residual drop magnitude
- Call:
>>> nOrders = hist.GetNOrders(n=1)
- Inputs:
- hist:
cape.cfdx.databook.CaseResid Instance of the DataBook residual history
- n:
int Number of iterations to analyze
- hist:
- Outputs:
- nOrders:
numpy.ndarray[float] Number of orders of magnitude of unsteady residual drop
- nOrders:
- Versions:
2015-01-01
@ddalle: First version
- PlotL1(n=None, nFirst=None, nLast=None, **kw)¶
Plot the L1 residual
- Call:
>>> h = hist.PlotL1(n=None, nFirst=None, nLast=None, **kw)
- Inputs:
- Outputs:
- h:
dict Dictionary of figure/plot handles
- h:
- Versions:
2014-11-12
@ddalle: v1.02014-12-09
@ddalle: v1.1; move toAeroPlot2015-02-15
@ddalle: v1.2; move todatabook.Aero2015-03-04
@ddalle: v1.3; add nStart and nLast2015-10-21
@ddalle: v1.4; refer toPlotResid()
- PlotL2(n=None, nFirst=None, nLast=None, **kw)¶
Plot the L2 residual
- Call:
>>> h = hist.PlotL2(n=None, nFirst=None, nLast=None, **kw)
- Inputs:
- Outputs:
- h:
dict Dictionary of figure/plot handles
- h:
- Versions:
2014-11-12
@ddalle: v1.02014-12-09
@ddalle: v1.1; move toAeroPlot2015-02-15
@ddalle: v1.2; move todatabook.Aero2015-03-04
@ddalle: v1.3; add nStart and nLast2015-10-21
@ddalle: v1.4; refer toPlotResid()
- PlotLInf(n=None, nFirst=None, nLast=None, **kw)¶
Plot the L-infinity residual
- Call:
>>> h = hist.PlotLInf(n=None, nFirst=None, nLast=None, **kw)
- Inputs:
- Outputs:
- h:
dict Dictionary of figure/plot handles
- h:
- Versions:
2016-02-04
@ddalle: v1.0
- PlotResid(c='L1Resid', n=None, nFirst=None, nLast=None, **kw)¶
Plot a residual by name
- Call:
>>> h = hist.PlotResid(c='L1Resid', n=None, **kw)
- Inputs:
- hist:
cape.cfdx.databook.CaseResid Instance of the DataBook residual history
- c:
str Name of coefficient to plot
- n:
int Only show the last n iterations
- PlotOptions:
dict Plot options for the primary line(s)
- nFirst:
int Plot starting at iteration nStart
- nLast:
int Plot up to iteration nLast
- FigureWidth:
float Figure width
- FigureHeight:
float Figure height
- YLabel:
str Label for y-axis
- hist:
- Outputs:
- h:
dict Dictionary of figure/plot handles
- h:
- Versions:
2014-11-12
@ddalle: v1.02014-12-09
@ddalle: v1.1; move toAeroPlot2015-02-15
@ddalle: v1.2; move todatabook.Aero2015-03-04
@ddalle: v1.3; add nStart and nLast2015-10-21
@ddalle: v1.4; fromPlotL1()2022-01-28
@ddalle: v1.5; add xcol
- find_subiters(col: str = 'i_sub')¶
Find indices of first and last subiter for each whole iter
- Call:
>>> maska, maskb = hist.find_subiters(col=None)
- Inputs:
- Outputs:
- maska:
np.ndarray[int] Index of first subiter for each whole iter
- maskb:
np.ndarray[int] Index of last subiter for each whole iter
- maska:
- Versions:
2024-07-18
@ddalle: v1.0
- class cape.cfdx.casedata.CaseSurfCp(comp: str, compids: List[str | int], ftriq: str, cntl: CntlBase, i: int)¶
Surface pressure coefficient
This class contains methods for reading data about an the histroy of an individual component for a single case.
- Call:
>>> fm = cape.cfdx.databook.CaseSurfCp()
- Outputs:
- cp:
cape.aero.CaseSurfCp Instance of the surface pressure class
- cp[“casenames”]:
list List of casenames of saved case data
- cp[“x”]:
np.ndarray X-coord of surface pressure points (global)
- cp[“casename.x”]:
np.ndarray X-coord of surface pressure points (case specific)
- cp[“casename.cp”]:
np.ndarray Surface pressure points (case specific)
- cp:
- Versions:
2025-09-26
@aburkhea: Started
- delete_datafile(fname, casename)¶
Delete surfcp data capefile
- get_conditions() dict¶
Get the freestream conditions needed for forces
- Call:
>>> xi = db.get_conditions()
- Inputs:
- db:
CaseTriqFM Interface to TriqFM data for one component of one case
- db:
- Outputs:
- xi:
dict Conditions, incl. Mach (mach), Reynolds number (Re)
- xi:
- Versions:
2017-03-28
@ddalle: v1.02025-08-13
@ddalle: v1.1 (dex)
- get_configfile() str¶
Find configuration file for
.triqfile- Call:
>>> fcfg = db.get_configfile()
- Inputs:
- db:
CaseTriqFM Interface to TriqFM data for one component of one case
- db:
- Outputs:
- fcfg:
str Name of XML/JSON/MIXSUR config file
- fcfg:
- Versions:
2025-08-13
@ddalle: v1.0
- map_tri_compid()¶
Perform any component ID mapping if necessary
- Call:
>>> triq = db.map_tri_compid()
- Inputs:
- db:
CaseTriqFM Interface to TriqFM data for one component of one case
- db:
- Attributes:
- DBF.compmap:
dict Map of component numbers altered during the mapping
- DBF.compmap:
- Versions:
2017-03-28
@ddalle: v1.0
- read_tri_map() Tri¶
Read the surface triangulation mapping file
This file defines the patches for the TriqFM output.
- Call:
>>> triq = db.read_triq()
- Inputs:
- db:
CaseTriqFM Interface to TriqFM data for one component of one case
- db:
- Outputs:
- triq:
cape.trifile.Triq Triangulated surface data (also stored in db.triq)
- triq:
- Versions:
2025-08-13
@ddalle: v1.0
- read_triq() Triq¶
Read the surface solution data from a
.triqfile- Call:
>>> triq = db.read_triq()
- Inputs:
- db:
CaseTriqFM Interface to TriqFM data for one component of one case
- db:
- Outputs:
- triq:
cape.trifile.Triq Triangulated surface data (also stored in db.triq)
- triq:
- Versions:
2025-08-13
@ddalle: v1.0
- write_datafile(fname, casename)¶
Write surfcp data capefile
Defaults to global x,y,z and case specific cp. When writing new case checks if global x,y,z exists then compares it to case x,y,z. Will switch to case x,y,z if they are different. Once case specific x,y,z started, will then always write case specific x,y,z.
- write_dbook_cdb(fname)¶
Write contents of history to
.cdbfile- Call:
>>> fm.write_dbook_cdb(fname)
- Inputs:
- fm:
CaseData Iterative history instance
- fm:
- Versions:
2024-10-09
@aburkhea: v1.0
- write_surf(**kw)¶
Write mapped solution as TRIQ or Tecplot file with zones
- Call:
>>> db.write_triq(**kw)
- Inputs:
- db:
CaseTriqFM Interface to TriqFM data for one component of one case
- db:
- Versions:
2017-03-30
@ddalle: v1.0 (TriqFMDataBook)2025-08-13
@ddalle: v2.0 (dex)
- class cape.cfdx.casedata.CaseTS(comp: str, **kw)¶
Force and moment time series iterative histories
This class contains methods for reading data about an the histroy of an individual component for a single case.
- Call:
>>> fm = cape.cfdx.databook.CaseFM(C, MRP=None, A=None)
- Inputs:
- Outputs:
- Versions:
2024-10-09
@aburkhea: Started
- class cape.cfdx.casedata.DBPlotOpts(*args, **kw)¶
- class cape.cfdx.casedata.FMPair(F, M)¶
Pair for force and moment vector [histories], F, M
- F¶
Alias for field number 0
- M¶
Alias for field number 1
- cape.cfdx.casedata.ImportPyPlot()¶
Import
matplotlib.pyplotif not already loaded- Call:
>>> ImportPyPlot()
- Versions:
2014-12-27
@ddalle: v1.0
- class cape.cfdx.casedata.Pair(a, b)¶
Tuple of two components, e.g. AoA and AoS, a, b
- a¶
Alias for field number 0
- b¶
Alias for field number 1
- class cape.cfdx.casedata.Point(x, y, z)¶
Tuple of coordinates, x, y, z
- x¶
Alias for field number 0
- y¶
Alias for field number 1
- z¶
Alias for field number 2
- class cape.cfdx.casedata.WindowRank(linear_fit_a1, trend_fit_a1, autocorrelation, sinusoid_amplitude)¶
Metrics used to rank candidate statistics windows
- autocorrelation¶
Alias for field number 2
- linear_fit_a1¶
Alias for field number 0
- sinusoid_amplitude¶
Alias for field number 3
- trend_fit_a1¶
Alias for field number 1
- cape.cfdx.casedata.autocorr(v: ndarray, t: ndarray | None = None, n: int = 100) Tuple[float, float]¶
Calculate autocorrelation of iterative history with offsets
- Call:
>>> dt, r = autocorr(v, t=None, n=100)
- Inputs:
- v:
np.ndarray[float] Iterative history
- t: {
None} |np.ndarray Optional time history (or just use iteration number)
- n: {
100} |int Number of offsets to analyze
- v:
- Outputs:
- dt:
np.ndarray[float] Time/iteration shifts
- r:
np.ndarray[float] Autocorrelation at each shift
- dt:
- Versions:
2026-06-14
@ddalle: v1.0
- cape.cfdx.casedata.find_autocorr_peaks(v: ndarray, polyorder: int = 3, window_length: int = 10) tuple¶
Find autocorrelation peaks; ensure alternating anticorr/corr
- Call:
>>> jlo, vlo, jhi, vhi = find_autocorr_peaks(v, **kw)
- Inputs:
- Outputs:
- jlo:
np.ndarray[int] Indices of local minima
- vlo:
np.ndarray[float] Lightly filetered values of v at local minima
- jhi:
np.ndarray[int] Indices of local maxima
- vhi:
np.ndarray[float] Lightly filtered values of v at local maxima
- jlo:
- Versions:
2026-06-17
@ddalle: v1.0
- cape.cfdx.casedata.find_max_autocorr(v: ndarray, polyorder: int = 3, window_length: int = 10) tuple¶
Find the maximum shifted autocorrelation peak
- Call:
>>> j, vmax = find_max_autocorr(v, **kw)
- Inputs:
- Outputs:
- Versions:
2026-09-03
@openai: v1.0
- cape.cfdx.casedata.find_peaks_filtered(v: ndarray, polyorder: int = 3, window_length: int = 10)¶
Find peaks of smoothed iterative history
- Call:
>>> jlo, vlo, jhi, vhi = find_pkeaks_filtered(v, **kw)
- Inputs:
- Outputs:
- jlo:
np.ndarray[int] Indices of local minima
- vlo:
np.ndarray[float] Lightly filetered values of v at local minima
- jhi:
np.ndarray[int] Indices of local maxima
- vhi:
np.ndarray[float] Lightly filtered values of v at local maxima
- jlo:
- Versions:
2026-06-15
@ddalle: v1.02026-09-06
@ddalle: v1.1; default for short histories