2.23.7.9. pycsamt.format.borehole.pcsf#

PCBH association and coordinate alignment for PCSF models.

Module Attributes

PCBH_FORMAT

PCBH as a pcsf companion format.

Functions

align_pcbh_to_pcsf(document, model, *[, ...])

Transform PCBH paths into PCSF x/y/depth coordinates.

association_from_dict(payload)

Deserialize an association from the PCSF HDF5 adapter.

association_to_dict(association)

Serialize an association for the PCSF HDF5 adapter.

embed_pcbh(model, document, *[, uri])

Return a model copy with a validated portable PCBH attachment.

extract_pcbh(model)

Return embedded PCBH data without resolving external resources.

model_association(model)

Borehole association of a model, decoded when needed.

pcbh_document_checksum(document)

Return SHA-256 of canonical compact PCBH JSON.

reference_pcbh(model, uri, sha256)

Return a model copy with an external PCBH reference.

Classes

AlignedTrajectoryPoint(md, x, y, z)

A trajectory point expressed in PCSF model coordinates.

BoreholeBoundsResult(borehole_id, relation, ...)

Per-hole relationship with the model bounding box.

PCBHAlignmentReport(source_crs, target_crs, ...)

Aligned paths plus compatibility and bounds diagnostics.

PCBHAssociation([embedded, reference])

Embedded and/or externally referenced PCBH attachment.

PCBHReference(uri, sha256)

External PCBH URI and integrity checksum.

class pycsamt.format.borehole.pcsf.PCBHReference(uri, sha256)[source]

Bases: PyCSAMTObject

External PCBH URI and integrity checksum.

Parameters:
uri: str
sha256: str
validate()[source]

Validate object state.

Subclasses can override this hook. The base implementation intentionally accepts all states.

Return type:

None

class pycsamt.format.borehole.pcsf.PCBHAssociation(embedded=None, reference=None)[source]

Bases: PyCSAMTObject

Embedded and/or externally referenced PCBH attachment.

Parameters:
  • embedded (PCBHDocument | None)

  • reference (PCBHReference | None)

embedded: PCBHDocument | None = None
reference: PCBHReference | None = None
validate()[source]

Validate object state.

Subclasses can override this hook. The base implementation intentionally accepts all states.

Return type:

None

to_dict()[source]

JSON payload stored in the boreholes group of a file.

pcsf writes the borehole association through this method and reads it back as a plain dictionary, which association_from_dict() turns into an association again.

Returns:

{"embedded": dict or None, "reference": dict or None}, as produced by association_to_dict().

Return type:

dict

class pycsamt.format.borehole.pcsf.AlignedTrajectoryPoint(md, x, y, z)[source]

Bases: PyCSAMTObject

A trajectory point expressed in PCSF model coordinates.

Parameters:
md: float
x: float
y: float
z: float
class pycsamt.format.borehole.pcsf.BoreholeBoundsResult(borehole_id, relation, points_inside, points_total)[source]

Bases: PyCSAMTObject

Per-hole relationship with the model bounding box.

Parameters:
  • borehole_id (str)

  • relation (str)

  • points_inside (int)

  • points_total (int)

borehole_id: str
relation: str
points_inside: int
points_total: int
class pycsamt.format.borehole.pcsf.PCBHAlignmentReport(source_crs, target_crs, vertical_compatible, warnings, model_bounds, trajectories, bounds_results)[source]

Bases: PyCSAMTObject

Aligned paths plus compatibility and bounds diagnostics.

Parameters:
source_crs: str
target_crs: str
vertical_compatible: bool
warnings: tuple[str, ...]
model_bounds: tuple[float, float, float, float, float, float]
trajectories: dict[str, tuple[AlignedTrajectoryPoint, ...]]
bounds_results: tuple[BoreholeBoundsResult, ...]
pycsamt.format.borehole.pcsf.pcbh_document_checksum(document)[source]

Return SHA-256 of canonical compact PCBH JSON.

Parameters:

document (PCBHDocument)

Return type:

str

pycsamt.format.borehole.pcsf.embed_pcbh(model, document, *, uri=None)[source]

Return a model copy with a validated portable PCBH attachment.

Parameters:
  • model (PCSFModel)

  • document (PCBHDocument)

  • uri (str | None)

Return type:

PCSFModel

pycsamt.format.borehole.pcsf.reference_pcbh(model, uri, sha256)[source]

Return a model copy with an external PCBH reference.

Parameters:
Return type:

PCSFModel

pycsamt.format.borehole.pcsf.extract_pcbh(model)[source]

Return embedded PCBH data without resolving external resources.

Parameters:

model (PCSFModel)

Return type:

PCBHDocument | None

pycsamt.format.borehole.pcsf.model_association(model)[source]

Borehole association of a model, decoded when needed.

pcsf stores the boreholes group without interpreting it, so a model read from a file carries the association as the dictionary written by PCBHAssociation.to_dict(). This function returns a validated PCBHAssociation in both cases.

Parameters:

model (PCSFModel) – Model whose boreholes attribute is None, a PCBHAssociation or its dictionary payload.

Returns:

None when the model has no borehole association.

Return type:

PCBHAssociation or None

Raises:
  • TypeError – If model.boreholes is neither of the accepted types.

  • ValueError – If the decoded association fails validation.

pycsamt.format.borehole.pcsf.align_pcbh_to_pcsf(document, model, *, vertical_offset=None, sampling_step_md=10.0)[source]

Transform PCBH paths into PCSF x/y/depth coordinates.

vertical_offset is required when PCBH and PCSF vertical references cannot be established as identical. It is added to PCBH elevations before conversion to PCSF depth-positive-down coordinates.

Parameters:
  • document (PCBHDocument)

  • model (PCSFModel)

  • vertical_offset (float | None)

  • sampling_step_md (float)

Return type:

PCBHAlignmentReport