Exemplo n.º 1
0
    def __convertDate(self, ert_time):
        """Convert normal dates to matplotlib dates."""
        if ert_time is None:
            ert_time = erttypes.time_t(0)

        if isinstance(ert_time, datetime.date):
            return matplotlib.dates.date2num(ert_time)
        else:
            return matplotlib.dates.date2num(ert_time.datetime())
Exemplo n.º 2
0
    def __convertDate(self, ert_time):
        """Convert normal dates to matplotlib dates."""
        if ert_time is None:
            ert_time = erttypes.time_t(0)

        if isinstance(ert_time, datetime.date):
            return matplotlib.dates.date2num(ert_time)
        else:
            return matplotlib.dates.date2num(ert_time.datetime())
Exemplo n.º 3
0
    def getMaxXLimit(self, x_max, data_type):
        """Returns the provided x_max value if the internal x_max value is None. Converts dates to numbers"""
        if self._x_limits[1] is None:
            x_limit = x_max
        else:
            x_limit = self._x_limits[1]

        if not x_limit is None and data_type == "time" and not isinstance(x_limit, time_t):
            x_limit = time_t(long(round(x_limit)))

        return x_limit
Exemplo n.º 4
0
    def getMaxXLimit(self, x_max, data_type):
        """Returns the provided x_max value if the internal x_max value is None. Converts dates to numbers"""
        if self._x_limits[1] is None:
            x_limit = x_max
        else:
            x_limit = self._x_limits[1]

        if not x_limit is None and data_type == "time" and not isinstance(x_limit, time_t):
            x_limit = time_t(long(round(x_limit)))

        return x_limit
Exemplo n.º 5
0
    def fetch(self, ert, key, parameter, data, comparison_fs):
        data.x_data_type = "time"
        fs = ert.main.get_fs
        config_node = ert.main.ensemble_config.get_node(key)
        node = config_node.alloc_node
        comp_node = config_node.alloc_node
        num_realizations = ert.main.ens_size
        var_type_set = False
        user_data = parameter.getUserData()
        if user_data is None:
            return False

        key_index = None
        if user_data.has_key("key_index"):
            key_index = user_data["key_index"]

        if parameter.getType() == FieldModel.TYPE:
            var_type = enums.enkf_var_type.PARAMETER
            var_type_set = True
            field_position = user_data["field_position"]
            field_config = config_node.field_model
            if field_config.ijk_active(field_position[0] - 1, field_position[1] - 1, field_position[2] - 1):
                key_index = "%i,%i,%i" % (field_position[0], field_position[1], field_position[2])
                data.setKeyIndexIsIndex(True)
            else:
                return False

        elif parameter.getType() == DataModel.TYPE:
            var_type = enums.enkf_var_type.PARAMETER
            var_type_set = True
            data_index = user_data["data_index"]
            key_index = "KEY:%d" % data_index
            data.setKeyIndexIsIndex(True)

        if not var_type_set:
            var_type = enums.enkf_var_type.DYNAMIC_RESULT

        data.setKeyIndex(key_index)
        state_list = [user_data["state"]]
        if state_list[0] == enums.ert_state_enum.BOTH:
            state_list = [enums.ert_state_enum.FORECAST, enums.ert_state_enum.ANALYZED]

        for member in range(0, num_realizations):
            data.x_data[member] = []
            data.y_data[member] = []
            x_time = data.x_data[member]
            y = data.y_data[member]

            if not comparison_fs is None:
                data.x_comp_data[member] = []
                data.y_comp_data[member] = []
                x_comp_time = data.x_comp_data[member]
                y_comp = data.y_comp_data[member]

            stop_time = ert.main.get_history_length

            for state in state_list:
                start_time = 0
                if config_node.get_impl_type == SummaryModel.TYPE:
                    start_time = 1
                for step in range(start_time, stop_time):
                    time_map = fs.get_time_map
                    sim_time_as_c_int = time_map.iget(step)
                    sim_time_as_time_t = time_t(sim_time_as_c_int)
                    sim_time_as_ordinal = sim_time_as_time_t.datetime().toordinal()
                    valid = ertwrapper.c_double()
                    value = node.user_get(fs, key_index, step, member, state.value(), ertwrapper.byref(valid))
                    if value == True:
                        data.checkMaxMin(sim_time_as_time_t)
                        data.checkMaxMinY(valid.value)
                        x_time.append(sim_time_as_ordinal)
                        y.append(valid.value)
                    # else:
                    # print "Not valid: ", key, member, step, key_index, value, state.value()

                    if not comparison_fs is None:
                        time_map = comparison_fs.get_time_map
                        sim_time_as_c_int = time_map.iget(step)
                        sim_time_as_time_t = time_t(sim_time_as_c_int)
                        sim_time_as_ordinal = sim_time_as_time_t.datetime().toordinal()
                        valid = ertwrapper.c_double()
                        value = node.user_get(comparison_fs, key, step, member, state.value(), ertwrapper.byref(valid))
                        if value == 1:
                            data.checkMaxMin(sim_time_as_time_t)
                            data.checkMaxMinY(valid.value)
                            x_comp_time.append(sim_time_as_ordinal)
                            y_comp.append(valid.value)
                        # else:
                        #    print "Not valid: ", key, member, step, key_index

            data.x_data[member] = numpy.array(x_time)  # [t.datetime() for t in x_time])
            data.y_data[member] = numpy.array(y)

            if not comparison_fs is None:
                data.x_comp_data[member] = numpy.array(x_comp_time)  # [t.datetime() for t in x_comp_time])
                data.y_comp_data[member] = numpy.array(y_comp)

        self._getObservations(ert, key, key_index, data)

        self._getRefCase(ert, key, data)

        # node.__del__
        # comp_node.__del__

        data.inverted_y_axis = False