adios_db.models.oil package

Subpackages

Submodules

adios_db.models.oil.bulk_composition module

dataclass to store the compounds

class adios_db.models.oil.bulk_composition.BulkComposition(name: str = '', groups: list = <factory>, method: str = '', measurement: ~adios_db.models.common.measurement.MassOrVolumeFraction = None, comment: str = '')

Bases: object

object to hold bulk composition – could be mass or volume fraction

comment: str = ''
classmethod from_py_json(py_json, allow_none=False)

classmethod to create a dataclass from json compatible python data structure.

groups: list
measurement: MassOrVolumeFraction = None
method: str = ''
name: str = ''
py_json(sparse=True)

function to convert a dataclass to json compatible python

Parameters:

sparse=True – If sparse is True, only non-empty fields will be written. If False, then all fields will be included.

validate()

Function to validate a dataclass with fields that have validate methods. The validate methods are expected to return a list of validation messages.

The top-level validator extends the existing list

class adios_db.models.oil.bulk_composition.BulkCompositionList(iterable=(), /)

Bases: JSON_List

item_type

alias of BulkComposition

adios_db.models.oil.ccme module

dataclass to hold the CCME data

CCME is kind of a special case, so this nails it down

class adios_db.models.oil.ccme.CCME(F1: MassFraction = None, F2: MassFraction = None, F3: MassFraction = None, F4: MassFraction = None, method: str = None)

Bases: object

hold the CCME data from env CA

