GEOS Utilities
The geos-utils python package defines utilities for all GEOS python packages including a logger, GEOS constants, basic functions, and unit management tools.
API
geos.utils.ConnectionSet module
Defines connection set and connection set collection data structures.
- class geos.utils.ConnectionSet.ConnectionSet(cellIdRef, connectedCellIds)[source]
Bases:
object
Define connection set data structure.
A ConnectionSet stores information of connection between a reference cell and adjacent cells. Cell information relies on unique ids, and each connected cell is associated with a side according to connection face normal vector.
- Parameters:
cellIdRef (int) – reference cell id.
connectedCellIds (int) – map of connected cell ids with the side.
- addConnectedCells(connectedCellsToAdd)[source]
Add connected cells to the existing map of connected cells.
The addConnectedCells() method adds element(s) to the dictionary if the cell Id is not in the dictionary. If the cell Id is in the dictionary, it updates the cell Id with the new side value.
- Parameters:
connectedCellsToAdd (dict[int, bool]) – connected cells to add.
- getConnectedCellIds()[source]
Get connected cell ids.
- Returns:
map of connected cell ids with side.
- Return type:
int
- class geos.utils.ConnectionSet.ConnectionSetCollection[source]
Bases:
MutableSet
Define a collection of ConnectionSet.
Because ConnectionSet relies on cell unique id, the collection imposes uniqueness of reference cell id.
- add(item)[source]
Add a ConnectionSet to the collection.
- Parameters:
item (ConnectionSet) – ConnectionSet to add.
- addMultiple(items)[source]
Add an iterable of ConnectionSet to the collection.
- Parameters:
items (Iterable[ConnectionSet]) – list of ConnectionSet to add.
- containsCellIdRef(cellIdRef)[source]
Test if a ConnectionSet with cellIdRef is present in the collection.
- Parameters:
cellIdRef (int) – reference cell id
- Returns:
True if a ConnectionSet is present, False otherwise.
- Return type:
bool
- containsEqual(item)[source]
Test if a ConnectionSet is present in the collection.
Both th reference cell id and connected cell dictionnary must match the input ConnectionSet.
- Parameters:
item (ConnectionSet) – ConnectionSet to add.
- discard(item)[source]
Remove a ConnectionSet to the collection.
ConnectionSet is removed if both reference cell id and connected cell dictionnary match an element of the collection.
- Parameters:
item (ConnectionSet) – ConnectionSet to remove.
- discardCellIdRef(cellIdRef)[source]
Remove a ConnectionSet to the collection using the reference cell id.
- Parameters:
cellIdRef (int) – reference cell id to remove.
- get(cellIdRef)[source]
Get ConnectionSet from reference cell id.
- Parameters:
cellIdRef (int) – reference cell id
- Returns:
ConnectionSet with cellIdRef.
- Return type:
Optional[ConnectionSet]
- getReversedConnectionSetCollection()[source]
Get the set of reversed connection set.
- Returns:
reversed collection of ConnectionSet
- Return type:
- replace(item)[source]
Replace a ConnectionSet if another one with the same cellIdRef exists.
- Parameters:
item (ConnectionSet) – ConnectionSet to add.
- update(item)[source]
Update or add a ConnectionSet to the collection.
- Parameters:
item (ConnectionSet) – ConnectionSet
geos.utils.enumUnits module
- class geos.utils.enumUnits.Density(value)[source]
Bases:
Enum
An enumeration.
- G_PER_CUBIC_CENTIMETER = <geos.utils.enumUnits.Unit object>
- KG_PER_CUBIC_METER = <geos.utils.enumUnits.Unit object>
- POUND_PER_BBL = <geos.utils.enumUnits.Unit object>
- class geos.utils.enumUnits.Length(value)[source]
Bases:
Enum
An enumeration.
- FEET = <geos.utils.enumUnits.Unit object>
- KILOMETER = <geos.utils.enumUnits.Unit object>
- METER = <geos.utils.enumUnits.Unit object>
- MILE = <geos.utils.enumUnits.Unit object>
- class geos.utils.enumUnits.Mass(value)[source]
Bases:
Enum
An enumeration.
- KG = <geos.utils.enumUnits.Unit object>
- MEGATON = <geos.utils.enumUnits.Unit object>
- POUND = <geos.utils.enumUnits.Unit object>
- TON = <geos.utils.enumUnits.Unit object>
- class geos.utils.enumUnits.MassRate(value)[source]
Bases:
Enum
An enumeration.
- KG_PER_DAY = <geos.utils.enumUnits.Unit object>
- KG_PER_HOUR = <geos.utils.enumUnits.Unit object>
- KG_PER_SECOND = <geos.utils.enumUnits.Unit object>
- MTPA = <geos.utils.enumUnits.Unit object>
- TON_PER_DAY = <geos.utils.enumUnits.Unit object>
- class geos.utils.enumUnits.NoUnit(value)[source]
Bases:
Enum
An enumeration.
- SAME = <geos.utils.enumUnits.Unit object>
- class geos.utils.enumUnits.Permeability(value)[source]
Bases:
Enum
An enumeration.
- DARCY = <geos.utils.enumUnits.Unit object>
- MILLI_DARCY = <geos.utils.enumUnits.Unit object>
- SQUARE_METER = <geos.utils.enumUnits.Unit object>
- class geos.utils.enumUnits.Pressure(value)[source]
Bases:
Enum
An enumeration.
- BAR = <geos.utils.enumUnits.Unit object>
- GPA = <geos.utils.enumUnits.Unit object>
- KPA = <geos.utils.enumUnits.Unit object>
- MPA = <geos.utils.enumUnits.Unit object>
- PA = <geos.utils.enumUnits.Unit object>
- PSI = <geos.utils.enumUnits.Unit object>
- class geos.utils.enumUnits.Temperature(value)[source]
Bases:
Enum
An enumeration.
- CELSIUS = <geos.utils.enumUnits.Unit object>
- FAHRENHEIT = <geos.utils.enumUnits.Unit object>
- K = <geos.utils.enumUnits.Unit object>
- class geos.utils.enumUnits.Time(value)[source]
Bases:
Enum
An enumeration.
- DAY = <geos.utils.enumUnits.Unit object>
- HOUR = <geos.utils.enumUnits.Unit object>
- MONTH = <geos.utils.enumUnits.Unit object>
- SECOND = <geos.utils.enumUnits.Unit object>
- YEAR = <geos.utils.enumUnits.Unit object>
- class geos.utils.enumUnits.Unit(conversionMultiplier, conversionAdder, unitLabel)[source]
Bases:
object
Unit enumeration.
- Parameters:
conversionMultiplier (float) – conversion multiplier
conversionAdder (float) – conversion adder
unitLabel (str) – symbol of the unit.
- class geos.utils.enumUnits.Volume(value)[source]
Bases:
Enum
An enumeration.
- BBL = <geos.utils.enumUnits.Unit object>
- CUBIC_FEET = <geos.utils.enumUnits.Unit object>
- CUBIC_METER = <geos.utils.enumUnits.Unit object>
- class geos.utils.enumUnits.VolumetricRate(value)[source]
Bases:
Enum
An enumeration.
- BBL_PER_DAY = <geos.utils.enumUnits.Unit object>
- CUBIC_METER_PER_DAY = <geos.utils.enumUnits.Unit object>
- CUBIC_METER_PER_HOUR = <geos.utils.enumUnits.Unit object>
- CUBIC_METER_PER_SECOND = <geos.utils.enumUnits.Unit object>
- geos.utils.enumUnits.convert(number, unitObj)[source]
Converts a float number that has SI unit to a specific unit.
- Parameters:
number (float) – Number to convert.
unitObj (Unit) – Object containing conversion multiplier and adder.
- Returns:
number converted to the correct unit.
- Return type:
float
- geos.utils.enumUnits.enumerationDomainUnit(enumObj)[source]
Get the xml code corresponding to unit enum object for drop down list.
- Parameters:
enumObj (Enum) – Unit enum object.
- Returns:
xml text.
- Return type:
str
- geos.utils.enumUnits.getPropertyUnitEnum(propertyName)[source]
Get the Unit enum from property name.
- Parameters:
propertyName (str) – name of the property.
- Returns:
Unit enum.
- Return type:
Enum
- geos.utils.enumUnits.getSIUnits()[source]
Get the dictionary of property Names:Units.
Generates a dict where the keys are meta-properties like pressure, mass etc … and where the values are Unit composed of a conversion factor and its unit associated. Here, the conversion factor will always be 1.0 and the unit will be the SI associate because we work with SI units.
- Returns:
dictionary of unit names as keys and Unit enum as value.
- Return type:
dict[str, Unit]
geos.utils.geometryFunctions module
Functions to permform geometry calculations.
- geos.utils.geometryFunctions.computeCoordinatesInNewBasis(vec, changeOfBasisMatrix)[source]
Computes the coordinates of a matrix from a basis B in the new basis B’.
- Parameters:
vec (npt.NDArray[np.floating[Any]]) – vector to compute the new coordinates
changeOfBasisMatrix (npt.NDArray[np.floating[Any]]) – Change of basis matrix
- Returns:
the new coordinates of the matrix in the basis B’.
- Return type:
npt.NDArray[np.floating[Any]]
- geos.utils.geometryFunctions.computePlaneFrom3Points(pt1, pt2, pt3)[source]
Compute the 4 coefficients of a plane equation.
Let’s defined a plane from the following equation: ax + by + cz + d = 0. This function determines a, b, c, d from 3 points of the plane.
- Parameters:
pt1 (npt.NDArray[np.floating[Any]]) – 1st point of the plane.
pt2 (npt.NDArray[np.floating[Any]]) – 2nd point of the plane.
pt3 (npt.NDArray[np.floating[Any]]) – 3rd point of the plane.
- Returns:
tuple of the 4 coefficients.
- Return type:
tuple[float, float, float, float]
- geos.utils.geometryFunctions.getCellSideAgainstPlane(cellPtsCoords, planePt, planeNormal)[source]
Get the side of input cell against input plane.
Input plane is defined by a point on it and its normal vector.
- Parameters:
cellPtsCoords (npt.NDArray[np.floating[Any]]) – Coordinates of the vertices of the cell to get the side.
planePt (npt.NDArray[np.floating[Any]]) – Point on the plane.
planeNormal (npt.NDArray[np.floating[Any]]) – Normal vector to the plane.
- Returns:
True if the cell is in the direction of the normal vector, False otherwise.
- Return type:
bool
- geos.utils.geometryFunctions.getChangeOfBasisMatrix(basisFrom, basisTo)[source]
Get the change of basis matrix from basis basisFrom to basis basisTo.
Let’s define the basis (basisFrom) (b1, b2, b3) and basis (basisTo) (c1, c2, c3) where b1, b2, b3, and c1, c2, c3 are the vectors of the basis in the canonic form. This method returns the change of basis matrix P from basisFrom to basisTo.
The coordinates of a vector Vb(vb1, vb2, vb3) from the basis B in the basis C is then Vc = P.Vb
- Parameters:
basisFrom (tuple[npt.NDArray[np.floating[Any]], npt.NDArray[np.floating[Any]], npt.NDArray[np.floating[Any]]]) – origin basis
basisTo (tuple[npt.NDArray[np.floating[Any]], npt.NDArray[np.floating[Any]], npt.NDArray[np.floating[Any]]]) – destination basis
- Returns:
change of basis matrix.
- Return type:
npt.NDArray[np.floating[Any]]
- geos.utils.geometryFunctions.getPointSideAgainstPlane(ptCoords, planePt, planeNormal)[source]
Get the side of input point against input plane.
Input plane is defined by a point on it and its normal vector.
- Parameters:
ptCoords (npt.NDArray[np.floating[Any]]) – Coordinates of the point to get the side.
planePt (npt.NDArray[np.floating[Any]]) – Point on the plane.
planeNormal (npt.NDArray[np.floating[Any]]) – Normal vector to the plane.
- Returns:
True if the point is in the direction of the normal vector, False otherwise.
- Return type:
bool
geos.utils.GeosOutputsConstants module
GeosOutputsConstants module defines usefull constant names such as attribute names, domain names, phase types, and the lists of attribute names to process.
Warning
Names may need to be updated when modifications occur in the GEOS code.
Todo
If possible, link GEOS names directly with GEOS code instead of redefining them here.
- class geos.utils.GeosOutputsConstants.AttributeEnum(value)[source]
Bases:
Enum
An enumeration.
Define the enumeration to store attrbute properties.
- Parameters:
attributeName (str) – name of the attribute
nbComponent (int) – number of component: 1 is scalar attribute, >1 is vectorial attribute
onPoints (bool) – location of the attribute: on Points (True) or on Cells (False)
- class geos.utils.GeosOutputsConstants.ComponentNameEnum(value)[source]
Bases:
Enum
An enumeration.
- NONE = ('',)
- NORMAL_TANGENTS = ('normal', 'tangent1', 'tangent2', 'T1T2', 'NT2', 'NT1')
- XYZ = ('XX', 'YY', 'ZZ', 'YZ', 'XZ', 'XY')
- class geos.utils.GeosOutputsConstants.FluidPrefixEnum(value)[source]
Bases:
Enum
Define usual names used for the fluid phase.
- FLUID = 'fluid'
- GAS = 'gas'
- WATER = 'water'
- class geos.utils.GeosOutputsConstants.GeosDomainNameEnum(value)[source]
Bases:
Enum
Name of the nodes in the MultiBlock data tree.
- FAULT_DOMAIN_NAME = 'SurfaceElementRegion'
- VOLUME_DOMAIN_NAME = 'CellElementRegion'
- WELL_DOMAIN_NAME = 'WellElementRegion'
- class geos.utils.GeosOutputsConstants.GeosLogOutputsEnum(value)[source]
Bases:
Enum
Define the keywords in Geos log.
- PHASE = 'phase'
- class geos.utils.GeosOutputsConstants.GeosMeshOutputsEnum(value)[source]
Bases:
AttributeEnum
Attribute names that come from Geos.
Define the names of Geos outputs, the number of components for vectorial attributes, and the location (Point or Cell) in the mesh
Define the enumeration to store attrbute properties.
- Parameters:
attributeName (str) – name of the attribute
nbComponent (int) – number of component: 1 is scalar attribute, >1 is vectorial attribute
onPoints (bool) – location of the attribute: on Points (True) or on Cells (False)
- BULK_MODULUS = ('bulkModulus', 1, False)
- CELL_ID = ('Cell ID', 1, False)
- DELTA_PRESSURE = ('deltaPressure', 1, False)
- DISPLACEMENT_JUMP = ('displacementJump', 3, False)
- ELEMENT_CENTER = ('elementCenter', 1, False)
- GRAIN_BULK_MODULUS = ('bulkModulusGrains', 1, False)
- MASS = ('mass', 1, False)
- PERMEABILITY = ('permeability', 1, False)
- POINT = ('Points', 3, True)
- POINTS_ID = ('Point ID', 1, True)
- POROSITY = ('porosity', 1, False)
- POROSITY_INI = ('porosityInitial', 1, False)
- PRESSURE = ('pressure', 1, False)
- ROCK_DENSITY = ('density', 1, False)
- SHEAR_MODULUS = ('shearModulus', 1, False)
- STRESS_EFFECTIVE = ('stressEffective', 6, False)
- TOTAL_DISPLACEMENT = ('totalDisplacement', 4, True)
- TRACTION = ('traction', 3, False)
- VTK_ORIGINAL_CELL_ID = ('vtkOriginalCellIds', 1, False)
- WATER_DENSITY = ('water_density', 1, False)
- class geos.utils.GeosOutputsConstants.GeosMeshSuffixEnum(value)[source]
Bases:
Enum
Define the suffix of attributes in Geos output mesh.
- BIOT_COEFFICIENT_SUFFIX = '_biotCoefficient'
- BULK_MODULUS_SUFFIX = '_bulkModulus'
- DENSITY_SUFFIX = '_density'
- GRAIN_BULK_MODULUS_SUFFIX = '_grainBulkModulus'
- PERMEABILITY_SUFFIX = '_permeability'
- PHASE_DENSITY_SUFFIX = '_phaseDensity'
- PHASE_FRACTION_SUFFIX = '_phaseFraction'
- PHASE_MASS_DENSITY_SUFFIX = '_phaseMassDensity'
- PHASE_VISCOSITY_SUFFIX = '_phaseViscosity'
- POROSITY_REF_SUFFIX = '_referencePorosity'
- POROSITY_SUFFIX = '_porosity'
- SHEAR_MODULUS_SUFFIX = '_shearModulus'
- STRAIN_SUFFIX = 'strain'
- STRESS_SUFFIX = '_stress'
- SURFACE_MINUS_SUFFIX = '_Minus'
- SURFACE_PLUS_SUFFIX = '_Plus'
- class geos.utils.GeosOutputsConstants.OutputObjectEnum(value)[source]
Bases:
Enum
Kind of objects present in GEOS pvd output.
- FAULTS = 'Faults'
- VOLUME = 'Volume'
- WELLS = 'Wells'
- geos.utils.GeosOutputsConstants.PHASE_SEP = '_'
Phase separator in Geos output log file.
- class geos.utils.GeosOutputsConstants.PhaseTypeEnum(value)[source]
Bases:
Enum
An enumeration.
Define the main phases and associated property suffix.
- Parameters:
phaseType (str) – name of the type of phase
attributes (tuple[str,...]) – list of attributes
- FLUID = ('Fluid', ('_phaseDensity', '_phaseViscosity', '_phaseFraction', '_phaseMassDensity'))
- ROCK = ('Rock', ('_density', '_stress', '_bulkModulus', '_shearModulus', '_porosity', '_referencePorosity', '_permeability'))
- UNKNOWN = ('Other', ())
- class geos.utils.GeosOutputsConstants.PostProcessingOutputsEnum(value)[source]
Bases:
AttributeEnum
Compute attributes enumeration.
Define the names of post-processing outputs, the number of components for vectorial attributes, and the location (Point or Cell) in the mesh
Define the enumeration to store attrbute properties.
- Parameters:
attributeName (str) – name of the attribute
nbComponent (int) – number of component: 1 is scalar attribute, >1 is vectorial attribute
onPoints (bool) – location of the attribute: on Points (True) or on Cells (False)
- ADJACENT_CELL_SIDE = ('SurfaceAdjacentCells', 1, False)
- BIOT_COEFFICIENT = ('biotCoefficient', 1, False)
- BIOT_COEFFICIENT_INITIAL = ('biotCoefficientInitial', 1, False)
- BLOCK_INDEX = ('blockIndex', 1, False)
- BULK_MODULUS_INITIAL = ('bulkModulusInitial', 1, False)
- COMPRESSIBILITY = ('compressibilityCoefficient', 1, False)
- COMPRESSIBILITY_OED = ('compressibilityCoefficient_oed', 1, False)
- COMPRESSIBILITY_REAL = ('compressibilityCoefficient_real', 1, False)
- CRITICAL_PORE_PRESSURE = ('porePressureCritical_real', 1, False)
- CRITICAL_PORE_PRESSURE_THRESHOLD = ('porePressureThreshold_real', 1, False)
- CRITICAL_TOTAL_STRESS_RATIO = ('totalStressRatioCritical_real', 1, False)
- LITHOSTATIC_STRESS = ('stressLithostatic', 1, False)
- OEDOMETRIC_MODULUS = ('oedometricModulus', 1, False)
- POISSON_RATIO = ('poissonRatio', 1, False)
- POISSON_RATIO_INITIAL = ('poissonRatioInitial', 1, False)
- RSP_OED = ('rsp_oed', 1, False)
- RSP_REAL = ('rsp_real', 6, False)
- SCU = ('SCU', 1, False)
- SHEAR_MODULUS_INITIAL = ('shearModulusInitial', 1, False)
- SPECIFIC_GRAVITY = ('specificGravity', 1, False)
- STRAIN_ELASTIC = ('strainElastic', 6, False)
- STRESS_EFFECTIVE_INITIAL = ('stressEffectiveInitial', 6, False)
- STRESS_EFFECTIVE_RATIO_OED = ('stressEffectiveRatio_oed', 6, False)
- STRESS_EFFECTIVE_RATIO_REAL = ('stressEffectiveRatio_real', 6, False)
- STRESS_TOTAL = ('stressTotal', 6, False)
- STRESS_TOTAL_DELTA = ('deltaStressTotal', 6, False)
- STRESS_TOTAL_INITIAL = ('stressTotalInitial', 6, False)
- STRESS_TOTAL_RATIO_REAL = ('stressTotalRatio_real', 6, False)
- TOTAL_STRESS_RATIO_THRESHOLD = ('totalStressRatioThreshold_real', 1, False)
- YOUNG_MODULUS = ('youngModulus', 1, False)
- YOUNG_MODULUS_INITIAL = ('youngModulusInitial', 1, False)
- geos.utils.GeosOutputsConstants.getAttributeToConvertFromLocalToXYZ()[source]
Get the list of attribute names to convert from local to xyz basis.
- Returns:
list of attributes to convert
- Return type:
list[str]
geos.utils.algebraFunctions module
GeosUtils module defines usefull methods to process GEOS outputs according to GEOS conventions.
- geos.utils.algebraFunctions.getAttributeMatrixFromVector(attrArray)[source]
Get the matrix of attribute values from the vector.
Matrix to vector conversion is the following:
- if input vector size is 3:
- if input vector size is 6:
Warning
Input vector must be of size 3 or 6.
- Parameters:
attrArray (npt.NDArray[np.float64]) – Vector of attribute values.
- Returns:
matrix of attribute values
- Return type:
npt.NDArray[np.float64]
- geos.utils.algebraFunctions.getAttributeVectorFromMatrix(attrMatrix, size)[source]
Get the vector of attribute values from the matrix.
Matrix to vector conversion is the following:
- 3x3 diagonal matrix:
- otherwise:
- Parameters:
attrMatrix (npt.NDArray[np.float64]) – Matrix of attribute values.
size (int) – Size of the final vector.
- Returns:
vector of attribute values
- Return type:
npt.NDArray[np.float64]
geos.utils.Logger module
Logger module manages logging tools.
Code was modified from <https://stackoverflow.com/questions/384076/how-can-i-color-python-logging-output>
- class geos.utils.Logger.CustomLoggerFormatter(fmt=None, datefmt=None, style='%', validate=True, *, defaults=None)[source]
Bases:
Formatter
Custom formatter for the logger.
Warning
Colors do not work in the ouput message window of Paraview.
To use it:
logger = logging.getLogger("Logger name") ch = logging.StreamHandler() ch.setFormatter(CustomLoggerFormatter()) logger.addHandler(ch)
Initialize the formatter with specified format strings.
Initialize the formatter either with the specified format string, or a default as described above. Allow for specialized date formatting with the optional datefmt argument. If datefmt is omitted, you get an ISO8601-like (or RFC 3339-like) format.
Use a style parameter of ‘%’, ‘{’ or ‘$’ to specify that you want to use one of %-formatting,
str.format()
({}
) formatting orstring.Template
formatting in your format string.Changed in version 3.2: Added the
style
parameter.- FORMATS = {10: '\x1b[38;20m%(asctime)s - %(name)s - %(levelname)s - %(message)s (%(filename)s:%(lineno)d)\x1b[0m', 20: '\x1b[38;20m%(asctime)s - %(name)s - %(levelname)s - %(message)s\x1b[0m', 30: '\x1b[33;20m%(asctime)s - %(name)s - %(levelname)s - %(message)s\x1b[0m', 40: '\x1b[31;20m%(asctime)s - %(name)s - %(levelname)s - %(message)s\x1b[0m', 50: '\x1b[31;1m%(asctime)s - %(name)s - %(levelname)s - %(message)s (%(filename)s:%(lineno)d)\x1b[0m'}
format for each logger output type
- FORMATS_PV = {10: '%(asctime)s - %(name)s - %(levelname)s - %(message)s (%(filename)s:%(lineno)d)', 20: '%(asctime)s - %(name)s - %(levelname)s - %(message)s', 30: '%(asctime)s - %(name)s - %(levelname)s - %(message)s', 40: '%(asctime)s - %(name)s - %(levelname)s - %(message)s', 50: '%(asctime)s - %(name)s - %(levelname)s - %(message)s (%(filename)s:%(lineno)d)'}
same without colors
- bold_red = '\x1b[31;1m'
- format(record)[source]
Return the format according to input record.
- Parameters:
record (logging.LogRecord) – record
- Returns:
format as a string
- Return type:
str
- format1 = '%(asctime)s - %(name)s - %(levelname)s - %(message)s'
- format2 = '%(asctime)s - %(name)s - %(levelname)s - %(message)s (%(filename)s:%(lineno)d)'
- grey = '\x1b[38;20m'
- red = '\x1b[31;20m'
- reset = '\x1b[0m'
- yellow = '\x1b[33;20m'
- class geos.utils.Logger.Logger(name, level=0)[source]
Bases:
Filterer
Instances of the Logger class represent a single logging channel. A “logging channel” indicates an area of an application. Exactly how an “area” is defined is up to the application developer. Since an application can have any number of areas, logging channels are identified by a unique string. Application areas can be nested (e.g. an area of “input processing” might include sub-areas “read CSV files”, “read XLS files” and “read Gnumeric files”). To cater for this natural nesting, channel names are organized into a namespace hierarchy where levels are separated by periods, much like the Java or Python package namespace. So in the instance given above, channel names might be “input” for the upper level, and “input.csv”, “input.xls” and “input.gnu” for the sub-levels. There is no arbitrary limit to the depth of nesting.
Initialize the logger with a name and an optional level.
- callHandlers(record)[source]
Pass a record to all relevant handlers.
Loop through all handlers for this logger and its parents in the logger hierarchy. If no handler was found, output a one-off error message to sys.stderr. Stop searching up the hierarchy whenever a logger with the “propagate” attribute set to zero is found - that will be the last logger whose handlers are called.
- critical(msg, *args, **kwargs)[source]
Log ‘msg % args’ with severity ‘CRITICAL’.
To pass exception information, use the keyword argument exc_info with a true value, e.g.
logger.critical(“Houston, we have a %s”, “major disaster”, exc_info=1)
- debug(msg, *args, **kwargs)[source]
Log ‘msg % args’ with severity ‘DEBUG’.
To pass exception information, use the keyword argument exc_info with a true value, e.g.
logger.debug(“Houston, we have a %s”, “thorny problem”, exc_info=1)
- error(msg, *args, **kwargs)[source]
Log ‘msg % args’ with severity ‘ERROR’.
To pass exception information, use the keyword argument exc_info with a true value, e.g.
logger.error(“Houston, we have a %s”, “major problem”, exc_info=1)
- exception(msg, *args, exc_info=True, **kwargs)[source]
Convenience method for logging an ERROR with exception information.
- findCaller(stack_info=False, stacklevel=1)[source]
Find the stack frame of the caller so that we can note the source file name, line number and function name.
- getChild(suffix)[source]
Get a logger which is a descendant to this one.
This is a convenience method, such that
logging.getLogger(‘abc’).getChild(‘def.ghi’)
is the same as
logging.getLogger(‘abc.def.ghi’)
It’s useful, for example, when the parent logger is named using __name__ rather than a literal string.
- getEffectiveLevel()[source]
Get the effective level for this logger.
Loop through this logger and its parents in the logger hierarchy, looking for a non-zero logging level. Return the first one found.
- handle(record)[source]
Call the handlers for the specified record.
This method is used for unpickled records received from a socket, as well as those created locally. Logger-level filtering is applied.
- hasHandlers()[source]
See if this logger has any handlers configured.
Loop through all handlers for this logger and its parents in the logger hierarchy. Return True if a handler was found, else False. Stop searching up the hierarchy whenever a logger with the “propagate” attribute set to zero is found - that will be the last logger which is checked for the existence of handlers.
- info(msg, *args, **kwargs)[source]
Log ‘msg % args’ with severity ‘INFO’.
To pass exception information, use the keyword argument exc_info with a true value, e.g.
logger.info(“Houston, we have a %s”, “interesting problem”, exc_info=1)
- log(level, msg, *args, **kwargs)[source]
Log ‘msg % args’ with the integer severity ‘level’.
To pass exception information, use the keyword argument exc_info with a true value, e.g.
logger.log(level, “We have a %s”, “mysterious problem”, exc_info=1)
- makeRecord(name, level, fn, lno, msg, args, exc_info, func=None, extra=None, sinfo=None)[source]
A factory method which can be overridden in subclasses to create specialized LogRecords.
- manager = <logging.Manager object>
- root = <RootLogger root (WARNING)>
- geos.utils.Logger.getLogger(title)[source]
Return the Logger with pre-defined configuration.
Example:
# module import import Logger # logger instanciation logger :Logger.Logger = Logger.getLogger("My application") # logger use logger.debug("debug message") logger.info("info message") logger.warning("warning message") logger.error("error message") logger.critical("critical message")
- Parameters:
title (str) – Name of the logger.
- Returns:
logger
- Return type:
geos.utils.PhysicalConstants module
Define default values of usefull physical constants.
- geos.utils.PhysicalConstants.DEFAULT_FRICTION_ANGLE_DEG = 10.0
default friction angle (deg)
- geos.utils.PhysicalConstants.DEFAULT_FRICTION_ANGLE_RAD = 0.17453292519943295
default friction angle (rad)
- geos.utils.PhysicalConstants.DEFAULT_GRAIN_BULK_MODULUS = 38000000000.0
default grain bulk modulus is that of Quartz (Pa)
- geos.utils.PhysicalConstants.DEFAULT_ROCK_COHESION = 0.0
default rock cohesion - fractured case - (Pa)
- geos.utils.PhysicalConstants.EPSILON = 1e-06
epsilon
- geos.utils.PhysicalConstants.GRAVITY = 9.81
gravity (m/s)
- geos.utils.PhysicalConstants.WATER_DENSITY = 1000.0
water density (kg/m³)
- geos.utils.PhysicalConstants.WATER_DYNAMIC_VISCOSITY = 0.001
water dynamic viscosity (kg.m^-1/s^-1 = Pa.s)
- geos.utils.PhysicalConstants.WATER_KINEMATIC_VISCOSITY = 1e-06
water kinematic viscosity (m²/s)
geos.utils.UnitRepository module
- class geos.utils.UnitRepository.UnitRepository(userPropertiesUnitChoice=None)[source]
Bases:
object
Unit repository.
Input example : { “pressure”: 4, “bhp”: 4,”stress”: 3, “length”: 2, …}
- Output example{ “pressure”: Pressure.BAR.value, “bhp”: Pressure.BAR.value,
“stress”: Pressure.MPA.value, “length”: Lenght.FEET.value, … }
These Pressure.BAR.value corresponds to Unit objects that have a conversion multiplier and a conversion adder, and also a unit label.
- Parameters:
userPropertiesUnitChoice (dict[str, int], Optional) –
dictionary of unit user choices.
Defaults {}.