cape.cfdx.pointsensor: Point sensor databooks¶
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.cfdx.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.
- cape.cfdx.pointsensor.ImportPyPlot()¶
Import
matplotlib.pyplotif not loaded- Call:
>>> cape.cfdx.databook.ImportPyPlot()
- Versions:
2014-12-27
@ddalle: First version
- class cape.cfdx.pointsensor.PointSensorDataBook(cntl, opts, pt, name=None, check=False, lock=False, **kw)¶
Point sensor data book
Plotting methods are inherited from
cape.cfdx.databook.DataBookComp, includingcape.cfdx.databook.DataBookComp.PlotHist()for plotting historgrams of point sensor results in particular.- Call:
>>> DBP = PointSensorDataBook(cntl, opts, pt, name=None, **kw)
- Inputs:
- cntl:
cape.cfdx.cntl.Cntl 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
- cntl:
- Outputs:
- DBP:
pyCart.pointsensor.PointSensorDataBook An individual point sensor data book
- DBP:
- 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.PointSensorDataBook 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
- DBP:
- Outputs:
- DBP1:
cape.cfdx.pointsensor.PointSensorDataBook Copy of data book object
- DBP1:
- Versions:
2017-06-26
@ddalle: v1.02017-10-11
@ddalle: FromDataBookComp
- UpdateCase(i)¶
Prepare to update one point sensor case if necessary
- Call:
>>> DBP.UpdateCase(i)
- Inputs:
- DBP:
cape.cfdx.pointsensor.PointSensorDataBook An individual point sensor data book
- i:
int Case index
- DBP:
- Versions:
2015-12-04
@ddalle: First version
- class cape.cfdx.pointsensor.PointSensorGroupDataBook(x, opts, name, **kw)¶
Point sensor group data book
- Call:
>>> DBPG = PointSensorGroupDataBook(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
- x:
- Outputs:
- DBPG:
cape.cfdx.pointsensor.PointSensorGroupDataBook A point sensor group data book
- DBPG:
- Versions:
2015-12-04
@ddalle: First version
- DeleteCases(I, pt=None)¶
Delete list of cases from point sensor data book
- DeleteCasesComp(I, pt)¶
Delete list of cases from data book
- Call:
>>> n = DBPG.Delete(I, pt)
- Inputs:
- DBPG:
cape.cfdx.pointsensor.PointSensorGroupDataBook Point sensor group data book
- I:
list[int] List of trajectory indices or update all cases in trajectory
- pt:
str Name of point sensor
- DBPG:
- Outputs:
- n:
int Number of deleted entries
- n:
- Versions:
2015-03-13
@ddalle: First version2017-04-13
@ddalle: Split by component2017-10-10
@ddalle: Fromcape.cfdx.databook.DataBook
- ProcessComps(pt=None, **kw)¶
Process list of points
This performs several conversions:
- 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
- DB:
- Versions:
2017-10-10
@ddalle: First version
- ReadCasePoint(pt, i)¶
Read point data from current run folder
- 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.PointSensorGroupDataBook A point sensor group data book
- pt:
str Name of the point to read
- DBPG:
- Versions:
2017-10-11
@ddalle: First version
- Sort()¶
Sort each point sensor data book in a group
- Call:
>>> DBPG.Sort()
- Inputs:
- DBPG:
cape.cfdx.pointsensor.PointSensorGroupDataBook A point sensor group data book
- DBPG:
- Versions:
2017-10-11
@ddalle: First version
- Update(I=None, pt=None)¶
Update the data book for a list of cases from the run matrix
- UpdateCase(i, pt=None)¶
Update all points for one case
- UpdateCaseComp(i: int, pt: str)¶
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.
The case is not already in the data book
The most recent iteration is greater than the data book value
The number of iterations used to create statistics has changed
- Call:
>>> n = DBPG.UpdateCaseComp(i, pt)
- Inputs:
- DBPG:
cape.cfdx.pointsensor.PointSensorGroupDataBook Point sensor group data book
- i:
int RunMatrix index
- pt:
str Name of point
- DBPG:
- Outputs:
- n:
0|1 How many updates were made
- n:
- Versions:
2014-12-22
@ddalle: First version2017-04-12
@ddalle: Modified to work one component2017-04-23
@ddalle: Added output2017-10-10
@ddalle: Fromcape.cfdx.databook.DataBook
- UpdateRunMatrix()¶
Match the trajectory to the cases in the data book
- Call:
>>> DBPG.UpdateRunMatrix()
- Inputs:
- DBPG:
cape.cfdx.pointsensor.PointSensorGroupDataBook A point sensor group data book
- DBPG:
- 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.PointSensorGroupDataBook 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
- DBPG:
- Versions:
2015-12-04
@ddalle: First version
- class cape.cfdx.pointsensor.TriqPointDataBook(cntl, opts, pt, name=None, check=False, lock=False, **kw)¶
TriQ point sensor data book
Plotting methods are inherited from
cape.cfdx.databook.DataBookComp, includingcape.cfdx.databook.DataBookComp.PlotHist()for plotting histograms of point sensor results in particular.- Call:
>>> DBP = TriqPointDataBook(cntl, opts, pt, name=None)
- Inputs:
- cntl:
cape.cfdx.cntl.Cntl 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
- cntl:
- Outputs:
- DBP:
cape.cfdx.pointsensor.PointSensorDataBook An individual point sensor data book
- DBP:
- 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.TriqPointDataBook 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
- DBP:
- Outputs:
- DBP1:
cape.cfdx.pointsensor.TriqPointDataBook Copy of data book object
- DBP1:
- Versions:
2017-06-26
@ddalle: First version2017-10-11
@ddalle: FromDataBookComp
- UpdateCase(i)¶
Prepare to update one point sensor case if necessary
- Call:
>>> DBP.UpdateCase(i)
- Inputs:
- DBP:
cape.cfdx.pointsensor.TriqPointDataBook An individual point sensor data book
- i:
int Case index
- DBP:
- Versions:
2015-12-04
@ddalle: First version
- class cape.cfdx.pointsensor.TriqPointGroupDataBook(cntl, opts, name, **kw)¶
Post-processed point sensor group data book
- Call:
>>> DBPG = TriqPointGroupDataBook(cntl, opts, name, **kw)
- Inputs:
- cntl:
cape.cfdx.cntl.Cntl 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
- cntl:
- Outputs:
- DBPG:
cape.cfdx.pointsensor.PointSensorGroupDataBook A point sensor group data book
- DBPG:
- Versions:
2017-10-10
@ddalle: First version
- ReadCasePoint(pt)¶
Read point data from current run folder
- Call:
>>> P = DBPG.ReadCasePoint(pt)
- Inputs:
- DBPG:
cape.cfdx.pointsensor.TriqPointGroupDataBook Point sensor group data book
- pt:
str Name of point to read
- DBPG:
- Outputs:
- P:
dict Dictionary of state variables as requested from the point
- P:
- Versions:
2017-10-10
@ddalle: First version
- ReadCaseTriq()¶
Read the the most recent Triq file from this folder
- Call:
>>> triq, VarList = DBPG.ReadCaseTriq()
- Inputs:
- DBPG:
cape.cfdx.pointsensor.TriqPointGroupDataBook Point sensor group data book
- DBPG:
- Outputs:
- triq:
cape.trifile.Triq Annotated triangulation interface
- VarList:
list(str) List of variable names
- triq:
- 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.TriqPointGroupDataBook A point sensor group data book
- pt:
str Name of the point to read
- DBPG:
- Versions:
2017-10-11
@ddalle: First version