Browse Source

Fix compton_combiner

There is found a problem. The first call of the combiner in the season with --only_last
flag uses the last measurement of the previous season. The fixing condition is added.
compton 2 years ago
parent
commit
c76557c817
1 changed files with 6 additions and 0 deletions
  1. 6 0
      compton_combiner.py

+ 6 - 0
compton_combiner.py

@@ -574,10 +574,16 @@ def main():
         if len(res_avg[0]) != 0:
             begintime = res_avg[0][0][res_avg[1].index("begintime")]
             runs_range = (begintime, None)
+            logging.info(f"only_last flag enabled. Time range for runs database is used: {runs_range}")
     
     res_rdb = rdb.load_tables(runs_range)
     runs_df = pd.DataFrame(res_rdb[0], columns=res_rdb[1])
     
+    if args.only_last:
+        # Remain the studied season only (important for the first averaging in the season with turned on only last flag)
+        start_season_run, stop_season_run = SEASONS['start_run'][idx], SEASONS['start_run'][idx+1] if SEASONS['start_run'][idx+1] else np.inf
+        runs_df = runs_df.query(f'(run>=@start_season_run)&(run<@stop_season_run)')
+    
     tdlt0 = timedelta(days=2)
     time_range = (runs_df.starttime.min() - tdlt0, runs_df.stoptime.max() + tdlt0)