cape.cfdx.pointSensor: Point sensor databook

This module contains a class for reading and averaging point sensors or extracting point sensor data from a CFD solution file. It is not included in the cape.cfdx.dataBook module in order to give finer import control when used in other modules.

Point sensors are often defined in two regions of the main Cape JSON file read by cape.cfdx.options.Options or cape.cntl.Cntl. Usually the coordinates of the points are defined in the "Config" section while the groups and other databook attributes are defined in the "DataBook" section.

The database components are split into groups, so the "DataBook" section of the JSON file may have a point sensor group called "P1" that includes points "p1", "p2", and "p3". To explain this example further, the following JSON snippets could be used to define these three points in one group.

{
    "Config": {
        "Points": {
            "p1": [2.5000, 1.00, 0.00], 
            "p2": [2.5000, 0.00, 1.00],
            "p3": [3.5000, 0.00, 1.00]
        }
    },
    "DataBook": {
        "P1": {
            "Type": "TriqPoint",
            "Points": ["p1", "p2", "p3"]
        }
    }
}

If a data book is read in as DB, the point sensor group DBP for group "P1" and the point sensor p1 are obtained using the commands below.

// Point sensor group
DBP = DB.PointSensors["P1"]
// Individual point sensor
p1 = DBP["p1"]

The same snippet could also be interpreted as a Python dict and used as raw inputs without using cape.cfdx.options.Options. Note that each point sensor group can be one of two point sensor types:

  • "Point": Point sensor data explicitly provided by CFD solver

  • "TriqPoint": Surface point sensor extracted from CFD solution

In many cases, the "Point" type is not fully implemented. It is a very sensitive method since it requires the user to specify the points before running the CFD case (whereas "TriqPoint" just requires a surface solution output), but it is the only way to extract point iterative histories.

Point sensor group data book

class cape.cfdx.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.cfdx.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: cape.cfdx.pointSensor.DBPointSensorGroup

A point sensor group data book

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

DeleteCases(I, pt=None)

Delete list of cases from point sensor data book

Call:
>>> DBPG.Delete(I)
Inputs:
DBPG: cape.cfdx.pointSensor.DBPointSensorGroup

Point sensor group data book

I: list[int]

List of trajectory indices

pt: {None} | list (str) | str

Point name or list of point names

Versions:
  • 2017-10-10 @ddalle: First version

DeleteCasesComp(I, pt)

Delete list of cases from data book

Call:
>>> n = DBPG.Delete(I, pt)
Inputs:
DBPG: cape.cfdx.pointSensor.DBPointSensorGroup

Point sensor group data book

I: list[int]

List of trajectory indices or update all cases in trajectory

pt: str

Name of point sensor

Outputs:
n: int

Number of deleted entries

Versions:
ProcessComps(pt=None, **kw)

Process list of points

This performs several conversions:

comp

Output

None

DBPG.pts

str

pt.split(',')

list

pt

Call:
>>> DBPG.ProcessComps(pt=None)
Inputs:
DB: cape.cfdx.dataBook.DataBook

Point sensor group data book

pt: {None} | list (str) | str

Point name or list of point names

Versions:
  • 2017-10-10 @ddalle: First version

ReadCasePoint(pt, i)

Read point data from current run folder

Call:
>>> P = DBPG.ReadCasePoint(pt, i)
Inputs:
DBPG: cape.cfdx.pointSensor.DBPointGroup

Point sensor group data book

pt: str

Name of point to read

i: int

Case index

Outputs:
P: dict

Dictionary of state variables as requested from the point

Versions:
  • 2017-10-10 @ddalle: First version

ReadPointSensor(pt)

Read a point sensor

This function needs to be customized for each derived class so that the correct class is used for each of the member data books

Call:
>>> DBPG.ReadPointSensor(pt)
Inputs:
DBPG: cape.cfdx.pointSensor.DBPointSensorGroup

A point sensor group data book

pt: str

Name of the point to read

Versions:
  • 2017-10-11 @ddalle: First version

Sort()

Sort point sensor group

Call:
>>> DBPG.Sort()
Inputs:
DBPG: cape.cfdx.pointSensor.DBPointSensorGroup

A point sensor group data book

Versions:
  • 2016-03-08 @ddalle: First version

Update(I=None, pt=None)

Update the data book for a list of cases from the run matrix

Call:
>>> DBPG.Update(I=None, pt=None)
Inputs:
DBPG: cape.cfdx.dataBook.DBPointGroup

Point sensor group data book

I: list[int] | None

List of trajectory indices or update all cases in trajectory

pt: {None} | list (str) | str

Point name or list of point names

Versions:
  • 2017-10-10 @ddalle: First version

UpdateCase(i, pt=None)

Update all points for one case

Call:
>>> n = DBPG.UpdateCase(i, pt=None)
Inputs:
DBPG: cape.cfdx.dataBook.DBPointGroup

