cape.pycart.dataBook: pyCart data book module

Databook module for cape.pycart

This module contains functions for reading and processing forces, moments, and other statistics from cases in a trajectory.

# Read Cart3D control instance
cntl = cape.pycart.cntl.Cntl("pyCart.json")
# Read the data book
cntl.ReadDataBook()
# Get a handle
db = cntl.DataBook

Data book modules are also invoked during update and reporting command-line calls.

$ pycart --aero
$ pycart --ll
$ pycart --report
See Also:
class cape.pycart.dataBook.CaseFM(comp: str, **kw)

Cart3D iterative force & moment class

This class contains methods for reading data about an the history of an individual component for a single case. It reads the file {comp}.dat where comp is the name of the component. From this file it determines which coefficients are recorded automatically. If some of the comment lines from the Cart3D output file have been deleted, it guesses at the column definitions based on the number of columns.

Call:
>>> fm = CaseFM(comp)
Inputs:
comp: str

Name of component to process

Outputs:
fm: cape.pycart.dataBook.CaseFM

Instance of the force and moment class

fm.coeffs: list[str]

List of coefficients

get_filelist() list

Get ordered list of files to read to build iterative history

Call:
>>> filelist = h.get_filelist()
Inputs:
h: CaseData

Single-case iterative history instance

Outputs:
filelist: list[str]

List of files to read

Versions:
  • 2024-01-22 @ddalle: v1.0

readfile(fname: str) dict

Read cart3D {COMP}.dat file

Call:
>>> data = h.readfile(fname)
Inputs:
h: CaseData

Single-case iterative history instance

fname: str

Name of file to read

Outputs:
data: tsvfile.TSVSimple

Data to add to or append to keys of h

Versions:
  • 2024-01-22 @ddalle: v1.0

class cape.pycart.dataBook.CaseResid(**kw)

Iterative history class

This class provides an interface to residuals, CPU time, and similar data for a given run directory

Call:
>>> hist = CaseResid()
Outputs:
hist: cape.pycart.dataBook.CaseResid

Instance of the run history class

get_filelist() list

Get ordered list of files to read to build iterative history

Call:
>>> filelist = h.get_filelist()
Inputs:
h: CaseResid

Single-case iterative history instance

Outputs:
filelist: list[str]

List of files to read

Versions:
  • 2024-01-23 @ddalle: v1.0

readfile(fname: str) dict

Read cart3D history.dat file

Call:
>>> data = h.readfile(fname)
Inputs:
h: CaseData

Single-case iterative history instance

fname: str

Name of file to read

Outputs:
data: tsvfile.TSVSimple

Data to add to or append to keys of h

Versions:
  • 2024-01-23 @ddalle: v1.0

class cape.pycart.dataBook.DBComp(comp, cntl, targ=None, check=False, lock=False, **kw)
class cape.pycart.dataBook.DBTarget(targ, x, opts, RootDir=None)
class cape.pycart.dataBook.DBTriqFM(x, opts, comp, **kw)

Force and moment component extracted from surface triangulation

Call:
>>> DBF = DBTriqFM(x, opts, comp, RootDir=None)
Inputs:
x: cape.runmatrix.RunMatrix

RunMatrix/run matrix interface

opts: cape.options.Options

Options interface

comp: str

Name of TriqFM component

RootDir: {None} | st

Root directory for the configuration

Outputs:
DBF: cape.pycart.dataBook.DBTriqFM

Instance of TriqFM data book

Versions:
  • 2017-03-29 @ddalle: v1.0

GetTriqFile()

Get most recent triq file and its associated iterations

Call:
>>> qtriq, ftriq, n, i0, i1 = DBF.GetTriqFile()
Inputs:
DBF: cape.pycart.dataBook.DBTriqFM

Instance of TriqFM data book

Outputs:
qtriq: {False}

Whether or not to convert file from other format

ftriq: str

Name of triq file

n: int

Number of iterations included

i0: int

First iteration in the averaging

i1: int

Last iteration in the averaging

Versions:
  • 2016-12-19 @ddalle: v1.0

class cape.pycart.dataBook.DataBook(cntl, RootDir=None, targ=None, **kw)

Interface to the overall Cart3D run matrix

Call:
>>> DB = pyCart.dataBook.DataBook(x, opts)
Inputs:
x: cape.pycart.runmatrix.RunMatrix

