pywellsfm.io

The pywellsfm.io package contains input/output utilities used to load and save pyWellSFM data structures (wells, curves, facies models, simulations) and to validate inputs against JSON schemas.

Files documented

This page is built from the following Python modules:

  • _common.py (pywellsfm.io._common)

  • accumulation_model_io.py (pywellsfm.io.accumulation_model_io)

  • curve_io.py (pywellsfm.io.curve_io)

  • depositional_environment_model_io.py (pywellsfm.io.depositional_environment_model_io)

  • depositional_environment_simulation_io.py (pywellsfm.io.depositional_environment_simulation_io)

  • environment_condition_model_io.py (pywellsfm.io.environment_condition_model_io)

  • facies_model_io.py (pywellsfm.io.facies_model_io)

  • json_schema_validation.py (pywellsfm.io.json_schema_validation)

  • fssimulation_io.py (pywellsfm.io.fssimulation_io)

  • striplog_io.py (pywellsfm.io.striplog_io)

  • tabulated_function_io.py (pywellsfm.io.tabulated_function_io)

  • well_io.py (pywellsfm.io.well_io)

API reference

I/O public API.

This package contains file-format specific loaders and utilities.

The symbols re-exported here form the supported, stable entry points. Callers should prefer importing from pywellsfm.io instead of submodules.

pywellsfm.io.depositionalEnvironmentModelToJsonObj(model: DepositionalEnvironmentModel) dict[str, Any]

Serialize a DepositionalEnvironmentModel to JSON object.

pywellsfm.io.depositionalEnvironmentSimulationToJsonObj(simulator: DepositionalEnvironmentSimulator) dict[str, Any]

Serialize DepositionalEnvironmentSimulator to JSON object.

pywellsfm.io.environmentConditionsModelToJsonObj(model: EnvironmentConditionsModel, *, curves_mode: str = 'inline') dict[str, Any]

Serialize an EnvironmentConditionsModel to JSON schema payload.

pywellsfm.io.importStriplog(filepath: str, csvDelimiter: str = ',') Striplog

Load a stripLog from a file.

Supported file format are:

  • .csv : comma-separated values file

Parameters:

filepath (str) – Path to the striplog CSV file.

Return Striplog:

Loaded striplog object.

pywellsfm.io.loadAccumulationModel(filepath: str) AccumulationModel

Load accumulation model from file.

The file can be a csv or a json file. Csv file supports only Gaussian element models. The json file conforms to the schema in jsonSchemas/AccumulationModelSchema.json.

Parameters:

filepath – Path to accumulation model file.

Returns:

An accumulation model.

pywellsfm.io.loadAccumulationModelGaussianFromCsv(filepath: str) AccumulationModel

Load Gaussian accumulation model from csv file.

The csv file must contain the following columns:

  • name: name of the element

  • accumulationRate: mean accumulation rate (m/My)

  • stddevFactor: standard deviation factor (multiplied by mean to get stddev)

Params str filepath:

Path to accumulation model csv file.

Returns AccumulationModel:

AccumulationModel with Gaussian element models.

pywellsfm.io.loadCurvesFromFile(path: Path) list[Curve]

Load one or multiple Curve from a .json or .csv file.

json files contain a single Curve object, csv files may contain multiple curves.

  • .json: must match the Curve JSON structure.

  • .csv: expects two numeric columns (x,y), 1 row header defining axis names.

Returns list[Curve]:

list of curve objects.

pywellsfm.io.loadDepositionalEnvironmentModel(filepath: str) DepositionalEnvironmentModel

Load a DepositionalEnvironmentModel from a .json file.

pywellsfm.io.loadDepositionalEnvironmentModelFromJsonObj(obj: dict[str, Any], base_dir: str | None = None) DepositionalEnvironmentModel

Parse a DepositionalEnvironmentModel JSON object.

The JSON must match jsonSchemas/DepositionalEnvironmentModelSchema.json.

pywellsfm.io.loadDepositionalEnvironmentSimulation(filepath: str) DepositionalEnvironmentSimulator

Load DepositionalEnvironmentSimulator from a .json file.

pywellsfm.io.loadDepositionalEnvironmentSimulationFromJsonObj(obj: dict[str, Any], *, base_dir: str | None = None) DepositionalEnvironmentSimulator

Parse a DepositionalEnvironmentSimulator JSON object.

pywellsfm.io.loadEnvironmentConditionsModel(filepath: str) EnvironmentConditionsModel

Load an EnvironmentConditionsModel from a .json file.

pywellsfm.io.loadEnvironmentConditionsModelFromJsonObj(obj: dict[str, Any], *, base_dir: Path | None) EnvironmentConditionsModel

Load an EnvironmentConditionsModel from a JSON object.

pywellsfm.io.loadEustaticCurve(filepath: str) Curve

Load an eustatic Curve from a .json or .csv file.

pywellsfm.io.loadFSSimulation(filepath: str) FSSimulator

Load scenario from json file.

json file schema is defined by jsonSchemas/ScenarioSchema.json

Parameters:

filepath (str) – path to scenario json file

Return FSSimulatorData:

data object containing scenario and realizations data for running

pywellsfm.io.loadFaciesModel(filepath: str) FaciesModel

Load a facies model from a JSON file.

The JSON must match the on-disk format used by this project:

  • format: “pyWellSFM.FaciesModelData”

  • version: “1.0”

Parameters:

filepath (str) – Path to the facies model JSON file.

