flightplotting 0.2.1__tar.gz → 0.2.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.2.1/flightplotting.egg-info → flightplotting-0.2.3}/PKG-INFO +6 -3
  2. {flightplotting-0.2.1 → flightplotting-0.2.3}/flightplotting/__init__.py +2 -2
  3. {flightplotting-0.2.1 → flightplotting-0.2.3}/flightplotting/plots.py +44 -25
  4. {flightplotting-0.2.1 → flightplotting-0.2.3}/flightplotting/traces.py +15 -21
  5. {flightplotting-0.2.1 → flightplotting-0.2.3/flightplotting.egg-info}/PKG-INFO +6 -3
  6. flightplotting-0.2.3/flightplotting.egg-info/requires.txt +7 -0
  7. {flightplotting-0.2.1 → flightplotting-0.2.3}/setup.cfg +6 -3
  8. flightplotting-0.2.1/flightplotting.egg-info/requires.txt +0 -4
  9. {flightplotting-0.2.1 → flightplotting-0.2.3}/COPYING +0 -0
  10. {flightplotting-0.2.1 → flightplotting-0.2.3}/MANIFEST.in +0 -0
  11. {flightplotting-0.2.1 → flightplotting-0.2.3}/README.md +0 -0
  12. {flightplotting-0.2.1 → flightplotting-0.2.3}/flightplotting/data/ColdDraftF3APlane.obj +0 -0
  13. {flightplotting-0.2.1 → flightplotting-0.2.3}/flightplotting/data/__init__.py +0 -0
  14. {flightplotting-0.2.1 → flightplotting-0.2.3}/flightplotting/model.py +0 -0
  15. {flightplotting-0.2.1 → flightplotting-0.2.3}/flightplotting/templates.py +0 -0
  16. {flightplotting-0.2.1 → flightplotting-0.2.3}/flightplotting/titlerenderer.py +0 -0
  17. {flightplotting-0.2.1 → flightplotting-0.2.3}/flightplotting.egg-info/SOURCES.txt +0 -0
  18. {flightplotting-0.2.1 → flightplotting-0.2.3}/flightplotting.egg-info/dependency_links.txt +0 -0
  19. {flightplotting-0.2.1 → flightplotting-0.2.3}/flightplotting.egg-info/top_level.txt +0 -0
  20. {flightplotting-0.2.1 → flightplotting-0.2.3}/setup.py +0 -0
  21. {flightplotting-0.2.1 → flightplotting-0.2.3}/tests/test_plots.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: flightplotting
3
- Version: 0.2.1
3
+ Version: 0.2.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
@@ -8,9 +8,12 @@ Author-email: thomasdavid0@gmail.com
8
8
  Description-Content-Type: text/markdown
9
9
  License-File: COPYING
10
10
  Requires-Dist: setuptools
11
- Requires-Dist: flightdata
12
- Requires-Dist: pfc-geometry
13
11
  Requires-Dist: plotly
12
+ Requires-Dist: numpy
13
+ Requires-Dist: pandas
14
+ Requires-Dist: pfc-geometry>=0.2.4
15
+ Requires-Dist: flightdata>=0.2.6
16
+ Requires-Dist: flightanalysis>=0.2.6
14
17
 
15
18
  # FlightPlotting
16
19
 
@@ -1,4 +1,4 @@
1
1
 
2
2
 
