irie 0.0.57__py3-none-any.whl → 0.0.59__py3-none-any.whl

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.

Potentially problematic release.


This version of irie might be problematic. Click here for more details.

@@ -21,14 +21,9 @@
21
21
  bb[event] += 1/(len(aa)-1)
22
22
 
23
23
  """
24
- import os
25
- import json
26
- from collections import defaultdict
27
24
 
28
25
  import numpy as np
29
- from irie.apps.events.models import EventRecord
30
- from irie.apps.site.view_utils import raise404
31
- from irie.apps.inventory.models import Asset
26
+ from irie.apps.evaluation.models import Evaluation
32
27
 
33
28
  def mkdd(asset, pid, key):
34
29
  evaluations = list(reversed(sorted(Evaluation.objects.filter(asset=asset),
@@ -0,0 +1,23 @@
1
+ # Generated by Django 5.1.2 on 2025-07-31 05:48
2
+
3
+ from django.db import migrations, models
4
+
5
+
6
+ class Migration(migrations.Migration):
7
+
8
+ dependencies = [
9
+ ('irie_apps_inventory', '0008_alter_sensor_dx_alter_sensor_dy_alter_sensor_dz_and_more'),
10
+ ]
11
+
12
+ operations = [
13
+ migrations.AddField(
14
+ model_name='datum',
15
+ name='angle_x',
16
+ field=models.DecimalField(blank=True, decimal_places=2, default=0.0, max_digits=10, null=True),
17
+ ),
18
+ migrations.AddField(
19
+ model_name='datum',
20
+ name='angle_y',
21
+ field=models.DecimalField(blank=True, decimal_places=2, default=0.0, max_digits=10, null=True),
22
+ ),
23
+ ]
@@ -111,10 +111,54 @@ class Datum(models.Model):
111
111
  locate_y = models.CharField(max_length=240) # eg, center of deck
112
112
  orient_z = models.CharField(max_length=240) # eg, vertical upwards
113
113
  locate_z = models.CharField(max_length=240) # eg, deck surface
114
+
115
+ angle_x = models.DecimalField(decimal_places=2, max_digits=10, default=0.0, null=True, blank=True)
116
+ angle_y = models.DecimalField(decimal_places=2, max_digits=10, default=0.0, null=True, blank=True)
114
117
  asset = models.ForeignKey(Asset, on_delete=models.RESTRICT)
115
118
 
116
119
  def __str__(self):
117
120
  return f"{self.name}"
121
+
122
+ def to_cardinal(self):
123
+ """
124
+ Create rotation matrix from datum basis to cardinal basis.
125
+ The cardinal basis is defined as:
126
+ cx = North,
127
+ cy = East,
128
+ cz = Up
129
+
130
+ The datum basis is defined as:
131
+ ex = Exp(orient_x cz) cx
132
+ ey = Exp(orient_y cz) cy
133
+ ez = Exp(orient_z cz) cz
134
+ where orient_x, orient_y, and orient_z are the angles in radians and
135
+ Exp is the exponential map which encodes the Rodrigues' rotation formula.
136
+
137
+ We want to return the rotation Rec such that:
138
+ Rec @ [ex, ey, ez] = [cx, cy, cz]
139
+ """
140
+ import numpy as np
141
+ from shps.rotor import exp
142
+
143
+ orient_x = self.angle_x
144
+ orient_y = self.angle_y
145
+
146
+ ex, ey, ez = np.eye(3)
147
+ cz = ez
148
+ cx = exp(-orient_x*cz) @ ex
149
+ cy = exp(-orient_y*cz) @ ey
150
+
151
+ rotation = np.column_stack((cx, cy, cz))
152
+
153
+ return rotation
154
+
155
+ def to_other(self, other: "Datum"):
156
+ """
157
+ Create rotation matrix from this datum to another datum.
158
+ """
159
+ R_cs = self.to_cardinal()
160
+ R_cm = other.to_cardinal()
161
+ return R_cm.T @ R_cs
118
162
 
119
163
  class SensorGroup(models.Model):
120
164
  name = models.CharField(max_length=100)
@@ -123,6 +167,7 @@ class SensorGroup(models.Model):
123
167
  datum = models.ForeignKey(Datum, on_delete=models.RESTRICT)
124
168
  # network = models.CharField(max_length=100)
125
169
  # events = None
170
+
126
171
  def __str__(self):
127
172
  return f"{self.asset.calid} - {self.name} ({self.datum})"
128
173
 
@@ -145,7 +190,7 @@ class Sensor(models.Model):
145
190
  on_delete=models.RESTRICT)
146
191
 
147
192
  def __str__(self):
148
- return f"{self.group.asset.calid} - {self.name} ({self.group.name})"
193
+ return f"{self.group.asset.cesmd} / {self.name}"
149
194
 
150
195
 
151
196
  def acceleration(self, event):
File without changes