Return FaciesModel:

Loaded facies model

pywellsfm.io.loadRealizationData(filepath: str) RealizationData

Load realization data from json file.

json file schema is defined by jsonSchemas/RealizationData.json

Parameters:

filepath (str) – path to realization data json file

Return RealizationData:

realization data object

pywellsfm.io.loadScenario(filepath: str) Scenario

Load scenario from json file.

json file schema is defined by jsonSchemas/ScenarioSchema.json

Parameters:

filepath (str) – path to scenario json file

Return Scenario:

scenario object

pywellsfm.io.loadSubsidenceCurve(filepath: str) Curve

Load a subsidence Curve from a .json or .csv file.

pywellsfm.io.loadTabulatedFunctionFromFile(path: Path) tuple[str, str, ndarray, ndarray]

Load a tabulated function from a .json or .csv file.

  • .json: must match the TabulatedFunction JSON structure.

  • .csv: expects two numeric columns (x,y), no header.

Parameters:

path (Path) – Path to the input file.

Returns tuple[str, str, np.ndarray, np.ndarray]:

(abscissa_name, ordinate_name, x, y).

pywellsfm.io.loadUncertaintyCurveFromFile(path: Path) UncertaintyCurve

Load an UncertaintyCurve from a .json or .csv file.

  • .json: must match the Curve JSON structure.

  • .csv: expects two to four numeric columns (x,y, ymin, ymax), 1 row header defining axis names.

Returns Curve:

curve object.

pywellsfm.io.loadWell(filepath: str) Well

Load a Well from a file.

Supported file formats are:

  • json file matching jsonSchemas/WellSchema.json.

  • las file matching LAS 2.0 format.

Note

  • well.location defines the well head (x,y,z).

  • continuousLogs items use the Curve schema and are stored under the log name derived from curve.yAxisName.

  • striplogs items are stored under the striplog name.

Parameters:

filepath (str) – path to the well file

pywellsfm.io.saveAccumulationModel(model: AccumulationModel, filepath: str, *, curves_mode: str = 'inline', curves_dir: str | None = None, curves_format: str = 'json') None

Save an accumulation model to .json or .csv.

  • .json: always supported (schema-compliant)

  • .csv: supported only when all elements are Gaussian

pywellsfm.io.saveAccumulationModelEnvironmentOptimumToJson(accumulationModel: AccumulationModel, filepath: str, *, curves_mode: str = 'inline', curves_dir: str | None = None, curves_format: str = 'json') None

Save EnvironmentOptimum accumulation model to json.

Only curves_mode=’inline’ is supported with the current JSON schema.

pywellsfm.io.saveAccumulationModelGaussianToCsv(accumulationModel: AccumulationModel, filepath: str) None

Save Gaussian accumulation model to csv file.

pywellsfm.io.saveAccumulationModelGaussianToJson(accumulationModel: AccumulationModel, filepath: str) None

Save Gaussian accumulation model to json file.

pywellsfm.io.saveCurve(curve: Curve, filepath: str, *, y_axis_name: str | None = None, x_axis_name_default: str = 'Age') None

Save a Curve to a .json or .csv file.

pywellsfm.io.saveCurveToCsv(curve: Curve, filepath: str, *, y_axis_name: str | None = None, x_axis_name_default: str = 'x') None

Save a Curve to a .csv file with header (xAxisName,yAxisName).

pywellsfm.io.saveCurveToJson(curve: Curve, filepath: str, *, y_axis_name: str | None = None, x_axis_name_default: str = 'Age', indent: int = 2) None

Save a Curve to a .json file.

pywellsfm.io.saveDepositionalEnvironmentModel(model: DepositionalEnvironmentModel, filepath: str) None

Save a DepositionalEnvironmentModel to a .json file.

pywellsfm.io.saveDepositionalEnvironmentSimulation(simulator: DepositionalEnvironmentSimulator, filepath: str) None

Save DepositionalEnvironmentSimulator to a .json file.

pywellsfm.io.saveEnvironmentConditionsModel(model: EnvironmentConditionsModel, filepath: str, *, indent: int = 2, curves_mode: str = 'inline') None

Save an EnvironmentConditionsModel to a .json file.

pywellsfm.io.saveFSSimulation(fsSimulator: FSSimulator, filepath: str, *, name: str) None

Save FSSimulator object to json file.

pywellsfm.io.saveFaciesModel(faciesModel: FaciesModel, filepath: str) None

Save a facies model to a JSON file.

pywellsfm.io.saveRealizationData(realizationData: RealizationData, filepath: str) None

Save RealizationData object to json file.

json file format conforms to json/RealizationDataSchema.json.

Parameters:
  • realizationData (RealizationData) – RealizationData object

  • filepath (str) – file path to write JSON output

Raises:

ValueError – if filepath does not have .json extension

pywellsfm.io.saveScenario(scenario: Scenario, filepath: str) None

Save Scenario object to json file.

json file format conforms to json/ScenarioSchema.json.

Parameters:
  • scenario (Scenario) – Scenario object

  • filepath (str) – file path to write JSON output

Raises:

ValueError – if filepath does not have .json extension

pywellsfm.io.saveTabulatedFunctionToCsv(*, x: ndarray, y: ndarray, filepath: str) None

Save a tabulated function to a .csv file.

csv file has two columns x,y, no header.

