pfc-geometry 0.2.0__tar.gz → 0.2.1__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 (26) hide show
  1. {pfc_geometry-0.2.0 → pfc_geometry-0.2.1}/PKG-INFO +4 -1
  2. {pfc_geometry-0.2.0 → pfc_geometry-0.2.1}/geometry/base.py +37 -3
  3. {pfc_geometry-0.2.0 → pfc_geometry-0.2.1}/geometry/mass.py +10 -1
  4. {pfc_geometry-0.2.0 → pfc_geometry-0.2.1}/geometry/quaternion.py +2 -1
  5. {pfc_geometry-0.2.0 → pfc_geometry-0.2.1}/geometry/transformation.py +9 -1
  6. {pfc_geometry-0.2.0 → pfc_geometry-0.2.1}/pfc_geometry.egg-info/PKG-INFO +4 -1
  7. {pfc_geometry-0.2.0 → pfc_geometry-0.2.1}/setup.cfg +1 -1
  8. {pfc_geometry-0.2.0 → pfc_geometry-0.2.1}/tests/test_base.py +7 -1
  9. {pfc_geometry-0.2.0 → pfc_geometry-0.2.1}/LICENSE +0 -0
  10. {pfc_geometry-0.2.0 → pfc_geometry-0.2.1}/README.md +0 -0
  11. {pfc_geometry-0.2.0 → pfc_geometry-0.2.1}/geometry/__init__.py +0 -0
  12. {pfc_geometry-0.2.0 → pfc_geometry-0.2.1}/geometry/coordinate_frame.py +0 -0
  13. {pfc_geometry-0.2.0 → pfc_geometry-0.2.1}/geometry/gps.py +0 -0
  14. {pfc_geometry-0.2.0 → pfc_geometry-0.2.1}/geometry/point.py +0 -0
  15. {pfc_geometry-0.2.0 → pfc_geometry-0.2.1}/geometry/testing.py +0 -0
  16. {pfc_geometry-0.2.0 → pfc_geometry-0.2.1}/pfc_geometry.egg-info/SOURCES.txt +0 -0
  17. {pfc_geometry-0.2.0 → pfc_geometry-0.2.1}/pfc_geometry.egg-info/dependency_links.txt +0 -0
  18. {pfc_geometry-0.2.0 → pfc_geometry-0.2.1}/pfc_geometry.egg-info/requires.txt +0 -0
  19. {pfc_geometry-0.2.0 → pfc_geometry-0.2.1}/pfc_geometry.egg-info/top_level.txt +0 -0
  20. {pfc_geometry-0.2.0 → pfc_geometry-0.2.1}/setup.py +0 -0
  21. {pfc_geometry-0.2.0 → pfc_geometry-0.2.1}/tests/test_coord.py +0 -0
  22. {pfc_geometry-0.2.0 → pfc_geometry-0.2.1}/tests/test_gps.py +0 -0
  23. {pfc_geometry-0.2.0 → pfc_geometry-0.2.1}/tests/test_mass.py +0 -0
  24. {pfc_geometry-0.2.0 → pfc_geometry-0.2.1}/tests/test_point.py +0 -0
  25. {pfc_geometry-0.2.0 → pfc_geometry-0.2.1}/tests/test_quaternion.py +0 -0
  26. {pfc_geometry-0.2.0 → pfc_geometry-0.2.1}/tests/test_transform.py +0 -0
@@ -1,12 +1,15 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pfc_geometry
3
- Version: 0.2.0
3
+ Version: 0.2.1
4
4
  Summary: A package for handling 3D geometry with a nice interface
5
5
  Home-page: https://github.com/PyFlightCoach/geometry
6
6
  Author: Thomas David
7
7
  Author-email: thomasdavid0@gmail.com
8
8
  Description-Content-Type: text/markdown
9
9
  License-File: LICENSE
10
+ Requires-Dist: setuptools
11
+ Requires-Dist: numpy
12
+ Requires-Dist: pandas
10
13
 
11
14
  # geometry #
12
15
 
@@ -72,7 +72,8 @@ class Base:
72
72
  self.data = self.__class__._clean_data(np.array(args).T)
73
73
  elif all(isinstance(arg, list) for arg in args):
74
74
  self.data = self.__class__._clean_data(np.array(args).T)
75
-
75
+ elif all(isinstance(arg, pd.Series) for arg in args):
76
+ self.data = self.__class__._clean_data(np.array(pd.concat(args, axis=1)))
76
77
  else:
77
78
  raise TypeError
78
79
  else:
@@ -219,7 +220,7 @@ class Base:
219
220
  assert len(dt) == len(self)
220
221
  return self.__class__(
221
222
  np.gradient(self.data,axis=0) \
222
- / \
223
+ / \
223
224
  np.tile(dt, (len(self.__class__.cols),1)).T)
224
225
 
225
226
  def to_pandas(self, prefix='', suffix='', columns=None, index=None):
@@ -284,4 +285,37 @@ class Base:
284
285
 
285
286
 
286
287
  def unwrap(self, discont=np.pi):
