From dc04124de025343e5dad8b8a0de9abe02448d46f Mon Sep 17 00:00:00 2001
From: Lionel GUEZ <guez@lmd.ens.fr>
Date: Wed, 3 Mar 2021 23:38:47 +0100
Subject: [PATCH] Do not re-compute `date_index`, just increment it

---
 Convert_Matlab/inst_eddies_v6.py | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/Convert_Matlab/inst_eddies_v6.py b/Convert_Matlab/inst_eddies_v6.py
index a90d74eb..dd6ef735 100755
--- a/Convert_Matlab/inst_eddies_v6.py
+++ b/Convert_Matlab/inst_eddies_v6.py
@@ -98,6 +98,8 @@ adt_file = sys.argv[1]
 dirname, basename = path.split(adt_file)
 my_date = parser.parse(basename, yearfirst=True, dayfirst = False,
                        fuzzy = True).date()
+date_index = my_date - datetime.date(1950, 1, 1)
+date_index = date_index.days
 
 if len(sys.argv) == 3:
     final_date = parser.parse(sys.argv[2], yearfirst=True, dayfirst = False)\
@@ -140,8 +142,6 @@ while True:
     # matlab_data is a dictionary.
 
     assert datetime.date.fromordinal(matlab_data["date_num"] - 366) == my_date
-    date_index = my_date - datetime.date(1950, 1, 1)
-    date_index = date_index.days
 
     for f in factories:
         write(f["writers"], matlab_data[f["cell_name"]], f["cyclone"])
@@ -149,6 +149,7 @@ while True:
     os.remove("adt.mat")
     my_date += datetime.timedelta(1)
     if my_date > final_date: break
+    date_index += 1
     basename = my_date.strftime("adt_%Y-%m-%d.mat")
     adt_file = path.join(dirname, basename)
     
-- 
GitLab