pywellsfm.io.saveTabulatedFunctionToJson(*, abscissa_name: str, ordinate_name: str, x: ndarray, y: ndarray, filepath: str, indent: int = 2) None

Save a tabulated function to a .json file.

pywellsfm.io.saveWell(well: Well, filepath: str) None

Save a Well to a file.

Supported output formats are:

  • json file following the schema defined by jsonSchemas/WellSchema.json.

Parameters:
  • well (Well) – well object to save

  • filepath (str) – path to output well file

pywellsfm.io.validateAccumulationModelJsonFile(filepath: str) dict[str, Any]

Validate an accumulation model JSON file against schema.

pywellsfm.io.validateEnvironmentConditionModelJsonFile(filepath: str) dict[str, Any]

Validate an environment condition model JSON file against schema.

pywellsfm.io.validateEnvironmentConditionsModelJsonFile(filepath: str) dict[str, Any]

Validate an environment conditions model JSON file against schema.

pywellsfm.io.validateFaciesModelJsonFile(filepath: str) dict[str, Any]

Validate a facies model JSON file against FaciesModelSchema.json.

pywellsfm.io.validateScenarioJsonFile(filepath: str) dict[str, Any]

Validate a top-level scenario/input JSON file against schema.

pywellsfm.io.validateTabulatedFunctionJsonFile(filepath: str) dict[str, Any]

Validate a TabulatedFunction JSON file against schema.

pywellsfm.io.validate_json_file_against_schema(filepath: str, schema_filename: str) Any

Validate a JSON file against a schema in jsonSchemas/.

Returns the parsed JSON object when valid.

Internal helpers shared by I/O modules.

This module centralizes small, repetitive patterns:

  • resolving relative paths against a base directory

  • parsing schema-style {“url”: “…”} references

  • rejecting unexpected keys (additionalProperties=false)

Not part of the public API; callers should import from pywellsfm.io.*.

pywellsfm.io._common.ensure_dict(value: Any, *, ctx: str) dict[str, Any]
pywellsfm.io._common.ensure_non_empty_list(value: Any, *, ctx: str) list[Any]
pywellsfm.io._common.is_url_ref(obj: dict[str, Any]) bool

Return True if obj is a strict schema ref object: {“url”: “…”}.

pywellsfm.io._common.load_inline_or_url(raw: Any, *, base_dir: Path | None, ctx: str, load_inline: Callable[[dict[str, Any]], T], load_file: Callable[[Path], T]) T

Load either an inline JSON object or a {“url”: “…”} reference.

pywellsfm.io._common.reject_extra_keys(*, obj: dict[str, Any], allowed_keys: set[str], ctx: str) None

Raises ValueError if json obj contains unallowed keys.

Parameters:
  • obj (dict[str, Any]) – json object

  • allowed_keys (set[str]) – allowed keys in obj

  • ctx (str) – context for error messages

Raises:

ValueError – if obj contains keys not in allowed_keys or allowed_keys_json

pywellsfm.io._common.relpath_posix(target: Path, *, start: Path) str

Return a relative path with forward slashes.

pywellsfm.io._common.require_url(*, obj: dict[str, Any], ctx: str) str
pywellsfm.io._common.resolve_ref_path(*, base_dir: Path | None, raw_url: str, ctx: str) Path

Resolve an absolute or base_dir-relative path.

  • Absolute paths are accepted even when base_dir is None.

  • Relative paths require base_dir.

I/O utilities for AccumulationModel variants.

This module contains serialization/deserialization helpers for:

  • Gaussian accumulation models

  • Environment optimum accumulation models

pywellsfm.io.accumulation_model_io._loadAccumulationCurveFromCurveJsonObj(curve_obj: dict[str, Any]) AccumulationCurve

Load an AccumulationCurve from a CurveSchema-compliant JSON object.

pywellsfm.io.accumulation_model_io._loadElementAccumulationModelFromJsonObj(element_name: str, obj: dict[str, Any], base_dir: str | None = None) AccumulationModelElementBase

Parse a single element entry from AccumulationModelSchema.json.

pywellsfm.io.accumulation_model_io.accumulationModelEnvironmentOptimumToJsonObjInline(accumulationModel: AccumulationModel) dict[str, Any]

Serialize an AccumulationModel containing EnvironmentOptimum elements.

Curves are embedded inline as CurveSchema-compliant objects.

pywellsfm.io.accumulation_model_io.accumulationModelGaussianToJsonObj(accumulationModel: AccumulationModel) dict[str, Any]

Serialize an AccumulationModel containing Gaussian element models.

The output matches jsonSchemas/AccumulationModelSchema.json.

pywellsfm.io.accumulation_model_io.accumulationModelToJsonObj(model: AccumulationModel) dict[str, Any]

Serialize an AccumulationModel to JSON.

Output follows jsonSchemas/AccumulationModelSchema.json:

  • accumulationModel.elements is a mapping: elementName -> element model

  • per-element model discriminated by model.modelType

pywellsfm.io.accumulation_model_io.loadAccumulationModel(filepath: str) AccumulationModel

Load accumulation model from file.

The file can be a csv or a json file. Csv file supports only Gaussian element models. The json file conforms to the schema in jsonSchemas/AccumulationModelSchema.json.

Parameters:

filepath – Path to accumulation model file.

Returns:

An accumulation model.

pywellsfm.io.accumulation_model_io.loadAccumulationModelFromJsonObj(obj: dict[str, Any], base_dir: str | None = None) AccumulationModel

