Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
_fread_alloc = EclPrototype("void* ecl_sum_fread_alloc_case__( char* , char* , bool)" , bind = False )
_create_writer = EclPrototype("ecl_sum_obj ecl_sum_alloc_writer( char* , bool , bool , char* , time_t , bool , int , int , int)" , bind = False)
_iiget = EclPrototype("double ecl_sum_iget( ecl_sum , int , int)")
_free = EclPrototype("void ecl_sum_free( ecl_sum )")
_data_length = EclPrototype("int ecl_sum_get_data_length( ecl_sum )")
_iget_sim_days = EclPrototype("double ecl_sum_iget_sim_days( ecl_sum , int) ")
_iget_report_step = EclPrototype("int ecl_sum_iget_report_step( ecl_sum , int) ")
_iget_mini_step = EclPrototype("int ecl_sum_iget_mini_step( ecl_sum , int) ")
_iget_sim_time = EclPrototype("time_t ecl_sum_iget_sim_time( ecl_sum , int) ")
_get_report_end = EclPrototype("int ecl_sum_iget_report_end( ecl_sum , int)")
_get_general_var = EclPrototype("double ecl_sum_get_general_var( ecl_sum , int , char*)")
_get_general_var_index = EclPrototype("int ecl_sum_get_general_var_params_index( ecl_sum , char*)")
_get_general_var_from_sim_days = EclPrototype("double ecl_sum_get_general_var_from_sim_days( ecl_sum , double , char*)")
_get_general_var_from_sim_time = EclPrototype("double ecl_sum_get_general_var_from_sim_time( ecl_sum , time_t , char*)")
_get_first_gt = EclPrototype("int ecl_sum_get_first_gt( ecl_sum , int , double )")
_get_first_lt = EclPrototype("int ecl_sum_get_first_lt( ecl_sum , int , double )")
_get_start_date = EclPrototype("time_t ecl_sum_get_start_time( ecl_sum )")
_get_end_date = EclPrototype("time_t ecl_sum_get_end_time( ecl_sum )")
_get_last_report_step = EclPrototype("int ecl_sum_get_last_report_step( ecl_sum )")
_get_first_report_step = EclPrototype("int ecl_sum_get_first_report_step( ecl_sum )")
_select_matching_keys = EclPrototype("void ecl_sum_select_matching_general_var_list( ecl_sum , char* , stringlist )")
_has_key = EclPrototype("bool ecl_sum_has_general_var( ecl_sum , char* )")
_check_sim_time = EclPrototype("bool ecl_sum_check_sim_time( ecl_sum , time_t )")
_check_sim_days = EclPrototype("bool ecl_sum_check_sim_days( ecl_sum , double )")
_sim_length = EclPrototype("double ecl_sum_get_sim_length( ecl_sum )")
_get_first_day = EclPrototype("double ecl_sum_get_first_day( ecl_sum )")
_get_data_start = EclPrototype("time_t ecl_sum_get_data_start( ecl_sum )")
_get_unit = EclPrototype("char* ecl_sum_get_unit( ecl_sum , char*)")
_get_simcase = EclPrototype("char* ecl_sum_get_case( ecl_sum )")
_get_base = EclPrototype("char* ecl_sum_get_base( ecl_sum )")
_get_path = EclPrototype("char* ecl_sum_get_path( ecl_sum )")
_get_abs_path = EclPrototype("char* ecl_sum_get_abs_path( ecl_sum )")
for such objects. The three different object types which can be
found in an RFT file are:
RFT: This is old-fashioned RFT which contains measurements of
saturations for each of the completed cells.
PLT: This contains production and flow rates for each phase in
each cell.
SEGMENT: Not implemented.
In addition to the measurements specific for RFT and PLT each cell
has coordinates, pressure and depth.
"""
TYPE_NAME = "ecl_rft"
_alloc = EclPrototype("void* ecl_rft_node_alloc_new( char* , char* , time_t , double)" , bind = False)
_free = EclPrototype("void ecl_rft_node_free( ecl_rft )")
_get_type = EclPrototype("int ecl_rft_node_get_type( ecl_rft )")
_get_well = EclPrototype("char* ecl_rft_node_get_well_name( ecl_rft )")
_get_date = EclPrototype("time_t ecl_rft_node_get_date( ecl_rft )")
_get_size = EclPrototype("int ecl_rft_node_get_size( ecl_rft )")
_iget_cell = EclPrototype("void* ecl_rft_node_iget_cell( ecl_rft )")
_iget_cell_sorted = EclPrototype("void* ecl_rft_node_iget_cell_sorted( ecl_rft )")
_sort_cells = EclPrototype("void* ecl_rft_node_inplace_sort_cells( ecl_rft )")
_iget_depth = EclPrototype("double ecl_rft_node_iget_depth( ecl_rft )")
_iget_pressure = EclPrototype("double ecl_rft_node_iget_pressure(ecl_rft)")
_iget_ijk = EclPrototype("void ecl_rft_node_iget_ijk( ecl_rft , int , int*, int*, int*)")
_iget_swat = EclPrototype("double ecl_rft_node_iget_swat(ecl_rft)")
_iget_sgas = EclPrototype("double ecl_rft_node_iget_sgas(ecl_rft)")
_iget_orat = EclPrototype("double ecl_rft_node_iget_orat(ecl_rft)")
_iget_wrat = EclPrototype("double ecl_rft_node_iget_wrat(ecl_rft)")
_iget_grat = EclPrototype("double ecl_rft_node_iget_grat(ecl_rft)")
READ_MODE = 1
WRITE_MODE = 2
READ_AND_WRITE_MODE = 3
APPEND_MODE = 4
_open_reader = EclPrototype("void* fortio_open_reader(char*, bool, bool)" , bind = False)
_open_writer = EclPrototype("void* fortio_open_writer(char*, bool, bool)" , bind = False)
_open_readwrite = EclPrototype("void* fortio_open_readwrite(char*, bool, bool)" , bind = False)
_open_append = EclPrototype("void* fortio_open_append(char*, bool, bool)" , bind = False)
_guess_fortran = EclPrototype("bool fortio_looks_like_fortran_file(char* , bool)" , bind = False)
_write_record = EclPrototype("void fortio_fwrite_record(fortio, char*, int)")
_get_position = EclPrototype("long fortio_ftell(fortio)")
_seek = EclPrototype("void fortio_fseek(fortio, long, int)")
_close = EclPrototype("bool fortio_fclose(fortio)")
_truncate = EclPrototype("bool fortio_ftruncate(fortio , long)")
_filename = EclPrototype("char* fortio_filename_ref(fortio)")
def __init__(self, file_name, mode=READ_MODE, fmt_file=False, endian_flip_header=True):
"""Will open a new FortIO handle to @file_name - default for reading.
The newly created FortIO handle will open the underlying FILE*
for reading, but if you pass the flag mode=FortIO.WRITE_MODE
the file will be opened for writing.
Observe that the flag @endian_flip_header will only affect the
interpretation of the block size markers in the file, endian
flipping of the actual data blocks must be handled at a higher
level.
_get_fortio_size = EclPrototype("size_t ecl_kw_fortio_size( ecl_kw )")
_get_type = EclPrototype("ecl_type_enum ecl_kw_get_type( ecl_kw )")
_iget_char_ptr = EclPrototype("char* ecl_kw_iget_char_ptr( ecl_kw , int )")
_iset_char_ptr = EclPrototype("void ecl_kw_iset_char_ptr( ecl_kw , int , char*)")
_iget_bool = EclPrototype("bool ecl_kw_iget_bool( ecl_kw , int)")
_iset_bool = EclPrototype("bool ecl_kw_iset_bool( ecl_kw , int, bool)")
_iget_int = EclPrototype("int ecl_kw_iget_int( ecl_kw , int )")
_iget_double = EclPrototype("double ecl_kw_iget_double( ecl_kw , int )")
_iget_float = EclPrototype("float ecl_kw_iget_float( ecl_kw , int)")
_float_ptr = EclPrototype("float* ecl_kw_get_float_ptr( ecl_kw )")
_int_ptr = EclPrototype("int* ecl_kw_get_int_ptr( ecl_kw )")
_double_ptr = EclPrototype("double* ecl_kw_get_double_ptr( ecl_kw )")
_free = EclPrototype("void ecl_kw_free( ecl_kw )")
_fwrite = EclPrototype("void ecl_kw_fwrite( ecl_kw , fortio )")
_get_header = EclPrototype("char* ecl_kw_get_header ( ecl_kw )")
_set_header = EclPrototype("void ecl_kw_set_header_name ( ecl_kw , char*)")
_int_sum = EclPrototype("int ecl_kw_element_sum_int( ecl_kw )")
_float_sum = EclPrototype("double ecl_kw_element_sum_float( ecl_kw )")
_iadd = EclPrototype("void ecl_kw_inplace_add( ecl_kw , ecl_kw )")
_imul = EclPrototype("void ecl_kw_inplace_mul( ecl_kw , ecl_kw )")
_idiv = EclPrototype("void ecl_kw_inplace_div( ecl_kw , ecl_kw )")
_isub = EclPrototype("void ecl_kw_inplace_sub( ecl_kw , ecl_kw )")
_iabs = EclPrototype("void ecl_kw_inplace_abs( ecl_kw )")
_equal = EclPrototype("bool ecl_kw_equal( ecl_kw , ecl_kw )")
_equal_numeric = EclPrototype("bool ecl_kw_numeric_equal( ecl_kw , ecl_kw , double , double)")
_assert_binary = EclPrototype("bool ecl_kw_assert_binary_numeric( ecl_kw , ecl_kw )")
_scale_int = EclPrototype("void ecl_kw_scale_int( ecl_kw , int )")
_scale_float = EclPrototype("void ecl_kw_scale_float_or_double( ecl_kw , double )")
_shift_int = EclPrototype("void ecl_kw_shift_int( ecl_kw , int )")
_shift_float = EclPrototype("void ecl_kw_shift_float_or_double( ecl_kw , double )")
_select_jslice = EclPrototype("void ecl_region_select_j1j2( ecl_region , int , int )")
_deselect_jslice = EclPrototype("void ecl_region_deselect_j1j2( ecl_region , int , int )")
_select_kslice = EclPrototype("void ecl_region_select_k1k2( ecl_region , int , int )")
_deselect_kslice = EclPrototype("void ecl_region_deselect_k1k2( ecl_region , int , int )")
_select_deep_cells = EclPrototype("void ecl_region_select_deep_cells( ecl_region , double )")
_deselect_deep_cells = EclPrototype("void ecl_region_select_deep_cells( ecl_region , double )")
_select_shallow_cells = EclPrototype("void ecl_region_select_shallow_cells( ecl_region , double )")
_deselect_shallow_cells = EclPrototype("void ecl_region_select_shallow_cells( ecl_region , double )")
_select_small = EclPrototype("void ecl_region_select_small_cells( ecl_region , double )")
_deselect_small = EclPrototype("void ecl_region_deselect_small_cells( ecl_region , double )")
_select_large = EclPrototype("void ecl_region_select_large_cells( ecl_region , double )")
_deselect_large = EclPrototype("void ecl_region_deselect_large_cells( ecl_region , double )")
_select_thin = EclPrototype("void ecl_region_select_thin_cells( ecl_region , double )")
_deselect_thin = EclPrototype("void ecl_region_deselect_thin_cells( ecl_region , double )")
_select_thick = EclPrototype("void ecl_region_select_thick_cells( ecl_region , double )")
_deselect_thick = EclPrototype("void ecl_region_deselect_thick_cells( ecl_region , double )")
_select_active = EclPrototype("void ecl_region_select_active_cells( ecl_region )")
_select_inactive = EclPrototype("void ecl_region_select_inactive_cells( ecl_region )")
_deselect_active = EclPrototype("void ecl_region_deselect_active_cells( ecl_region )")
_deselect_inactive = EclPrototype("void ecl_region_deselect_inactive_cells( ecl_region )")
_select_above_plane = EclPrototype("void ecl_region_select_above_plane( ecl_region , double* , double* )")
_select_below_plane = EclPrototype("void ecl_region_select_below_plane( ecl_region , double* , double* )")
_deselect_above_plane = EclPrototype("void ecl_region_deselect_above_plane( ecl_region, double* , double* )")
_deselect_below_plane = EclPrototype("void ecl_region_deselect_below_plane( ecl_region, double* , double* )")
_select_inside_polygon = EclPrototype("void ecl_region_select_inside_polygon( ecl_region , geo_polygon)")
_select_outside_polygon = EclPrototype("void ecl_region_select_outside_polygon( ecl_region , geo_polygon)")
_deselect_inside_polygon = EclPrototype("void ecl_region_deselect_inside_polygon( ecl_region , geo_polygon)")
_deselect_outside_polygon = EclPrototype("void ecl_region_deselect_outside_polygon( ecl_region , geo_polygon)")
_set_name = EclPrototype("void ecl_region_set_name( ecl_region , char*)")
_get_name = EclPrototype("char* ecl_region_get_name( ecl_region )")
_contains_ijk = EclPrototype("void ecl_region_contains_ijk( ecl_region , int , int , int)")
_contains_global = EclPrototype("void ecl_region_contains_global( ecl_region, int )")
TYPE_NAME = "ecl_kw"
_alloc_new = EclPrototype("void* ecl_kw_alloc( char* , int , ecl_type_enum )", bind = False)
_fread_alloc = EclPrototype("ecl_kw_obj ecl_kw_fread_alloc( fortio )" , bind = False)
_load_grdecl = EclPrototype("ecl_kw_obj ecl_kw_fscanf_alloc_grdecl_dynamic__( FILE , char* , bool , int )" , bind = False)
_fseek_grdecl = EclPrototype("bool ecl_kw_grdecl_fseek_kw(char* , bool , FILE )" , bind = False)
_sub_copy = EclPrototype("ecl_kw_obj ecl_kw_alloc_sub_copy( ecl_kw , char*, int , int)")
_copyc = EclPrototype("ecl_kw_obj ecl_kw_alloc_copy( ecl_kw )")
_slice_copyc = EclPrototype("ecl_kw_obj ecl_kw_alloc_slice_copy( ecl_kw , int , int , int )")
_fprintf_grdecl = EclPrototype("void ecl_kw_fprintf_grdecl( ecl_kw , FILE )")
_fprintf_data = EclPrototype("void ecl_kw_fprintf_data( ecl_kw , char* , FILE )")
_get_size = EclPrototype("int ecl_kw_get_size( ecl_kw )")
_get_fortio_size = EclPrototype("size_t ecl_kw_fortio_size( ecl_kw )")
_get_type = EclPrototype("ecl_type_enum ecl_kw_get_type( ecl_kw )")
_iget_char_ptr = EclPrototype("char* ecl_kw_iget_char_ptr( ecl_kw , int )")
_iset_char_ptr = EclPrototype("void ecl_kw_iset_char_ptr( ecl_kw , int , char*)")
_iget_bool = EclPrototype("bool ecl_kw_iget_bool( ecl_kw , int)")
_iset_bool = EclPrototype("bool ecl_kw_iset_bool( ecl_kw , int, bool)")
_iget_int = EclPrototype("int ecl_kw_iget_int( ecl_kw , int )")
_iget_double = EclPrototype("double ecl_kw_iget_double( ecl_kw , int )")
_iget_float = EclPrototype("float ecl_kw_iget_float( ecl_kw , int)")
_float_ptr = EclPrototype("float* ecl_kw_get_float_ptr( ecl_kw )")
_int_ptr = EclPrototype("int* ecl_kw_get_int_ptr( ecl_kw )")
_double_ptr = EclPrototype("double* ecl_kw_get_double_ptr( ecl_kw )")
_free = EclPrototype("void ecl_kw_free( ecl_kw )")
_fwrite = EclPrototype("void ecl_kw_fwrite( ecl_kw , fortio )")
_get_header = EclPrototype("char* ecl_kw_get_header ( ecl_kw )")
_set_header = EclPrototype("void ecl_kw_set_header_name ( ecl_kw , char*)")
_int_sum = EclPrototype("int ecl_kw_element_sum_int( ecl_kw )")
_float_sum = EclPrototype("double ecl_kw_element_sum_float( ecl_kw )")
import ctypes
import os
import sys
from ert.cwrap import BaseCClass
from ert.ecl import EclPrototype
class FortIO(BaseCClass):
TYPE_NAME = "fortio"
READ_MODE = 1
WRITE_MODE = 2
READ_AND_WRITE_MODE = 3
APPEND_MODE = 4
_open_reader = EclPrototype("void* fortio_open_reader(char*, bool, bool)" , bind = False)
_open_writer = EclPrototype("void* fortio_open_writer(char*, bool, bool)" , bind = False)
_open_readwrite = EclPrototype("void* fortio_open_readwrite(char*, bool, bool)" , bind = False)
_open_append = EclPrototype("void* fortio_open_append(char*, bool, bool)" , bind = False)
_guess_fortran = EclPrototype("bool fortio_looks_like_fortran_file(char* , bool)" , bind = False)
_write_record = EclPrototype("void fortio_fwrite_record(fortio, char*, int)")
_get_position = EclPrototype("long fortio_ftell(fortio)")
_seek = EclPrototype("void fortio_fseek(fortio, int)")
_close = EclPrototype("bool fortio_fclose(fortio)")
def __init__(self, file_name, mode=READ_MODE, fmt_file=False, endian_flip_header=True):
"""Will open a new FortIO handle to @file_name - default for reading.
The newly created FortIO handle will open the underlying FILE*
# The file 'ecl_grav.py' is part of ERT - Ensemble based Reservoir Tool.
#
# ERT is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# ERT is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE.
#
# See the GNU General Public License at
# for more details.
from ert.ecl import EclPrototype
_phase_deltag = EclPrototype("double ecl_grav_phase_deltag( double, double ,double , ecl_grid , ecl_file , ecl_kw , ecl_kw , ecl_kw , ecl_kw , ecl_kw , ecl_kw")
def phase_deltag( xyz, grid, init, sat1, rho1, porv1, sat2, rho2, porv2):
return _phase_deltag(xyz[0], xyz[1], xyz[2],
grid.c_ptr, init.c_ptr,
sat1.c_ptr, rho1.c_ptr, porv1.c_ptr,
sat2.c_ptr, rho2.c_ptr, porv2.c_ptr)
# 1. All restart files should have water, i.e. the SWAT keyword.
# 2. All phases present in the restart file should also be present as densities,
# in addition the model must contain one additional phase - which should have a density.
# 3. The restart files can never contain oil saturation.
_get_cell_dx = EclPrototype("double ecl_grid_get_cell_dx1( ecl_grid , int )")
_get_cell_dy = EclPrototype("double ecl_grid_get_cell_dy1( ecl_grid , int )")
_get_depth = EclPrototype("double ecl_grid_get_cdepth1( ecl_grid , int )")
_fwrite_grdecl = EclPrototype("void ecl_grid_grdecl_fprintf_kw( ecl_grid , ecl_kw , char* , FILE , double)")
_load_column = EclPrototype("void ecl_grid_get_column_property( ecl_grid , ecl_kw , int , int , double_vector)")
_get_top = EclPrototype("double ecl_grid_get_top2( ecl_grid , int , int )")
_get_top1A = EclPrototype("double ecl_grid_get_top1A(ecl_grid , int )")
_get_bottom = EclPrototype("double ecl_grid_get_bottom2( ecl_grid , int , int )")
_locate_depth = EclPrototype("int ecl_grid_locate_depth( ecl_grid , double , int , int )")
_invalid_cell = EclPrototype("bool ecl_grid_cell_invalid1( ecl_grid , int)")
_valid_cell = EclPrototype("bool ecl_grid_cell_valid1( ecl_grid , int)")
_get_distance = EclPrototype("void ecl_grid_get_distance( ecl_grid , int , int , double* , double* , double*)")
_fprintf_grdecl2 = EclPrototype("void ecl_grid_fprintf_grdecl2( ecl_grid , FILE , ecl_unit_enum) ")
_fwrite_GRID2 = EclPrototype("void ecl_grid_fwrite_GRID2( ecl_grid , char* , ecl_unit_enum)")
_fwrite_EGRID2 = EclPrototype("void ecl_grid_fwrite_EGRID2( ecl_grid , char*, ecl_unit_enum)")
_equal = EclPrototype("bool ecl_grid_compare(ecl_grid , ecl_grid , bool, bool)")
_dual_grid = EclPrototype("bool ecl_grid_dual_grid( ecl_grid )")
_init_actnum = EclPrototype("void ecl_grid_init_actnum_data( ecl_grid , int* )")
_compressed_kw_copy = EclPrototype("void ecl_grid_compressed_kw_copy( ecl_grid , ecl_kw , ecl_kw)")
_global_kw_copy = EclPrototype("void ecl_grid_global_kw_copy( ecl_grid , ecl_kw , ecl_kw)")
_create_volume_keyword = EclPrototype("ecl_kw_obj ecl_grid_alloc_volume_kw( ecl_grid , bool)")
@classmethod
def loadFromGrdecl(cls , filename):
"""Will create a new EclGrid instance from grdecl file.
This function will scan the input file @filename and look for
the keywords required to build a grid. The following keywords
are required:
# ERT is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE.
#
# See the GNU General Public License at
# for more details.
from ert.util import CTime
from ert.ecl import EclPrototype , EclFile, Ecl3DKW , Ecl3DFile, EclFileEnum
from cwrap import BaseCClass
class EclRestartHead(BaseCClass):
TYPE_NAME = "ecl_rsthead"
_alloc = EclPrototype("void* ecl_rsthead_alloc(ecl_file_view , int )", bind = False)
_alloc_from_kw = EclPrototype("void* ecl_rsthead_alloc_from_kw(int , ecl_kw , ecl_kw , ecl_kw )", bind = False)
_free = EclPrototype("void ecl_rsthead_free(ecl_rsthead)")
_get_report_step = EclPrototype("int ecl_rsthead_get_report_step(ecl_rsthead)")
_get_sim_time = EclPrototype("time_t ecl_rsthead_get_sim_time(ecl_rsthead)")
_get_sim_days = EclPrototype("double ecl_rsthead_get_sim_days(ecl_rsthead)")
def __init__(self , kw_arg = None , rst_view = None):
if kw_arg is None and rst_view is None:
raise ValueError('Cannot construct EclRestartHead without one of kw_arg and rst_view, both were None!')
if not kw_arg is None:
report_step , intehead_kw , doubhead_kw , logihead_kw = kw_arg
c_ptr = self._alloc_from_kw( report_step , intehead_kw , doubhead_kw , logihead_kw )
else:
c_ptr = self._alloc( rst_view , -1 )
super(EclRestartHead, self).__init__(c_ptr)