flightplotting 0.1.1__tar.gz → 0.1.3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (21) hide show
  1. {flightplotting-0.1.1/flightplotting.egg-info → flightplotting-0.1.3}/PKG-INFO +1 -1
  2. flightplotting-0.1.3/flightplotting/__init__.py +4 -0
  3. {flightplotting-0.1.1 → flightplotting-0.1.3}/flightplotting/plots.py +31 -24
  4. {flightplotting-0.1.1 → flightplotting-0.1.3}/flightplotting/traces.py +26 -24
  5. {flightplotting-0.1.1 → flightplotting-0.1.3/flightplotting.egg-info}/PKG-INFO +1 -1
  6. {flightplotting-0.1.1 → flightplotting-0.1.3}/setup.cfg +1 -1
  7. flightplotting-0.1.1/flightplotting/__init__.py +0 -3
  8. {flightplotting-0.1.1 → flightplotting-0.1.3}/COPYING +0 -0
  9. {flightplotting-0.1.1 → flightplotting-0.1.3}/MANIFEST.in +0 -0
  10. {flightplotting-0.1.1 → flightplotting-0.1.3}/README.md +0 -0
  11. {flightplotting-0.1.1 → flightplotting-0.1.3}/flightplotting/data/ColdDraftF3APlane.obj +0 -0
  12. {flightplotting-0.1.1 → flightplotting-0.1.3}/flightplotting/data/__init__.py +0 -0
  13. {flightplotting-0.1.1 → flightplotting-0.1.3}/flightplotting/model.py +0 -0
  14. {flightplotting-0.1.1 → flightplotting-0.1.3}/flightplotting/templates.py +0 -0
  15. {flightplotting-0.1.1 → flightplotting-0.1.3}/flightplotting/titlerenderer.py +0 -0
  16. {flightplotting-0.1.1 → flightplotting-0.1.3}/flightplotting.egg-info/SOURCES.txt +0 -0
  17. {flightplotting-0.1.1 → flightplotting-0.1.3}/flightplotting.egg-info/dependency_links.txt +0 -0
  18. {flightplotting-0.1.1 → flightplotting-0.1.3}/flightplotting.egg-info/requires.txt +0 -0
  19. {flightplotting-0.1.1 → flightplotting-0.1.3}/flightplotting.egg-info/top_level.txt +0 -0
  20. {flightplotting-0.1.1 → flightplotting-0.1.3}/setup.py +0 -0
  21. {flightplotting-0.1.1 → flightplotting-0.1.3}/tests/test_traces.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: flightplotting
3
- Version: 0.1.1
3
+ Version: 0.1.3
4
4
  Summary: Tools for Plotting Flight Data in Plotly
5
5
  Home-page: https://github.com/PyFlightCoach/FlightPlotting
6
6
  Author: Thomas David
@@ -0,0 +1,4 @@
1
+
2
+
3
+ from flightplotting.plots import plotsec, plot_analysis, plotdtw, create_3d_plot
4
+ from flightplotting.traces import axestrace, trace3d, dtwtrace, vector, vectors
@@ -12,28 +12,41 @@ from flightplotting.traces import (
12
12
  control_inputs,
13
13
  cgtrace,
14
14
  ribbon,
15
- vectors
15
+ vectors,
16
+ axestrace
16
17
  )
17
18
 
18
19
  from flightanalysis import State, Manoeuvre
20
+ from geometry import Coord
19
21
  from flightplotting.model import obj, OBJ
22
+ from flightanalysis import State
20
23
  import numpy as np
24
+ from typing import List, Union
21
25
 
22
26
 
23
- def plotsec(sec, scale=5, nmodels=0, fig=None, color="orange", obj: OBJ=obj, cg=False, width=None, height=None, show_axes=False, ribb: bool=False, tips: bool=True):
24
- text = ["{:.1f}".format(val) for val in sec.data.index]
27
+ def plotsec(secs: Union[State, list[State]], scale=5, nmodels=0, fig=None,
28
+ color: Union[str, list[str]]=None, obj: OBJ=obj, cg=False, width=None,
29
+ height=None, show_axes=False, ribb: bool=False, tips: bool=True, origin=False):
30
+
25
31
  traces = []
