Exemplo n.º 1
0
        """
        return self.test_case.cmpSummaryVector(self.ref_case, key, sample=sample)


    def test_keys(self):
        """
        Will return a list of summary keys in the test case.
        """
        return self.test_case.keys()


    def test_wells(self):
        """
        Will return a list of wells keys in the test case.
        """
        return self.test_case.wells()



monkey_the_camel(EclCase, 'loadSummary', EclCase.load_summary)
monkey_the_camel(EclCase, 'startTimeEqual', EclCase.start_time_equal)
monkey_the_camel(EclCase, 'endTimeEqual', EclCase.end_time_equal)
monkey_the_camel(EclCase, 'cmpSummaryVector', EclCase.cmp_summary_vector)

monkey_the_camel(EclCmp, 'initCheck', EclCmp.init_check)
monkey_the_camel(EclCmp, 'hasSummaryVector', EclCmp.has_summary_vector)
monkey_the_camel(EclCmp, 'endTimeEqual', EclCmp.end_time_equal)
monkey_the_camel(EclCmp, 'cmpSummaryVector', EclCmp.cmp_summary_vector)
monkey_the_camel(EclCmp, 'testKeys', EclCmp.test_keys)
monkey_the_camel(EclCmp, 'testWells', EclCmp.test_wells)
Exemplo n.º 2
0
            layer.addInterpBarrier(c0, c1)
            print('%g,%g -> %d,%d   %d' % (p1[0], p1[1], i,j,c1))
            print('Adding barrier %d -> %d' % (c0, c1))
            c0 = c1


    def get_geo_layer(self):
        """Returns the underlying geometric layer."""
        return self._get_layer()


    def cell_contact(self, p1, p2):
        layer = self.getGeoLayer()
        return layer.cellContact(p1,p2)

monkey_the_camel(FaultBlockLayer, 'scanKeyword', FaultBlockLayer.scan_keyword)
monkey_the_camel(FaultBlockLayer, 'loadKeyword', FaultBlockLayer.load_keyword)
monkey_the_camel(FaultBlockLayer, 'getBlock', FaultBlockLayer.get_block)
monkey_the_camel(FaultBlockLayer, 'deleteBlock', FaultBlockLayer.delete_block)
monkey_the_camel(FaultBlockLayer, 'addBlock', FaultBlockLayer.add_block)
monkey_the_camel(FaultBlockLayer, 'getNextID', FaultBlockLayer.get_next_id)
monkey_the_camel(FaultBlockLayer, 'getK', FaultBlockLayer.get_k)
monkey_the_camel(FaultBlockLayer, 'scanLayer', FaultBlockLayer.scan_layer)
monkey_the_camel(FaultBlockLayer, 'insertBlockContent', FaultBlockLayer.insert_block_content)
monkey_the_camel(FaultBlockLayer, 'exportKeyword', FaultBlockLayer.export_keyword)
monkey_the_camel(FaultBlockLayer, 'addFaultBarrier', FaultBlockLayer.add_fault_barrier)
monkey_the_camel(FaultBlockLayer, 'addFaultLink', FaultBlockLayer.add_fault_link)
monkey_the_camel(FaultBlockLayer, 'joinFaults', FaultBlockLayer.join_faults)
monkey_the_camel(FaultBlockLayer, 'addPolylineBarrier', FaultBlockLayer.add_polyline_barrier)
monkey_the_camel(FaultBlockLayer, 'getGeoLayer', FaultBlockLayer.get_geo_layer)
monkey_the_camel(FaultBlockLayer, 'cellContact', FaultBlockLayer.cell_contact)
Exemplo n.º 3
0
        """
        self._fwrite(fortio, 0)


class EclFileContextManager(object):
    def __init__(self, ecl_file):
        self.__ecl_file = ecl_file

    def __enter__(self):
        return self.__ecl_file

    def __exit__(self, exc_type, exc_val, exc_tb):
        self.__ecl_file.close()
        return False


def openEclFile(file_name, flags=0):
    print('The function openEclFile is deprecated, use open_ecl_file.')
    return open_ecl_file(file_name, flags)


def open_ecl_file(file_name, flags=0):
    return EclFileContextManager(EclFile(file_name, flags))