Parse an AccumulationModel JSON object into an AccumulationModel.

The JSON must match the on-disk format used by this project:

  • format: “pyWellSFM.AccumulationModelData”

  • version: “1.0”

Note

EnvironmentOptimum model curves can be embedded objects or relative paths When paths are used, they are resolved against base_dir.

Parameters:

obj (dict[str, Any]) – Parsed accumulation model JSON object.

Return AccumulationModel:

Loaded accumulation model.

pywellsfm.io.accumulation_model_io.loadAccumulationModelGaussianFromCsv(filepath: str) AccumulationModel

Load Gaussian accumulation model from csv file.

The csv file must contain the following columns:

  • name: name of the element

  • accumulationRate: mean accumulation rate (m/My)

  • stddevFactor: standard deviation factor (multiplied by mean to get stddev)

Params str filepath:

Path to accumulation model csv file.

Returns AccumulationModel:

AccumulationModel with Gaussian element models.

pywellsfm.io.accumulation_model_io.saveAccumulationModel(model: AccumulationModel, filepath: str, *, curves_mode: str = 'inline', curves_dir: str | None = None, curves_format: str = 'json') None

Save an accumulation model to .json or .csv.

  • .json: always supported (schema-compliant)

  • .csv: supported only when all elements are Gaussian

pywellsfm.io.accumulation_model_io.saveAccumulationModelEnvironmentOptimumToJson(accumulationModel: AccumulationModel, filepath: str, *, curves_mode: str = 'inline', curves_dir: str | None = None, curves_format: str = 'json') None

Save EnvironmentOptimum accumulation model to json.

Only curves_mode=’inline’ is supported with the current JSON schema.

pywellsfm.io.accumulation_model_io.saveAccumulationModelGaussianToCsv(accumulationModel: AccumulationModel, filepath: str) None

Save Gaussian accumulation model to csv file.

pywellsfm.io.accumulation_model_io.saveAccumulationModelGaussianToJson(accumulationModel: AccumulationModel, filepath: str) None

Save Gaussian accumulation model to json file.

I/O utilities for Curve and UncertaintyCurve.

pywellsfm.io.curve_io._curve_interpolation_method(curve: Curve) str | dict[str, Any]

Best-effort extraction of the interpolation method from a Curve.

pywellsfm.io.curve_io._load_single_curve(filepath: str, *, kind: str) Curve
pywellsfm.io.curve_io._updateEustaticCurveName(curve: Curve) Curve

Normalize an already-loaded Curve to an eustatic curve.

pywellsfm.io.curve_io._updateSubsidenceCurveName(curve: Curve) Curve

Normalize an already-loaded Curve to a subsidence curve.

pywellsfm.io.curve_io.curveToJsonObj(curve: Curve, *, y_axis_name: str | None = None, x_axis_name_default: str = 'Age') dict[str, Any]

Serialize a Curve to JSON matching jsonSchemas/CurveSchema.json.

pywellsfm.io.curve_io.loadCurveFromJsonObj(obj: dict[str, Any]) Curve

Parse a Curve JSON object into a Curve.

CurveSchema.json expects as an example:

{
  "format": "pyWellSFM.CurveData",
  "version": "1.0",
  "curve": {
    "xAxisName": "Depth",
    "yAxisName": "Value",
    "interpolationMethod": "linear",
    "data": [
      {"x": 0, "y": 0},
      {"x": 1, "y": 1}
    ]
  }
}
Returns Curve:

Curve object.

pywellsfm.io.curve_io.loadCurvesFromCsv(path: Path) list[Curve]

Load one or multiple Curve from a CSV file.

The csv file is expected to have a row header defining axis names and at least two columns (the first one defines the x values and the other ones the y values of the curves):

  • depth: depth value

  • Curve 1 values: the value of the first curve at the given depth.

  • Curve 2 values: the value of the second curve at the given depth.

Parameters:

path (Path) – Path to the CSV file.

Returns list[Curve]:

Loaded curves.

pywellsfm.io.curve_io.loadCurvesFromFile(path: Path) list[Curve]

Load one or multiple Curve from a .json or .csv file.

json files contain a single Curve object, csv files may contain multiple curves.

  • .json: must match the Curve JSON structure.

  • .csv: expects two numeric columns (x,y), 1 row header defining axis names.

Returns list[Curve]:

list of curve objects.

pywellsfm.io.curve_io.loadEustaticCurve(filepath: str) Curve

Load an eustatic Curve from a .json or .csv file.

pywellsfm.io.curve_io.loadEustaticCurveFromJsonObj(obj: dict[str, Any]) Curve

Load an eustatic Curve from an embedded Curve JSON object.

pywellsfm.io.curve_io.loadSubsidenceCurve(filepath: str) Curve

Load a subsidence Curve from a .json or .csv file.

pywellsfm.io.curve_io.loadSubsidenceCurveFromJsonObj(obj: dict[str, Any]) Curve

Load a subsidence Curve from an embedded Curve JSON object.

pywellsfm.io.curve_io.loadUncertaintyCurveFromCsv(path: Path, delimiter: str = ',') UncertaintyCurve

Load an UncertaintyCurve from a CSV file.

The csv file is expected to have a row header defining axis names and two to four columns:

  • depth: depth value

  • value: the value of the curve at the given depth.

  • ymin (optional): minimum value at the given depth.

  • ymax (optional): maximum value at the given depth.

