Skip to content

Commit

Permalink
fix scale of longitude/latitude on 3d plot
Browse files Browse the repository at this point in the history
  • Loading branch information
MedadRufus committed Jun 8, 2021
1 parent 949f5fc commit 25a270b
Showing 1 changed file with 23 additions and 8 deletions.
31 changes: 23 additions & 8 deletions Bike_logger/Data_analysis/analyse_ebike_blackbox_data.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,7 @@
"\n",
" df_baro['Barometric Altitude (m)'] = df_baro.apply(lambda x: get_altitude(x['Pressure (mbar)'], x['temperature (°C)']), axis=1)\n",
" \n",
" df_baro = df_baro[df_baro['Barometric Altitude (m)'] > -10] # Filter out unrealistic pressures\n",
" df_baro = df_baro[df_baro['Barometric Altitude (m)'] > -30] # Filter out unrealistic pressures\n",
" \n",
" df_baro['Barometric Altitude Filtered (m)'] = signal_filter(df_baro['Barometric Altitude (m)'], highcut=10, method='butterworth_ba', order=2)\n",
"\n",
Expand Down Expand Up @@ -829,6 +829,14 @@
" width=2\n",
" ),\n",
" ))\n",
" \n",
" # Fix long lat scale here: https://stackoverflow.com/a/39540339/13737285\n",
" \n",
" current_latitude = 52 # approximately london\n",
"\n",
" latitude_km = 111.32\n",
" longitude_km = 40075 * np.cos( np.deg2rad(current_latitude) ) / 360\n",
" \n",
"\n",
" fig.update_layout(\n",
" width=800,\n",
Expand All @@ -838,6 +846,7 @@
" xaxis = dict(title='Longitude (°)'),\n",
" yaxis = dict(title='Latitude (°)'),\n",
" zaxis = dict(title='Barometric Altitude Filtered (m)'),\n",
" aspectratio=dict(x=latitude_km/longitude_km, y=1, z=1)\n",
" ),\n",
" )\n",
"\n",
Expand Down Expand Up @@ -1312,12 +1321,13 @@
" fig = px.line_mapbox(df_gps,\n",
" lat=df_gps[lat_feature],\n",
" lon=df_gps[long_feature],\n",
" color='Test Number',#'Test-Train',#\"GPS Horizontal Speed (km/h)\",#\"trip\",#\"slope\",#\"LOCATION Altitude ( m)\",,#\"Speed(km/h)\", # \"abs_acceleration\" or \"gps_acceleration\" or \"power\"\n",
" #color='Test Number',#'Test-Train',#\"GPS Horizontal Speed (km/h)\",#\"trip\",#\"slope\",#\"LOCATION Altitude ( m)\",,#\"Speed(km/h)\", # \"abs_acceleration\" or \"gps_acceleration\" or \"power\"\n",
" zoom=14,\n",
" hover_data=[#'Datetime (UTC)',\n",
" 'GPS altitude (m)',\n",
" #\"sats\",\n",
" 'heading (radians)'\n",
" \n",
" ],\n",
" title=\"Training and Testing Routes in dataset\",\n",
" #size=\"LOCATION Accuracy ( m)\"\n",
Expand Down Expand Up @@ -1362,14 +1372,19 @@
"metadata": {},
"outputs": [],
"source": [
"\n",
"split_into_n_minute_tests(600, 0.01, df_ml_test)\n",
"df_ml_train.loc[:, 'Test Number'] = 'Training'\n",
"df_ml = pd.concat([df_ml_train, df_ml_test])\n",
"\n",
"\n",
"#display_gps_positions(raw_dfs[1]) # df_gps is index 1 TODO: don't use indexes. use labels for readiblity\n",
"display_gps_positions(df_ml.sample(100000)) # df_gps is index 1 TODO: don't use indexes. use labels for readiblity"
"df_ml = pd.concat([df_ml_train, df_ml_test])"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"display_gps_positions(raw_dfs[1]) # df_gps is index 1 TODO: don't use indexes. use labels for readiblity\n",
"# display_gps_positions(df_ml.sample(100000)) # df_gps is index 1 TODO: don't use indexes. use labels for readiblity"
]
},
{
Expand Down

0 comments on commit 25a270b

Please sign in to comment.