monkey_the_camel(EclFile, 'getFileType', EclFile.get_filetype, staticmethod)
monkey_the_camel(EclFile, 'blockView', EclFile.block_view)
monkey_the_camel(EclFile, 'blockView2', EclFile.block_view2)
monkey_the_camel(EclFile, 'restartView', EclFile.restart_view)
monkey_the_camel(EclFile, 'getFilename', EclFile.get_filename)
Exemplo n.º 4
0
    def is_total(self):
        """
        Will check if the node corresponds to a total quantity.

        The question of whether a variable corresponds to a 'total'
        quantity or not can be interesting for e.g. interpolation
        purposes. The actual question whether a quantity is total or
        not is based on a hardcoded list in smspec_node_set_flags() in
        smspec_node.c; this list again is based on the tables 2.7 -
        2.11 in the ECLIPSE fileformat documentation.
        """
        return self._node_is_total()

    def is_historical(self):
        """
        Checks if the key corresponds to a historical variable.

        The check is only based on the last character; all variables
        ending with 'H' are considered historical.
        """
        return self._node_is_historical()


monkey_the_camel(EclSMSPECNode, 'getKey1', EclSMSPECNode.get_key1)
monkey_the_camel(EclSMSPECNode, 'getKey2', EclSMSPECNode.get_key2)
monkey_the_camel(EclSMSPECNode, 'varType', EclSMSPECNode.var_type)
monkey_the_camel(EclSMSPECNode, 'getNum', EclSMSPECNode.get_num)
monkey_the_camel(EclSMSPECNode, 'isRate', EclSMSPECNode.is_rate)
monkey_the_camel(EclSMSPECNode, 'isTotal', EclSMSPECNode.is_total)
monkey_the_camel(EclSMSPECNode, 'isHistorical', EclSMSPECNode.is_historical)
Exemplo n.º 5
0

def openFortIO(file_name,
               mode=FortIO.READ_MODE,
               fmt_file=False,
               endian_flip_header=True):
    """Will create FortIO based context manager for use with with.

    The with: statement and context managers is a good alternative in
    the situation where you need to ensure resource cleanup.

       import sys
       from ecl.ecl import FortIO, EclFile

       rst_file = EclFile(sys.argv[1])
       with openFortIO("PRESSURE", mode=FortIO.WRITE_MODE) as fortio:
          for kw in rst_file:
              if kw.name() == "PRESSURE":
                 kw.write(fortio)

    """
    return FortIOContextManager(
        FortIO(file_name,
               mode=mode,
               fmt_file=fmt_file,
               endian_flip_header=endian_flip_header))


monkey_the_camel(FortIO, 'getPosition', FortIO.get_position)
monkey_the_camel(FortIO, 'isFortranFile', FortIO.is_fortran_file, classmethod)
Exemplo n.º 6
0
        if index >= len(self):
            raise IndexError("Out of range")

        return self._iget_key(index)

    def __len__(self):
        return self._get_size()

    def free(self):
        self._free()

    def add_keyword(self, keyword):
        success = self._add(keyword)
        if not success:
            raise KeyError("Failed to add keyword to vector")

    def add_keywords(self, keyword_pattern):
        self._add_multiple(keyword_pattern)

    def __repr__(self):
        return self._create_repr('len=%d' % len(self))

    def copy(self, ecl_sum):
        return self._alloc_copy(ecl_sum)


monkey_the_camel(EclSumKeyWordVector, 'addKeyword',
                 EclSumKeyWordVector.add_keyword)
monkey_the_camel(EclSumKeyWordVector, 'addKeywords',
                 EclSumKeyWordVector.add_keywords)
