Skip to content

Commit d18295a

Browse files
author
emason
committed
More fixes for TypeError: The numpy boolean negative
1 parent eab5ee1 commit d18295a

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

src/py_eddy_tracker/observations.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ def load_from_netcdf(cls, filename):
363363
return eddies
364364

365365
@staticmethod
366-
def cost_function(records_in, records_out, distance):
366+
def cost_function2(records_in, records_out, distance):
367367
nb_records = records_in.shape[0]
368368
costs = ma.empty(nb_records,dtype='f4')
369369
for i_record in xrange(nb_records):
@@ -390,8 +390,8 @@ def mask_function(self, other):
390390
return self.circle_mask(other, radius=125)
391391

392392
@staticmethod
393-
def cost_function2(records_in, records_out, distance):
394-
m = EddiesObservations.across_ground(records_in, records_out, distance)
393+
def cost_function(records_in, records_out, distance):
394+
#m = EddiesObservations.across_ground(records_in, records_out, distance)
395395
cost = ((records_in['amplitude'] - records_out['amplitude']
396396
) / records_in['amplitude']
397397
) ** 2
@@ -401,7 +401,7 @@ def cost_function2(records_in, records_out, distance):
401401
cost += (distance / 125) ** 2
402402
cost **= 0.5
403403
# Mask value superior at 60 % of variation
404-
return ma.array(cost, mask=m)
404+
#return ma.array(cost, mask=m)
405405
return cost
406406

407407
def circle_mask(self, other, radius=100):
@@ -502,7 +502,7 @@ def solve_conflict(cost):
502502

503503
@staticmethod
504504
def solve_simultaneous(cost):
505-
mask = -cost.mask
505+
mask = ~cost.mask
506506
# Count number of link by self obs and other obs
507507
self_links = mask.sum(axis=1)
508508
other_links = mask.sum(axis=0)
@@ -526,7 +526,7 @@ def solve_simultaneous(cost):
526526
# Cost to resolve conflict
527527
cost_reduce = cost[i_self_keep][:, i_other_keep]
528528
shape = cost_reduce.shape
529-
nb_conflict = (-cost_reduce.mask).sum()
529+
nb_conflict = (~cost_reduce.mask).sum()
530530
logging.debug('Shape conflict matrix : %s, %d conflicts', shape, nb_conflict)
531531

532532
if nb_conflict >= (shape[0] + shape[1]):
@@ -630,7 +630,7 @@ def tracking(self, other):
630630
dist[mask_accept_dist])
631631

632632
cost_mat = ma.empty(mask_accept_dist.shape, dtype='f4')
633-
cost_mat.mask = -mask_accept_dist
633+
cost_mat.mask = ~mask_accept_dist
634634
cost_mat[mask_accept_dist] = cost_values
635635

636636
i_self, i_other = self.solve_function(cost_mat)
@@ -720,8 +720,8 @@ def filled_by_interpolation(self, mask):
720720
var = field[0]
721721
if var in ['n', 'virtual', 'track'] or var in self.array_variables:
722722
continue
723-
self.obs[var][mask] = interp(index[mask], index[-mask],
724-
self.obs[var][-mask])
723+
self.obs[var][mask] = interp(index[mask], index[~mask],
724+
self.obs[var][~mask])
725725

726726
def extract_longer_eddies(self, nb_min, nb_obs, compress_id=True):
727727
"""Select eddies which are longer than nb_min

src/py_eddy_tracker/tracking.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,7 @@ def merge(self, until=-1):
447447
index_final = self.i_current_by_tracks[i_id]
448448

449449
# First obs of eddies
450-
m_first_obs = -first_obs_save_in_tracks[i_id]
450+
m_first_obs = ~first_obs_save_in_tracks[i_id]
451451
if m_first_obs.any():
452452
# Index in the previous file
453453
index_in = self[i]['in'][m_first_obs]

0 commit comments

Comments
 (0)