Skip to content

Commit

Permalink
Adding functionality to save drivecycle including cumulative distance…
Browse files Browse the repository at this point in the history
… traveled
  • Loading branch information
Danika MacDonell authored and Danika MacDonell committed Mar 19, 2024
1 parent 1f1dad4 commit aea5229
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions source/AnalyzeData.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
DISTANCE_UNCERTAINTY = 2.5*np.sqrt(2)/1600. # Distance measurement uncertainty (from https://community.geotab.com/s/article/How-does-the-GO-device-evaluate-coordinates?language=en_US)
KM_PER_MILE = 1.60934
DAYS_PER_MONTH = 30.437
METERS_PER_MILE = 1609.34

def get_top_dir():
'''
Expand Down Expand Up @@ -326,7 +327,7 @@ def draw_binned_step(binned_data, linecolor='red', linelabel='', linewidth=2):
############################################################################################################
"""


"""
############################ Analysis of actual driving range and battery energy ###########################
######### Add activity, driving and charging events to dataframes #########
Expand Down Expand Up @@ -664,9 +665,9 @@ def draw_binned_step(binned_data, linecolor='red', linelabel='', linewidth=2):
plt.savefig(f'{top_dir}/plots/{name}_charging_summary.pdf')
###################################################################
"""



"""
################ Drivecycle and extrapolated range ################
# Read in saved csv file with battery capacities
Expand Down Expand Up @@ -817,7 +818,7 @@ def draw_binned_step(binned_data, linecolor='red', linelabel='', linewidth=2):
plt.savefig(f'{top_dir}/plots/{name}_range_summary.pdf')
###################################################################

"""

########################## Drive Cycle ##########################
for name in names:
Expand Down Expand Up @@ -913,6 +914,12 @@ def draw_binned_step(binned_data, linecolor='red', linelabel='', linewidth=2):
# Save to a csv file
drive_cycle_df.to_csv(f'{top_dir}/tables/{name}_drive_cycle_{driving_event}.csv', header=['Time (s)', 'Vehicle speed (km/h)', 'Road grade (%)'], index=False)

# Add in the accumulated distance since the start of the drivecycle
drive_cycle_df['accumulated_distance'] = (data_df_event['accumulated_distance'] - data_df_event['accumulated_distance'].iloc[0]) * METERS_PER_MILE

# Save to a csv file
drive_cycle_df.to_csv(f'{top_dir}/tables/{name}_drive_cycle_{driving_event}_with_distance.csv', header=['Time (s)', 'Vehicle speed (km/h)', 'Road grade (%)', 'Cumulative distance (m)'], index=False)

#################################################################


Expand Down

0 comments on commit aea5229

Please sign in to comment.