Exemplo n.º 7
0
        """
        i_list = IntVector()
        j_list = IntVector()
        self._cells_equal(value, i_list, j_list)
        ij_list= []
        for (i,j) in zip(i_list, j_list):
            ij_list.append((i,j))
        return ij_list


    def count_equal(self, value):
        return self._count_equal(value)



monkey_the_camel(Layer, 'activeCell', Layer.active_cell)
monkey_the_camel(Layer, 'updateActive', Layer.update_active)
monkey_the_camel(Layer, 'bottomBarrier', Layer.bottom_barrier)
monkey_the_camel(Layer, 'leftBarrier', Layer.left_barrier)
monkey_the_camel(Layer, 'getNX', Layer.get_nx)
monkey_the_camel(Layer, 'getNY', Layer.get_ny)
monkey_the_camel(Layer, 'cellContact', Layer.cell_contact)
monkey_the_camel(Layer, 'addInterpBarrier', Layer.add_interp_barrier)
monkey_the_camel(Layer, 'addPolylineBarrier', Layer.add_polyline_barrier)
monkey_the_camel(Layer, 'addFaultBarrier', Layer.add_fault_barrier)
monkey_the_camel(Layer, 'addIJBarrier', Layer.add_ij_barrier)
monkey_the_camel(Layer, 'cellSum', Layer.cell_sum)
monkey_the_camel(Layer, 'clearCells', Layer.clear_cells)
monkey_the_camel(Layer, 'updateConnected', Layer.update_connected)
monkey_the_camel(Layer, 'cellsEqual', Layer.cells_equal)
monkey_the_camel(Layer, 'countEqual', Layer.count_equal)
Exemplo n.º 8
0
            raise IndexError("Offset:%d invalid - size:%d" %
                             (offset, len(self)))

        if self.getEclType() != other.getEclType():
            raise TypeError("The two keywords have different type")

        if abs_epsilon is None:
            abs_epsilon = epsilon

        if rel_epsilon is None:
            rel_epsilon = epsilon

        return self._first_different(other, offset, abs_epsilon, rel_epsilon)


monkey_the_camel(EclKW, 'intKeywords', EclKW.int_keywords, classmethod)
monkey_the_camel(EclKW, 'isNumeric', EclKW.is_numeric)
monkey_the_camel(EclKW, 'fortIOSize', EclKW.fort_io_size)
monkey_the_camel(EclKW, 'setName', EclKW.set_name)
monkey_the_camel(EclKW, 'getName', EclKW.get_name)
monkey_the_camel(EclKW, 'getMinMax', EclKW.get_min_max)
monkey_the_camel(EclKW, 'getMax', EclKW.get_max)
monkey_the_camel(EclKW, 'getMin', EclKW.get_min)
monkey_the_camel(EclKW, 'typeName', EclKW.type_name)
monkey_the_camel(EclKW, 'getEclType', EclKW.get_ecl_type)
monkey_the_camel(EclKW, 'numpyView', EclKW.numpy_view)
monkey_the_camel(EclKW, 'numpyCopy', EclKW.numpy_copy)
monkey_the_camel(EclKW, 'fixUninitialized', EclKW.fix_uninitialized)
monkey_the_camel(EclKW, 'getDataPtr', EclKW.get_data_ptr)
monkey_the_camel(EclKW, 'firstDifferent', EclKW.first_different)
Exemplo n.º 9
0
    def export_coord(self):
        return self._export_coord()

    def export_zcorn(self):
        return self._export_zcorn()

    def export_actnum(self):
        return self._export_actnum()

    def export_mapaxes(self):
        if not self._use_mapaxes():
            return None

        return self._export_mapaxes()

monkey_the_camel(EclGrid, 'loadFromGrdecl', EclGrid.load_from_grdecl, classmethod)
monkey_the_camel(EclGrid, 'loadFromFile', EclGrid.load_from_file, classmethod)
monkey_the_camel(EclGrid, 'createRectangular', EclGrid.create_rectangular, classmethod)
monkey_the_camel(EclGrid, 'dualGrid', EclGrid.dual_grid)
monkey_the_camel(EclGrid, 'getDims', EclGrid.get_dims)
monkey_the_camel(EclGrid, 'getNX', EclGrid.get_nx)
monkey_the_camel(EclGrid, 'getNY', EclGrid.get_ny)
monkey_the_camel(EclGrid, 'getNZ', EclGrid.get_nz)
monkey_the_camel(EclGrid, 'getGlobalSize', EclGrid.get_global_size)
monkey_the_camel(EclGrid, 'getNumActive', EclGrid.get_num_active)
monkey_the_camel(EclGrid, 'getNumActiveFracture', EclGrid.get_num_active_fracture)
monkey_the_camel(EclGrid, 'getBoundingBox2D', EclGrid.get_bounding_box_2d)
monkey_the_camel(EclGrid, 'getName', EclGrid.get_name)
monkey_the_camel(EclGrid, 'validCellGeometry', EclGrid.valid_cell_geometry)
monkey_the_camel(EclGrid, 'getNodePos', EclGrid.get_node_pos)
monkey_the_camel(EclGrid, 'getCellCorner', EclGrid.get_cell_corner)
Exemplo n.º 10
0
Arquivo: fault.py Projeto: pgdr/libecl
            count += 1
        except ValueError:
            pass

        if count == 1:
            xy_list = []
            for ij in join:
                xyz = fault1.__grid.getNodeXYZ(ij[0], ij[1], k)
                xy_list.append((xyz[0], xyz[1]))

            return xy_list
        else:
            return fault1.endJoin(fault2, k)


monkey_the_camel(FaultLayer, 'addSegment', FaultLayer.add_segment)
monkey_the_camel(FaultLayer, 'getK', FaultLayer.get_k)
monkey_the_camel(FaultLayer, 'getNeighborCells', FaultLayer.get_neighbor_cells)
monkey_the_camel(FaultLayer, 'getPolyline', FaultLayer.get_polyline)
monkey_the_camel(FaultLayer, 'getIJPolyline', FaultLayer.get_ij_polyline)
monkey_the_camel(FaultLayer, 'numLines', FaultLayer.num_lines)
monkey_the_camel(FaultLayer, 'processSegments', FaultLayer.process_segments)

monkey_the_camel(Fault, 'hasLayer', Fault.has_layer)
monkey_the_camel(Fault, 'addLayer', Fault.add_layer)
monkey_the_camel(Fault, 'createSegment', Fault.create_segment)
monkey_the_camel(Fault, 'addRecord', Fault.add_record)
monkey_the_camel(Fault, 'getName', Fault.get_name)
monkey_the_camel(Fault, 'getNeighborCells', Fault.get_neighbor_cells)
monkey_the_camel(Fault, 'getPolyline', Fault.get_polyline)
monkey_the_camel(Fault, 'getIJPolyline', Fault.get_ij_polyline)
Exemplo n.º 11
0
        integer for the step number.

        """
        fmt_file = ctypes.c_bool()
        report_step = ctypes.c_int(-1)
        file_type = EclUtil._get_file_type(filename, ctypes.byref(fmt_file),
                                           ctypes.byref(report_step))
        if report_step.value == -1:
            step = None
        else:
            step = report_step.value

        return (file_type, fmt_file.value, step)

    @staticmethod
    def report_step(filename):
        report_step = EclUtil._get_report_step(filename)
        if report_step < 0:
            raise ValueError("Could not infer report step from: %s" % filename)

        return report_step


