diff --git a/ThirdParty/Ert/devel/libecl/applications/esummary.c b/ThirdParty/Ert/devel/libecl/applications/esummary.c index 245123f780..98fcbb9ed0 100644 --- a/ThirdParty/Ert/devel/libecl/applications/esummary.c +++ b/ThirdParty/Ert/devel/libecl/applications/esummary.c @@ -84,7 +84,9 @@ int main(int argc , char ** argv) { time = time_union; else time = time_intersect; + vector_append_owned_ref( ecl_sum_list , ecl_sum , ecl_sum_free__ ); + load_count++; } else { const time_interval_type * ti = ecl_sum_get_sim_time( ecl_sum ); if (time_interval_has_overlap(time , ti)) { diff --git a/ThirdParty/Ert/devel/libecl/src/fortio.c b/ThirdParty/Ert/devel/libecl/src/fortio.c index 48dcfb0d6b..68dcdef697 100644 --- a/ThirdParty/Ert/devel/libecl/src/fortio.c +++ b/ThirdParty/Ert/devel/libecl/src/fortio.c @@ -494,7 +494,7 @@ void fortio_data_fseek(fortio_type* fortio, offset_type data_offset, size_t data int block_index = data_element / block_size; int headers = (block_index + 1) * 4; int trailers = block_index * 4; - int bytes_to_skip = data_offset + headers + trailers + (data_element * element_size); + offset_type bytes_to_skip = data_offset + headers + trailers + (data_element * element_size); fortio_fseek(fortio, bytes_to_skip, SEEK_SET); } diff --git a/ThirdParty/Ert/devel/libplot/src/plplot_driver.c b/ThirdParty/Ert/devel/libplot/src/plplot_driver.c index d37a8b5771..a4bab757ec 100644 --- a/ThirdParty/Ert/devel/libplot/src/plplot_driver.c +++ b/ThirdParty/Ert/devel/libplot/src/plplot_driver.c @@ -207,7 +207,7 @@ static void plplot_set_axis(plot_driver_type * driver , const plot_range_type * static void plplot_setup_linestyle( line_attribute_type line_attr ) { pllsty(line_attr.line_style); /* Setting solid/dashed/... */ - plwid(line_attr.line_width * PLOT_DEFAULT_LINE_WIDTH); /* Setting line width.*/ + plwidth(line_attr.line_width * PLOT_DEFAULT_LINE_WIDTH); /* Setting line width.*/ plcol0(line_attr.line_color); /* Setting line color. */ } diff --git a/ThirdParty/Ert/devel/python/python/ert/ecl/ecl_sum.py b/ThirdParty/Ert/devel/python/python/ert/ecl/ecl_sum.py index a74d379b8d..7fa1178d3e 100644 --- a/ThirdParty/Ert/devel/python/python/ert/ecl/ecl_sum.py +++ b/ThirdParty/Ert/devel/python/python/ert/ecl/ecl_sum.py @@ -394,7 +394,7 @@ def get_interp( self , key , days = None , date = None): raise ValueError("Must supply either days or date") - def timeRange(self , start = None , end = None , interval = "1Y"): + def timeRange(self , start = None , end = None , interval = "1Y", extend_end = True): (num , timeUnit) = TimeVector.parseTimeUnit( interval ) if start is None: @@ -418,26 +418,31 @@ def timeRange(self , start = None , end = None , interval = "1Y"): month2 = end.month day1 = start.day day2 = end.day - - if timeUnit == 'm': - if day2 > 1: - month2 += 1 - if month2 == 13: + if extend_end: + if timeUnit == 'm': + if day2 > 1: + month2 += 1 + if month2 == 13: + year2 += 1 + month2 = 1 + elif timeUnit == "y": + month1 = 1 + if year2 > 1 or day2 > 1: year2 += 1 month2 = 1 - elif timeUnit == "y": - month1 = 1 - if year2 > 1 or day2 > 1: - year2 += 1 - month2 = 1 day1 = 1 day2 = 1 + start = datetime.date( year1, month1 , day1) end = datetime.date(year2 , month2 , day2) trange = TimeVector.createRegular(start , end , interval) if trange[-1] < end: - trange.appendTime( num , timeUnit ) + if extend_end: + trange.appendTime( num , timeUnit ) + else: + trange.append( end ) + return trange diff --git a/ThirdParty/Ert/devel/python/python/ert/well/well_info.py b/ThirdParty/Ert/devel/python/python/ert/well/well_info.py index 937b142f67..61e4fdcba1 100644 --- a/ThirdParty/Ert/devel/python/python/ert/well/well_info.py +++ b/ThirdParty/Ert/devel/python/python/ert/well/well_info.py @@ -76,6 +76,10 @@ def addWellFile(self, rst_file, load_segment_information): raise TypeError("Expected the RST file to be a filename or an EclFile instance.") + def hasWell(self , well_name): + return well_name in self + + def free(self): WellInfo.cNamespace().free(self) diff --git a/ThirdParty/Ert/devel/python/python/ert/well/well_segment.py b/ThirdParty/Ert/devel/python/python/ert/well/well_segment.py index 21a38758b4..07fd72f525 100644 --- a/ThirdParty/Ert/devel/python/python/ert/well/well_segment.py +++ b/ThirdParty/Ert/devel/python/python/ert/well/well_segment.py @@ -9,6 +9,9 @@ def __init__(self): def free(self): pass + def __str__(self): + return "{Segment ID:%d BranchID:%d Length:%g}" % (self.id() , self.branchId() , self.length()) + def id(self): """ @rtype: int """ return WellSegment.cNamespace().id(self) diff --git a/ThirdParty/Ert/devel/python/python/ert/well/well_state.py b/ThirdParty/Ert/devel/python/python/ert/well/well_state.py index 694fbd79c4..5c0ceaa733 100644 --- a/ThirdParty/Ert/devel/python/python/ert/well/well_state.py +++ b/ThirdParty/Ert/devel/python/python/ert/well/well_state.py @@ -52,18 +52,38 @@ def globalConnections(self): return values + def numSegments(self): + """ @rtype: int """ + segment_collection = WellState.cNamespace().get_segment_collection(self) + count = WellState.cNamespace().segment_collection_size(segment_collection) + return count + + def segments(self): """ @rtype: list of WellSegment """ segment_collection = WellState.cNamespace().get_segment_collection(self) - count = WellState.cNamespace().segment_collection_size(segment_collection) values = [] - for index in range(count): + for index in range(self.numSegments()): value = WellState.cNamespace().segment_collection_iget(segment_collection, index).setParent(self) values.append(value) return values + + def igetSegment(self , segment_index): + """ @rtype: WellSegment """ + if segment_index < 0: + segment_index += len(self) + + if not 0 <= segment_index < self.numSegments(): + raise IndexError("Invalid index:%d - valid range [0,%d)" % (index , len(self))) + + segment_collection = WellState.cNamespace().get_segment_collection(self) + return WellState.cNamespace().segment_collection_iget(segment_collection, segment_index).setParent(self) + + + # def branches(self): # """ @rtype: BranchCollection """ diff --git a/ThirdParty/Ert/devel/python/python/ert/well/well_time_line.py b/ThirdParty/Ert/devel/python/python/ert/well/well_time_line.py index 22ec7f1cf3..05c57e7235 100644 --- a/ThirdParty/Ert/devel/python/python/ert/well/well_time_line.py +++ b/ThirdParty/Ert/devel/python/python/ert/well/well_time_line.py @@ -18,6 +18,9 @@ def __getitem__(self, index): @rtype: WellState """ + if index < 0: + index += len(self) + if not 0 <= index < len(self): raise IndexError("Index must be in range 0 <= %d < %d" % (index, len(self))) @@ -32,4 +35,4 @@ def free(self): WellTimeLine.cNamespace().size = cwrapper.prototype("int well_ts_get_size(well_time_line)") -WellTimeLine.cNamespace().iget = cwrapper.prototype("well_state_ref well_ts_iget_state(well_time_line, int)") \ No newline at end of file +WellTimeLine.cNamespace().iget = cwrapper.prototype("well_state_ref well_ts_iget_state(well_time_line, int)") diff --git a/ThirdParty/Ert/devel/python/test/CMakeLists.txt b/ThirdParty/Ert/devel/python/test/CMakeLists.txt index 00607d9c16..9b21ce7155 100644 --- a/ThirdParty/Ert/devel/python/test/CMakeLists.txt +++ b/ThirdParty/Ert/devel/python/test/CMakeLists.txt @@ -127,6 +127,7 @@ set(TEST_SOURCES ert_tests/server/test_socket.py ert_tests/well/test_ecl_well.py + ert_tests/well/test_ecl_well2.py ecl_isosurf.py ens_config_test.py @@ -445,6 +446,10 @@ add_test( NAME python.tests.ert.ecl.ecl_sum_vector WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} COMMAND ctest_run.py ${PROJECT_BINARY_DIR}/${PYTHON_INSTALL_PREFIX} ert_tests.ecl.test_ecl_sum_vector.EclSumVectorTest) +add_test( NAME python.tests.ert.ecl.ecl_sum_time_range + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + COMMAND ctest_run.py ${PROJECT_BINARY_DIR}/${PYTHON_INSTALL_PREFIX} ert_tests.ecl.test_ecl_sum.EclSumTest) + add_test( NAME python.tests.ert.ecl.layer WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} COMMAND ctest_run.py ${PROJECT_BINARY_DIR}/${PYTHON_INSTALL_PREFIX} ert_tests.ecl.test_layer.LayerTest ) @@ -601,6 +606,11 @@ add_test( NAME python.tests.ert.well.ecl_well COMMAND ctest_run.py ${PROJECT_BINARY_DIR}/${PYTHON_INSTALL_PREFIX} ert_tests.well.test_ecl_well.EclWellTest) +add_test( NAME python.tests.ert.well.ecl_well2 + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + COMMAND ctest_run.py ${PROJECT_BINARY_DIR}/${PYTHON_INSTALL_PREFIX} ert_tests.well.test_ecl_well2.EclWellTest2) + + set_property( TEST python.tests.ert.sched.sched PROPERTY LABELS Python:StatoilData ) set_property( TEST python.tests.ert.ecl.fortio PROPERTY LABELS Python:StatoilData ) set_property( TEST python.tests.ert.ecl.ecl_grdecl PROPERTY LABELS Python:StatoilData ) @@ -618,6 +628,7 @@ set_property( TEST python.tests.ert.ecl.ecl_grid PROPERTY LABELS Python set_property( TEST python.tests.ert.ecl.ecl_deprecation PROPERTY LABELS Python ) #set_property( TEST python.tests.import_local PROPERTY LABELS Python:StatoilBuild ) set_property( TEST python.tests.ert.well.ecl_well PROPERTY LABELS Python:StatoilData ) +set_property( TEST python.tests.ert.well.ecl_well2 PROPERTY LABELS Python:StatoilData ) set_property( TEST python.tests.ert.test_run PROPERTY LABELS Python) set_property( TEST python.tests.ert.import PROPERTY LABELS Python) @@ -639,6 +650,7 @@ set_property( TEST python.tests.ert.enkf.ert_test_context PROPERTY LABELS Py set_property( TEST python.tests.ert.enkf.plot.plot_block_data PROPERTY LABELS Python:StatoilData ) set_property( TEST python.tests.ert.enkf.data.gen_data_config PROPERTY LABELS Python:StatoilData ) set_property( TEST python.tests.ert.enkf.data.gen_data PROPERTY LABELS Python:StatoilData ) +set_property( TEST python.tests.ert.ecl.ecl_sum_time_range PROPERTY LABELS Python:StatoilData ) if (ERT_BUILD_GUI) set_property( TEST python.tests.ert_gui.import PROPERTY ENVIRONMENT "ERT_SHARE_PATH=${PROJECT_SOURCE_PATH}/share") diff --git a/ThirdParty/Ert/devel/python/test/ert_tests/ecl/test_ecl_sum.py b/ThirdParty/Ert/devel/python/test/ert_tests/ecl/test_ecl_sum.py new file mode 100644 index 0000000000..65ed92a699 --- /dev/null +++ b/ThirdParty/Ert/devel/python/test/ert_tests/ecl/test_ecl_sum.py @@ -0,0 +1,43 @@ +# !/usr/bin/env python +# Copyright (C) 2014 Statoil ASA, Norway. +# +# The file 'test_ecl_sum.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 EclSum +from ert.test import ExtendedTestCase + +try: + from unittest2 import skipIf +except ImportError: + from unittest import skipIf + +class EclSumTest(ExtendedTestCase): + def setUp(self): + self.test_file = self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE.SMSPEC") + self.ecl_sum = EclSum(self.test_file) + + def test_time_range_year(self): + real_range = self.ecl_sum.timeRange(interval="1y", extend_end = False) + extended_range = self.ecl_sum.timeRange(interval="1y", extend_end = True) + assert real_range[-1] < extended_range[-1] + + def test_time_range_day(self): + real_range = self.ecl_sum.timeRange(interval = "1d", extend_end = False) + extended_range = self.ecl_sum.timeRange(interval = "1d", extend_end = True) + assert real_range[-1] == extended_range[-1] + + def test_time_range_month(self): + real_range = self.ecl_sum.timeRange(interval = "1m", extend_end = False) + extended_range = self.ecl_sum.timeRange(interval = "1m", extend_end = True) + assert real_range[-1] < extended_range[-1] \ No newline at end of file diff --git a/ThirdParty/Ert/devel/python/test/ert_tests/well/test_ecl_well2.py b/ThirdParty/Ert/devel/python/test/ert_tests/well/test_ecl_well2.py new file mode 100644 index 0000000000..07a78629f7 --- /dev/null +++ b/ThirdParty/Ert/devel/python/test/ert_tests/well/test_ecl_well2.py @@ -0,0 +1,43 @@ +import datetime +import os.path + +from ert.ecl import EclGrid, EclFile, EclFileFlagEnum +from ert.test import ExtendedTestCase +from ert.util.ctime import CTime +from ert.well import WellInfo, WellConnection, WellTypeEnum, WellConnectionDirectionEnum, WellSegment + + + +class EclWellTest2(ExtendedTestCase): + grid = None + + + def getGrid(self): + if EclWellTest2.grid is None: + EclWellTest2.grid = EclGrid( self.createTestPath("Statoil/ECLIPSE/Troll/Ref2014/T07-4A-W2014-06.EGRID")) + + return EclWellTest2.grid + + + def checkWell(self , rst_file): + segment_length = [2660 , 20 , 121 , 1347.916 , 20.585 , 56.249 , 115.503 , 106.978 , 47.124 , 279.529, + 128.534 , 165.33 , 59.97 , 936.719 ] + + well_info = WellInfo( self.getGrid() , self.createTestPath( os.path.join("Statoil/ECLIPSE/Troll/Ref2014" , rst_file ))) + well_time_line = well_info["F4BYH"] + for well_state in well_time_line: + self.assertTrue( well_state.isMultiSegmentWell() ) + self.assertTrue( well_state.hasSegmentData() ) + + for index,length in enumerate(segment_length): + segment = well_state.igetSegment(index) + self.assertFloatEqual( segment.length() , length ) + + + + + def testWell(self): + self.checkWell("T07-4A-W2014-06.X0695") + self.checkWell("T07-4A-W2014-06.X0709") + self.checkWell("T07-4A-W2014-06.UNRST") +