cape.pycart.pointSensor: Cart3D point sensors module

This module contains several classes for reading and averaging point sensors. The database classes, DBPointSensorGroup and DBPointSensor, are based on versions from the generic point sensor module cape.cfdx.pointSensor, while the iterative history class CasePointSensor is based off of the generic cape.cfdx.dataBook.CaseData module.

Tracking the iterative history of a point sensor requires declaring a point sensor in the Cart3D input.cntl file and requesting information about it at regularly scheduled iterations.

At present, there is no support for extracting point sensors from a surface solution file ("TriqPoint" data book type).

See also:
class cape.pycart.pointSensor.CasePointSensor

Individual case point sensor history

Call:
>>> P = CasePointSensor()
Outputs:
P: pyCart.pointSensor.CasePointSensor

Case point sensor

P.mach: float

Mach number for this case; for calculating pressure coefficient

P.nPoint: int

Number of point sensors

P.nIter: int

Number of iterations recorded in point sensor history

P.nd: 2 | 3

Number of dimensions

P.iSteady: int

Maximum steady-state iteration number

P.data: numpy.ndarray (nPoint, nIter, 10 | 12)

Data array

Versions:
  • 2015-12-01 @ddalle: First version

AppendIteration(PS)

Add a single-iteration of point sensor data to the history

Call:
>>> P.AppendIteration(PS)
Inputs:
P: pyCart.pointSensor.CasePointSensor

Iterative point sensor history

PS: pyCart.pointSensor.PointSensor

Point sensor

Versions:
  • 2015-11-30 @ddalle: First version

ExtractValue(c, k=None)

Extract the iterative history for one coefficient/state