get_num_cpu = EclUtil.get_num_cpu
get_file_type = EclUtil.get_file_type
get_start_date = EclUtil.get_start_date

monkey_the_camel(EclUtil, 'inspectExtension', EclUtil.inspect_extension,
                 staticmethod)
monkey_the_camel(EclUtil, 'reportStep', EclUtil.report_step, staticmethod)
Exemplo n.º 12
0
        The monitor survey can be 'None' - the resulting answer has
        nothing whatsovever to do with subsidence, but can be
        interesting to determine the numerical size of the quantities
        which are subtracted in a 4D study.

        The @pos argument should be a tuple of three elements with the
        (utm_x , utm_y , depth) position where we want to evaluate the
        change in subsidence.

        If supplied the optional argument @region should be an
        EclRegion() instance; this region will be used to limit the
        part of the reserviour included in the subsidence calculations.

        The argument @compressibility is the total reservoir compressibility.
        """
        if not base_survey in self:
            raise KeyError("No such survey: %s" % base_survey)

        if not monitor_survey in self:
            raise KeyError("No such survey: %s" % monitor_survey)

        return self._eval(base_survey, monitor_survey, region, pos[0], pos[1],
                          pos[2], compressibility, poisson_ratio)

    def free(self):
        self._free()


monkey_the_camel(EclSubsidence, 'evalGeertsma', EclSubsidence.eval_geertsma)
Exemplo n.º 13
0
        contact with this block.
        """
        neighbour_id_list = IntVector()
        if polylines is None:
            polylines = CPolylineCollection()

        self._get_neighbours(connected_only, polylines, neighbour_id_list)

        parent_layer = self.getParentLayer()
        neighbour_list = []
        for id in neighbour_id_list:
            neighbour_list.append(parent_layer.getBlock(id))
        return neighbour_list

    def get_parent_layer(self):
        return self.parent()