26
- if ribb:
27
- traces += ribbon(sec, scale * 1.85, color)
28
-
29
- if tips:
30
- traces += tiptrace(sec, scale * 1.85, text=text)
31
-
32
- if nmodels > 0:
33
- traces += meshes(nmodels, sec, color, obj.scale(scale))
34
32
 
35
- if cg:
36
- traces += cgtrace(sec, text=text)
33
+ if isinstance(secs, State):
34
+ secs = [secs]
35
+
36
+ for i, sec in enumerate(secs):
37
+ text = ["{:.1f}".format(val) for val in sec.data.index]
38
+ _color = color if not color is None else px.colors.qualitative.Plotly[i]
39
+ if ribb:
40
+ traces += ribbon(sec, scale * 1.85, _color)
41
+ if tips:
42
+ traces += tiptrace(sec, scale * 1.85, text=text)
43
+ if nmodels > 0:
44
+ traces += meshes(nmodels, sec, _color, obj.scale(scale))
45
+ if cg:
46
+ traces += cgtrace(sec, text=text, color=_color)
47
+
48
+ if origin:
49
+ traces += axestrace(Coord.zero(), 50)
37
50
 
38
51
  if fig is None:
39
52
 
@@ -60,21 +73,15 @@ def plotsec(sec, scale=5, nmodels=0, fig=None, color="orange", obj: OBJ=obj, cg=
60
73
 
61
74
 
62
75
 
63
- def plotdtw(sec: State, manoeuvres, span=3):
76
+ def plotdtw(sec: State, manoeuvres: List[str], span=3):
64
77
  fig = go.Figure()
65
78
 
66
79
  traces = []#tiptrace(sec, span)
67
80
 
68
- for i, man in enumerate(manoeuvres):
69
- name = f"el {i}"
70
- if hasattr(man, 'name'):
71
- name=man.name
72
- elif hasattr(man, "uid"):
73
- name = man.uid
74
-
81
+ for i, name in enumerate(manoeuvres):
75
82
  try:
76
- seg = man.get_data(sec)
77
-
83
+ seg = sec.get_man_or_el(name)
84
+
78
85
  traces += ribbon(seg, span, px.colors.qualitative.Alphabet[i], name)
79
86
 
80
87
  traces.append(go.Scatter3d(
@@ -90,7 +97,7 @@ def plotdtw(sec: State, manoeuvres, span=3):
90
97
  print("no data for manoeuvre {}, {}".format(name, ex))
91
98
  fig = go.Figure(
92
99
  data=traces,
93
- layout=go.Layout(template="flight3d+judge_view")
100
+ layout=go.Layout(template="flight3d+judge_view"),
94
101
  )
95
102
 
96
103
  return fig
@@ -27,10 +27,19 @@ def boxtrace():
27
27
  )]
28
28
 
29
29
 
30
- def meshes(npoints, seq, colour, obj: OBJ=obj):
31
- step = int(len(seq.data) / (npoints+1))
30
+ def meshes(npoints, seq: State, colour, obj: OBJ=obj):
31
+ step = int(len(seq.data) / max(npoints, 1))
32
32
 
33
- return [obj.transform(Transformation(st.pos, st.att)).create_mesh(colour,f"{st.time.t[0]:.1f}") for st in seq[::step]]
33
+ ms = []
34
+
35
+ sts = [seq[0]] + [ st for st in seq[::step]] + [seq[-1]]
36
+ for st in sts:
37
+ ms.append(obj.transform(Transformation(st.pos, st.att)).create_mesh(colour,f"{st.time.t[0]:.1f}"))
38
+ return ms
39
+
40
+ def vector(origin, direction, **kwargs):
41
+ pdata = Point.concatenate([origin, origin+direction])
42
+ return trace3d(*pdata.data.T, **kwargs)
34
43
 
35
44
 
36
45
  def vectors(npoints: int, seq: State, vectors: Point, **kwargs):
@@ -38,7 +47,7 @@ def vectors(npoints: int, seq: State, vectors: Point, **kwargs):
38
47
  step = int(len(seq.data) / (npoints+1))
39
48
  for pos, wind in zip(seq.pos[::step], vectors[::step]):
40
49
  pdata = Point.concatenate([pos, pos+wind])
41
- trs.append(trace3d(*pdata.data.T, **kwargs))
50
+ trs.append(trace3d(*pdata.data.T, text=abs(vectors), **kwargs))
42
51
  return trs
43
52
 
44
53
 
@@ -161,9 +170,6 @@ def axis_rate_trace(sec, dash="solid", colours = px.colors.qualitative.Plotly):
161
170
 
162
171
 
163
172
 
164
-
165
-
166
-
167
173
  control_inputs = ["aileron_1", "aileron_2", "elevator", "rudder", "throttle"]
168
174
 
169
175
  def control_input_trace(sec, dash="solid", colours = px.colors.qualitative.Plotly, control_inputs = None):
@@ -176,24 +182,21 @@ def aoa_trace(sec, dash="dash", colours = px.colors.qualitative.Plotly):
176
182
  #sec = sec.append_columns(sec.aoa())
177
183
  return sec_col_trace(sec, ["alpha", "beta"], dash, colours, np.degrees)
178
184
 
179
- def _axistrace(cid: Coord, length:float=20.0):
185
+ def axestrace(cid: Coord, length:float=20.0):
180
186
  ntraces = []
181
187
  colours = {"x":"red", "y":"blue", "z":"green"}
182
- for ax, col in zip([cid.x_axis, cid.y_axis, cid.z_axis], list("xyz")):
183
- axis = Point.concatenate([cid.origin, cid.origin + ax * length])
184
- ntraces.append(go.Scatter3d(
185
- x=axis.x, y=axis.y, z=axis.z, mode="lines",
186
- line=dict(color=colours[col]),
187
- name=col
188
- ))
188
+ for i, ci in enumerate(cid):
189
+ for ax, col in zip([ci.x_axis, ci.y_axis, ci.z_axis], list("xyz")):
190
+ axis = Point.concatenate([ci.origin, ci.origin + ax * length])
191
+ ntraces.append(go.Scatter3d(
192
+ x=axis.x, y=axis.y, z=axis.z, mode="lines",
193
+ line=dict(color=colours[col]),
194
+ name=col,
195
+ showlegend=True if i==0 else False
196
+ ))
189
197
 
190
198
  return ntraces
191
199
 
192
- def axestrace(cids: Union[Coord, List[Coord]]):
193
- if isinstance(cids, List):
194
- return [_axistrace(cid) for cid in cids]
195
- elif isinstance(cids, Coord):
196
- return _axistrace(cids)
197
200
 
198
201
 
199
202
 
@@ -238,8 +241,8 @@ def ribbon(sec: State, span: float, color: str, name="none"):
238
241
 
239
242
  points = Point(_npinterzip(left.data, right.data))
240
243
 
241
- triids = np.array(range(len(points) - 2))
242
- _i = triids # 1 2 3 4 5
244
+
245
+ _i = np.array(range(len(points) - 2)) # 1 2 3 4 5
243
246
 
244
247
  _js = np.array(range(1, len(points), 2))
245
248
  _j = _npinterzip(_js, _js)[1:-1] # 1 3 3 4 4 5
@@ -251,7 +254,6 @@ def ribbon(sec: State, span: float, color: str, name="none"):
251
254
  return [go.Mesh3d(
252
255
  x=points.x, y=points.y, z=points.z, i=_i, j=_j, k=_k,
253
256
  intensitymode="cell",
254
- facecolor=np.full(len(triids), color),
255
- #hoverinfo=name,
257
+ facecolor=np.full(len(_i), color),
256
258
  name=name,
257
259
  )]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: flightplotting
3
- Version: 0.1.1
3
+ Version: 0.1.3
4
4
  Summary: Tools for Plotting Flight Data in Plotly
5
5
  Home-page: https://github.com/PyFlightCoach/FlightPlotting
6
6
  Author: Thomas David
@@ -5,7 +5,7 @@ author_email = thomasdavid0@gmail.com
5
5
  description = Tools for Plotting Flight Data in Plotly
6
6
  long_description = file: README.md
7
7
  long_description_content_type = text/markdown
8
- version = 0.1.1
8
+ version = 0.1.3
9
9
  url = https://github.com/PyFlightCoach/FlightPlotting
10
10
 
11
11
  [options]
@@ -1,3 +0,0 @@
1
-
2
-
3
- from flightplotting.plots import plotsec, plot_analysis, plotdtw
File without changes
File without changes
File without changes