Skip to content

Commit 35c4832

Browse files
authored
Merge pull request #4497 from lisajulia/python-documentation
More Python documentation
2 parents 287509a + b8a6bc6 commit 35c4832

File tree

2 files changed

+150
-40
lines changed

2 files changed

+150
-40
lines changed

python/cxx/eclipse_io.cpp

+29-29
Original file line numberDiff line numberDiff line change
@@ -477,37 +477,37 @@ void python::common::export_IO(py::module& m) {
477477
.def("__get_data", &get_erst_vector, py::arg("name"), py::arg("report_step"), py::arg("occurrence"), ERst_get_data_vector_docstring);
478478

479479

480-
py::class_<ESmryBind>(m, "ESmry")
481-
.def(py::init<const std::string &, const bool>(), py::arg("filename"), py::arg("load_base_run") = false)
482-
.def("__contains__", &ESmryBind::hasKey, py::arg("key"))
483-
.def("make_esmry_file", &ESmryBind::make_esmry_file)
484-
.def("__len__", &ESmryBind::numberOfTimeSteps)
485-
.def("__get_all", &ESmryBind::get_smry_vector, py::arg("key"))
486-
.def("__get_at_rstep", &ESmryBind::get_smry_vector_at_rsteps, py::arg("key"))
487-
.def_property_readonly("start_date", &ESmryBind::smry_start_date)
480+
py::class_<ESmryBind>(m, "ESmry", ESmry_docstring)
481+
.def(py::init<const std::string &, const bool>(), py::arg("filename"), py::arg("load_base_run") = false, ESmry_init_docstring)
482+
.def("__contains__", &ESmryBind::hasKey, py::arg("key"), ESmry_contains_docstring)
483+
.def("make_esmry_file", &ESmryBind::make_esmry_file, ESmry_make_esmry_file_docstring)
484+
.def("__len__", &ESmryBind::numberOfTimeSteps, ESmry_len_docstring)
485+
.def("__get_all", &ESmryBind::get_smry_vector, py::arg("key"), ESmry_get_all_docstring)
486+
.def("__get_at_rstep", &ESmryBind::get_smry_vector_at_rsteps, py::arg("key"), ESmry_get_at_rstep_docstring)
487+
.def_property_readonly("start_date", &ESmryBind::smry_start_date, ESmry_start_date_docstring)
488488
.def("keys", (const std::vector<std::string>& (ESmryBind::*) (void) const)
489-
&ESmryBind::keywordList)
489+
&ESmryBind::keywordList, ESmry_keys1_docstring)
490490
.def("keys", (std::vector<std::string> (ESmryBind::*) (const std::string&) const)
491-
&ESmryBind::keywordList)
492-
.def("dates", &ESmryBind::dates)
493-
.def("units", &ESmryBind::units, py::arg("field"));
494-
495-
py::class_<Opm::EclIO::EGrid>(m, "EGrid")
496-
.def(py::init<const std::string &, const std::string &>(), py::arg("filename"),
497-
py::arg("grid_name") = "global")
498-
.def_property_readonly("active_cells", &Opm::EclIO::EGrid::activeCells)
499-
.def_property_readonly("dimension", &Opm::EclIO::EGrid::dimension)
500-
.def("ijk_from_global_index", &Opm::EclIO::EGrid::ijk_from_global_index)
501-
.def("ijk_from_active_index", &Opm::EclIO::EGrid::ijk_from_active_index)
502-
.def("active_index", &Opm::EclIO::EGrid::active_index)
503-
.def("global_index", &Opm::EclIO::EGrid::global_index)
504-
.def("export_mapaxes", &Opm::EclIO::EGrid::get_mapaxes)
505-
.def("xyz_from_ijk", &get_xyz_from_ijk)
506-
.def("xyz_from_ijk", &get_xyz_from_ijk_mapaxes)
507-
.def("xyz_from_active_index", &get_xyz_from_active_index)
508-
.def("xyz_from_active_index", &get_xyz_from_active_index_mapaxes)
509-
.def("cellvolumes", &get_cellvolumes)
510-
.def("cellvolumes", &get_cellvolumes_mask);
491+
&ESmryBind::keywordList, py::arg("pattern"), ESmry_keys2_docstring)
492+
.def("dates", &ESmryBind::dates, ESmry_dates_docstring)
493+
.def("units", &ESmryBind::units, py::arg("field"), ESmry_units_docstring);
494+
495+
py::class_<Opm::EclIO::EGrid>(m, "EGrid", EGrid_docstring)
496+
.def(py::init<const std::string &, const std::string &>(), py::arg("filename"), py::arg("grid_name") = "global", EGrid_init_docstring)
497+
.def_property_readonly("active_cells", &Opm::EclIO::EGrid::activeCells, EGrid_active_cells_docstring)
498+
.def_property_readonly("dimension", &Opm::EclIO::EGrid::dimension, EGrid_dimension_docstring)
499+
.def("ijk_from_global_index", &Opm::EclIO::EGrid::ijk_from_global_index, py::arg("global_index"), EGrid_ijk_from_global_index_docstring)
500+
.def("ijk_from_active_index", &Opm::EclIO::EGrid::ijk_from_active_index, py::arg("active_index"), EGrid_ijk_from_active_index_docstring)
501+
.def("active_index", &Opm::EclIO::EGrid::active_index, py::arg("i"), py::arg("j"), py::arg("k"), EGrid_active_index_docstring)
502+
.def("global_index", &Opm::EclIO::EGrid::global_index, py::arg("i"), py::arg("j"), py::arg("k"), EGrid_global_index_docstring)
503+
.def("export_mapaxes", &Opm::EclIO::EGrid::get_mapaxes, EGrid_export_mapaxes_docstring)
504+
.def("xyz_from_ijk", &get_xyz_from_ijk, py::arg("i"), py::arg("j"), py::arg("k"), EGrid_xyz_from_ijk_docstring)
505+
.def("xyz_from_ijk", &get_xyz_from_ijk_mapaxes, py::arg("i"), py::arg("j"), py::arg("k"), py::arg("apply_mapaxes"), EGrid_xyz_from_ijk_mapaxes_docstring)
506+
.def("xyz_from_active_index", &get_xyz_from_active_index, py::arg("active_index"), EGrid_xyz_from_active_index_docstring)
507+
.def("xyz_from_active_index", &get_xyz_from_active_index_mapaxes, py::arg("active_index"), py::arg("apply_mapaxes"), EGrid_xyz_from_active_index_mapaxes_docstring)
508+
.def("cellvolumes", &get_cellvolumes, EGrid_cellvolumes_docstring)
509+
.def("cellvolumes", &get_cellvolumes_mask, py::arg("mask"), EGrid_cellvolumes_mask_docstring);
510+
511511