3
- from flightplotting.plots import plotsec, plot_analysis, plotdtw, create_3d_plot
4
- from flightplotting.traces import axestrace, trace3d, dtwtrace, vector, vectors, boxtrace, axis_rate_traces
3
+ from flightplotting.plots import plotsec, plot_analysis, plotdtw, create_3d_plot, plot_regions
4
+ from flightplotting.traces import axestrace, trace3d, dtwtrace, vector, vectors, boxtrace, axis_rate_traces, colour_from_scale
@@ -8,8 +8,6 @@ from flightplotting.traces import (
8
8
  control_input_trace,
9
9
  axis_rate_trace,
10
10
  aoa_trace,
11
- dtwtrace,
12
- control_inputs,
13
11
  cgtrace,
14
12
  ribbon,
15
13
  vectors,
@@ -34,7 +32,7 @@ def plotsec(secs: Union[State, list[State]], scale=5, nmodels=0, fig=None,
34
32
 
35
33
  for i, sec in enumerate(secs):
36
34
  text = ["{:.1f}".format(val) for val in sec.data.index]
37
- _color = color if not color is None else px.colors.qualitative.Plotly[i]
35
+ _color = color if color is not None else px.colors.qualitative.Plotly[i]
38
36
  if ribb:
39
37
  traces += ribbon(sec, scale * 1.85, _color)
40
38
  if tips:
@@ -62,9 +60,9 @@ def plotsec(secs: Union[State, list[State]], scale=5, nmodels=0, fig=None,
62
60
  zaxis=dict(visible=True, showticklabels=True)
63
61
  )
64
62
  )
65
- if not width is None:
63
+ if width is not None:
66
64
  fig.update_layout(width=width)
67
- if not height is None:
65
+ if height is not None:
68
66
  fig.update_layout(height=height)
69
67
  else:
70
68
  fig.add_traces(traces)
@@ -101,7 +99,48 @@ def plotdtw(sec: State, manoeuvres: List[str], span=3, fig=None):
101
99
 
102
100
  return fig
103
101
 
102
+ def plot_regions(st: State, lab_cols: list[str], span=3, colours=None, fig=None):
103
+ colours = px.colors.qualitative.Plotly if colours is None else colours
104
+ lab_cols = [lab_cols] if isinstance(lab_cols, str) else lab_cols
104
105
 
106
+ st = st.label(clabs=st.cumulative_labels(*lab_cols))
107
+
108
+ def get_base_label(clab):
109
+ base = clab
110
+ try:
111
+ id = int(clab.split('_')[-1])
112
+ base = clab[:-len(f'_{id}')]
113
+ except Exception:
114
+ pass
115
+ return base
116
+
117
+ colmap = {}
118
+
119
+ traces = []
120
+ for i, (k, seg) in enumerate(st.split_labels('clabs').items()):
121
+ blab = get_base_label(k)
122
+ if blab not in colmap:
123
+ colmap[blab] = colours[len(colmap) % len(colours)]
124
+ leg = True
125
+ else:
126
+ leg = False
127
+
128
+ traces += ribbon(seg, span, colmap[blab], name=k, showlegend=leg)
129
+
130
+ traces.append(go.Scatter3d(
131
+ x=seg.pos.x,
132
+ y=seg.pos.y,
133
+ z=seg.pos.z,
134
+ mode='lines',
135
+ line=dict(width=6, color=colmap[blab]),
136
+ name=k,
137
+ showlegend=False
138
+ ))
139
+
140
+ if fig is None:
141
+ fig = go.Figure(layout=go.Layout(template="flight3d+judge_view"))
142
+ fig.add_traces(traces)
143
+ return fig
105
144
 
106
145
  def create_3d_plot(traces):
107
146
  return go.Figure(
@@ -221,23 +260,3 @@ axis = dict(
221
260
  showline=True
222
261
  )
223
262
 
224
-
225
- aiaa_layout = dict(
226
- margin=dict(l=1, r=1, t=5, b=1),
227
- legend=dict(yanchor="top", xanchor="left", x=0.8, y=0.99),
228
- font_family="Times New Roman",
229
- font_size=18,plot_bgcolor='rgba(0,0,0,0)',
230
- # xaxis=dict(**axis),
231
- # yaxis=dict(range=(-100,700), **axis),
232
- # yaxis2=dict(range=(-100/20,700/20), **axis),
233
- )
234
-
235
- aiaa_full_width = dict(width=1200,**aiaa_layout)
236
- aiaa_half_width = dict(width=600,**aiaa_layout)
237
-
238
- aiaa_axis_rates = dict(
239
- xaxis=dict(range=(0,1.1), **axis),
240
- yaxis=dict(range=(-100,700), **axis),
241
- yaxis2=dict(range=(-100/20,700/20), **axis),
242
- **aiaa_half_width
243
- )
@@ -1,10 +1,8 @@
1
1
  import plotly.graph_objects as go
2
2
  import flightplotting.templates
3
- from .model import OBJ
4
3
  from geometry import Point, Coord, Transformation
5
4
  import numpy as np
6
- from typing import List, Union
7
-
5
+ from plotly.colors import DEFAULT_PLOTLY_COLORS
8
6
  from flightdata import State
9
7
  from flightplotting.model import obj, OBJ
10
8
  import plotly.express as px
@@ -53,11 +51,11 @@ def vectors(npoints: int, seq: State, vectors: Point, **kwargs):
53
51
 
54
52
  def trace3d(datax, datay, dataz, **kwargs):
55
53
 
56
- if not 'mode' in kwargs:
54
+ if 'mode' not in kwargs:
57
55
  kwargs['mode'] = 'lines'
58
- if kwargs['mode'] == 'lines' and not 'line' in kwargs:
56
+ if kwargs['mode'] == 'lines' and 'line' not in kwargs:
59
57
  kwargs['line']=dict(width=2, dash="solid")
60
- if not 'showlegend' in kwargs:
58
+ if 'showlegend' not in kwargs:
61
59
  kwargs['showlegend'] = False
62
60
 
63
61
  return go.Scatter3d(x=datax,y=datay,z=dataz,**kwargs)
@@ -103,8 +101,7 @@ def elementtraces(manoeuvre, sec: State):
103
101
 
104
102
 
105
103
  def tiptrace(seq, span, **kwargs):
106
- text = ["{:.1f}".format(val) for val in seq.data.index]
107
-
104
+
108
105
  def make_offset_trace(pos, colour):
109
106
  tr = trace3d(
110
107
  *seq.body_to_world(pos).data.T,
@@ -119,8 +116,13 @@ def tiptrace(seq, span, **kwargs):
119
116
  ]
120
117
 
121
118
 
122
- get_colour = lambda i : DEFAULT_PLOTLY_COLORS[i % len(DEFAULT_PLOTLY_COLORS)]
123
- from plotly.colors import DEFAULT_PLOTLY_COLORS
119
+ def get_colour(i):
120
+ return DEFAULT_PLOTLY_COLORS[i % len(DEFAULT_PLOTLY_COLORS)]
121
+
122
+
123
+ def colour_from_scale(v, vmax, scale=px.colors.sequential.Burg):
124
+ return scale[int((len(scale) - 1) * v / vmax)]
125
+
124
126
 
125
127
  def dtwtrace(sec: State, elms, showlegend = True):
126
128
  traces = tiptrace(sec, 10)
@@ -234,16 +236,8 @@ def _npinterzip(a, b):
234
236
  return c
235
237
 
236
238
 
237
- def ribbon(sec: State, span: float, color: str, name="none"):
238
- """WIP Vectorised version of ribbon, borrowed from kdoaij/FlightPlotting
239
-
240
- refactoring ribbon, objectives:
241
- speed it up by avoiding looping over array - done
242
- make the colouring more generic - not yet
243
- minor mod - 2 triangles per pair of points: - done
244
- current pair to next left
245
- current right to next pair
246
-
239
+ def ribbon(sec: State, span: float, color, **kwargs):
240
+ """TODO make the colouring more generic
247
241
  """
248
242
 
249
243
  left = sec.body_to_world(Point(0, span/2, 0))
@@ -265,5 +259,5 @@ def ribbon(sec: State, span: float, color: str, name="none"):
265
259
  x=points.x, y=points.y, z=points.z, i=_i, j=_j, k=_k,
266
260
  intensitymode="cell",
267
261
  facecolor=np.full(len(_i), color),
268
- name=name,
262
+ **kwargs
269
263
  )]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: flightplotting
3
- Version: 0.2.1
3
+ Version: 0.2.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
@@ -8,9 +8,12 @@ Author-email: thomasdavid0@gmail.com
8
8
  Description-Content-Type: text/markdown
9
9
  License-File: COPYING
10
10
  Requires-Dist: setuptools
11
- Requires-Dist: flightdata
12
- Requires-Dist: pfc-geometry
13
11
  Requires-Dist: plotly
12
+ Requires-Dist: numpy
13
+ Requires-Dist: pandas
14
+ Requires-Dist: pfc-geometry>=0.2.4
15
+ Requires-Dist: flightdata>=0.2.6
16
+ Requires-Dist: flightanalysis>=0.2.6
14
17
 
15
18
  # FlightPlotting
16
19
 
@@ -0,0 +1,7 @@
1
+ setuptools
2
+ plotly
3
+ numpy
4
+ pandas
5
+ pfc-geometry>=0.2.4
6
+ flightdata>=0.2.6
7
+ flightanalysis>=0.2.6
@@ -5,15 +5,18 @@ 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.2.1
8
+ version = 0.2.3
9
9
  url = https://github.com/PyFlightCoach/FlightPlotting
10
10
 
11
11
  [options]
12
12
  install_requires =
13
13
  setuptools
14
- flightdata
15
- pfc-geometry
16
14
  plotly
15
+ numpy
16
+ pandas
17
+ pfc-geometry>=0.2.4
18
+ flightdata>=0.2.6
19
+ flightanalysis>=0.2.6
17
20
  include_package_data = True
18
21
 
19
22
  [egg_info]
@@ -1,4 +0,0 @@
1
- setuptools
2
- flightdata
3
- pfc-geometry
4
- plotly
File without changes
File without changes
File without changes