(https://www.ccme.ca/en/resources/canadian_environmental_quality_guidelines/index.html)

F1: MassFraction = None
F2: MassFraction = None
F3: MassFraction = None
F4: MassFraction = None
classmethod from_py_json(py_json, allow_none=False)

classmethod to create a dataclass from json compatible python data structure.

method: str = None
py_json(sparse=True)

function to convert a dataclass to json compatible python

Parameters:

sparse=True – If sparse is True, only non-empty fields will be written. If False, then all fields will be included.

validate()

Function to validate a dataclass with fields that have validate methods. The validate methods are expected to return a list of validation messages.

The top-level validator extends the existing list

adios_db.models.oil.completeness module

Calculate the completeness of the data contained in an oil record.

The top-level interface is a single function:

completeness(oil)

Where oil is an oil record

It performs calculations that were designed by Robert Jones, and returns a value with a scale of 0->100

As of June 2021, these were the criteria:

The scores should be normalized by total possible score.

One emulsion water content in any subsample. Score = 2.5

Fresh oil:

One density. Score = 1

Second density separated by temperature.

Score = deltaT/40 but not greater than 0.5

One viscosity. Score = 0.5

Second viscosity at a different temperature.

Score = maxDeltaT/40, but not greater than 0.5

Two Distillation cuts separated by mass or volume fraction. Score = 3*maxDeltaFraction

Fraction recovered =1. Score = 2. Fraction recovered <1. Score = 1.

One Weathered oil:

Density. Score = 1 Viscosity. Score = 1

class adios_db.models.oil.completeness.CheckDistillation

Bases: object

max_score = 5
class adios_db.models.oil.completeness.CheckViscosity

Bases: object

max_score = 2.5
class adios_db.models.oil.completeness.Check_density

Bases: object

Fresh oil: One density Score = 1

max_score = 1.0
class adios_db.models.oil.completeness.Check_emulsion_water_content

Bases: object

max_score = 2.5
class adios_db.models.oil.completeness.Check_second_density

Bases: object

Fresh oil: One density Score = 0.5

max_score = 0.5
class adios_db.models.oil.completeness.Check_weathered_density

Bases: object

max_score = 1
adios_db.models.oil.completeness.completeness(oil)

Calculate the completeness of the data contained in an oil record.

Parameters:

oil – The oil record to be validated

adios_db.models.oil.completeness.is_measurement_good(measurement)
adios_db.models.oil.completeness.set_completeness(oil)

adios_db.models.oil.compound module

dataclass to store the compounds

class adios_db.models.oil.compound.Compound(name: str = '', groups: list = <factory>, method: str = '', measurement: ~adios_db.models.common.measurement.MassFraction = None, comment: str = '')

Bases: object

Some compounds that will be handled by this dataclass: - sulfur_mass_fraction: MassFraction = None - carbon_mass_fraction: MassFraction = None - hydrogen_mass_fraction: MassFraction = None - mercaptan_sulfur_mass_fraction: MassFraction = None - nitrogen_mass_fraction: MassFraction = None - ccr_percent: MassFraction = None # conradson carbon residue - calcium_mass_fraction: MassFraction = None - hydrogen_sulfide_concentration: MassFraction = None - salt_content: MassFraction = None - paraffin_volume_fraction: MassFraction = None - naphthene_volume_fraction: MassFraction = None - aromatic_volume_fraction: MassFraction = None

comment: str = ''
classmethod from_py_json(py_json, allow_none=False)

classmethod to create a dataclass from json compatible python data structure.

groups: list
measurement: MassFraction = None
method: str = ''
name: str = ''
py_json(sparse=True)

function to convert a dataclass to json compatible python

Parameters:

sparse=True – If sparse is True, only non-empty fields will be written. If False, then all fields will be included.

validate()

Function to validate a dataclass with fields that have validate methods. The validate methods are expected to return a list of validation messages.

The top-level validator extends the existing list

class adios_db.models.oil.compound.CompoundList(iterable=(), /)

Bases: JSON_List

item_type

alias of Compound

adios_db.models.oil.distillation module

Classes for storing measured values within an Oil record

class adios_db.models.oil.distillation.DistCut(fraction: adios_db.models.common.measurement.MassOrVolumeFraction = None, vapor_temp: adios_db.models.common.measurement.Temperature = None)

Bases: object

fraction: MassOrVolumeFraction = None
classmethod from_py_json(py_json, allow_none=False)

classmethod to create a dataclass from json compatible python data structure.

py_json(sparse=True)

function to convert a dataclass to json compatible python

Parameters:

sparse=True – If sparse is True, only non-empty fields will be written. If False, then all fields will be included.

validate()

Function to validate a dataclass with fields that have validate methods. The validate methods are expected to return a list of validation messages.

The top-level validator extends the existing list

vapor_temp: Temperature = None
class adios_db.models.oil.distillation.DistCutList(iterable=(), /)

Bases: JSON_List

classmethod from_data_arrays(fractions, temps, frac_unit, temp_unit, unit_type='MassFraction')

Create a DistCutList from arrays of dist cut data

Parameters:
  • fractions – sequence of cut fractions

  • temps – sequence of cut vapor temperatures

  • frac_unit – unit of fractions: e.g.”%”, “fraction”

  • temp_unit – temperature unit: e.g. “C”, “F”, “K”

  • unit_type="MassFraction" – “MassFraction” or “VolumeFraction”

item_type

alias of DistCut

class adios_db.models.oil.distillation.Distillation(type: str = None, method: str = None, end_point: adios_db.models.common.measurement.Temperature = None, fraction_recovered: adios_db.models.common.measurement.MassOrVolumeFraction = None, cuts: adios_db.models.oil.distillation.DistCutList = <factory>)

Bases: object

cuts: DistCutList
end_point: Temperature = None
fraction_recovered: MassOrVolumeFraction = None
classmethod from_py_json(py_json, allow_none=False)

classmethod to create a dataclass from json compatible python data structure.

method: str = None
py_json(sparse=True)

function to convert a dataclass to json compatible python

Parameters:

sparse=True – If sparse is True, only non-empty fields will be written. If False, then all fields will be included.

type: str = None
validate()

Function to validate a dataclass with fields that have validate methods. The validate methods are expected to return a list of validation messages.

The top-level validator extends the existing list

adios_db.models.oil.environmental_behavior module

Main class that represents an oil record.

This maps to the JSON used in the DB

Having a Python class makes it easier to write importing, validating etc, code.

class adios_db.models.oil.environmental_behavior.EnvironmentalBehavior(dispersibilities: ~adios_db.models.oil.properties.DispersibilityList = <factory>, emulsions: ~adios_db.models.oil.properties.EmulsionList = <factory>, adhesion: ~adios_db.models.common.measurement.NeedleAdhesion = None, ests_evaporation_test: ~adios_db.models.oil.properties.ESTSEvaporationTest = <factory>)

Bases: object

class to hold data about environmental behavior –

dispersabilty, emulsion formation, adhesion, …

adhesion: NeedleAdhesion = None
dispersibilities: DispersibilityList
emulsions: EmulsionList
ests_evaporation_test: ESTSEvaporationTest
classmethod from_py_json(py_json, allow_none=False)

classmethod to create a dataclass from json compatible python data structure.

py_json(sparse=True)

function to convert a dataclass to json compatible python

Parameters:

sparse=True – If sparse is True, only non-empty fields will be written. If False, then all fields will be included.

validate()

Function to validate a dataclass with fields that have validate methods. The validate methods are expected to return a list of validation messages.

The top-level validator extends the existing list

adios_db.models.oil.ests_fractions module

dataclass to hold the ESTS Hydrocarbon Fractions

This is kind of a special case, so this nails it down

class adios_db.models.oil.ests_fractions.ESTSFractions(method: str = None, saturates: ~adios_db.models.oil.compound.CompoundList = <factory>, aromatics: ~adios_db.models.oil.compound.CompoundList = <factory>, GC_TPH: ~adios_db.models.oil.compound.CompoundList = <factory>)

Bases: object

hold the ESTS Hydrocarbon Fractions from env CA

(https://www.ccme.ca/en/resources/canadian_environmental_quality_guidelines/index.html)

GC_TPH: CompoundList
aromatics: CompoundList
classmethod from_py_json(py_json, allow_none=False)

classmethod to create a dataclass from json compatible python data structure.

method: str = None
py_json(sparse=True)

function to convert a dataclass to json compatible python

Parameters:

sparse=True – If sparse is True, only non-empty fields will be written. If False, then all fields will be included.

saturates: CompoundList
validate()

Function to validate a dataclass with fields that have validate methods. The validate methods are expected to return a list of validation messages.

The top-level validator extends the existing list

adios_db.models.oil.industry_property module

dataclass to store the industry properties

These are tricky, as they can be any weird unit

class adios_db.models.oil.industry_property.IndustryProperty(name: str = '', method: str = '', measurement: AnyUnit = None, comment: str = '')

Bases: object

This handles the various odd industry properties.

For example:

  • Total Acid Number

  • Reid Vapor Pressure

  • Aniline Point

  • Cetane Index

  • Cloud Point

  • Smoke Point

  • Freeze Point

comment: str = ''
classmethod from_py_json(py_json, allow_none=False)

classmethod to create a dataclass from json compatible python data structure.

measurement: AnyUnit = None
method: str = ''
name: str = ''
py_json(sparse=True)

function to convert a dataclass to json compatible python

Parameters:

sparse=True – If sparse is True, only non-empty fields will be written. If False, then all fields will be included.

validate()

Function to validate a dataclass with fields that have validate methods. The validate methods are expected to return a list of validation messages.

The top-level validator extends the existing list

class adios_db.models.oil.industry_property.IndustryPropertyList(iterable=(), /)

Bases: JSON_List

item_type

alias of IndustryProperty

adios_db.models.oil.location_coordinates module

Location Coordinates Object

When saved out as JSON, this is a subset of geoJSON

i.e. a geoJSON geometry, but can only be a Point or a Polygon.

So either:

{
  'type': 'Point',
  'coordinates': [0, 0]
}

or:

{
  'type': 'Polygon',
  'coordinates': [[[-5e6, -1e6], [-4e6, 1e6], [-3e6, -1e6]]]
}
class adios_db.models.oil.location_coordinates.LocationCoordinates(type: str, coordinates: list)

Bases: object

coordinates: list
classmethod from_py_json(py_json, allow_none=False)

classmethod to create a dataclass from json compatible python data structure.

py_json(sparse=True)

function to convert a dataclass to json compatible python

Parameters:

sparse=True – If sparse is True, only non-empty fields will be written. If False, then all fields will be included.

type: str
validate()

Function to validate a dataclass with fields that have validate methods. The validate methods are expected to return a list of validation messages.

The top-level validator extends the existing list

adios_db.models.oil.metadata module

Class that represents the demographic data (metadata) of an oil record.

class adios_db.models.oil.metadata.ChangeLog(iterable=(), /)

Bases: JSON_List

item_type

alias of ChangeLogEntry

class adios_db.models.oil.metadata.ChangeLogEntry(name: str = '', date: str = '', comment: str = '')

Bases: object

comment: str = ''
date: str = ''
classmethod from_py_json(py_json, allow_none=False)

classmethod to create a dataclass from json compatible python data structure.

name: str = ''
py_json(sparse=True)

function to convert a dataclass to json compatible python

Parameters:

sparse=True – If sparse is True, only non-empty fields will be written. If False, then all fields will be included.

validate()

Function to validate a dataclass with fields that have validate methods. The validate methods are expected to return a list of validation messages.

The top-level validator extends the existing list

class adios_db.models.oil.metadata.MetaData(name: str = '', source_id: str = '', alternate_names: list = <factory>, location: str = '', reference: adios_db.models.oil.values.Reference = <factory>, sample_date: str = '', product_type: adios_db.models.oil.product_type.ProductType = '', API: float = None, comments: str = '', labels: list = <factory>, model_completeness: float = None, location_coordinates: adios_db.models.oil.location_coordinates.LocationCoordinates = None, gnome_suitable: bool = None, change_log: adios_db.models.oil.metadata.ChangeLog = <factory>)

Bases: object

API: float = None
alternate_names: list
change_log: ChangeLog
comments: str = ''
classmethod from_py_json(py_json, allow_none=False)

classmethod to create a dataclass from json compatible python data structure.

gnome_suitable: bool = None
labels: list
location: str = ''
location_coordinates: LocationCoordinates = None
model_completeness: float = None
name: str = ''
product_type: ProductType = ''
py_json(sparse=True)

function to convert a dataclass to json compatible python

Parameters:

sparse=True – If sparse is True, only non-empty fields will be written. If False, then all fields will be included.

reference: Reference
sample_date: str = ''
source_id: str = ''
validate()

Function to validate a dataclass with fields that have validate methods. The validate methods are expected to return a list of validation messages.

The top-level validator extends the existing list

class adios_db.models.oil.metadata.SampleMetaData(name: str = 'Fresh Oil Sample', short_name: str = None, sample_id: str = None, description: str = None, fraction_evaporated: adios_db.models.common.measurement.MassFraction = None, boiling_point_range: adios_db.models.common.measurement.Temperature = None)

Bases: object

boiling_point_range: Temperature = None
description: str = None
fraction_evaporated: MassFraction = None
classmethod from_py_json(py_json, allow_none=False)

classmethod to create a dataclass from json compatible python data structure.

name: str = 'Fresh Oil Sample'
py_json(sparse=True)

function to convert a dataclass to json compatible python

Parameters:

sparse=True – If sparse is True, only non-empty fields will be written. If False, then all fields will be included.

sample_id: str = None
short_name: str = None
validate()

Function to validate a dataclass with fields that have validate methods. The validate methods are expected to return a list of validation messages.

The top-level validator extends the existing list

adios_db.models.oil.oil module

Main class that represents an oil record.

This maps to the JSON used in the DB

Having a Python class makes it easier to write importing, validating etc, code.

class adios_db.models.oil.oil.Oil(oil_id: str, adios_data_model_version: adios_db.models.oil.version.Version = Version(0, 12, 0), metadata: adios_db.models.oil.metadata.MetaData = <factory>, sub_samples: adios_db.models.oil.sample.SampleList = <factory>, status: list = <factory>, permanent_warnings: list = <factory>, extra_data: dict = <factory>, review_status: adios_db.models.oil.review_status.ReviewStatus = <factory>)

Bases: object

adios_data_model_version: Version = Version(0, 12, 0)
extra_data: dict
classmethod from_file(infile)

load an Oil object from the passed in JSON file

it can be either a path or an open file object

NOTE: this could be in the decorator – but we only really need it

for a full record.

classmethod from_py_json(py_json, allow_none=False)

classmethod to create a dataclass from json compatible python data structure.

metadata: MetaData
oil_id: str
permanent_warnings: list
py_json(sparse=True)

function to convert a dataclass to json compatible python

Parameters:

sparse=True – If sparse is True, only non-empty fields will be written. If False, then all fields will be included.

reset_validation()

calls the validate method, and updates the status with the result

review_status: ReviewStatus
status: list
sub_samples: SampleList
to_file(outfile, sparse=True)

save an Oil object as JSON to the passed in file

it can be either a path or a writable open file object

NOTE: this could be in the decorator – but we only really need it

for a full record.

validate()

Function to validate a dataclass with fields that have validate methods. The validate methods are expected to return a list of validation messages.

The top-level validator extends the existing list

adios_db.models.oil.oil.get_current_version()

adios_db.models.oil.physical_properties module

Main class that represents an oil record.

This maps to the JSON used in the DB

Having a Python class makes it easier to write importing, validating etc, code.

class adios_db.models.oil.physical_properties.DensityList(iterable=(), /)

Bases: RefTempList, JSON_List

classmethod from_data(data_table)

Create a DensityList from data of the format:

``` [(density, density_unit, temp, temp_unit),

(density, density_unit, temp, temp_unit), … ]

``` example:

``` [(0.8663, “g/cm³”, 15, “C”),

(0.9012, “g/cm³”, 0.0, “C”), ]

item_type

alias of DensityPoint

class adios_db.models.oil.physical_properties.DensityPoint(density: adios_db.models.common.measurement.Density = None, ref_temp: adios_db.models.common.measurement.Temperature = None, method: str = None, comment: str = None)

Bases: object

comment: str = None
density: Density = None
classmethod from_py_json(py_json, allow_none=False)

classmethod to create a dataclass from json compatible python data structure.

method: str = None
py_json(sparse=True)

function to convert a dataclass to json compatible python

Parameters:

sparse=True – If sparse is True, only non-empty fields will be written. If False, then all fields will be included.

ref_temp: Temperature = None
validate()

Function to validate a dataclass with fields that have validate methods. The validate methods are expected to return a list of validation messages.

The top-level validator extends the existing list

class adios_db.models.oil.physical_properties.DynamicViscosityList(iterable=(), /)

Bases: RefTempList, JSON_List

classmethod from_data(data_table)

Create a DensityList from data of the format:

``` [(viscosity, viscosity_unit, temp, temp_unit),

(viscosity, viscosity, temp, temp_unit), … ]

``` example:

``` [(100, “cSt”, 273.15, “K”),

(1234.3, “cSt”, 15.0, “C”), ]

item_type

alias of DynamicViscosityPoint

validate()

validator for viscosity

Checks dvis are increasing with temperature.

class adios_db.models.oil.physical_properties.DynamicViscosityPoint(viscosity: adios_db.models.common.measurement.DynamicViscosity = None, ref_temp: adios_db.models.common.measurement.Temperature = None, shear_rate: adios_db.models.common.measurement.AngularVelocity = None, method: str = None, comment: str = None)

Bases: object

comment: str = None
classmethod from_py_json(py_json, allow_none=False)

classmethod to create a dataclass from json compatible python data structure.

method: str = None
py_json(sparse=True)

function to convert a dataclass to json compatible python

Parameters:

sparse=True – If sparse is True, only non-empty fields will be written. If False, then all fields will be included.

ref_temp: Temperature = None
shear_rate: AngularVelocity = None
validate()

Function to validate a dataclass with fields that have validate methods. The validate methods are expected to return a list of validation messages.

The top-level validator extends the existing list

viscosity: DynamicViscosity = None
class adios_db.models.oil.physical_properties.FlashPoint(measurement: adios_db.models.common.measurement.Temperature = None, method: str = None, comment: str = None)

Bases: object

comment: str = None
classmethod from_py_json(py_json, allow_none=False)

classmethod to create a dataclass from json compatible python data structure.

measurement: Temperature = None
method: str = None
py_json(sparse=True)

function to convert a dataclass to json compatible python

Parameters:

sparse=True – If sparse is True, only non-empty fields will be written. If False, then all fields will be included.

validate()

Function to validate a dataclass with fields that have validate methods. The validate methods are expected to return a list of validation messages.

The top-level validator extends the existing list

class adios_db.models.oil.physical_properties.InterfacialTensionList(iterable=(), /)

Bases: RefTempList, JSON_List

item_type

alias of InterfacialTensionPoint

class adios_db.models.oil.physical_properties.InterfacialTensionPoint(tension: adios_db.models.common.measurement.InterfacialTension = None, ref_temp: adios_db.models.common.measurement.Temperature = None, method: str = None, comment: str = None)

Bases: object

comment: str = None
classmethod from_py_json(py_json, allow_none=False)

classmethod to create a dataclass from json compatible python data structure.

method: str = None
py_json(sparse=True)

function to convert a dataclass to json compatible python

Parameters:

sparse=True – If sparse is True, only non-empty fields will be written. If False, then all fields will be included.

ref_temp: Temperature = None
tension: InterfacialTension = None
validate()

Function to validate a dataclass with fields that have validate methods. The validate methods are expected to return a list of validation messages.

The top-level validator extends the existing list

class adios_db.models.oil.physical_properties.KinematicViscosityList(iterable=(), /)

Bases: RefTempList, JSON_List

classmethod from_data(data_table)

Create a DensityList from data of the format:

``` [(viscosity, viscosity_unit, temp, temp_unit),

(viscosity, viscosity, temp, temp_unit), … ]

``` example:

``` [(100, “cSt”, 273.15, “K”),

(1234.3, “cSt”, 15.0, “C”), ]

item_type

alias of KinematicViscosityPoint

validate()

validator for viscosity

Checks kvis are increasing with temperature.

class adios_db.models.oil.physical_properties.KinematicViscosityPoint(viscosity: adios_db.models.common.measurement.KinematicViscosity = None, ref_temp: adios_db.models.common.measurement.Temperature = None, shear_rate: adios_db.models.common.measurement.AngularVelocity = None, method: str = None, comment: str = None)

Bases: object

comment: str = None
classmethod from_py_json(py_json, allow_none=False)

classmethod to create a dataclass from json compatible python data structure.

method: str = None
py_json(sparse=True)

function to convert a dataclass to json compatible python

Parameters:

sparse=True – If sparse is True, only non-empty fields will be written. If False, then all fields will be included.

ref_temp: Temperature = None
shear_rate: AngularVelocity = None
validate()

Function to validate a dataclass with fields that have validate methods. The validate methods are expected to return a list of validation messages.

The top-level validator extends the existing list

viscosity: KinematicViscosity = None
class adios_db.models.oil.physical_properties.PhysicalProperties(pour_point: adios_db.models.oil.physical_properties.PourPoint = None, flash_point: adios_db.models.oil.physical_properties.FlashPoint = None, appearance: str = '', densities: adios_db.models.oil.physical_properties.DensityList = <factory>, kinematic_viscosities: adios_db.models.oil.physical_properties.KinematicViscosityList = <factory>, dynamic_viscosities: adios_db.models.oil.physical_properties.DynamicViscosityList = <factory>, interfacial_tension_air: adios_db.models.oil.physical_properties.InterfacialTensionList = <factory>, interfacial_tension_water: adios_db.models.oil.physical_properties.InterfacialTensionList = <factory>, interfacial_tension_seawater: adios_db.models.oil.physical_properties.InterfacialTensionList = <factory>)

Bases: object

appearance: str = ''
densities: DensityList
dynamic_viscosities: DynamicViscosityList
flash_point: FlashPoint = None
classmethod from_py_json(py_json, allow_none=False)

classmethod to create a dataclass from json compatible python data structure.

interfacial_tension_air: InterfacialTensionList
interfacial_tension_seawater: InterfacialTensionList
interfacial_tension_water: InterfacialTensionList
kinematic_viscosities: KinematicViscosityList
pour_point: PourPoint = None
py_json(sparse=True)

function to convert a dataclass to json compatible python

Parameters:

sparse=True – If sparse is True, only non-empty fields will be written. If False, then all fields will be included.

validate()

Function to validate a dataclass with fields that have validate methods. The validate methods are expected to return a list of validation messages.

The top-level validator extends the existing list

class adios_db.models.oil.physical_properties.PourPoint(measurement: adios_db.models.common.measurement.Temperature = None, method: str = None, comment: str = None)

Bases: object

comment: str = None
classmethod from_py_json(py_json, allow_none=False)

classmethod to create a dataclass from json compatible python data structure.

measurement: Temperature = None
method: str = None
py_json(sparse=True)

function to convert a dataclass to json compatible python

Parameters:

sparse=True – If sparse is True, only non-empty fields will be written. If False, then all fields will be included.

validate()

Function to validate a dataclass with fields that have validate methods. The validate methods are expected to return a list of validation messages.

The top-level validator extends the existing list

class adios_db.models.oil.physical_properties.RefTempList

Bases: object

mixin for all classes that are a list of points with reference temperatures

validate()

validator for anything that has a list of reference temps

e.g. density and viscosity

For viscosity it checks for shear rate as well.

class adios_db.models.oil.physical_properties.SayboltViscosityList(iterable=(), /)

Bases: RefTempList, JSON_List

item_type

alias of SayboltViscosityPoint

class adios_db.models.oil.physical_properties.SayboltViscosityPoint(viscosity: adios_db.models.common.measurement.SayboltViscosity = None, ref_temp: adios_db.models.common.measurement.Temperature = None, shear_rate: adios_db.models.common.measurement.AngularVelocity = None, method: str = None, comment: str = None)

Bases: object

comment: str = None
classmethod from_py_json(py_json, allow_none=False)

classmethod to create a dataclass from json compatible python data structure.

method: str = None
py_json(sparse=True)

function to convert a dataclass to json compatible python

Parameters:

sparse=True – If sparse is True, only non-empty fields will be written. If False, then all fields will be included.

ref_temp: Temperature = None
shear_rate: AngularVelocity = None
validate()

Function to validate a dataclass with fields that have validate methods. The validate methods are expected to return a list of validation messages.

The top-level validator extends the existing list

viscosity: SayboltViscosity = None

adios_db.models.oil.product_type module

Class that represents the product type

With validation

Also maintains the products types and labels mapping

class adios_db.models.oil.product_type.ProductType

Bases: str

classmethod validate(value)
class adios_db.models.oil.product_type.TypeLabelsMap(initial_data=None)

Bases: ManyMany

class to maintain a many to many relationship between product types and labels

The .product_types attribute is a mapping with the labels as keys, and product types as values.

The .labels attribute is a mapping with the product type as keys, and the associated labels as values.

property all_labels
property all_labels_dict

All the labels, and their property types, as a JSON service compatible dict

Returns:

list of dicts for each label:

[{'_id': 0,
'name': 'a label name,
'product_types': ['type one', 'type two', ...]},
...
]
property all_product_types
property labels

A copy of the left dict

It’s a copy, so it won’t change the internal ones if mutated

property product_types

A copy of the right dict

It’s a copy, so it won’t change the internal ones if mutated

adios_db.models.oil.product_type.load_from_csv_file(filepath=None)

Loads the product types and labels mapping from a CSV file

Parameters:

filepath=None – The name of the file to load from. If not provided, it will look for: “product_types_and_labels.csv” next to this module

adios_db.models.oil.properties module

Classes for storing measured values within an Oil record

class adios_db.models.oil.properties.Dispersibility(dispersant: str = None, effectiveness: adios_db.models.common.measurement.MassFraction = None, method: str = None)

Bases: object

dispersant: str = None
effectiveness: MassFraction = None
classmethod from_py_json(py_json, allow_none=False)

classmethod to create a dataclass from json compatible python data structure.

method: str = None
py_json(sparse=True)

function to convert a dataclass to json compatible python

Parameters:

sparse=True – If sparse is True, only non-empty fields will be written. If False, then all fields will be included.

validate()

Function to validate a dataclass with fields that have validate methods. The validate methods are expected to return a list of validation messages.

The top-level validator extends the existing list

class adios_db.models.oil.properties.DispersibilityList(iterable=(), /)

Bases: JSON_List

item_type

alias of Dispersibility

class adios_db.models.oil.properties.ESTSEvaporationTest(a_for_ev_a_b_ln_t_c: float = None, a_for_ev_a_b_ln_t: float = None, a_for_ev_a_b_sqrt_t: float = None, b_for_ev_a_b_ln_t_c: float = None, b_for_ev_a_b_ln_t: float = None, b_for_ev_a_b_sqrt_t: float = None, c_for_ev_a_b_ln_t_c: float = None, method: str = None)

Bases: object

a_for_ev_a_b_ln_t: float = None
a_for_ev_a_b_ln_t_c: float = None
a_for_ev_a_b_sqrt_t: float = None
b_for_ev_a_b_ln_t: float = None
b_for_ev_a_b_ln_t_c: float = None
b_for_ev_a_b_sqrt_t: float = None
c_for_ev_a_b_ln_t_c: float = None
classmethod from_py_json(py_json, allow_none=False)

classmethod to create a dataclass from json compatible python data structure.

method: str = None
py_json(sparse=True)

function to convert a dataclass to json compatible python

Parameters:

sparse=True – If sparse is True, only non-empty fields will be written. If False, then all fields will be included.

validate()

Function to validate a dataclass with fields that have validate methods. The validate methods are expected to return a list of validation messages.

The top-level validator extends the existing list

class adios_db.models.oil.properties.Emulsion(age: ~adios_db.models.common.measurement.Time = None, water_content: ~adios_db.models.common.measurement.MassFraction = None, ref_temp: ~adios_db.models.common.measurement.Temperature = None, complex_modulus: ~adios_db.models.common.measurement.Pressure = None, storage_modulus: ~adios_db.models.common.measurement.Pressure = None, loss_modulus: ~adios_db.models.common.measurement.Pressure = None, tan_delta_v_e: ~adios_db.models.common.measurement.Unitless = None, complex_viscosity: ~adios_db.models.common.measurement.DynamicViscosity = None, kinematic_viscosities: ~adios_db.models.oil.physical_properties.KinematicViscosityList = <factory>, dynamic_viscosities: ~adios_db.models.oil.physical_properties.DynamicViscosityList = <factory>, method: str = None, visual_stability: str = None)

Bases: object

There is no use for an empty Emulsion object

But there is a use for one that has an arbitrary subset of fields,

so making them all optional

age: Time = None
complex_modulus: Pressure = None
complex_viscosity: DynamicViscosity = None
dynamic_viscosities: DynamicViscosityList
classmethod from_py_json(py_json, allow_none=False)

classmethod to create a dataclass from json compatible python data structure.

kinematic_viscosities: KinematicViscosityList
loss_modulus: Pressure = None
method: str = None
py_json(sparse=True)

function to convert a dataclass to json compatible python

Parameters:

sparse=True – If sparse is True, only non-empty fields will be written. If False, then all fields will be included.

ref_temp: Temperature = None
storage_modulus: Pressure = None
tan_delta_v_e: Unitless = None
validate()

Function to validate a dataclass with fields that have validate methods. The validate methods are expected to return a list of validation messages.

The top-level validator extends the existing list

visual_stability: str = None
water_content: MassFraction = None
class adios_db.models.oil.properties.EmulsionList(iterable=(), /)

Bases: JSON_List

item_type

alias of Emulsion

class adios_db.models.oil.properties.InterfacialTensionList(iterable=(), /)

Bases: JSON_List

item_type

alias of InterfacialTensionPoint

class adios_db.models.oil.properties.InterfacialTensionPoint(tension: adios_db.models.common.measurement.InterfacialTension, ref_temp: adios_db.models.common.measurement.Temperature, interface: str = None, method: str = None)

Bases: object

classmethod from_py_json(py_json, allow_none=False)

classmethod to create a dataclass from json compatible python data structure.

interface: str = None
method: str = None
py_json(sparse=True)

function to convert a dataclass to json compatible python

Parameters:

sparse=True – If sparse is True, only non-empty fields will be written. If False, then all fields will be included.

ref_temp: Temperature
tension: InterfacialTension
validate()

Function to validate a dataclass with fields that have validate methods. The validate methods are expected to return a list of validation messages.

The top-level validator extends the existing list

adios_db.models.oil.review_status module

simple class to hold the review status of a record

class adios_db.models.oil.review_status.ReviewStatus(status: str = 'Not Reviewed', reviewers: str = '', review_date: str = '', notes: str = '')

Bases: object

classmethod from_py_json(py_json, allow_none=False)

classmethod to create a dataclass from json compatible python data structure.

notes: str = ''
py_json(sparse=True)

function to convert a dataclass to json compatible python

Parameters:

sparse=True – If sparse is True, only non-empty fields will be written. If False, then all fields will be included.

review_date: str = ''
reviewers: str = ''
status: str = 'Not Reviewed'
validate()

Function to validate a dataclass with fields that have validate methods. The validate methods are expected to return a list of validation messages.

The top-level validator extends the existing list

adios_db.models.oil.sample module

Main class that represents an oil record.

This maps to the JSON used in the DB

Having a Python class makes it easier to write importing, validating etc, code.

class adios_db.models.oil.sample.Sample(metadata: ~adios_db.models.oil.metadata.SampleMetaData = <factory>, cut_volume: ~adios_db.models.common.measurement.VolumeFraction = None, physical_properties: ~adios_db.models.oil.physical_properties.PhysicalProperties = <factory>, environmental_behavior: ~adios_db.models.oil.environmental_behavior.EnvironmentalBehavior = <factory>, SARA: ~adios_db.models.oil.sara.Sara = <factory>, distillation_data: ~adios_db.models.oil.distillation.Distillation = <factory>, compounds: ~adios_db.models.oil.compound.CompoundList = <factory>, bulk_composition: ~adios_db.models.oil.bulk_composition.BulkCompositionList = <factory>, industry_properties: ~adios_db.models.oil.industry_property.IndustryPropertyList = <factory>, headspace_analysis: ~adios_db.models.oil.compound.CompoundList = <factory>, CCME: ~adios_db.models.oil.ccme.CCME = <factory>, ESTS_hydrocarbon_fractions: ~adios_db.models.oil.ests_fractions.ESTSFractions = None, miscellaneous: ~adios_db.models.oil.compound.CompoundList = <factory>, extra_data: dict = <factory>)

Bases: object

represents the physical and chemical properties of particular sub sample.

could be fresh oil, or weathered samples, or distillation cuts, or …

CCME: CCME
ESTS_hydrocarbon_fractions: ESTSFractions = None
SARA: Sara
bulk_composition: BulkCompositionList
compounds: CompoundList
cut_volume: VolumeFraction = None
distillation_data: Distillation
environmental_behavior: EnvironmentalBehavior
extra_data: dict
classmethod from_py_json(py_json, allow_none=False)

classmethod to create a dataclass from json compatible python data structure.

headspace_analysis: CompoundList
industry_properties: IndustryPropertyList
metadata: SampleMetaData
miscellaneous: CompoundList
physical_properties: PhysicalProperties
py_json(sparse=True)

function to convert a dataclass to json compatible python

Parameters:

sparse=True – If sparse is True, only non-empty fields will be written. If False, then all fields will be included.

validate()

Function to validate a dataclass with fields that have validate methods. The validate methods are expected to return a list of validation messages.

The top-level validator extends the existing list

class adios_db.models.oil.sample.SampleList(iterable=(), /)

Bases: JSON_List

item_type

alias of Sample

validate()

adios_db.models.oil.sara module

Model class definitions for SARA fractions

class adios_db.models.oil.sara.Sara(method: str = None, saturates: adios_db.models.common.measurement.MassFraction = None, aromatics: adios_db.models.common.measurement.MassFraction = None, resins: adios_db.models.common.measurement.MassFraction = None, asphaltenes: adios_db.models.common.measurement.MassFraction = None)

Bases: object

aromatics: MassFraction = None
asphaltenes: MassFraction = None
classmethod from_data(data, unit)

create a Sara object from the data provided

must be a 4-sequence:

Parameters:
  • data – [saturate_fraction, aromatic_fraction, resin_fraction, asphaltene_fraction] (any value can be None)

  • unit – unit – must be mass fraction, e.g. ‘fraction’, “%”

classmethod from_py_json(py_json, allow_none=False)

classmethod to create a dataclass from json compatible python data structure.

method: str = None
py_json(sparse=True)

function to convert a dataclass to json compatible python

Parameters:

sparse=True – If sparse is True, only non-empty fields will be written. If False, then all fields will be included.

resins: MassFraction = None
saturates: MassFraction = None
validate()

Function to validate a dataclass with fields that have validate methods. The validate methods are expected to return a list of validation messages.

The top-level validator extends the existing list

adios_db.models.oil.values module

Classes for individual classes -not much here!

class adios_db.models.oil.values.Reference(year: int = None, reference: str = '')

Bases: ReferenceBase

classmethod validate(value)

Function to validate a dataclass with fields that have validate methods. The validate methods are expected to return a list of validation messages.

The top-level validator extends the existing list

class adios_db.models.oil.values.ReferenceBase(year: int = None, reference: str = '')

Bases: object

classmethod from_py_json(py_json, allow_none=False)

classmethod to create a dataclass from json compatible python data structure.

py_json(sparse=True)

function to convert a dataclass to json compatible python

Parameters:

sparse=True – If sparse is True, only non-empty fields will be written. If False, then all fields will be included.

reference: str = ''
validate()

Function to validate a dataclass with fields that have validate methods. The validate methods are expected to return a list of validation messages.

The top-level validator extends the existing list

year: int = None

adios_db.models.oil.version module

class to handle the version number

class adios_db.models.oil.version.Version(major, minor=0, patch=0)

Bases: object

class to represent a version with major, minor, and patch components

classmethod from_py_json(py_json, allow_none=False)
py_json(sparse=True)
exception adios_db.models.oil.version.VersionError

Bases: ValueError

adios_db.models.oil.version_update module

version_update.py: Code for dealing with different versions of the data model

NOTE: this may need some refactoring when it gets more complicated

class adios_db.models.oil.version_update.Updater

Bases: object

update(py_json)
ver_from = None
ver_to = None
class adios_db.models.oil.version_update.update_0_10_0_to_0_11_0

Bases: Updater

update(py_json)
ver_from = Version(0, 10, 0)
ver_to = Version(0, 11, 0)
class adios_db.models.oil.version_update.update_0_11_0_to_0_12_0

Bases: Updater

an updater for only additions – nothing to be done other than update the version

ver_from = Version(0, 11, 0)
ver_to = Version(0, 12, 0)
adios_db.models.oil.version_update.update_json(py_json)

updates JSON for an oil object from an older version to a newer one