monkey_the_camel(FaultBlock, 'getCentroid', FaultBlock.get_centroid)
monkey_the_camel(FaultBlock, 'countInside', FaultBlock.count_inside)
monkey_the_camel(FaultBlock, 'getBlockID', FaultBlock.get_block_id)
monkey_the_camel(FaultBlock, 'assignToRegion', FaultBlock.assign_to_region)
monkey_the_camel(FaultBlock, 'getRegionList', FaultBlock.get_region_list)
monkey_the_camel(FaultBlock, 'addCell', FaultBlock.add_cell)
monkey_the_camel(FaultBlock, 'getGlobalIndexList',
                 FaultBlock.get_global_index_list)
monkey_the_camel(FaultBlock, 'getEdgePolygon', FaultBlock.get_edge_polygon)
monkey_the_camel(FaultBlock, 'containsPolyline', FaultBlock.contains_polyline)
monkey_the_camel(FaultBlock, 'getNeighbours', FaultBlock.get_neighbours)
monkey_the_camel(FaultBlock, 'getParentLayer', FaultBlock.get_parent_layer)
Exemplo n.º 14
0
        else:
            var_list = StringList()
            for key in keys:
                var_list |= self.keys(pattern=key)
        self._export_csv(filename, var_list, date_format, sep)


import ecl.ecl.ecl_sum_keyword_vector
EclSum._dump_csv_line = EclPrototype(
    "void  ecl_sum_fwrite_interp_csv_line(ecl_sum, time_t, ecl_sum_vector, FILE)",
    bind=False)
EclSum._get_interp_vector = EclPrototype(
    "void  ecl_sum_get_interp_vector(ecl_sum, time_t, ecl_sum_vector, double_vector)",
    bind=False)

monkey_the_camel(EclSum, 'varType', EclSum.var_type, classmethod)
monkey_the_camel(EclSum, 'addVariable', EclSum.add_variable)
monkey_the_camel(EclSum, 'addTStep', EclSum.add_t_step)
monkey_the_camel(EclSum, 'assertKeyValid', EclSum.assert_key_valid)
monkey_the_camel(EclSum, 'scaleVector', EclSum.scale_vector)
monkey_the_camel(EclSum, 'shiftVector', EclSum.shift_vector)
monkey_the_camel(EclSum, 'timeRange', EclSum.time_range)
monkey_the_camel(EclSum, 'blockedProduction', EclSum.blocked_production)
monkey_the_camel(EclSum, 'getDataStartTime', EclSum.get_data_start_time)
monkey_the_camel(EclSum, 'getStartTime', EclSum.get_start_time)
monkey_the_camel(EclSum, 'getEndTime', EclSum.get_end_time)
monkey_the_camel(EclSum, 'solveDates', EclSum.solve_dates)
monkey_the_camel(EclSum, 'solveDays', EclSum.solve_days)
monkey_the_camel(EclSum, 'dumpCSVLine', EclSum.dump_csv_line)
monkey_the_camel(EclSum, 'exportCSV', EclSum.export_csv)
Exemplo n.º 15
0
        """
        @rtype: FaultBlockLayer
        """
        if isinstance(index, int):
            if 0 <= index < len(self):
                return self._get_layer(index).setParent(self)
            else:
                raise IndexError("Index:%d out of range [0,%d)" % (index, len(self)))
        else:
            raise TypeError("Index should be integer type")


    def get_layer(self, k):
        """
        @rtype: FaultBlockLayer
        """
        return self[k]

    def free(self):
        self._free()


    def scan_keyword(self, fault_block_kw):
        ok = self._scan_keyword(fault_block_kw)
        if not ok:
            raise ValueError("The fault block keyword had wrong type/size")


