
.. DO NOT EDIT.
.. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY.
.. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE:
.. "auto_examples/03_visualise_blockmodel.py"
.. LINE NUMBERS ARE GIVEN BELOW.

.. only:: html

    .. note::
        :class: sphx-glr-download-link-note

        :ref:`Go to the end <sphx_glr_download_auto_examples_03_visualise_blockmodel.py>`
        to download the full example code.

.. rst-class:: sphx-glr-example-title

.. _sphx_glr_auto_examples_03_visualise_blockmodel.py:


Block Models
============

Block models represent 3D data, typically via a 3D array.  3D arrays can be flattened into a 2D tabular
representation that can be stored in a parquet file.

.. GENERATED FROM PYTHON SOURCE LINES 9-16

.. code-block:: Python

    import tempfile

    import pandas as pd
    from pathlib import Path

    from parq_blockmodel import ParquetBlockModel








.. GENERATED FROM PYTHON SOURCE LINES 17-20

Create a Parquet Block Model
----------------------------
We leverage the create_demo_block_model class method to create a Parquet Block Model.

.. GENERATED FROM PYTHON SOURCE LINES 20-28

.. code-block:: Python


    temp_dir = Path(tempfile.gettempdir()) / "block_model_example"
    temp_dir.mkdir(parents=True, exist_ok=True)

    pbm: ParquetBlockModel = ParquetBlockModel.create_demo_block_model(
        filename=temp_dir / "demo_block_model.parquet")
    pbm





.. rst-class:: sphx-glr-script-out

 .. code-block:: none


    ParquetBlockModel(name=demo_block_model, path=/tmp/block_model_example/demo_block_model.pbm)



.. GENERATED FROM PYTHON SOURCE LINES 29-32

Create Report
-------------
We'll create a report for the Parquet Block Model.

.. GENERATED FROM PYTHON SOURCE LINES 32-35

.. code-block:: Python


    pbm.create_report(open_in_browser=True, show_progress=True)





.. rst-class:: sphx-glr-script-out

 .. code-block:: none

    Profiling columns:   0%|          | 0/11 [00:00<?, ?it/s]    Profiling columns:  91%|█████████ | 10/11 [00:00<00:00, 22.73it/s]    Profiling columns: 100%|██████████| 11/11 [00:00<00:00, 15.59it/s]
      0%|          | 0/10 [00:00<?, ?it/s]    100%|██████████| 10/10 [00:00<00:00, 689.54it/s]

    PosixPath('/tmp/block_model_example/demo_block_model.html')



.. GENERATED FROM PYTHON SOURCE LINES 36-38

Visualise the Model
-------------------

.. GENERATED FROM PYTHON SOURCE LINES 38-41

.. code-block:: Python


    p = pbm.plot(scalar='depth', threshold=False, enable_picking=True)
    p.show()



.. image-sg:: /auto_examples/images/sphx_glr_03_visualise_blockmodel_001.png
   :alt: 03 visualise blockmodel
   :srcset: /auto_examples/images/sphx_glr_03_visualise_blockmodel_001.png
   :class: sphx-glr-single-img






.. rst-class:: sphx-glr-timing

   **Total running time of the script:** (0 minutes 5.133 seconds)


.. _sphx_glr_download_auto_examples_03_visualise_blockmodel.py:

.. only:: html

  .. container:: sphx-glr-footer sphx-glr-footer-example

    .. container:: sphx-glr-download sphx-glr-download-jupyter

      :download:`Download Jupyter notebook: 03_visualise_blockmodel.ipynb <03_visualise_blockmodel.ipynb>`

    .. container:: sphx-glr-download sphx-glr-download-python

      :download:`Download Python source code: 03_visualise_blockmodel.py <03_visualise_blockmodel.py>`

    .. container:: sphx-glr-download sphx-glr-download-zip

      :download:`Download zipped: 03_visualise_blockmodel.zip <03_visualise_blockmodel.zip>`


.. only:: html

 .. rst-class:: sphx-glr-signature

    `Gallery generated by Sphinx-Gallery <https://sphinx-gallery.github.io>`_