Depending on csv file format, the UncertaintyCurve object is populated as follows:

  • if 1 column, set ymin=ymax=value by default

  • if 2 columns, search for min or max keywords in header to set ymin/ymax. Otherwise, compare the values to the mean, if values < mean, then set ymin=value, ymax=mean, else set ymin=mean, ymax=value

  • if 3 columns, search for min or max keywords in header to set ymin/ymax, or compare values to mean as above.

Parameters:

path (Path) – Path to the CSV file.

Returns UncertaintyCurve:

Loaded uncertainty curve.

pywellsfm.io.curve_io.loadUncertaintyCurveFromFile(path: Path) UncertaintyCurve

Load an UncertaintyCurve from a .json or .csv file.

  • .json: must match the Curve JSON structure.

  • .csv: expects two to four numeric columns (x,y, ymin, ymax), 1 row header defining axis names.

Returns Curve:

curve object.

pywellsfm.io.curve_io.loadUncertaintyCurveFromJsonObj(obj: dict[str, Any]) UncertaintyCurve

Parse an UncertaintyCurve JSON object into an UncertaintyCurve.

Schema in jsonSchemas/UncertaintyCurveSchema.json uses:

  • format: “pyWellSFM.UncertaintyCurveData”

  • version: “1.0”

  • data: {“name”: str, “curves”: [<CurveSchema objects>]}

Returns UncertaintyCurve:

uncertainty curve object.

pywellsfm.io.curve_io.saveCurve(curve: Curve, filepath: str, *, y_axis_name: str | None = None, x_axis_name_default: str = 'Age') None

Save a Curve to a .json or .csv file.

pywellsfm.io.curve_io.saveCurveToCsv(curve: Curve, filepath: str, *, y_axis_name: str | None = None, x_axis_name_default: str = 'x') None

Save a Curve to a .csv file with header (xAxisName,yAxisName).

pywellsfm.io.curve_io.saveCurveToJson(curve: Curve, filepath: str, *, y_axis_name: str | None = None, x_axis_name_default: str = 'Age', indent: int = 2) None

Save a Curve to a .json file.

I/O utilities for DepositionalEnvironmentModel variants.

This module contains serialization/deserialization helpers.

pywellsfm.io.depositional_environment_model_io._depositionalEnvironmentToJsonObj(environment: DepositionalEnvironment) dict[str, Any]

Serialize one DepositionalEnvironment to JSON object.

pywellsfm.io.depositional_environment_model_io._loadDepositionalEnvironmentFromJsonObj(obj: dict[str, Any], *, base_dir: Path | None, index: int) DepositionalEnvironment

Parse one DepositionalEnvironment JSON object.

pywellsfm.io.depositional_environment_model_io.depositionalEnvironmentModelToJsonObj(model: DepositionalEnvironmentModel) dict[str, Any]

Serialize a DepositionalEnvironmentModel to JSON object.

pywellsfm.io.depositional_environment_model_io.loadDepositionalEnvironmentModel(filepath: str) DepositionalEnvironmentModel

Load a DepositionalEnvironmentModel from a .json file.

pywellsfm.io.depositional_environment_model_io.loadDepositionalEnvironmentModelFromJsonObj(obj: dict[str, Any], base_dir: str | None = None) DepositionalEnvironmentModel

Parse a DepositionalEnvironmentModel JSON object.

The JSON must match jsonSchemas/DepositionalEnvironmentModelSchema.json.

pywellsfm.io.depositional_environment_model_io.saveDepositionalEnvironmentModel(model: DepositionalEnvironmentModel, filepath: str) None

Save a DepositionalEnvironmentModel to a .json file.

I/O utilities for DepositionalEnvironmentModel variants.

This module contains serialization/deserialization helpers.

pywellsfm.io.depositional_environment_simulation_io.depositionalEnvironmentSimulationToJsonObj(simulator: DepositionalEnvironmentSimulator) dict[str, Any]

Serialize DepositionalEnvironmentSimulator to JSON object.

pywellsfm.io.depositional_environment_simulation_io.loadDepositionalEnvironmentSimulation(filepath: str) DepositionalEnvironmentSimulator

Load DepositionalEnvironmentSimulator from a .json file.

pywellsfm.io.depositional_environment_simulation_io.loadDepositionalEnvironmentSimulationFromJsonObj(obj: dict[str, Any], *, base_dir: str | None = None) DepositionalEnvironmentSimulator

Parse a DepositionalEnvironmentSimulator JSON object.

pywellsfm.io.depositional_environment_simulation_io.loadSimulatorParametersFromJsonObj(obj: dict[str, Any]) DESimulatorParameters

Parse simulator parameters from JSON object.

pywellsfm.io.depositional_environment_simulation_io.loadSimulatorWeights(obj: dict[str, Any]) dict[str, float]

Parse simulator weights from JSON object.

pywellsfm.io.depositional_environment_simulation_io.saveDepositionalEnvironmentSimulation(simulator: DepositionalEnvironmentSimulator, filepath: str) None

Save DepositionalEnvironmentSimulator to a .json file.

pywellsfm.io.depositional_environment_simulation_io.simulatorParametersToJsonObj(params: DESimulatorParameters) dict[str, Any]

Serialize simulator parameters to JSON object.

I/O utilities for EnvironmentConditionModel* and EnvironmentConditionsModel.

JSON format is defined by jsonSchemas/EnvironmentConditionsModelSchema.json.

