From 651827bcc9a82f3e7dde621ceb236efcd1dd1107 Mon Sep 17 00:00:00 2001 From: Jean-Guy Nistad Date: Mon, 18 Mar 2024 13:26:50 +0100 Subject: [PATCH] Hypack profile exporter now exports to VEL Version 3 format. --- hyo2/ssm2/lib/formats/writers/hypack.py | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/hyo2/ssm2/lib/formats/writers/hypack.py b/hyo2/ssm2/lib/formats/writers/hypack.py index a8796c4a..a68a60ad 100644 --- a/hyo2/ssm2/lib/formats/writers/hypack.py +++ b/hyo2/ssm2/lib/formats/writers/hypack.py @@ -33,13 +33,31 @@ def _write_header(self): header = str() - header += "FTP NEW 2\n" - + # position + if not self.ssp.cur.meta.latitude or not self.ssp.cur.meta.longitude: + latitude = 0.0 + longitude = 0.0 + else: + latitude = self.ssp.cur.meta.latitude + longitude = self.ssp.cur.meta.longitude + while longitude > 180.0: + longitude -= 360.0 + + position_string = "{0:.9f} {1:.9f}".format(latitude, longitude) + + # date + if self.ssp.cur.meta.utc_time: + date_string = "%s" % self.ssp.cur.meta.utc_time.strftime("%H:%M %m/%d/%Y") + else: + date_string = "%s" % datetime.datetime.now().strftime("%H:%M %m/%d/%Y") + + header += "FTP NEW 3 " + position_string + " " + date_string + "\r\n" + self.fod.io.write(header) def _write_body(self): # logger.debug('generating body') vi = self.ssp.cur.proc_valid for idx in range(np.sum(vi)): - self.fod.io.write("%.1f %.1f\n" + self.fod.io.write("%.2f %.2f\r\n" % (self.ssp.cur.proc.depth[vi][idx], self.ssp.cur.proc.speed[vi][idx],))