Skip to content

Commit 790cc10

Browse files
committed
Add method to normalize longitude for network
1 parent 0e0b44f commit 790cc10

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

src/py_eddy_tracker/observations/network.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -542,6 +542,33 @@ def close_network(self, other, nb_obs_min=10, **kwargs):
542542
m[other.network_slice(i)] = True
543543
return other.extract_with_mask(m)
544544

545+
def normalize_longitude(self):
546+
"""Normalize all longitude
547+
548+
Normalize longitude field and in the same range :
549+
- longitude_max
550+
- contour_lon_e (how to do if in raw)
551+
- contour_lon_s (how to do if in raw)
552+
"""
553+
i_start, i_stop, _ = self.index_network
554+
lon0 = (self.lon[i_start] - 180).repeat(i_stop - i_start)
555+
logger.debug("Normalize longitude")
556+
self.lon[:] = (self.lon - lon0) % 360 + lon0
557+
if "lon_max" in self.obs.dtype.names:
558+
logger.debug("Normalize longitude_max")
559+
self.lon_max[:] = (self.lon_max - self.lon + 180) % 360 + self.lon - 180
560+
if not self.raw_data:
561+
if "contour_lon_e" in self.obs.dtype.names:
562+
logger.debug("Normalize effective contour longitude")
563+
self.contour_lon_e[:] = (
564+
(self.contour_lon_e.T - self.lon + 180) % 360 + self.lon - 180
565+
).T
566+
if "contour_lon_s" in self.obs.dtype.names:
567+
logger.debug("Normalize speed contour longitude")
568+
self.contour_lon_s[:] = (
569+
(self.contour_lon_s.T - self.lon + 180) % 360 + self.lon - 180
570+
).T
571+
545572
def numbering_segment(self, start=0):
546573
"""
547574
New numbering of segment

0 commit comments

Comments
 (0)