monkey_the_camel(FaultBlockCollection, 'getLayer', FaultBlockCollection.get_layer)
monkey_the_camel(FaultBlockCollection, 'scanKeyword', FaultBlockCollection.scan_keyword)
Exemplo n.º 16
0
        used before you use the add_survey_FIP() method to add a
        survey based on the FIP keyword.
        """
        self._new_std_density(phase_enum, default_density)

    def add_std_density(self, phase_enum, pvtnum, density):
        """
        Add standard conditions density for PVT region @pvtnum.

        The new_std_density() method will add a standard conditions
        density which applies to all cells in the model. Using the
        add_std_density() method it is possible to add standard
        conditions densities on a per PVT region basis. You can add
        densities for as many PVT regions as you like, and then fall
        back to the default density for the others.

        The new_std_density() method must be called before calling the
        add_std_density() method.

        The new_std_density() and add_std_density() methods must be
        used before you use the add_survey_FIP() method to add a
        survey based on the FIP keyword.
        """
        self._add_std_density(phase_enum, pvtnum, density)

    def free(self):
        self._free()


monkey_the_camel(EclGrav, 'addSurvey', EclGrav.add_survey)
Exemplo n.º 17
0
    def load_faults(self, grid, fileH):
        for line in fileH:
            line = comment_regexp.sub("", line)
            line = line.strip()
            if line == "/":
                break

            if line:
                (name, I1, I2, J1, J2, K1, K2, face) = self.splitLine(line)
                if not self.hasFault(name):
                    fault = Fault(grid, name)
                    self.addFault(fault)
                else:
                    fault = self.getFault(name)

                fault.addRecord(I1, I2, J1, J2, K1, K2, face)

    def load(self, grid, file_name):
        with open(file_name) as fileH:
            for line in fileH:
                if line.startswith("FAULTS"):
                    self.loadFaults(grid, fileH)


monkey_the_camel(FaultCollection, 'getGrid', FaultCollection.get_grid)
monkey_the_camel(FaultCollection, 'getFault', FaultCollection.get_fault)
monkey_the_camel(FaultCollection, 'hasFault', FaultCollection.has_fault)
monkey_the_camel(FaultCollection, 'addFault', FaultCollection.add_fault)
monkey_the_camel(FaultCollection, 'splitLine', FaultCollection.split_line)
monkey_the_camel(FaultCollection, 'loadFaults', FaultCollection.load_faults)
Exemplo n.º 18
0
        return start_segment

    def pop_next(self, segment):
        (C1, C2) = segment.getCorners()
        if self.__count_map[C1] >= 1:
            next_segment = self.__segment_map[C1].values()[0]
        elif self.__count_map[C2] >= 1:
            next_segment = self.__segment_map[C2].values()[0]
        else:
            next_segment = None

        if next_segment:
            self.delSegment(next_segment)
        return next_segment

    def print_content(self):
        for d in self.__segment_map.values():
            for (C, S) in d.iteritems():
                print(S)


monkey_the_camel(FaultSegment, 'getCorners', FaultSegment.get_corners)
monkey_the_camel(FaultSegment, 'getC1', FaultSegment.get_c1)
monkey_the_camel(FaultSegment, 'getC2', FaultSegment.get_c2)

monkey_the_camel(SegmentMap, 'addSegment', SegmentMap.add_segment)
monkey_the_camel(SegmentMap, 'delSegment', SegmentMap.del_segment)
monkey_the_camel(SegmentMap, 'popStart', SegmentMap.pop_start)
monkey_the_camel(SegmentMap, 'popNext', SegmentMap.pop_next)
monkey_the_camel(SegmentMap, 'printContent', SegmentMap.print_content)
Exemplo n.º 19
0
        self.code = "trange = self.baseCase.timeRange(self.start, self.end, self.interval)\n"
        for (key, var) in self.keyList.items():
            self.code += "%s = self.baseCase.blockedProduction(\"%s\", trange)\n" % (
                var, key)

        self.code += "npv = 0\n"
        self.code += """
for i in range(len(trange) - 1):
   npv += %s
