UnitConverter

petrophys.model.UnitConverter

class UnitConverter[source]

Comprehensive unit converter for petrophysical measurements.

Examples

>>> # Convert depth
>>> depth_m = UnitConverter.depth(100, "ft", "m")
>>> print(depth_m)
30.48
>>> # Convert temperature
>>> temp_c = UnitConverter.temperature(68, "F", "C")
>>> print(temp_c)
20.0
>>> # Convert porosity
>>> phi_frac = UnitConverter.porosity(20, "%", "v/v")
>>> print(phi_frac)
0.2

Methods

celsius_to_fahrenheit

Convert Celsius to Fahrenheit.

density

Convert density between units.

depth

Convert depth between units.

fahrenheit_to_celsius

Convert Fahrenheit to Celsius.

feet_to_meters

Convert feet to meters.

meters_to_feet

Convert meters to feet.

porosity

Convert porosity between units.

resistivity

Convert resistivity between units.

slowness

Convert sonic slowness between units.

temperature

Convert temperature between units.

static depth(value, from_unit, to_unit)[source]

Convert depth between units.

Parameters:
  • value (float or np.ndarray) – Depth value(s) to convert

  • from_unit (str) – Source unit (“ft”, “m”)

  • to_unit (str) – Target unit (“ft”, “m”)

Returns:

Converted depth value(s)

Return type:

float or np.ndarray

static temperature(value, from_unit, to_unit)[source]

Convert temperature between units.

Parameters:
  • value (float or np.ndarray) – Temperature value(s) to convert

  • from_unit (str) – Source unit: any label temperature_unit() recognizes, such as “F”, “degC” or “K”

  • to_unit (str) – Target unit, likewise

Returns:

Converted temperature value(s)

Return type:

float or np.ndarray

Raises:

ValueError – If either unit is not a recognized temperature unit.

static density(value, from_unit, to_unit)[source]

Convert density between units.

Parameters:
  • value (float or np.ndarray) – Density value(s) to convert

  • from_unit (str) – Source unit (“g/cm3”, “kg/m3”, “lb/ft3”)

  • to_unit (str) – Target unit (“g/cm3”, “kg/m3”, “lb/ft3”)

Returns:

Converted density value(s)

Return type:

float or np.ndarray

static porosity(value, from_unit, to_unit)[source]

Convert porosity between units.

Parameters:
  • value (float or np.ndarray) – Porosity value(s) to convert

  • from_unit (str) – Source unit (“v/v”, “%”, “pu”)

  • to_unit (str) – Target unit (“v/v”, “%”, “pu”)

Returns:

Converted porosity value(s)

Return type:

float or np.ndarray

static slowness(value, from_unit, to_unit)[source]

Convert sonic slowness between units.

Parameters:
  • value (float or np.ndarray) – Slowness value(s) to convert

  • from_unit (str) – Source unit (“us/ft”, “us/m”)

  • to_unit (str) – Target unit (“us/ft”, “us/m”)

Returns:

Converted slowness value(s)

Return type:

float or np.ndarray

static resistivity(value, from_unit, to_unit)[source]

Convert resistivity between units.

Parameters:
  • value (float or np.ndarray) – Resistivity value(s) to convert

  • from_unit (str) – Source unit (“ohm.m”, “ohm.ft”)

  • to_unit (str) – Target unit (“ohm.m”, “ohm.ft”)

Returns:

Converted resistivity value(s)

Return type:

float or np.ndarray

static feet_to_meters(value)[source]

Convert feet to meters.

Parameters:

value (float | ndarray)

Return type:

float | ndarray

static meters_to_feet(value)[source]

Convert meters to feet.

Parameters:

value (float | ndarray)

Return type:

float | ndarray

static fahrenheit_to_celsius(value)[source]

Convert Fahrenheit to Celsius.

Parameters:

value (float | ndarray)

Return type:

float | ndarray

static celsius_to_fahrenheit(value)[source]

Convert Celsius to Fahrenheit.

Parameters:

value (float | ndarray)

Return type:

float | ndarray