In [1]:
%matplotlib inline

import sys,time,math
import numpy as np
import pandas as pd

import matplotlib.pyplot as plt
import pandas as pd

plt.rcParams['figure.figsize']=(8,9)
%config InlineBackend.figure_format="png"

from __future__ import print_function
from ipywidgets import interact, interactive, fixed, interact_manual
import ipywidgets as widgets
from scipy.interpolate import splprep, splev

import datetime

from scipy.signal import savgol_filter
import matplotlib as mpl

import mplleaflet

from bokeh.plotting import figure, output_notebook, show
from bokeh.tile_providers import STAMEN_TERRAIN
output_notebook()
Loading BokehJS ...
In [2]:
import geopandas as gp
from shapely.geometry import Point
In [3]:
path="/home/noel3/Dokumente/raspi-Sicherung-2018-11-25/logs/"
file_sweep="SWEEP-2018-11-25 14:58:10.717850.csv"

file_gps="GPS-2018-11-25 14:58:18.379819.csv"
In [4]:
dfs=pd.read_csv(path+file_sweep,header=None)
dfs.columns=["First","ANGLE","DIST","STRENGTH","timestamp"]
dfs["alpha"]=dfs.ANGLE*np.pi/180/1000.
len(dfs)
Out[4]:
425220
In [5]:
dfs["time_int"]=pd.to_numeric(pd.to_datetime(dfs.timestamp))
dfs["time_int"][dfs["time_int"]<0]=np.NaN
dfs["time_fill"]=dfs[["time_int"]].interpolate(method='linear')
/home/noel3/anaconda3/lib/python3.6/site-packages/ipykernel_launcher.py:2: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  
In [6]:
dfs["time"]=pd.to_datetime(dfs.time_fill)
In [7]:
dfs.head()
Out[7]:
First ANGLE DIST STRENGTH timestamp alpha time_int time_fill time
0 True 5375 132 199 2018-11-25 14:58:15.964572 0.093811 1.543158e+18 1.543158e+18 2018-11-25 14:58:15.964571904
1 False 5750 130 199 NaN 0.100356 NaN 1.543158e+18 2018-11-25 14:58:15.967394048
2 False 6187 130 199 NaN 0.107984 NaN 1.543158e+18 2018-11-25 14:58:15.970216192
3 False 6562 130 199 NaN 0.114529 NaN 1.543158e+18 2018-11-25 14:58:15.973038336
4 False 6937 130 199 NaN 0.121073 NaN 1.543158e+18 2018-11-25 14:58:15.975860736
In [8]:
dfs.dtypes
Out[8]:
First                  bool
ANGLE                 int64
DIST                  int64
STRENGTH              int64
timestamp            object
alpha               float64
time_int            float64
time_fill           float64
time         datetime64[ns]
dtype: object
In [9]:
dfs=dfs[dfs.DIST>1]
In [10]:
dfs.index=dfs["time"]
dfs.index=dfs.index+datetime.timedelta(seconds=0.1)
In [11]:
dfs[80000:81010];
In [12]:
plt.plot(dfs[0:1000].alpha.values,"x");
#plt.plot(df[50000:50400].DIST.values/100.);
In [ ]:
 
In [14]:
len(dfs)
Out[14]:
389065
In [15]:
fig=plt.figure(figsize=(8,9));
<matplotlib.figure.Figure at 0x7f22ec9d9cc0>
In [16]:
def plotpolar(von,bis):
    dff=dfs[von:von+bis]
    ax = plt.subplot(111, projection='polar')
    #ax.set_theta_direction(-1)
    #ax.scatter(np.pi+dff.ANGLE.values*np.pi/180/1000.,dff.DIST.astype(float).values,c=dff.STRENGTH.values/dff.DIST.astype(float).values**2,s=1.5)  #c=dff.STRENGTH.astype(float).values
    ax.plot(np.pi+dff.ANGLE.values*np.pi/180/1000.,dff.DIST.astype(float).values,alpha=0.5)#,marker="o")   #,c=dff.STRENGTH.values/dff.DIST.astype(float).values**2,s=1.5)  #c=dff.STRENGTH.astype(float).values
    #ax.set_theta_zero_location("N")
    ax.set_theta_zero_location("N")
    ax.set_rmax(800)
    ax.grid(True)
    plt.title("test"+str(dff.index[0]))
    plt.show();
    
In [17]:
interact(plotpolar, von=(0,len(dfs),500),bis=(0,500,10));
In [18]:
coords=pd.read_csv(path+file_gps,skiprows=5)
In [ ]:
 
In [19]:
coords.columns=["lat","lon","time"]
coords.index=pd.to_datetime(coords.time)
del coords["time"]
#coords.drop(coords.index[:1], inplace=True)
coords.head()
coords=coords[:-2]
In [20]:
fig=plt.figure()
plt.plot(coords.lon,coords.lat,".");
mplleaflet.display(fig=fig)
Out[20]: