Skip to content

Commit 5751bb9

Browse files
add lifetime attr as item (AntSimi#37)
* add test for lifetime (item) * add lifetime as attribut (item)
1 parent 08f937c commit 5751bb9

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/py_eddy_tracker/observations/observation.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,8 @@ def __getitem__(self, attr: str):
288288
return self.obs[attr]
289289
elif attr in VAR_DESCR_inv:
290290
return self.obs[VAR_DESCR_inv[attr]]
291+
elif attr in ("lifetime", "age"):
292+
return getattr(self, attr)
291293
raise KeyError("%s unknown" % attr)
292294

293295
def __getattr__(self, attr):
@@ -1104,12 +1106,7 @@ def cost_function(records_in, records_out, distance):
11041106

11051107
def shifted_ellipsoid_degrees_mask(self, other, minor=1.5, major=1.5):
11061108
return shifted_ellipsoid_degrees_mask2(
1107-
self.lon,
1108-
self.lat,
1109-
other.lon,
1110-
other.lat,
1111-
minor,
1112-
major,
1109+
self.lon, self.lat, other.lon, other.lat, minor, major,
11131110
)
11141111

11151112
def fixed_ellipsoid_mask(

tests/test_track.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,6 @@ def test_area_tracking_parameter():
4545
c.to_netcdf(h)
4646
c_reloaded = Correspondances.from_netcdf(h)
4747
assert class_kw == c_reloaded.class_kw
48+
49+
# test access to the lifetime (item)
50+
eddies_tracked["lifetime"]

0 commit comments

Comments
 (0)