The following states are available

  • "X": x-coordinate of point

  • "Y": y-coordinate of point

  • "Z": z-coordinate of point

  • "dp": static pressure, \(p/p_\infty-1\)

  • "rho": static density, \(\rho/\rho_\infty\)

  • "U": x-component of velocity, \(u/a_\infty\)

  • "V": y-component of velocity, \(v/a_\infty\)

  • "W": z-component of velocity, \(w/a_\infty\)

  • "P": static pressure, \(p/(\gamma p_\infty)\)

  • "Cp": pressure coefficient, \(dp/(0.7*M_\infty^2\)

  • "p": static pressure, \(p/p_\infty\)

  • "T": Static temperature, \(T/T_\infty\)

  • "M": Mach number

Call:
>>> C = PS.ExtractValue(c, k=None)
Inputs:
PS: pyCart.pointSensor.PointSensor

Point sensor

c: str

Name of state

k: str | int | None

Point sensor name or index

Outputs:
C: np.ndarray

Array of values for c at each sample

Versions:
  • 2015-12-07 @ddalle: First version

GetPointSensorIndex(name)

Get the index of a point sensor by its name in input.cntl

Call:
>>> k = P.GetPointSensorIndex(name)
Inputs:
P: pyCart.pointSensor.CasePointSensor

Iterative point sensor history

name: str

Name of the sensor

Outputs:
k: :class;`int`

Index of nearest point in the sampled data

Versions:
  • 2105-12-04 @ddalle: First version

GetStats(k, nStats=1, nLast=None)

Compute min, max, mean, and standard deviation of each quantity

This includes computing pressure coefficient. NaNs are reported as the standard deviation if nStats is 1 or 0. If the point sensor is two-dimensional, i.e. P.nd is 2, the W velocity is reported as 0.0.

Call:
>>> s = P.GetStats(k, nStats=1, nLast=None)
Inputs:
P: pyCart.pointSensor.CasePointSensor

Iterative point sensor history

nStats: int

Number of samples to use for computing statistics

nLast: int | None

If specified, maximum iteration to use

Outputs:
s: dict[float]

Dictionary of mean, min, max, std for each variable

Versions:
  • 2015-12-04 @ddalle: First version

PlotState(c, pt, **kw)

Plot the iterative history of a state

Call:
>>> h = P.PlotState(c, pt, n=None, nAvg=100, **kw)
Inputs:
P: pyCart.dataBook.PointSensor

Case component history class

c: str

Name of coefficient to plot, e.g. 'Cp'

pt: str | int

Name or index of point sensor

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

k: float

Multiple of iterative standard deviation to plot

u: float

Multiple of sampling error standard deviation to plot

eps: float

Fixed sampling error, default uses SigmaMean()

nLast: int

Last iteration to use (defaults to last iteration available)

nFirst: int

First iteration to plot

FigWidth: float

Figure width

FigHeight: float

Figure height

LineOptions: 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

ShowEpsilon: bool

Option to print value of sampling error

ShowDelta: bool

Option to print reference value

Outputs:
h: dict

Dictionary of figure/plot handles

Versions:
  • 2015-12-07 @ddalle: First version

ReadHist(fname='pointSensors.hist.dat')

Read point sensor iterative history file

Call:
>>> P.ReadHist(fname='pointSensors.hist.dat')
Inputs:
fname: str

Name of point sensor history file

Versions:
  • 2015-11-30 @ddalle: First version

UpdateIterations()

Read any Cart3D point sensor output files and save them

Call:
>>> P.UpdateIterations()
Inputs:
P: pyCart.pointSensor.CasePointSensor

Iterative point sensor history

Versions:
  • 2015-11-30 @ddalle: First version

WriteHist(fname='pointSensors.hist.dat')

Write point sensor iterative history file

Call:
>>> P.WriteHist(fname='pointSensors.hist.dat')
Inputs:
fname: str

Name of point sensor history file

Versions:
  • 2015-12-01 @ddalle: First version

class cape.pycart.pointSensor.DBPointSensor(x, opts, pt, name=None, **kw)

Point sensor data book

Call:
>>> DBP = DBPointSensor(x, opts, pt, name=None)
Inputs:
x: cape.runmatrix.RunMatrix

RunMatrix/run matrix interface

opts: cape.options.Options

Options interface

pt: str

Name of point

name: str | None

Name of data book item (defaults to pt)

RootDir: str | None

Project root directory absolute path, default is PWD

Outputs:
DBP: pyCart.pointSensor.DBPointSensor

An individual point sensor data book

Versions:
  • 2015-12-04 @ddalle: Started

UpdateCase(i)

Prepare to update one point sensor case if necessary

Call:
>>> DBP.UpdateCase(i)
Inputs:
DBP: pyCart.pointSensor.DBPointSensor

An individual point sensor data book

i: int

Case index

Versions:
  • 2015-12-04 @ddalle: First version

class cape.pycart.pointSensor.DBPointSensorGroup(x, opts, name, **kw)

Point sensor group data book

Call:
>>> DBPG = DBPointSensorGroup(x, opts, name)
Inputs:
x: cape.runmatrix.RunMatrix

RunMatrix/run matrix interface

opts: cape.options.Options

Options interface

name: str | None

Name of data book item (defaults to pt)

pts: list[str] | None

List of points to read, by default all points in the group

RootDir: str | None

Project root directory absolute path, default is PWD

Outputs:
DBPG: pyCart.pointSensor.DBPointSensorGroup

A point sensor group data book

Versions:
  • 2015-12-04 @ddalle: First version

UpdateCase(i)

Prepare to update one point sensor case if necessary

Call:
>>> DBPG.UpdateCase(i)
Inputs:
DBPG: pyCart.pointSensor.DBPointSensorGroup

A point sensor group data book

i: int

Case index

Versions:
  • 2015-12-04 @ddalle: First version

cape.pycart.pointSensor.ImportPyPlot()

Import matplotlib.pyplot if not loaded

Call:
>>> pyCart.dataBook.ImportPyPlot()
Versions:
  • 2014-12-27 @ddalle: First version

class cape.pycart.pointSensor.PointSensor(fname='pointSensors.dat', data=None)

Class for individual point sensor

Call:
>>> PS = PointSensor(fname="pointSensors.dat", data=None)
Inputs:
fname: str

Name of Cart3D output point sensors file

data: np.ndarray[float]

Data array with either 9 (2-D) or 11 (3-D) columns

Outputs:
PS: pyCart.pointSensor.PointSensor

Point sensor

PS.data: np.ndarray[float]

Data array with either 9 (2-D) or 11 (3-D) columns

PS.nd: 2 | 3

Number of dimensions of the data

PS.nPoint: int

Number of points in the file

PS.nIter: int

Number of iterations used to calculate the average

Versions:
  • 2015-11-30 @ddalle: First version

ExtractValue(c)

Extract the iterative history for one coefficient/state

The following states are available

  • "X": x-coordinate of point

  • "Y": y-coordinate of point

  • "Z": z-coordinate of point

  • "dp": static pressure, \(p/p_\infty-1\)

  • "rho": static density, \(\rho/\rho_\infty\)

  • "U": x-component of velocity, \(u/a_\infty\)

  • "V": y-component of velocity, \(v/a_\infty\)

  • "W": z-component of velocity, \(w/a_\infty\)

  • "P": static pressure, \(p/(\gamma p_\infty)\)

  • "Cp": pressure coefficient, \(dp/(0.7*M_\infty^2\)

  • "p": static pressure, \(p/p_\infty\)

  • "T": Static temperature, \(T/T_\infty\)

  • "M": Mach number

The values Z and W are not available for 2D data

Call:
>>> C = PS.ExtractValue(c)
Inputs:
PS: pyCart.pointSensor.PointSensor

Point sensor

c: str

Name of state

Outputs:
C: np.ndarray

Array of values for c at each sample

Versions:
  • 2015-12-07 @ddalle: First version

PlotPoint(c, n=None, nAvg=100, **kw)

Plot a single point sensor iterative history

Call:
>>> h = PS.PlotPoint(c, n=None, nAvg=100, **kw)
Inputs:
PS: pyCart.pointSensor.PointSensor

Point sensor

c: {‘dp’} | ‘rho’ | ‘U’ | ‘V’ | ‘W’ | ‘P’

Name of state quantity to plot

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

FigWidth: float

Figure width

FigHeight: float

Figure height

Outputs:
h: dict

Dictionary of figure/plot handles

Versions:
  • 2015-12-07 @ddalle: First version

Write(fname)

Write single-iteration point sensor file

Call:
>>> PS.Write(fname):
Inputs:
PS: pyCart.pointSensor.PointSensor

Point sensor

fname: str

Name of Cart3D output point sensors file

Versions:
  • 2015-11-30 @ddalle: First version

copy()

Copy a point sensor

Call:
>>> P2 = PS.copy()
Inputs:
PS: pyCart.pointSensor.PointSensor

Point sensor

Outputs:
P2: pyCart.pointSensor.PointSensor

Point sensor copied

Versions:
  • 2015-11-30 @ddalle: First version

cape.pycart.pointSensor.get_InputCntl()

Read the best input.cntl or input.??.cntl file

Call:
>>> IC = get_InputCntl()
Outputs:
IC: pyCart.inputCntl.InputCntl

File interface to Cart3D input file input.cntl

Versions:
  • 2015-12-04 @ddalle: First version

cape.pycart.pointSensor.get_iter(fname)

Get iteration number from a point sensor single-iteration file

Call:
>>> i = get_iter(fname)
Inputs:
fname: str

Point sensor file name

Outputs:
i: float

Iteration number or time

Versions:
  • 2015-11-30 @ddalle: First version

cape.pycart.pointSensor.get_mach(IC=None)

Get Mach number from most appropriate input.??.cntl file

Call:
>>> M = get_mach(IC=None)
Inputs:
IC: pyCart.inputCntl.InputCntl

File interface to Cart3D input file input.cntl

Outputs:
M: float

Mach number as determined from Cart3D input file

Versions:
  • 2015-12-01 @ddalle: First version

cape.pycart.pointSensor.get_nStatsPS()

Return info about iterations at which point sensors have been recorded

Call:
>>> nStats = get_nStatsPS()
Outputs:
nIter: int

Last available iteration for which a point sensor is recorded

nStats: int

Number of iterations at which point sensors are recorded

Versions:
  • 2015-12-04 @ddalle: First version