287
- return self.__class__(np.unwrap(self.data, discont=discont, axis=0))
288
+ return self.__class__(np.unwrap(self.data, discont=discont, axis=0))
289
+
290
+ def filter(self, order, cutoff, ts: np.ndarray=None):
291
+ from scipy.signal import butter, freqz, filtfilt
292
+ if ts is None:
293
+ ts = np.array(range(len(self)))
294
+ N = len(self)
295
+ T = (ts[-1] - ts[0]) / N
296
+
297
+ fs = 1/T
298
+ b, a = butter(
299
+ order,
300
+ cutoff,
301
+ fs=fs,
302
+ btype='low', analog=False
303
+ )
304
+
305
+ return self.__class__(filtfilt(b, a, self.data, axis=0))
306
+
307
+ def fft(self, ts: np.ndarray=None):
308
+ from scipy.fft import fft, fftfreq
309
+ if ts is None:
310
+ ts = np.array(range(len(self)))
311
+ N = len(self)
312
+ T = (ts[-1] - ts[0]) / N
313
+
314
+ yf = fft(self.data, axis=0)
315
+ xf = fftfreq(N, T)[:N//2]
316
+
317
+
318
+ y=2.0/N * np.abs(yf[0:N//2, :])
319
+
320
+ return pd.DataFrame(np.column_stack([xf, y]), columns=['freq'] + self.cols).set_index('freq')
321
+
@@ -50,5 +50,14 @@ class Mass(Base):
50
50
  ]))
51
51
  ) + self
52
52
 
53
+ def momentum(self, v: Point):
54
+ return self.m * v
55
+
56
+ def angular_momentum(self, rvel: Point):
57
+ return Point(
58
+ self.xx * rvel.x + self.xy * rvel.y + self.xz * rvel.z,
59
+ self.yx * rvel.x + self.yy * rvel.y + self.yz * rvel.z,
60
+ self.zx * rvel.x + self.zy * rvel.y + self.zz * rvel.z,
61
+ )
62
+
53
63
 
54
-
@@ -96,7 +96,8 @@ class Quaternion(Base):
96
96
  roll = np.arctan2(sinr_cosp, cosr_cosp)
97
97
 
98
98
  sinp = 2 * (self.w * self.y - self.z * self.x)
99
- pitch = np.arcsin(sinp)
99
+ with np.errstate(invalid='ignore'):
100
+ pitch = np.arcsin(sinp)
100
101
 
101
102
  siny_cosp = 2 * (self.w * self.z + self.x * self.y)
102
103
  cosy_cosp = 1 - 2 * (self.y * self.y + self.z * self.z)
@@ -21,8 +21,16 @@ class Transformation(Base):
21
21
  def __init__(self, *args, **kwargs):
22
22
  if len(args) == len(kwargs) == 0:
23
23
  args = np.concatenate([P0().data,Q0().data],axis=1)
24
+ elif len(args) == 1:
25
+ if isinstance(args[0], Point):
26
+ args = np.concatenate([args[0].data,Q0().data],axis=1)
27
+ elif isinstance(args[0], Quaternion):
28
+ args = np.concatenate([P0().data,args[0].data],axis=1)
24
29
  if len(args) == 2:
25
- args = np.concatenate([args[0].data, args[1].data], axis=1)
30
+ _q = args[0] if isinstance(args[0], Quaternion) else args[1]
31
+ _p = args[0] if isinstance(args[0], Point) else args[1]
32
+ assert isinstance(_q, Quaternion) and isinstance(_p, Point)
33
+ args = np.concatenate([_p.data, _q.data], axis=1)
26
34
  super().__init__(*args, **kwargs)
27
35
  self.p = Point(self.data[:,:3])
28
36
  self.q = Quaternion(self.data[:,3:])
@@ -1,12 +1,15 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pfc-geometry
3
- Version: 0.2.0
3
+ Version: 0.2.1
4
4
  Summary: A package for handling 3D geometry with a nice interface
5
5
  Home-page: https://github.com/PyFlightCoach/geometry
6
6
  Author: Thomas David
7
7
  Author-email: thomasdavid0@gmail.com
8
8
  Description-Content-Type: text/markdown
9
9
  License-File: LICENSE
10
+ Requires-Dist: setuptools
11
+ Requires-Dist: numpy
12
+ Requires-Dist: pandas
10
13
 
11
14
  # geometry #
12
15
 
@@ -5,7 +5,7 @@ author_email = thomasdavid0@gmail.com
5
5
  description = A package for handling 3D geometry with a nice interface
6
6
  long_description = file: README.md
7
7
  long_description_content_type = text/markdown
8
- version = 0.2.0
8
+ version = 0.2.1
9
9
  url = https://github.com/PyFlightCoach/geometry
10
10
 
11
11
  [options]
@@ -208,4 +208,10 @@ def test_repr__():
208
208
  p = ABC(1,2,3)
209
209
  rpr = p.__repr__()
210
210
  assert rpr == "ABC(a_=1.0 b_=2.0 c_=3.0, len=1)"
211
-
211
+
212
+
213
+ def test_three_pandas_series():
214
+ df = pd.DataFrame(np.random.random((10,3)), columns=list("abc"))
215
+ abc = ABC(df.a, df.b, df.c)
216
+
217
+ pd.testing.assert_frame_equal(abc.to_pandas(), df)
File without changes
File without changes
File without changes