Skip to content

Commit

Permalink
Merge pull request #22 from onnela-lab/develop
Browse files Browse the repository at this point in the history
Update traj2stats.py >> ensure that it doesn't fail if the record is empty
  • Loading branch information
debeuker authored Apr 19, 2021
2 parents c797fdf + fe3c960 commit 76c426e
Showing 1 changed file with 10 additions and 15 deletions.
25 changes: 10 additions & 15 deletions forest/jasmine/traj2stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,18 +310,13 @@ def gps_stats_main(study_folder, output_folder, tz_str, option, save_traj, time_

logger.info("End")
## generate the record file together with logger and comm_logs.csv
record = pd.DataFrame(np.array(record), columns=['ID','start_stamp','start_year','start_month','start_day','start_hour','start_min','start_sec','end_stamp','end_year','end_month','end_day','end_hour','end_min','end_sec'])
record.to_csv(output_folder + "/record.csv",index=False)
## save all_memory_dict and all_BV_set
f = open(output_folder + "/all_memory_dict.pkl","wb")
pickle.dump(all_memory_dict,f)
f.close()
f = open(output_folder + "/all_BV_set.pkl","wb")
pickle.dump(all_BV_set,f)
f.close()
if os.path.exists(output_folder + "/log.csv")==True:
temp = pd.read_csv(output_folder + "/log.csv")
if temp.shape[0]==3:
print("Finished without any warning messages.")
else:
print("Finished. Please check log.csv for warning messages.")
if len(record)>0:
record = pd.DataFrame(np.array(record), columns=['ID','start_stamp','start_year','start_month','start_day','start_hour','start_min','start_sec','end_stamp','end_year','end_month','end_day','end_hour','end_min','end_sec'])
record.to_csv(output_folder + "/record.csv",index=False)
## save all_memory_dict and all_BV_set
f = open(output_folder + "/all_memory_dict.pkl","wb")
pickle.dump(all_memory_dict,f)
f.close()
f = open(output_folder + "/all_BV_set.pkl","wb")
pickle.dump(all_BV_set,f)
f.close()

0 comments on commit 76c426e

Please sign in to comment.