Point sensor group data book

i: int

Case index

pt: {None} | list (str) | str

Point name or list of point names

Outputs:
n: 0 | 1

How many updates were made

Versions:
  • 2017-10-11 @ddalle: First version

UpdateCaseComp(i, pt)

Update or add a case to a point data book

The history of a run directory is processed if either one of three criteria are met.

  1. The case is not already in the data book

  2. The most recent iteration is greater than the data book value

  3. The number of iterations used to create statistics has changed

Call:
>>> n = DBPG.UpdateCaseComp(i, pt)
Inputs:
DBPG: cape.cfdx.pointSensor.DBPointSensorGroup

Point sensor group data book

i: int

RunMatrix index

pt: str

Name of point

Outputs:
n: 0 | 1

How many updates were made

Versions:
  • 2014-12-22 @ddalle: First version

  • 2017-04-12 @ddalle: Modified to work one component

  • 2017-04-23 @ddalle: Added output

  • 2017-10-10 @ddalle: From cape.cfdx.dataBook.DataBook

UpdateRunMatrix()

Match the trajectory to the cases in the data book

Call:
>>> DBPG.UpdateRunMatrix()
Inputs:
DBPG: cape.cfdx.pointSensor.DBPointSensorGroup

A point sensor group data book

Versions:
  • 2015-05-22 @ddalle: First version

Write(merge=False, unlock=True)

Write to file each point sensor data book in a group

Call:
>>> DBPG.Write()
Inputs:
DBPG: cape.cfdx.pointSensor.DBPointSensorGroup

A point sensor group data book

merge: True | {False}

Whether or not to attempt a merger before writing

unlock: {True} | False

Whether or not to delete any lock files

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

class cape.cfdx.pointSensor.DBTriqPointGroup(x, opts, name, **kw)

Post-processed point sensor group data book

Call:
>>> DBPG = DBTriqPointGroup(x, opts, name, pts=None, RootDir=None)
Inputs:
x: cape.runmatrix.RunMatrix

RunMatrix/run matrix interface

opts: cape.cfdx.options.Options

Options interface

name: str | None

Name of data book group

pts: {None} | list (str)

List of points to read; defaults to all points in thegroup

RootDir: {None} | str

Project root directory absolute path, default is PWD

Outputs:
DBPG: cape.cfdx.pointSensor.DBPointSensorGroup

A point sensor group data book

Versions:
  • 2017-10-10 @ddalle: First version

Individual point sensor data books

class cape.cfdx.pointSensor.DBPointSensor(x, opts, pt, name=None, check=False, lock=False, **kw)

Point sensor data book

Plotting methods are inherited from cape.cfdx.dataBook.DBBase, including cape.cfdx.dataBook.DBBase.PlotHist() for plotting historgrams of point sensor results in particular.

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

RunMatrix/run matrix interface

opts: cape.cfdx.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

check: True | {False}

Whether or not to check LOCK status

lock: True | {False}

If True, create a LOCK file

Outputs:
DBP: pyCart.pointSensor.DBPointSensor

An individual point sensor data book

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

ReadCopy(check=False, lock=False)

Read a copied database object

Call:
>>> DBP1 = DBP.ReadCopy(check=False, lock=False)
Inputs:
DBP: cape.cfdx.pointSensor.DBPointSensor

Data book base object

check: True | {False}

Whether or not to check LOCK status

lock: True | {False}

If True, wait if the LOCK file exists

Outputs:
DBP1: cape.cfdx.pointSensor.DBPointSensor

Copy of data book object

Versions:
UpdateCase(i)

Prepare to update one point sensor case if necessary

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

An individual point sensor data book

i: int

Case index

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

class cape.cfdx.pointSensor.DBTriqPoint(x, opts, pt, name=None, check=False, lock=False, **kw)

TriQ point sensor data book

Plotting methods are inherited from cape.cfdx.dataBook.DBBase, including cape.cfdx.dataBook.DBBase.PlotHist() for plotting historgrams of point sensor results in particular.

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

RunMatrix/run matrix interface

opts: cape.cfdx.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: cape.cfdx.pointSensor.DBPointSensor

An individual point sensor data book

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

ReadCopy(check=False, lock=False)

Read a copied database object

Call:
>>> DBP1 = DBP.ReadCopy(check=False, lock=False)
Inputs:
DBP: cape.cfdx.pointSensor.DBTriqPoint

Data book base object

check: True | {False}

Whether or not to check LOCK status

lock: True | {False}

If True, wait if the LOCK file exists

Outputs:
DBP1: cape.cfdx.pointSensor.DBTriqPoint

Copy of data book object

Versions:
UpdateCase(i)

Prepare to update one point sensor case if necessary

Call:
>>> DBP.UpdateCase(i)
Inputs:
DBP: cape.cfdx.pointSensor.DBTriqPoint

An individual point sensor data book

i: int

Case index

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