Execute function which adds new vector layer to the EOPatch

        :param eopatch: input EOPatch
        :type eopatch: EOPatch
        :return: New EOPatch with added vector layer
        :rtype: EOPatch
495165
def execute(self, eopatch):
        
        bbox_map = self._get_submap(eopatch)
        height, width = self._get_shape(eopatch)
        data_transform = rasterio.transform.from_bounds(*eopatch.bbox, width=width, height=height)

        if self.feature_name in eopatch[self.feature_type]:
            raster = eopatch[self.feature_type][self.feature_name].squeeze()
        else:
            raster = np.ones((height, width), dtype=self.raster_dtype) * self.no_data_value

        if not bbox_map.empty:
            rasterio.features.rasterize([(bbox_map.cascaded_union.buffer(0), self.raster_value)], out=raster,
                                        transform=data_transform, dtype=self.raster_dtype)

        eopatch[self.feature_type][self.feature_name] = raster[..., np.newaxis]

        return eopatch
985958
def execute(self, eopatch):
        
        self.check_params()
        self.get_params()

        new_eopatch = copy.deepcopy(eopatch)

        f_type, f_name = next(self.registration_feature(eopatch))
        sliced_data = copy.deepcopy(eopatch[f_type][f_name][..., self.channel])
        time_frames = sliced_data.shape[0]

        iflag = self._get_interpolation_flag(self.interpolation_type)

        for idx in range(time_frames - 1, 0, -1):  # Pair-wise registration starting from the most recent frame

            src_mask, trg_mask = None, None
            if self.valid_mask_feature is not None:
                f_type, f_name = next(self.valid_mask_feature(eopatch))
                src_mask = new_eopatch[f_type][f_name][idx - 1]
                trg_mask = new_eopatch[f_type][f_name][idx]

            # Estimate transformation
            warp_matrix = self.register(sliced_data[idx - 1], sliced_data[idx], src_mask=src_mask, trg_mask=trg_mask)

            # Check amount of deformation
            rflag = self.is_registration_suspicious(warp_matrix)

            # Flag suspicious registrations and set them to the identity
            if rflag:
                LOGGER.warning("{:s} warning in pair-wise reg {:d} to {:d}".format(self.__class__.__name__, idx - 1,
                                                                                   idx))
                warp_matrix = np.eye(2, 3)

            # Transform and update sliced_data
            sliced_data[idx - 1] = self.warp(warp_matrix, sliced_data[idx - 1], iflag)

            # Apply tranformation to every given feature
            for feature_type, feature_name in self.apply_to_features(eopatch):
                new_eopatch[feature_type][feature_name][idx - 1] = \
                    self.warp(warp_matrix, new_eopatch[feature_type][feature_name][idx - 1], iflag)

        return new_eopatch
958757
def addThreeLayers(self, inc, hidc, outc):
        
        self.addLayer('input', inc)
        self.addContextLayer('context', hidc, 'hidden')
        self.addLayer('hidden', hidc)
        self.addLayer('output', outc)
        self.connect('input', 'hidden')
        self.connect('context', 'hidden')
        self.connect('hidden', 'output')
1335310
def add_layer_item(self, layer):
        
        if not layer.is_draft_version:
            raise ValueError("Layer isn't a draft version")

        self.items.append(layer.latest_version)
1241698
def addContext(self, layer, hiddenLayerName = 'hidden', verbosity = 0):
        
        # better not add context layer first if using sweep() without mapInput
        SRN.add(self, layer, verbosity)
        if hiddenLayerName in self.contextLayers:
            raise KeyError('There is already a context layer associated with this hidden layer.', \
                             hiddenLayerName)
        else:
            self.contextLayers[hiddenLayerName] = layer
            layer.kind = 'Context'
721358
def execute(self, eopatch):
        
        for raster_ft, raster_fn, vector_fn in self.feature_gen(eopatch):
            vector_ft = FeatureType.VECTOR_TIMELESS if raster_ft.is_timeless() else FeatureType.VECTOR

            raster = eopatch[raster_ft][raster_fn]
            height, width = raster.shape[:2] if raster_ft.is_timeless() else raster.shape[1: 3]

            if self.raster_dtype:
                raster = raster.astype(self.raster_dtype)

            data_transform = rasterio.transform.from_bounds(*eopatch.bbox, width=width, height=height)

            crs = eopatch.bbox.get_crs()

            if raster_ft.is_timeless():
                eopatch[vector_ft][vector_fn] = self._vectorize_single_raster(raster, data_transform, crs)
            else:
                gpd_list = [self._vectorize_single_raster(raster[time_idx, ...], data_transform, crs,
                                                          timestamp=eopatch.timestamp[time_idx])
                            for time_idx in range(raster.shape[0])]

                eopatch[vector_ft][vector_fn] = GeoDataFrame(pd.concat(gpd_list, ignore_index=True),
                                                             crs=gpd_list[0].crs)

        return eopatch
183810
def create_pipeline(self, name, description, **kwargs):
		'''
		'''
		#req sanity check
		if not (name and description):
			return requests.codes.bad_request, None

		kwargs.update({'name':name, 'description':description})

		new_pl = StreakPipeline(**kwargs)
		uri = '/'.join([
						self.api_uri,
						self.pipelines_suffix
						])
		code, r_data = self._req('put', uri, new_pl.to_dict())
		
		return code, r_data
1112622
def hook(self, name):
        
        def wrapper(func):
            self.hooks.add(name, func)
            return func
        return wrapper
