summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorBernhard Tittelbach <xro@realraum.at>2012-03-21 00:50:10 +0000
committerBernhard Tittelbach <xro@realraum.at>2012-03-21 00:50:10 +0000
commit0bee89a319f67285a86825916f2f6034bb55c198 (patch)
tree30486be2cc934fcf68cbc4f63269d7bed664cc8c /tools
parentcleanups (diff)
photodiode simulator version 0.1
git-svn-id: https://svn.spreadspace.org/mur.sat@321 7de4ea59-55d0-425e-a1af-a3118ea81d4c
Diffstat (limited to 'tools')
-rwxr-xr-xtools/photodiodesim/pd_sim.py82
1 files changed, 82 insertions, 0 deletions
diff --git a/tools/photodiodesim/pd_sim.py b/tools/photodiodesim/pd_sim.py
new file mode 100755
index 0000000..abfca48
--- /dev/null
+++ b/tools/photodiodesim/pd_sim.py
@@ -0,0 +1,82 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+"""
+Created on Tue Mar 20 21:18:28 2012
+
+@author: bernhard
+"""
+
+import math
+import numpy as np
+import pylab as pl
+
+simduration = 60 #s
+simtimestep = 0.1 #s
+w_x = 0.1 #rad/s
+w_y = 0.2 #rad/s
+w_z = 0.5 #rad/s
+
+#todo simloop mit random werten
+
+simtimeline = np.arange(0,simduration,simtimestep)
+
+w_xyz = np.matrix([w_x,w_y,w_z])
+
+torque_sum_vectors = ( w_xyz.transpose() * simtimeline ).transpose() % (2 *math.pi)
+
+sensors = np.matrix([[ 1,0,0],
+ [0,1,0],
+ [0,0,1],
+ [-1,0,0],
+ [0,-1,0],
+ [0,0,-1]])
+
+sun= np.matrix([ 1,0,0])
+
+def getRotationMatrix(angles):
+ x_angle = angles[0,0]
+ y_angle = angles[0,1]
+ z_angle = angles[0,2]
+ return np.matrix([
+ [1,0,0],
+ [0,math.cos(x_angle),math.sin(x_angle)],
+ [0,math.sin(x_angle),math.cos(x_angle)]]) * np.matrix(
+ [ [math.cos(y_angle),0,math.sin(y_angle)],
+ [0,1,0],
+ [math.sin(y_angle),0,math.cos(y_angle)]]
+ ) * np.matrix([
+ [math.cos(z_angle),math.sin(z_angle),0],
+ [math.sin(z_angle),math.cos(z_angle),0],
+ [0,0,1]
+ ])
+
+def rotateVector(vec_to_rotate, angles_vector):
+ return vec_to_rotate * getRotationMatrix(angles_vector)
+
+def sensor_model_rel_sensitivity_cos(angle):
+ if angle < math.pi/2.0:
+ return np.cos(angle[0,0])
+ else:
+ return 0.0
+
+phicostrace=[]
+senstrace=[]
+for cur_rot in torque_sum_vectors:
+ sens1=rotateVector(sensors[0],cur_rot)
+ rot_sensors=rotateVector(sensors,cur_rot)
+ #sinphi=np.cross(sens1,sun) # /1 / 1
+ cosphi=np.dot(rot_sensors,sun.transpose())
+ #print np.arccos(sincos)
+ #phi=np.sqrt(np.square(sinphi).sum())*float(np.sign(sinphi).prod())
+ #phisintrace.append(np.arcsin(np.sqrt(np.sum(np.square(sinphi)))))
+ angle=np.arccos(cosphi)
+ #print angle
+ #print [sensor_rel_sensitivity_cos(a) for a in angle]
+ phicostrace.append(angle)
+ senstrace.append([sensor_model_rel_sensitivity_cos(a) for a in angle])
+
+#print senstrace
+#print np.matrix(senstrace).transpose()
+pl.plot(simtimeline, senstrace)
+pl.legend(["Sensor"+str(x) for x in range(1,7)])
+pl.show()