The top-level payload stores a mapping from condition name to a model configuration (discriminated by modelType).

Curve-based models support both inline CurveSchema objects and { “url”: … } references resolved relative to the environment-conditions JSON file.

pywellsfm.io.environment_condition_model_io._environmentConditionModelDefToJsonObj(model: EnvironmentConditionModelBase, *, curves_mode: str = 'inline') dict[str, Any]

Serialize only the model definition object ({modelType, …}).

pywellsfm.io.environment_condition_model_io._loadEnvironmentConditionModelDefFromJsonObj(model_obj: dict[str, Any], *, condition_name: str, base_dir: Path | None, ctx: str) EnvironmentConditionModelBase

Parse only the model definition object ({modelType, …}).

pywellsfm.io.environment_condition_model_io._load_single_curve_from_file(path: Path, *, ctx: str) Curve
pywellsfm.io.environment_condition_model_io.environmentConditionModelToJsonObj(model: EnvironmentConditionModelBase, *, curves_mode: str = 'inline') dict[str, Any]

Serialize an EnvironmentConditionModel* to a schema-shaped JSON object.

Note: saving curves by url is not implemented yet (inline-only), but loading supports both inline and url references.

pywellsfm.io.environment_condition_model_io.environmentConditionsModelToJsonObj(model: EnvironmentConditionsModel, *, curves_mode: str = 'inline') dict[str, Any]

Serialize an EnvironmentConditionsModel to JSON schema payload.

pywellsfm.io.environment_condition_model_io.loadEnvironmentConditionModelFromJsonObj(obj: dict[str, Any], *, condition_name: str, base_dir: Path | None, ctx: str) EnvironmentConditionModelBase

Parse a wrapped model object into an EnvironmentConditionModel*.

pywellsfm.io.environment_condition_model_io.loadEnvironmentConditionsModel(filepath: str) EnvironmentConditionsModel

Load an EnvironmentConditionsModel from a .json file.

pywellsfm.io.environment_condition_model_io.loadEnvironmentConditionsModelFromJsonObj(obj: dict[str, Any], *, base_dir: Path | None) EnvironmentConditionsModel

Load an EnvironmentConditionsModel from a JSON object.

pywellsfm.io.environment_condition_model_io.saveEnvironmentConditionsModel(model: EnvironmentConditionsModel, filepath: str, *, indent: int = 2, curves_mode: str = 'inline') None

Save an EnvironmentConditionsModel to a .json file.

I/O utilities for FaciesModel.

pywellsfm.io.facies_model_io.faciesModelToJsonObj(faciesModel: FaciesModel) dict[str, Any]

Serialize a FaciesModel to a JSON object.

The returned object conforms to the on-disk format used by this project:

  • format: “pyWellSFM.FaciesModelData”

  • version: “1.0”

Note

JSON doesn’t support +/-inf; infinite ranges are omitted.

pywellsfm.io.facies_model_io.loadFaciesModel(filepath: str) FaciesModel

Load a facies model from a JSON file.

The JSON must match the on-disk format used by this project:

  • format: “pyWellSFM.FaciesModelData”

  • version: “1.0”

Parameters:

filepath (str) – Path to the facies model JSON file.

Return FaciesModel:

Loaded facies model

pywellsfm.io.facies_model_io.loadFaciesModelFromJsonObj(obj: dict[str, Any]) FaciesModel

Parse a FaciesModel JSON object into a FaciesModel.

The JSON must match the on-disk format used by this project:

  • format: “pyWellSFM.FaciesModelData”

  • version: “1.0”

Parameters:

obj (dict[str, Any]) – Parsed facies model JSON object.

Return FaciesModel:

Loaded facies model

pywellsfm.io.facies_model_io.saveFaciesModel(faciesModel: FaciesModel, filepath: str) None

Save a facies model to a JSON file.

JSON Schema validation helpers.

This module centralizes JSON Schema loading and validation so that domain/model mapping code in I/O helpers stays focused on constructing model objects.

Schemas are expected in the repository-level jsonSchemas/ directory.

pywellsfm.io.json_schema_validation._format_jsonschema_path(path_items: Any) str
pywellsfm.io.json_schema_validation._iter_schema_errors(instance: Any, schema_filename: str) list[Any]

Return jsonschema validation errors for instance (does not raise).

pywellsfm.io.json_schema_validation._json_schema_dir() Path
pywellsfm.io.json_schema_validation._json_schema_store() dict[str, Any]

Load all schemas in jsonSchemas/ and index them by a few common keys.

This supports offline resolution for $ref values that look like remote URLs (via $id) as well as short local-like names (e.g. “TabulatedFunction.json”)

pywellsfm.io.json_schema_validation._raise_first_schema_error(*, instance_path: str, schema_filename: str, errors: list[Any]) None
pywellsfm.io.json_schema_validation.expect_format_version(data: Any, *, expected_format: str, expected_version: str, kind: str = 'JSON') None

Validate the top-level format/version metadata of a JSON-like object.

Many project file formats share the convention:

  • format: a string identifying the payload type

  • version: a string identifying the payload version

Parameters:
  • data (Any) – The JSON-like object to validate. Must be a dict with “format” and “version” keys.

  • expected_format (str) – Required value for the format field.

  • expected_version (str) – Required value for the version field.

  • kind (str) – Human-friendly label used in error messages.

Raises:

ValueError – If data is not a dict or if format/version do not match

