Skip to content
Snippets Groups Projects
Commit c66ee134 authored by Christopher Polster's avatar Christopher Polster
Browse files

Fixes

parent b2c75427
No related branches found
No related tags found
1 merge request!1Single- and Double Threshold Identification and Tracking
......@@ -2,13 +2,14 @@ from ..identification import IdentificationTechnique
from .processing import mask_to_proto, detection_double_thresh
import operator
import numpy as np
import xarray as xr
class DoubleThresholdIdentification(IdentificationTechnique):
def __init__(self, field, outer_threshold, inner_threshold,
comparison_operator, processing_mode="2d", compress=True, **kwargs):
def __init__(self, field, outer_threshold, inner_threshold, comparison_operator,
processing_mode="2d", compress=True, **kwargs):
self.field = field
self.outer_threshold = outer_threshold
self.inner_threshold = inner_threshold
......@@ -38,12 +39,12 @@ class DoubleThresholdIdentification(IdentificationTechnique):
return dataset
def identify(self, dataset: xr.Dataset, **kwargs):
field = dataset["field"].values
field = dataset[self.field].values
if self.processing_mode == "2d":
field = field.reshape((1,) + field.shape)
# TODO Start from which id? What happens when executed in parallel?
# TODO give operator to routine
ids, outer_features, inner_features = detection_double_thresh(
feature_id=0,
data=field,
......@@ -56,10 +57,13 @@ class DoubleThresholdIdentification(IdentificationTechnique):
obj_list = []
for id_ in ids:
# Feature 0 is the "no-feature feature"
if id_ == 0: continue
# get an instance of a new object, can pass an ID or set in manually afterwards
obj = self.get_new_object()
# set some ID to it
obj.id = id_
obj.id = id_ # TODO Needs offset? What happens when executed in parallel?
# get properties of object and populate them (like defined in template.proto)
properties = obj.properties
......
......@@ -19,7 +19,7 @@ def proto_to_mask(proto_obj):
@njit
def detection_double_thresh(feature_id, data, threshold, lower_threshold, entire_globe):
def detection_double_thresh(feature_id, data, lower_threshold, threshold, entire_globe):
# Find datapoint over upper thresh that trigger feature detection
upper_thresh_mask = data > threshold
......
......@@ -11,7 +11,7 @@ message MaskArray {
}
message Properties {
required MaskArray masks = 1;
required MaskArray mask = 1;
required float outer_threshold = 2;
required float inner_threshold = 3;
required string comparison_operator = 4;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment