Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add count of neighboring cells #56

Draft
wants to merge 1 commit into
base: v2.0-dev
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions tobac/themes/tint/objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,20 @@ def check_isolation(raw, filtered, grid_size, params):
params['ISO_THRESH'])
nobj_iso = np.max(iso_filtered)
iso = np.empty(nobj, dtype='bool')
neighbors = np.ones(nobj)*(-9999)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this set to -9999? I'm not that familiar with the tint code yet, so if there's something obvious, let me know. Trying to figure out missing data vs. 0 neighbors; is this better as 0?


for iso_id in np.arange(nobj_iso) + 1:
obj_ind = np.where(iso_filtered == iso_id)
objects = np.unique(filtered[obj_ind])
objects = objects[objects != 0]


obj_count = len(objects)
neighbors[objects-1] = obj_count-1
if len(objects) == 1 and single_max(obj_ind, raw, params):
iso[objects - 1] = True
else:
iso[objects - 1] = False
return iso
return iso, neighbors


def get_obj_extent(labeled_image, obj_label):
Expand Down Expand Up @@ -211,7 +214,7 @@ def get_object_prop(image1, grid1, field, record, params):
volume.append(np.nan)
field_max.append(np.max(obj_slices))
# cell isolation
isolation = check_isolation(raw3D, image1, record.grid_size, params)
isolation, neighborhood = check_isolation(raw3D, image1, record.grid_size, params)

objprop = {'id1': id1,
'center': center,
Expand All @@ -223,7 +226,8 @@ def get_object_prop(image1, grid1, field, record, params):
'volume': volume,
'lon': longitude,
'lat': latitude,
'isolated': isolation}
'isolated': isolation,
'neighborhood': neighborhood}
return objprop


Expand All @@ -247,7 +251,8 @@ def write_tracks(old_tracks, record, current_objects, obj_props):
'vol': obj_props['volume'],
'max': obj_props['field_max'],
'max_alt': obj_props['max_height'],
'isolated': obj_props['isolated']
'isolated': obj_props['isolated'],
'neighborhood': obj_props['neighborhood']
})
new_tracks.set_index(['scan'], inplace=True)
tracks = old_tracks.append(new_tracks)
Expand Down