pywellsfm.io.json_schema_validation.validateAccumulationModelJsonFile(filepath: str) dict[str, Any]

Validate an accumulation model JSON file against schema.

pywellsfm.io.json_schema_validation.validateCurveJsonFile(filepath: str) dict[str, Any]

Validate a Curve JSON file against schema.

pywellsfm.io.json_schema_validation.validateEnvironmentConditionModelJsonFile(filepath: str) dict[str, Any]

Validate an environment condition model JSON file against schema.

pywellsfm.io.json_schema_validation.validateEnvironmentConditionsModelJsonFile(filepath: str) dict[str, Any]

Validate an environment conditions model JSON file against schema.

pywellsfm.io.json_schema_validation.validateFaciesModelJsonFile(filepath: str) dict[str, Any]

Validate a facies model JSON file against FaciesModelSchema.json.

pywellsfm.io.json_schema_validation.validateScenarioJsonFile(filepath: str) dict[str, Any]

Validate a top-level scenario/input JSON file against schema.

pywellsfm.io.json_schema_validation.validateTabulatedFunctionJsonFile(filepath: str) dict[str, Any]

Validate a TabulatedFunction JSON file against schema.

pywellsfm.io.json_schema_validation.validateUncertaintyCurveJsonFile(filepath: str) dict[str, Any]

Validate an UncertaintyCurve JSON file against schema.

pywellsfm.io.json_schema_validation.validateWellJsonFile(filepath: str) dict[str, Any]

Validate a Well JSON file against schema.

pywellsfm.io.json_schema_validation.validate_json_file_against_schema(filepath: str, schema_filename: str) Any

Validate a JSON file against a schema in jsonSchemas/.

Returns the parsed JSON object when valid.

I/O utilities for Simulation data.

pywellsfm.io.fssimulation_io._loadRealizationDataFromJsonObj(obj: dict[str, Any], base_dir: Path) RealizationData

Helper to load RealizationData from json dict.

Parameters:
  • obj (dict[str, Any]) – json dict representing RealizationData

  • base_dir (Path) – base directory for resolving relative file paths

Raises:
  • ValueError – if well property is missing or not an object

  • ValueError – if subsidenceCurve property is missing or not an object

Return RealizationData:

realization data object

pywellsfm.io.fssimulation_io._loadScenarioFromJsonObj(obj: dict[str, Any], base_dir: Path) Scenario

Helper to load Scenario from json dict.

Supports inline or URL-referenced objects for:

  • faciesModel

  • accumulationModel

  • eustaticCurve

Relative URLs are resolved against base_dir.

Parameters:
  • obj (dict[str, Any]) – json dict representing Scenario

  • base_dir (Path) – base directory for resolving relative file paths

Raises:

ValueError – if required properties are missing/invalid

Return Scenario:

scenario object

pywellsfm.io.fssimulation_io.exportRealizationDataToJsonObj(realizationData: RealizationData) dict[str, Any]

Export RealizationData object to json object.

json format conforms to json/RealizationDataSchema.json.

Parameters:

realizationData (RealizationData) – RealizationData object

Raises:

ValueError – if realizationData.well is not defined

Return dict[str, Any]:

JSON-serializable dictionary representing the realization data

pywellsfm.io.fssimulation_io.exportScenarioToJsonObj(scenario: Scenario) dict[str, Any]

Export Scenario object to json object.

json format conforms to json/ScenarioSchema.json.

Parameters:

scenario (Scenario) – Scenario object

Raises:

ValueError – if Scenario.name is not a non-empty string

Return dict[str, Any]:

JSON-serializable dictionary representing the scenario

pywellsfm.io.fssimulation_io.exportSimulationDataToJsonObj(fsSimulator: FSSimulator, *, name: str) dict[str, Any]

Export FSSimulator object to json object.

json format conforms to json/FSSimulationDataSchema.json.

Parameters:
  • FSSimulationData (FSSimulationData) – FSSimulationData object

  • name (str) – name of the simulation data

Raises:
  • ValueError – if name is not a non-empty string

  • ValueError – if realizationsData is not a non-empty list

Return dict[str, Any]:

JSON-serializable dictionary representing the simulation data

pywellsfm.io.fssimulation_io.loadFSSimulation(filepath: str) FSSimulator

Load scenario from json file.

json file schema is defined by jsonSchemas/ScenarioSchema.json

Parameters:

filepath (str) – path to scenario json file

Return FSSimulatorData:

data object containing scenario and realizations data for running

pywellsfm.io.fssimulation_io.loadRealizationData(filepath: str) RealizationData

Load realization data from json file.

json file schema is defined by jsonSchemas/RealizationData.json

Parameters:

filepath (str) – path to realization data json file

Return RealizationData:

realization data object

pywellsfm.io.fssimulation_io.loadScenario(filepath: str) Scenario

Load scenario from json file.

json file schema is defined by jsonSchemas/ScenarioSchema.json

Parameters:

filepath (str) – path to scenario json file

Return Scenario:

scenario object

pywellsfm.io.fssimulation_io.saveFSSimulation(fsSimulator: FSSimulator, filepath: str, *, name: str) None

Save FSSimulator object to json file.

pywellsfm.io.fssimulation_io.saveRealizationData(realizationData: RealizationData, filepath: str) None

Save RealizationData object to json file.

json file format conforms to json/RealizationDataSchema.json.

Parameters:
  • realizationData (RealizationData) – RealizationData object

  • filepath (str) – file path to write JSON output

Raises:

ValueError – if filepath does not have .json extension

pywellsfm.io.fssimulation_io.saveScenario(scenario: Scenario, filepath: str) None

Save Scenario object to json file.

json file format conforms to json/ScenarioSchema.json.

Parameters:
  • scenario (Scenario) – Scenario object

  • filepath (str) – file path to write JSON output

Raises:

ValueError – if filepath does not have .json extension

pywellsfm.io.striplog_io._importStriplogFromCsv(path: Path, delimiter: str) Striplog

Load a stripLog from a csv file.

csv file contains a row per layer, each layer has “top”, “base”,

Parameters:

path (Path) – Path to the striplog CSV file.

Return Striplog:

Loaded striplog object.

pywellsfm.io.striplog_io.importStriplog(filepath: str, csvDelimiter: str = ',') Striplog

Load a stripLog from a file.

Supported file format are:

  • .csv : comma-separated values file

Parameters:

filepath (str) – Path to the striplog CSV file.

Return Striplog:

Loaded striplog object.

pywellsfm.io.tabulated_function_io.loadTabulatedFunctionFromFile(path: Path) tuple[str, str, ndarray, ndarray]

Load a tabulated function from a .json or .csv file.

  • .json: must match the TabulatedFunction JSON structure.

  • .csv: expects two numeric columns (x,y), no header.

Parameters:

path (Path) – Path to the input file.

Returns tuple[str, str, np.ndarray, np.ndarray]:

(abscissa_name, ordinate_name, x, y).

pywellsfm.io.tabulated_function_io.loadTabulatedFunctionFromJsonObj(obj: dict[str, Any]) tuple[str, str, ndarray, ndarray]

Parse a TabulatedFunction JSON object into arrays.

Expects the object format used throughout this project:

  • format: “pyWellSFM.TabulatedFunctionData”

  • version: “1.0”

Returns (abscissa_name, ordinate_name, x, y).

pywellsfm.io.tabulated_function_io.saveTabulatedFunctionToCsv(*, x: ndarray, y: ndarray, filepath: str) None

Save a tabulated function to a .csv file.

csv file has two columns x,y, no header.

pywellsfm.io.tabulated_function_io.saveTabulatedFunctionToJson(*, abscissa_name: str, ordinate_name: str, x: ndarray, y: ndarray, filepath: str, indent: int = 2) None

Save a tabulated function to a .json file.

pywellsfm.io.tabulated_function_io.tabulatedFunctionToJsonObj(*, abscissa_name: str, ordinate_name: str, x: ndarray, y: ndarray) dict[str, Any]

Serialize a tabulated function to a JSON object.

The returned object conforms to the on-disk format used by this project:

  • format: “pyWellSFM.TabulatedFunctionData”

  • version: “1.0”

I/O utilities for Well.

Currently supports loading a well from a JSON file that conforms to jsonSchemas/WellSchema.json.

pywellsfm.io.well_io._load_striplog_from_csv(path: Path, delimiter: str = ',') Striplog
pywellsfm.io.well_io._load_striplog_from_json_obj(obj: dict[str, Any]) tuple[str, Striplog]
pywellsfm.io.well_io._parse_stratigraphic_type(raw: Any) StratigraphicSurfaceType
pywellsfm.io.well_io.loadWell(filepath: str) Well

Load a Well from a file.

Supported file formats are:

  • json file matching jsonSchemas/WellSchema.json.

  • las file matching LAS 2.0 format.

Note

  • well.location defines the well head (x,y,z).

  • continuousLogs items use the Curve schema and are stored under the log name derived from curve.yAxisName.

  • striplogs items are stored under the striplog name.

Parameters:

filepath (str) – path to the well file

pywellsfm.io.well_io.loadWellFromJsonObj(obj: dict[str, Any], base_dir: Path | None = None) Well

Load a Well from a JSON file matching jsonSchemas/WellSchema.json.

Note

  • well.location defines the well head (x,y,z).

  • continuousLogs items use the Curve schema and are stored under the log name derived from curve.yAxisName.

  • striplogs items are stored under the striplog name.

pywellsfm.io.well_io.loadWellFromLasFile(filepath: str) Well

Load a Well from a LAS file.

Uses lasio to parse well header and curves.

Populates:

  • Well.name

  • Well.wellHeadCoords (defaults to [0,0,0] if not found)

  • Well.depth (prefers STOP if present, else max depth index)

  • Well._wellPath (vertical path with 2 points)

  • Well._logs (continuous logs as Curve, keyed by LAS mnemonic)

Parameters:

filepath (str) – path to the LAS file

Raises:
  • FileNotFoundError – if file does not exist

  • ImportError – if lasio is not installed

pywellsfm.io.well_io.saveWell(well: Well, filepath: str) None

Save a Well to a file.

Supported output formats are:

  • json file following the schema defined by jsonSchemas/WellSchema.json.

Parameters:
  • well (Well) – well object to save

  • filepath (str) – path to output well file

pywellsfm.io.well_io.saveWellToJson(well: Well, filepath: str) None

Save a Well to a JSON file.

Output json file follows the schema defined by jsonSchemas/WellSchema.json.

Parameters:
  • well (Well) – well object to save

  • filepath (str) – path to output well file

pywellsfm.io.well_io.wellToJsonObj(well: Well) dict[str, Any]

Serialize a Well to JSON matching jsonSchemas/WellSchema.json.