varDict[\"npv\"] = npv
""" % parsedExpression

    def eval_npv(self):
        byteCode = compile(self.code, "<string>", 'exec')
        varDict = {}
        eval(byteCode)
        return varDict["npv"]


monkey_the_camel(NPVPriceVector, 'addItem', NPVPriceVector.add_item)
monkey_the_camel(NPVPriceVector, 'assertDate', NPVPriceVector.assert_date,
                 staticmethod)
monkey_the_camel(NPVPriceVector, 'evalDate', NPVPriceVector.eval_date)

monkey_the_camel(EclNPV, 'getExpression', EclNPV.get_expression)
monkey_the_camel(EclNPV, 'setExpression', EclNPV.set_expression)
monkey_the_camel(EclNPV, 'getKeyList', EclNPV.get_key_list)
monkey_the_camel(EclNPV, 'addKey', EclNPV.add_key)
monkey_the_camel(EclNPV, 'parseExpression', EclNPV.parse_expression)
monkey_the_camel(EclNPV, 'evalNPV', EclNPV.eval_npv)
Exemplo n.º 20
0
        """
        return self[index]


    def get(self , well_name , date ):
        """
        Will look up the RFT object corresponding to @well and @date.

        Raise Exception if not found.
        """
        if self.size( well = well_name , date = date) == 0:
            raise KeyError("No RFT for well:%s at %s" % (well_name , date))

        rft = self._get_rft( well_name , CTime( date ))
        rft.setParent( self )
        return rft

    def free(self):
        self._free( )

    def __repr__(self):
        w = len(self)
        return self._create_repr('wells = %d' % w)


monkey_the_camel(EclRFT, 'getWellName', EclRFT.get_well_name)
monkey_the_camel(EclRFT, 'getDate', EclRFT.get_date)

monkey_the_camel(EclRFTFile, 'getNumWells', EclRFTFile.get_num_wells)
monkey_the_camel(EclRFTFile, 'getHeaders', EclRFTFile.get_headers)
Exemplo n.º 21
0
              (20, datetime.datetime( 2010 , 5 , 1 , 0 , 0 , 0 ) , 220.0) ]

        For a non-unified restart file the list will have only one element.
        """

        self.assertHeaders()
        time_list = []
        for header in self.rst_headers:
            time_list.append((header.getReportStep(), header.getSimDate(),
                              header.getSimDays()))

        return time_list

    def headers(self):
        self.assertHeaders()
        return self.rst_headers

    def get_header(self, index):
        self.assertHeaders()
        return self.rst_headers[index]


monkey_the_camel(EclRestartHead, 'getReportStep',
                 EclRestartHead.get_report_step)
monkey_the_camel(EclRestartHead, 'getSimDate', EclRestartHead.get_sim_date)
monkey_the_camel(EclRestartHead, 'getSimDays', EclRestartHead.get_sim_days)

monkey_the_camel(EclRestartFile, 'assertHeaders',
                 EclRestartFile.assert_headers)
monkey_the_camel(EclRestartFile, 'timeList', EclRestartFile.time_list)
Exemplo n.º 22
0
            if len(bound) != 2:
                raise ValueError(
                    "Expected bound to consist of two elements, was %s",
                    str(bound))

            if not (isinstance(bound[0], int) and isinstance(bound[1], int)):
                raise TypeError(
                    "Expected bound to consist of two integers, ",
                    "was %s (%s)" % (str(bound), str((map(type, bound)))))

            if not (0 <= bound[0] <= bound[1] < n):
                raise ValueError(
                    "Expected bounds to have the following format: " +
                    "0 <= lower bound <= upper_bound < ni, " +
                    "was %d <=? %d <=? %d <? %d." % (0, bound[0], bound[1], n))

        return ijk_bounds

    @classmethod
    def assert_decomposition_change(cls, ijk_bounds, decomposition_change):
        if sum(zip(*ijk_bounds)[0]) % 2 == 1 and not decomposition_change:
            raise ValueError(
                "The subgrid defined by %s " % str(ijk_bounds) +
                "will cause an unintended decomposition change. " +
                "Either change one of the lower bounds by 1 " +
                "or activate decomposition_change.")


monkey_the_camel(EclGridGenerator, 'createRectangular',
                 EclGridGenerator.create_rectangular, classmethod)
Exemplo n.º 23
0
        return self._get_ministep()

    def get_sim_time(self):
        """ @rtype: CTime """
        return self._get_sim_time()

    def __getitem__(self, key):
        """ @rtype: double """
        if not key in self:
            raise KeyError("Key '%s' is not available." % key)

        return self._get_from_key(key)

    def __setitem__(self, key, value):
        if not key in self:
            raise KeyError("Key '%s' is not available." % key)

        self._set_from_key(key, value)

    def __contains__(self, key):
        return self._has_key(key)

    def free(self):
        self._free(self)


monkey_the_camel(EclSumTStep, 'getSimDays', EclSumTStep.get_sim_days)
monkey_the_camel(EclSumTStep, 'getReport', EclSumTStep.get_report)
monkey_the_camel(EclSumTStep, 'getMiniStep', EclSumTStep.get_mini_step)
monkey_the_camel(EclSumTStep, 'getSimTime', EclSumTStep.get_sim_time)
Exemplo n.º 24
0
    def contains_active(self, active_index):
        """
        Will check if the cell given by @active_index is part of the region.
        """
        return self._contains_active(active_index)

    def kw_index_list(self, ecl_kw, force_active):
        c_ptr = self._get_kw_index_list(ecl_kw, force_active)
        index_list = IntVector.createCReference(c_ptr, self)
        return index_list

    @property
    def name(self):
        return self._get_name()

    def get_name(self):
        return self._get_name()

    def set_name(self, name):
        self._set_name(name)


monkey_the_camel(EclRegion, 'selectTrue', EclRegion.select_true)
monkey_the_camel(EclRegion, 'selectFalse', EclRegion.select_false)
monkey_the_camel(EclRegion, 'selectFromLayer', EclRegion.select_from_layer)
monkey_the_camel(EclRegion, 'getActiveList', EclRegion.get_active_list)
monkey_the_camel(EclRegion, 'getGlobalList', EclRegion.get_global_list)
monkey_the_camel(EclRegion, 'getIJKList', EclRegion.get_ijk_list)
monkey_the_camel(EclRegion, 'getName', EclRegion.get_name)
monkey_the_camel(EclRegion, 'setName', EclRegion.set_name)
Exemplo n.º 25
0
            rseg = FaultSegment(C2, C1)
            self.tryAppend(rseg)


    def start_point(self):
        pl = self.getPolyline()
        return pl[0]

    def end_point(self):
        pl = self.getPolyline()
        return pl[-1]

    def dump(self):
        print('-----------------------------------------------------------------')
        for segment in self:
            C1 = segment.getC1()
            C2 = segment.getC2()
            (J1, I1) = divmod(C1, self.__grid.getNX() + 1)
            (J2, I2) = divmod(C2, self.__grid.getNX() + 1)
            print('[Corner:%5d IJ:(%3d,%d)] -> [Corner:%5d IJ:(%3d,%d)]'
                  % (C1, I1, J1, C2, I2, J2))


monkey_the_camel(FaultLine, 'tryAppend', FaultLine.try_append)
monkey_the_camel(FaultLine, 'getK', FaultLine.get_k)
monkey_the_camel(FaultLine, 'getPolyline', FaultLine.get_polyline)
monkey_the_camel(FaultLine, 'getIJPolyline', FaultLine.get_ij_polyline)
monkey_the_camel(FaultLine, 'getNeighborCells', FaultLine.get_neighbor_cells)
monkey_the_camel(FaultLine, 'startPoint', FaultLine.start_point)
monkey_the_camel(FaultLine, 'endPoint', FaultLine.end_point)
Exemplo n.º 26
0
                     seqnum_index=None,
                     report_step=None,
                     sim_time=None,
                     sim_days=None):
        if report_step is None:
            report_step = -1

        if sim_time is None:
            sim_time = -1

        if sim_days is None:
            sim_days = -1

        if seqnum_index is None:
            seqnum_index = -1

        view = self._restart_view(seqnum_index, report_step, CTime(sim_time),
                                  sim_days)
        if view is None:
            raise ValueError("No such restart block could be identiefied")

        view.setParent(parent=self)
        return view


monkey_the_camel(EclFileView, 'numKeywords', EclFileView.num_keywords)
monkey_the_camel(EclFileView, 'uniqueSize', EclFileView.unique_size)
monkey_the_camel(EclFileView, 'blockView2', EclFileView.block_view2)
monkey_the_camel(EclFileView, 'blockView', EclFileView.block_view)
monkey_the_camel(EclFileView, 'restartView', EclFileView.restart_view)
Exemplo n.º 27
0
    def global_copy(self):
        """Will return a EclKW copy with nx*ny*nz elements.

        The returned copy will be of type EclKW; i.e. no default
        interpolation and only linear access in the [] operator. The
        main purpose of this is to facilitate iteration over the
        global index, and for writing binary files.
        """
        return self.grid.globalKWCopy( self , self.getDefault() )



    def dims(self):
        return (self.grid.getNX() , self.grid.getNY() , self.grid.getNZ())


    def set_default(self, default_value):
        self.default_value = default_value


    def get_default(self):
        return self.default_value


monkey_the_camel(Ecl3DKW, 'castFromKW', Ecl3DKW.cast_from_kw, classmethod)
monkey_the_camel(Ecl3DKW, 'compressedCopy', Ecl3DKW.compressed_copy)
monkey_the_camel(Ecl3DKW, 'globalCopy', Ecl3DKW.global_copy)
monkey_the_camel(Ecl3DKW, 'setDefault', Ecl3DKW.set_default)
monkey_the_camel(Ecl3DKW, 'getDefault', Ecl3DKW.get_default)