Commit dde5d15a authored by Michele Maris's avatar Michele Maris
Browse files

u

parent a32a8780
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -7,9 +7,14 @@ license = "MIT"
readme = "README.md"

[tool.poetry.dependencies]
python = "^>3.7"
python = ">3.7"

[tool.poetry.dev-dependencies]

[tool.poetry.group.dev.dependencies]
pytest = "^7.4.0"
pytest-cov = "^4.1.0"

[tool.semantic_release]
version_variable = "pyproject.toml:version" # version location
branch = "main"                             # branch to make releases of
+36 −14
Original line number Diff line number Diff line
@@ -143,7 +143,12 @@ PRM of order 0
      return self._thetaSign
   @thetaSign.setter
   def thetaSign(self,this) : 
      try :
         self._thetaSign=int(this)
      except :
         raise Exception("Error: thetaSign must be either -1 or +1","")
      if not self._thetaSign in [-1,1] :
         raise Exception("Error: thetaSign must be either -1 or +1","")
      self._mark['thetaSign']=1
      self._isComplete=False
   #
@@ -163,7 +168,12 @@ PRM of order 0
      return self._phiSign
   @phiSign.setter
   def phiSign(self,this) : 
      try :
         self._phiSign=int(this)
      except :
         raise Exception("Error: phiSign must be either -1 or +1","")
      if not self._phiSign in [-1,1] :
         raise Exception("Error: phiSign must be either -1 or +1","")
      self._mark['phiSign']=1
      self._isComplete=False
   #
@@ -220,6 +230,11 @@ PRM of order 0
            return False
      return True
   #
   @property
   def RM(self) :
      """rotation matrices"""
      return self._matr
   #
   def __init__(self,ideal=False) :
      """
      Keywords
@@ -243,15 +258,17 @@ PRM of order 0
      """return angles names"""
      return ['roll','pan','tilt','thetaSign','ctheta0','phiSign','cphi0','tiltFork','zVAX','omegaVAX']
   #
   def __getitem__(self,this) :
      return self._d[this]
   #
   def copy(self) :
      """make a physical copy"""
      import copy
      return copy.deepcopy(self)
   #
   def __getitem__(self,this) :
      """ returns an angle in deg """
      return self._d[this]
   #
   def __setitem__(self,this,that) :
      """ set an angle in deg """
      self._d[this]=that
   #
   def M(self,k) :
@@ -320,7 +337,7 @@ PRM of order 0
      self.omegaVAX=0.
      self.phiSign=1
      self.cphi0=0.
      self.tethaPhi=1
      self.thetaSign=1
      self.ctheta0=0.
      self.commit()
   #
@@ -340,14 +357,18 @@ PRM of order 0
      if self.isAllSet :
         #
         #single angle rotation matrices
         self._matr['roll']=self.ERotZ(np.deg2rad(np.array([this])))
         self._matr['pan']=self.ERotY(np.deg2rad(np.array([this])))
         self._matr['tilt']=self.ERotX(np.deg2rad(np.array([this])))
         self._matr['ctheta0']=self.ERotY(-self._thetaSign*np.deg2rad(np.array([this])))
         self._matr['cphi0']=self.ERotZ(-self._phiSign*np.deg2rad(np.array([this])))
         self._matr['tiltFork']=self.ERotX(np.deg2rad(np.array([this])))
         self._matr['zVAX']=self.ERotX(np.deg2rad(np.array([this])))
         self._matr['omegaVAX']=self.ERotZ(np.deg2rad(np.array([this])))
         for k in ['roll','pan','tilt','tiltFork','zVAX','omegaVAX'] :
            self._matr[k]=self.ERotZ(np.deg2rad(np.array([self._d[k]])))
         self._matr['ctheta0']=self.ERotY(-self._thetaSign*np.deg2rad(np.array([self._d['ctheta0']])))
         self._matr['cphi0']=self.ERotY(-self._thetaSign*np.deg2rad(np.array([self._d['cphi0']])))
         #self._matr['roll']=self.ERotY(np.deg2rad(np.array([this])))
         #self._matr['pan']=self.ERotY(np.deg2rad(np.array([this])))
         #self._matr['tilt']=self.ERotX(np.deg2rad(np.array([this])))
         #self._matr['ctheta0']=self.ERotY(-self._thetaSign*np.deg2rad(np.array([this])))
         #self._matr['cphi0']=self.ERotZ(-self._phiSign*np.deg2rad(np.array([this])))
         #self._matr['tiltFork']=self.ERotX(np.deg2rad(np.array([this])))
         #self._matr['zVAX']=self.ERotX(np.deg2rad(np.array([this])))
         #self._matr['omegaVAX']=self.ERotZ(np.deg2rad(np.array([this])))
         #
         out=self._matr['tilt'][0].dot(self._matr['pan'][0].dot(self._matr['roll'][0]))
         out=self._matr['ctheta0'][0].dot(out)
@@ -369,6 +390,7 @@ PRM of order 0
         #
         self._isComplete=True
      else :
         print(self._isComplete,self._mark)
         self._isComplete=False
         raise Error('Configuration not completed','')
   #

tests/test_lspe_prm.py

0 → 100644
+24 −0
Original line number Diff line number Diff line
from lspe_prm import PRM0

def test_ideal_generation() : 
   """test the generation of an ideal telescope"""
   prm=PRM0(ideal=True)
   expected=[True        ,True        , 0.      , 0.      , 0.      , 1            , 0.          , 1           , 0.        , 0.           ,0.       , 0.          ]
   actual=[prm.isComplete,prm.isAllSet, prm.roll, prm.pan , prm.tilt, prm.thetaSign, prm.ctheta0 , prm.phiSign , prm.cphi0 , prm.tiltFork , prm.zVAX, prm.omegaVAX]
   print(expected)
   print(actual)
   assert expected==actual, "angles are not all set"

def test_ideal_matrices_shapes() : 
   """test the generation of an ideal telescope"""
   prm=PRM0(ideal=True)
   expected = []
   actual = []
   a=[k for k in prm.keys() if not k in ['thetaSign','phiSign']]
   for k in a:
      expected.append((1,3,3))
      actual.append(prm.RM[k].shape)
   print(expected)
   print(actual)
   assert expected==actual, "fixed angles matrices are all not of size (1,3,3)"