From f75822ef4714603d7c5f06b1c952d7de106cdba9 Mon Sep 17 00:00:00 2001
From: David Robert Verelst <dave@dtu.dk>
Date: Mon, 11 Dec 2017 20:11:26 +0100
Subject: [PATCH] prepost.Simulations: files from df_stats for life time
 fatigue and AEP

---
 wetb/prepost/Simulations.py | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/wetb/prepost/Simulations.py b/wetb/prepost/Simulations.py
index 3ca38cd..0c15b8f 100755
--- a/wetb/prepost/Simulations.py
+++ b/wetb/prepost/Simulations.py
@@ -4720,6 +4720,8 @@ class Cases(object):
             sim_id = new_sim_id
 
         if fh_lst is None:
+            # FIXME: wb has overlap with dlc_config.xlsx, and shape_k doesn't
+            # seemed to be used by DLCHighLevel
             wb = WeibullParameters()
             if 'Weibull' in self.config:
                 for key in self.config['Weibull']:
@@ -4732,7 +4734,13 @@ class Cases(object):
                                        fail_on_resfile_not_found=True)
             # if you need all DLCs, make sure to have %s in the file name
             dlc_cfg.res_folder = os.path.join(run_dir, res_dir, dlc_folder)
-            fh_lst = dlc_cfg.file_hour_lst(years=years)
+            # no need to build list of result files, we already have it form
+            # the statistics analysis
+            # TODO: could be faster if working with df directly, but how to
+            # assure you're res_dir is always ending with path separator?
+            p1, p2 = dfs['[res_dir]'].values, dfs['[case_id]'].values
+            files = [os.path.join(q1, q2) + '.sel' for q1, q2 in zip(p1, p2)]
+            fh_lst = dlc_cfg.file_hour_lst(years=years, files=files)
 
         # now we have a full path to the result files, but we only need the
         # the case_id to indentify the corresponding entry from the statistics
@@ -4898,7 +4906,11 @@ class Cases(object):
             dlc_cfg = dlc.DLCHighLevel(fname, shape_k=wb.shape_k)
             # if you need all DLCs, make sure to have %s in the file name
             dlc_cfg.res_folder = os.path.join(run_dir, res_dir, dlc_folder)
-            fh_lst = dlc_cfg.file_hour_lst(years=1.0)
+            # TODO: could be faster if working with df directly, but how to
+            # assure you're res_dir is always ending with path separator?
+            p1, p2 = dfs['[res_dir]'].values, dfs['[case_id]'].values
+            files = [os.path.join(q1, q2) + '.sel' for q1, q2 in zip(p1, p2)]
+            fh_lst = dlc_cfg.file_hour_lst(years=1.0, files=files)
 
         # now we have a full path to the result files, but we only need the
         # the case_id to indentify the corresponding entry from the statistics
-- 
GitLab