1154088
def execute(self, eopatch):
        
        # pylint: disable=too-many-locals
        feature_type, feature_name, new_feature_name = next(self.feature(eopatch))

        # Make a copy not to change original numpy array
        feature_data = eopatch[feature_type][feature_name].copy()
        time_num, height, width, band_num = feature_data.shape
        if time_num <= 1:
            raise ValueError('Feature {} has time dimension of size {}, required at least size '
                             '2'.format((feature_type, feature_name), time_num))

        # Apply a mask on data
        if self.mask_feature is not None:
            for mask_type, mask_name in self.mask_feature(eopatch):
                negated_mask = ~eopatch[mask_type][mask_name].astype(np.bool)
                feature_data = self._mask_feature_data(feature_data, negated_mask, mask_type)

        # Flatten array
        feature_data = np.reshape(feature_data, (time_num, height * width * band_num))

        # If resampling create new EOPatch
        new_eopatch = EOPatch() if self.resample_range else eopatch

        # Resample times
        times = eopatch.time_series(scale_time=self.scale_time)
        new_eopatch.timestamp = self.get_resampled_timestamp(eopatch.timestamp)
        total_diff = int((new_eopatch.timestamp[0].date() - eopatch.timestamp[0].date()).total_seconds())
        resampled_times = new_eopatch.time_series(scale_time=self.scale_time) + total_diff // self.scale_time

        # Add BBox to eopatch if it was created anew
        if new_eopatch.bbox is None:
            new_eopatch.bbox = eopatch.bbox

        # Replace duplicate acquisitions which have same values on the chosen time scale with their average
        feature_data, times = self._get_unique_times(feature_data, times)

        # Interpolate
        feature_data = self.interpolate_data(feature_data, times, resampled_times)

        # Normalize
        if self.result_interval:
            min_val, max_val = self.result_interval
            valid_mask = ~np.isnan(feature_data)
            feature_data[valid_mask] = np.maximum(np.minimum(feature_data[valid_mask], max_val), min_val)

        # Replace unknown value
        if not np.isnan(self.unknown_value):
            feature_data[np.isnan(feature_data)] = self.unknown_value

        # Reshape back
        new_eopatch[feature_type][new_feature_name] = np.reshape(feature_data,
                                                                 (feature_data.shape[0], height, width, band_num))

        # append features from old patch
        new_eopatch = self._copy_old_features(new_eopatch, eopatch, self.copy_features)

        return new_eopatch
509722
def new_action(self, method='GET', **kwargs):
        
        if method not in self.methods:
            raise TypeError('{} not in valid method(s): {}.'.format(method, self.methods))
        return Action(self, method, **kwargs)
1137686
def add(self, *args, **kwargs):
        
        return self._apply(operator.add, *args, **kwargs)
637993
def extend(self, elts):
        
        # Use a copy, not a reference, as it is later necessary to mutate
        # the proto field from which elts are drawn in order to construct
        # the bundled request.
        elts = elts[:]
        self._in_deque.append(elts)
        event = self._event_for(elts)
        self._event_deque.append(event)
        return event
11440
def execute(self, eopatch):
        
        feature_type, feature_name = next(self.feature(eopatch))

        good_idxs = self._get_filtered_indices(eopatch[feature_type][feature_name] if feature_name is not ... else
                                               eopatch[feature_type])

        for feature_type, feature_name in self.filter_features(eopatch):
            if feature_type.is_time_dependent():
                if feature_type.has_dict():
                    if feature_type.contains_ndarrays():
                        eopatch[feature_type][feature_name] = np.asarray([eopatch[feature_type][feature_name][idx] for
                                                                          idx in good_idxs])
                    # else:
                    #     NotImplemented
                else:
                    eopatch[feature_type] = [eopatch[feature_type][idx] for idx in good_idxs]

        self._update_other_data(eopatch)

        return eopatch
1046766
def execute(self, eopatch):
        
        if self.mask_data:
            valid_data_mask = eopatch.mask['VALID_DATA']
        else:
            valid_data_mask = eopatch.mask['IS_DATA']

        if self.data_index is None:
            data = eopatch.data[self.data_feature]
        else:
            data = eopatch.data[self.data_feature][..., self.data_index]

        madata = np.ma.array(data,
                             dtype=np.float32,
                             mask=~valid_data_mask.astype(np.bool))

        argmax_data = np.ma.MaskedArray.argmax(madata, axis=0)
        argmin_data = np.ma.MaskedArray.argmin(madata, axis=0)

        if argmax_data.ndim == 2:
            argmax_data = argmax_data.reshape(argmax_data.shape + (1,))

        if argmin_data.ndim == 2:
            argmin_data = argmin_data.reshape(argmin_data.shape + (1,))

        eopatch.data_timeless[self.amax_feature] = argmax_data
        eopatch.data_timeless[self.amin_feature] = argmin_data

        return eopatch
897671
def add_layer(self, layer):
        
        assert (
            isinstance(layer,
                       (TiledTileLayer, TiledImageLayer, TiledObjectGroup)))

        self.layers.append(layer)
        self.layernames[layer.name] = layer
692189
def start_import(self, layer_id, version_id):
        
        target_url = self.client.get_url('VERSION', 'POST', 'import', {'layer_id': layer_id, 'version_id': version_id})
        r = self.client.request('POST', target_url, json={})
        return self.create_from_result(r.json())
476572
def new_module(self):
        ''' 

        '''
        self.reset_run_errors()

        if self._code is None:
            return None

        module_name = 'bk_script_' + make_id().replace('-', '')
        module = ModuleType(str(module_name)) # str needed for py2.7
        module.__dict__['__file__'] = os.path.abspath(self._path)

        return module