The current pyCart trajectory (i.e. run matrix)

opts: cape.pycart.options.Options

Global pyCart options instance

Outputs:
DB: cape.pycart.dataBook.DataBook

Instance of the pyCart data book class

Versions:
  • 2015-01-03 @ddalle: v1.0

  • 2015-10-16 @ddalle: v1.1: subclass

Delete(I)

Delete list of cases from data book

Call:
>>> DB.Delete(I)
Inputs:
DB: cape.pycart.dataBook.DataBook

Instance of the pyCart data book class

I: list[int]

List of trajectory indices or update all cases in trajectory

Versions:
  • 2015-03-13 @ddalle: v1.0

GetCurrentIter()

Determine iteration number of current folder

Call:
>>> n = DB.GetCurrentIter()
Inputs:
DB: cape.pycart.dataBook.DataBook

Instance of data book class

Outputs:
n: int | None

Iteration number

Versions:
  • 2017-04-13 @ddalle: v1.0

ReadCaseFM(comp)

Read a CaseFM object

Call:
>>> FM = DB.ReadCaseFM(comp)
Inputs:
DB: cape.pycart.dataBook.DataBook

Instance of data book class

comp: str

Name of component

Outputs:
FM: pyFun.dataBook.CaseFM

Residual history class

Versions:
  • 2017-04-13 @ddalle: First separate version

ReadCaseResid()

Read a CaseResid object

Call:
>>> H = DB.ReadCaseResid()
Inputs:
DB: cape.pycart.dataBook.DataBook

Instance of data book class

Outputs:
H: pyFun.dataBook.CaseResid

Residual history class

Versions:
  • 2017-04-13 @ddalle: First separate version

ReadDBComp(comp, check=False, lock=False)

Initialize data book for one component

Call:
>>> DB.ReadDBComp(comp, check=False, lock=False)
Inputs:
DB: cape.pycart.dataBook.DataBook

Instance of the pyCart data book class

comp: str

Name of component

check: True | {False}

Whether or not to check LOCK status

lock: True | {False}

If True, wait if the LOCK file exists

Versions:
  • 2015-11-10 @ddalle: v1.0

  • 2016-06-27 @ddalle: v1.1; add targ keyword

  • 2017-04-13 @ddalle: v2.0; self-contained

ReadLineLoad(comp, conf=None, targ=None)

Read a line load data book target if not already present

Call:
>>> DB.ReadLineLoad(comp)
Inputs:
DB: pycart.dataBook.DataBook

Instance of the pycart data book class

comp: str

Line load component group

conf: {"None"} | cape.config.Config

Surface configuration interface

targ: {"None"} | str

Sets alternate directory to read from, defaults to DB.targ

Versions:
  • 2015-09-16 @ddalle: v1.0

  • 2016-06-27 @ddalle: v1.1; add targ

ReadPointSensor(name, pts=None)

Read a point sensor group if it is not already present

Call:
>>> DB.ReadPointSensor(name)
Inputs:
DB: cape.pycart.dataBook.DataBook

Instance of the pyCart data book class

name: str

Name of point sensor group

Versions:
  • 2015-12-04 @ddalle: v1.0

ReadTarget(targ)

Read a data book target if it is not already present

Call:
>>> DB.ReadTarget(targ)
Inputs:
DB: cape.pycart.dataBook.DataBook

Instance of the Cape data book class

targ: str

Target name

Versions:
  • 2015-09-16 @ddalle: v1.0

ReadTriqFM(comp, check=False, lock=False)

Read a TriqFM data book if not already present

Call:
>>> DB.ReadTriqFM(comp, check=False, lock=False)
Inputs:
DB: cape.pycart.dataBook.DataBook

Instance of pyCart data book class

comp: str

Name of TriqFM component

check: True | {False}

Whether or not to check LOCK status

lock: True | {False}

If True, wait if the LOCK file exists

Versions:
  • 2017-03-29 @ddalle: v1.0

UpdatePointSensor(name, I=None)

Update a point sensor group data book for a list of cases

Call:
>>> DB.UpdatePointSensorGroup(name)
>>> DB.UpdatePointSensorGroup(name, I)
Inputs:
DB: cape.pycart.dataBook.DataBook

Instance of the pyCart data book class

I: list[int] or None

List of trajectory indices or update all cases in trajectory

Versions:
  • 2015-10-04 @ddalle: v1.0