Esempio n. 1
0
 def riseset(self, crd, ev="5deg"):
     a = self.rise(crd, ev)
     if isinstance(a, str):
         a = a.split()
         return { "rise": { "last": a[0], "utc": a[0] },
                  "set" : { "last": a[1], "utc": a[1] },
                  "solved": False }
     ofe = self.measure(self._framestack["epoch"], "utc")
     if not is_measure(ofe):
         ofe = self.epoch('utc', 'today')
     x = a.copy()
     for k in x.keys():
         x[k] = self.measure(self.epoch("last", dq.totime(a[k]),
                                        off=self.epoch("r_utc",
                                                       (dq.quantity(ofe["m0"]) + dq.quantity("0.5d")))),
                             "utc")
     return { "rise": { "last": self.epoch("last",
                                           dq.totime(a["rise"])),
                        "utc": x["rise"] },
              
              "set": { "last": self.epoch("last",
                                          dq.totime(a["set"])),
                        "utc": x["set"] },
              "solved" : True
              }
Esempio n. 2
0
 def direction(self, rf='', v0='0..', v1='90..', off=False):
     loc = { 'type': 'direction' , 'refer':  rf}
     loc['m0'] = dq.quantity(v0)
     loc['m1'] = dq.quantity(v1)
     if is_measure(off):
         if not off['type'] == "direction":
             raise TypeError('Illegal offset type specified.')
         loc["offset"] = off
     return self.measure(loc, rf)
Esempio n. 3
0
 def earthmagnetic(self, rf='', v0='0G', v1='0..', v2='90..', off=False):
     loc = { 'type': "earthmagnetic", 'refer': rf }
     loc['m0'] = dq.quantity(v0)
     loc['m1'] = dq.quantity(v1)
     loc['m2'] = dq.quantity(v2)
     if is_measure(off):
         if not off['type'] == "earthmagnetic":
             raise TypeError('Illegal offset type specified.')
         loc["offset"] = off
     return self.measure(loc, rf)
Esempio n. 4
0
 def todoppler(self, rf, v0, rfq=False):
     if is_measure(rfq) and rfq['type'] == 'frequency':
         rfq = dq.from_dict(rfq['m0'])
     if is_measure(v0):
         if v0['type'] == 'radialvelocity':
             return self.todop(v0, dq.to_dict(dq.quantity(1.,'Hz')))
         elif v0['type'] == 'frequency' and  isinstance(rfq, dq._quanta.Quantity) \
                  and rfq.conforms(dq.quantity('Hz')):
             return self.todop(v0, dq.to_dict(rfq))
         else:
             raise TypeError('Illegal Doppler or rest frequency specified')
     else:
         raise TypeError('Illegal Frequency specified')
Esempio n. 5
0
 def epoch(self, rf='', v0='0.0d', off=False):
     loc = { 'type': 'epoch' , 'refer':  rf}
     loc['m0'] = dq.quantity(v0)
     if is_measure(off):
         if not off['type'] == "epoch":
             raise TypeError('Illegal offset type specified.')        
         loc["offset"] = off
     return self.measure(loc, rf)
Esempio n. 6
0
 def doppler(self, rf='', v0='0', off=False):
     loc = { 'type': "doppler",
             'refer': rf,
             'm0': dq.quantity(v0) }
     if is_measure(off):
         if not off['type'] == "doppler":
             raise TypeError('Illegal offset type specified.')        
         loc["offset"] = off
     return self.measure(loc, rf)
Esempio n. 7
0
 def tofrequency(self, rf, v0, rfq):
     if is_measure(rfq) and rfq['type'] == 'frequency':
         rfq = dq.from_dict(rfq['m0'])
     if is_measure(v0) and  v0['type'] == 'doppler' \
            and  isinstance(rfq, dq._quanta.Quantity) \
            and  rfq.conforms(dq.quantity('Hz')):
         return self.doptofreq(v0, rf, dq.to_dict(rfq))
     else:
         raise TypeError('Illegal Doppler or rest frequency specified')
Esempio n. 8
0
    def rise(self, crd, ev='5deg'):
        if  not is_measure(crd):
            raise TypeError('No rise/set coordinates specified')
        ps = self._getwhere()
        self._fillnow()
        hd = self.measure(crd, "hadec")
        c = self.measure(crd, "app")
        evq = dq.quantity(ev)
        hdm1 = dq.from_dict(hd["m1"])
        psm1 = dq.from_dict(ps["m1"])
        ct = (dq.quantity(ev) - dq.sin(hdm1) * dq.sin(psm1)) / (dq.cos(hdm1) * dq.cos(psm1))

        if ct.get_value() >= 1:
            return "below below"
        if ct.get_value() <= -1:
            return "above above"
        a = dq.acos(ct)
        return { "rise": dq.norm(dq.quantity(c["m0"]), 0) - a,
                 "set" : dq.norm(dq.quantity(c["m0"]), 0) + a
                 }
Esempio n. 9
0
 def getvalue(self, v):
     if  not is_measure(v):
         raise TypeError('Incorrect input type for getvalue()')
     import re
     rx = re.compile("m\d+")
     out = []
     v.keys().sort()
     for key in v.keys():
         if re.match(rx, key):
             out.append(dq.quantity(v.get(key)))
     return out