512512
py::class_<Opm::EclIO::ERft>(m, "ERft")
513513
.def(py::init<const std::string &>())

python/docstrings_common.json

+121-11
Original file line numberDiff line numberDiff line change
@@ -645,36 +645,36 @@
645645
"doc": "Returns a tuple containing the IJK indices of the grid cell with global index g.\n\n:return: A a tuple containing the IJK indices of the grid cell with global index g.\n:type: tuple(int,int,int)"
646646
},
647647
"EclipseGrid_getCellVolume1G": {
648-
"signature": "EclipseGrid.getCellVolume1G(g: int) -> double",
648+
"signature": "EclipseGrid.getCellVolume(g: int) -> double",
649649
"doc": "Returns the cell volume for the grid cell at the global index g.\n\n:param g: The global index of the grid cell.\n:type g: int\n:return: The volume of the grid cell.\n:type: double"
650650
},
651651
"EclipseGrid_getCellVolume3": {
652-
"signature": "EclipseGrid.getCellVolume3(i: int, j: int, k: int) -> double",
652+
"signature": "EclipseGrid.getCellVolume(i: int, j: int, k: int) -> double",
653653
"doc": "Returns the cell volume for a grid cell identified by its (i, j, k) indices.\n\n:param i: The I index of the grid cell.\n:type i: int\n:param j: The J index of the grid cell.\n:type j: int\n:param k: The K index of the grid cell.\n:type k: int\n:return: The volume of the grid cell identified by the (i, j, k) indices.\n:type: double"
654654
},
655655
"EclipseGrid_getCellVolumeAll": {
656-
"signature": "EclipseGrid.getCellVolumeAll() -> numpy.ndarray[double]",
656+
"signature": "EclipseGrid.getCellVolume() -> numpy.ndarray[double]",
657657
"doc": "Returns a `numpy.ndarray <https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html>`_ containing the volumes of all grid cells. Each entry in the array corresponds to the volume of a grid cell, with the array index matching the global index of that cell.\n\n:return: A numpy.ndarray each entry represents the volume of a grid cell, the index being to the global index.\n:type: numpy.ndarray[double]"
658658
},
659659
"EclipseGrid_getCellVolumeMask": {
660-
"signature": "EclipseGrid.getCellVolumeMask(mask: list[int]) -> numpy.ndarray[double]",
661-
"doc": "Returns the cell volumes for the cells with the global ids given in the input list.\n\n:return: The cell volumes for the given cells.\n:type: numpy.ndarray[double]"
660+
"signature": "EclipseGrid.getCellVolume(mask: list[int]) -> numpy.ndarray[double]",
661+
"doc": "Returns the cell volumes for the selected cells.\n\n:param mask: List containing one entry per grid cell, if the entry in the list is '1', this cell is selected by the mask.\n:type mask: list[int]\n:return: The cell volumes for the given cells.\n:type: numpy.ndarray[double]"
662662
},
663663
"EclipseGrid_getCellDepth1G": {
664-
"signature": "EclipseGrid.getCellDepth1G(g: int) -> double",
664+
"signature": "EclipseGrid.getCellDepth(g: int) -> double",
665665
"doc": "Returns the depth of the grid cell corresponding to the given global index.\n\n:param g: The global index of the grid cell.\n:type g: int\n:return: The depth of the grid cell with the specified global index.\n:type: double"
666666
},
667667
"EclipseGrid_getCellDepth3": {
668-
"signature": "EclipseGrid.getCellDepth3(i: int, j: int, k: int) -> double",
668+
"signature": "EclipseGrid.getCellDepth(i: int, j: int, k: int) -> double",
669669
"doc": "Returns the depth of the grid cell specified by the given IJK indices.\n\n:param i: The I index of the grid cell.\n:type i: int\n:param j: The J index of the grid cell.\n:type j: int\n:param k: The K index of the grid cell.\n:type k: int\n:return: The depth of the grid cell with the specified IJK indices.\n:type: double"
670670
},
671671
"EclipseGrid_getCellDepthAll": {
672-
"signature": "EclipseGrid.getCellDepthAll() -> numpy.ndarray[double]",
672+
"signature": "EclipseGrid.getCellDepth() -> numpy.ndarray[double]",
673673
"doc": "Returns a `numpy.ndarray <https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html>`_ containing the depths of all grid cells. Each entry in the array corresponds to the depth of a grid cell, with the array index matching the global index of that cell.\n\n:return: A numpy.ndarray each entry represents the depth of a grid cell, and the index being the global index.\n:type: numpy.ndarray[double]"
674674
},
675675
"EclipseGrid_getCellDepthMask": {
676676
"signature": "EclipseGrid.getCellDepthMask(mask: list[int]) -> numpy.ndarray[double]",
677-
"doc": "Returns the depths for the cell with the global ids given in the input list.\n\n:return: The depths for the given cells.\n:type: numpy.ndarray[double]"
677+
"doc": "Returns the depths for the selected cells.\n\n:param mask: List containing one entry per grid cell, if the entry in the list is '1', this cell is selected by the mask.\n:type mask: list[int]\n:return: The depths for the given cells.\n:type: numpy.ndarray[double]"
678678
},
679679
"eclArrType": {
680680
"type": "class",
@@ -752,8 +752,8 @@
752752
"doc": "Represents an Eclipse Restart file. This class inherits from the class EclFile."
753753
},
754754
"ERst_init": {
755-
"signature": "opm.io.ecl.ERst.__init__(filename: str)",
756-
"doc": "Initializes the ERst object by loading the Restart file (and the underlying EclFile) from the specified path.\n\n:param filename: The path to the Restart file.\n:type filename: str"
755+
"signature": "opm.io.ecl.ERst.__init__(filename: str) -> ERst",
756+
"doc": "Initializes the ERst object by loading the Restart file (and the underlying EclFile) from the specified path.\n\n:param filename: The path to the Restart file.\n:type filename: str\n:return: The ERst object.\n:type: ERst"
757757
},
758758
"ERst_has_report_step": {
759759
"signature": "opm.io.ecl.ERst.__has_report_step(report_step: int) -> bool",
@@ -794,6 +794,116 @@
794794
"ERst_get_data_vector": {
795795
"signature": "opm.io.ecl.ERst.get_erst_vector(name: str, report_step: int, occurrence: int) -> tuple[numpy.ndarray, eclArrType]",
796796
"doc": "Retrieves the data array of the given name a the given occurrence at the given report step.\n\n:param name: The name of the arrays.\n:type name: str\n:param report_step: The report step.\n:type report_step: int\n:param occurrence: The occurrence to retrieve.\n:type occurrence: int\n:return: A tuple containing the data array and its associated type.\n:rtype: tuple[numpy.ndarray, eclArrType]"
797+
},
798+
"ESmry": {
799+
"type": "class",
800+
"signature": "opm.io.ecl.ESmry",
801+
"doc": "Handles summary data from Eclipse simulations."
802+
},
803+
"ESmry_init": {
804+
"signature": "opm.io.ecl.ESmry.__init__(filename: str, load_base_run: bool = False) -> ESmry",
805+
"doc": "Initializes the ESmry object by loading the summary file.\n\n:param filename: Path to the .SMSPEC or .ESMRY file.\n:type filename: str\n:param load_base_run: Whether to load base run data. Default is False.\n:type load_base_run: bool\n:return: The ESmry object.\n:rtype: ESmry"
806+
},
807+
"ESmry_contains": {
808+
"signature": "opm.io.ecl.ESmry.__contains__(key: str) -> bool",
809+
"doc": "Checks if the specified key exists in the summary data.\n\n:param key: The key to check.\n:type key: str\n:return: True if the key exists, otherwise False.\n:rtype: bool"
810+
},
811+
"ESmry_make_esmry_file": {
812+
"signature": "opm.io.ecl.ESmry.make_esmry_file() -> None",
813+
"doc": "Generates an ESMRY file from an SMSPEC input file."
814+
},
815+
"ESmry_len": {
816+
"signature": "opm.io.ecl.ESmry.__len__() -> int",
817+
"doc": "Returns the number of time steps in the summary data.\n\n:return: The number of available time steps.\n:rtype: int"
818+
},
819+
"ESmry_get_all": {
820+
"signature": "opm.io.ecl.ESmry.__get_all(key: str) -> numpy.ndarray",
821+
"doc": "Retrieves the summary vector for the given key.\n\n:param key: The key.\n:type key: str\n:return: The summary for the specified key.\n:rtype: numpy.ndarray"
822+
},
823+
"ESmry_get_at_rstep": {
824+
"signature": "opm.io.ecl.ESmry.__get_at_rstep(key: str) -> numpy.ndarray",
825+
"doc": "Retrieves the report step summary vector for the given key.\n\n:param key: The key.\n:type key: str\n:return: The report step summary for the specified key.\n:rtype: numpy.ndarray"
826+
},
827+
"ESmry_start_date": {
828+
"signature": "opm.io.ecl.ESmry.start_date -> datetime.datetime",
829+
"doc": "The start date of the summary data as a `datetime.datetime <https://docs.python.org/3/library/datetime.html#datetime.datetime>`_.\n\n:return: The start date.\n:rtype: datetime.datetime"
830+
},
831+
"ESmry_keys1": {
832+
"signature": "opm.io.ecl.ESmry.keys() -> list[str]",
833+
"doc": "Retrieves a list of summary keys.\n\n:return: A list of available summary keys.\n:rtype: list[str]"
834+
},
835+
"ESmry_keys2": {
836+
"signature": "opm.io.ecl.ESmry.keys(pattern: str) -> list[str]",
837+
"doc": "Retrieves a list of summary keys matching the given pattern.\n\n:param pattern: A pattern to filter the keys.\n:type pattern: str\n:return: A list of available summary keys.\n:rtype: list[str]"
838+
},
839+
"ESmry_dates": {
840+
"signature": "opm.io.ecl.ESmry.dates() -> list[datetime.datetime]",
841+
"doc": "Retrieves a list of dates corresponding to the time steps in the summary data.\n\n:return: A list of dates.\n:rtype: list[datetime.datetime]"
842+
},
843+
"ESmry_units": {
844+
"signature": "opm.io.ecl.ESmry.units(field: str) -> str",
845+
"doc": "Retrieves the unit for a given field.\n\n:param field: The field name.\n:type field: str\n:return: The unit corresponding to the specified field.\n:rtype: str"
846+
},
847+
"EGrid": {
848+
"type": "class",
849+
"signature": "opm.io.ecl.EGrid",
850+
"doc": "Represents an Eclipse Grid file."
851+
},
852+
"EGrid_init": {
853+
"signature": "opm.io.ecl.EGrid.__init__(filename: str, grid_name: str = 'global') -> EGrid",
854+
"doc": "Initializes an EGrid object by loading the grid file.\n\n:param filename: Path to the grid file.\n:type filename: str\n:param grid_name: The name of the grid (default is 'global').\n:type grid_name: str\n:return: The EGrid object.\n:rtype: EGrid"
855+
},
856+
"EGrid_active_cells": {
857+
"signature": "opm.io.ecl.EGrid.active_cells -> int",
858+
"doc": "Returns the number of active cells in the grid.\n\n:return: Number of active cells.\n:type: int"
859+
},
860+
"EGrid_dimension": {
861+
"signature": "opm.io.ecl.EGrid.dimension -> tuple[int, int, int]",
862+
"doc": "Returns the dimensions of the grid.\n\n:return: The (x,y,z) dimensions.\n:type: tuple[int, int, int]"
863+
},
864+
"EGrid_ijk_from_global_index": {
865+
"signature": "opm.io.ecl.EGrid.ijk_from_global_index(global_index: int) -> tuple[int, int, int]",
866+
"doc": "Converts a global index to IJK indices.\n\n:param global_index: The global index of the cell.\n:type global_index: int\n:return: The (I, J, K) indices.\n:type: tuple[int, int, int]"
867+
},
868+
"EGrid_ijk_from_active_index": {
869+
"signature": "opm.io.ecl.EGrid.ijk_from_active_index(active_index: int) -> tuple[int, int, int]",
870+
"doc": "Converts an active cell index to IJK indices.\n\n:param active_index: The active cell index.\n:type active_index: int\n:return: The (I, J, K) indices.\n:type: tuple[int, int, int]"
871+
},
872+
"EGrid_active_index": {
873+
"signature": "opm.io.ecl.EGrid.active_index(i: int, j: int, k: int) -> int",
874+
"doc": "Returns the active index corresponding to the given IJK index.\n\n:param i: The i index.\n:type i: int\n:param j: The j index.\n:type j: int\n:param k: The k index.\n:type k: int\n:return: The active cell index.\n:type: int"
875+
},
876+
"EGrid_global_index": {
877+
"signature": "opm.io.ecl.EGrid.global_index(i: int, j: int, k: int) -> int",
878+
"doc": "Returns the global index corresponding to the given IJK index.\n\n:param i: The i index.\n:type i: int\n:param j: The j index.\n:type j: int\n:param k: The k index.\n:type k: int\n:return: The global index.\n:type: int"
879+
},
880+
"EGrid_export_mapaxes": {
881+
"signature": "opm.io.ecl.EGrid.export_mapaxes() -> tuple[double, 8]",
882+
"doc": "Exports the map axes transformation for visualization.\n\n:return: tuple[double, 8]"
883+
},
884+
"EGrid_xyz_from_ijk": {
885+
"signature": "opm.io.ecl.EGrid.xyz_from_ijk(i: int, j: int, k: int) -> tuple[tuple[double, 8], tuple[double, 8], tuple[double, 8]]",
886+
"doc": "Computes the XYZ coordinates of the 8 cell corners given its ijk indices.\n\n:param i: The i index of the cell.\n:type i: int\n:param j: The j index of the cell.\n:type j: int\n:param k: The k index of the cell.\n:type k: int\n:return: The XYZ coordinates, as three tuples.\n:type: tuple[tuple[double, 8], tuple[double, 8], tuple[double, 8]]"
887+
},
888+
"EGrid_xyz_from_ijk_mapaxes": {
889+
"signature": "opm.io.ecl.EGrid.xyz_from_ijk(i: int, j: int, k: int, apply_mapaxes: bool) -> tuple[tuple[double, 8], tuple[double, 8], tuple[double, 8]]",
890+
"doc": "Computes the XYZ coordinates of the 8 cell corners given its ijk indices.\n\n:param i: The i index of the cell.\n:type i: int\n:param j: The j index of the cell.\n:type j: int\n:param k: The k index of the cell.\n:type k: int\n:param apply_mapaxes: Boolean to indicate if a mapaxes tranformation (if available) should be carried out before.\n:type apply_mapaxes: bool\n:return: The XYZ coordinates, as three tuples.\n:type: tuple[tuple[double, 8], tuple[double, 8], tuple[double, 8]]"
891+
},
892+
"EGrid_xyz_from_active_index": {
893+
"signature": "opm.io.ecl.EGrid.xyz_from_active_index(active_index: int) -> tuple[tuple[double, 8], tuple[double, 8], tuple[double, 8]]",
894+
"doc": "Computes the XYZ coordinates of a cell given its active index.\n\n:param active_index: The active cell index.\n:type active_index: int\n:return: XYZ coordinates.\n:type: tuple[float, float, float]"
895+
},
896+
"EGrid_xyz_from_active_index_mapaxes": {
897+
"signature": "opm.io.ecl.EGrid.xyz_from_active_index(active_index: int, apply_mapaxes: bool) -> tuple[tuple[double, 8], tuple[double, 8], tuple[double, 8]]",
898+
"doc": "Computes the XYZ coordinates of a cell given its active index.\n\n:param active_index: The active cell index.\n:type active_index: int\n:param apply_mapaxes: Boolean to indicate if a mapaxes tranformation (if available) should be carried out before.\n:type apply_mapaxes: bool\n:return: XYZ coordinates.\n:type: tuple[float, float, float]"
899+
},
900+
"EGrid_cellvolumes": {
901+
"signature": "opm.io.ecl.EGrid.cellvolumes() -> numpy.ndarray",
902+
"doc": "Returns an array containing the volume of each cell in the grid.\n\n:return: A NumPy array containing cell volumes.\n:type: numpy.ndarray"
903+
},
904+
"EGrid_cellvolumes_mask": {
905+
"signature": "opm.io.ecl.EGrid.cellvolumes(mask: list[int]) -> numpy.ndarray",
906+
"doc": "Returns an array containing the volume of the selected cells.\n\n:param mask: List containing one entry per grid cell, if the entry in the list is '1', this cell is selected by the mask.\n:type mask: list[int]\n:return: A NumPy array containing cell volumes.\n:type: numpy.ndarray"
797907
}
798908

799909
}

0 commit comments

Comments
 (0)