Example #1
0
    def process(action):

        camera = ExposeHandler.camera
        filterwheel = ExposeHandler.filterwheel

        # not considered in abort handling (should be fast enough to wait!)
        if action.filter is not None:
            filterwheel.setFilter(str(action.filter))

        ir = ImageRequest(frames=int(action.frames),
                          exptime=float(action.exptime),
                          shutter=str(action.shutter),
                          type=str(action.imageType),
                          filename=str(action.filename),
                          object_name=str(action.objectName),
                          window=action.window,
                          binning=action.binning,
                          wait_dome=action.wait_dome,
                          compress_format=action.compress_format)

        ir.headers += [("PROGRAM", str(action.program.name), "Program Name"),
                       ("PROG_PI", str(action.program.pi),
                        "Principal Investigator")]

        try:
            images = camera.expose(ir)
        except Exception as e:
            printException(e)
            raise ProgramExecutionException("Error while exposing")
Example #2
0
    def process(action):

        camera = ExposeHandler.camera
        filterwheel = ExposeHandler.filterwheel

        # not considered in abort handling (should be fast enough to wait!)
        if action.filter is not None:
            filterwheel.setFilter(str(action.filter))
            
        ir = ImageRequest(frames   = int(action.frames),
                          exptime  = float(action.exptime),
                          shutter  = str(action.shutter),
                          type     = str(action.imageType),
                          filename = str(action.filename),
                          object_name = str(action.objectName),
                          window = action.window,
                          binning = action.binning,
                          wait_dome = True)

        ir.headers += [("PROGRAM", str(action.program.name), "Program Name"),
                       ("PROG_PI", str(action.program.pi), "Principal Investigator")]

        try:
            camera.expose(ir)
        except Exception, e:
            printException(e)
            raise ProgramExecutionException("Error while exposing")
Example #3
0
    def process(action):
        autoflat = AutoFlatHandler.autoflat

        try:
            autoflat.getFlats(action.filter, n_flats=action.frames)
        except Exception, e:
            printException(e)
            raise ProgramExecutionException("Error trying to take flats")
Example #4
0
    def formatException(self, exc_info):
        stream = StringIO.StringIO()
        printException(exc_info[1], stream=stream)

        try:
            return stream.getvalue()
        finally:
            stream.close()
Example #5
0
    def process(action):
        autoflat = AutoFlatHandler.autoflat

        try:
            autoflat.getFlats(action.filter, n_flats=action.frames)
        except Exception, e:
            printException(e)
            raise ProgramExecutionException("Error trying to take flats")
Example #6
0
    def formatException(self, exc_info):
        stream = StringIO.StringIO()
        printException(exc_info[1], stream=stream)

        try:
            return stream.getvalue()
        finally:
            stream.close()
Example #7
0
    def _runAction(self, action, options):

        try:
            if action.target is not None:
                method = getattr(self, action.target.__name__)
                method(options)
        except Exception, e:
            self.err("Something wrong with '%s' action." % (action.name))
            printException(e)
            return False
Example #8
0
    def _runAction(self, action, options):

        try:
            if action.target is not None:
                method = getattr(self, action.target.__name__)
                method(options)
        except Exception, e:
            self.err("Something wrong with '%s' action." % (action.name))
            printException(e)
            return False
Example #9
0
    def process(action):
        autoflat = AutoFlatHandler.autoflat

        if action.binning is None:
            request = {"binning": "1x1"}
        else:
            request = {"binning": action.binning}

        try:
            autoflat.getFlats(action.filter, n_flats=action.frames, request=request)
        except Exception, e:
            printException(e)
            raise ProgramExecutionException("Error trying to take flats")
Example #10
0
    def process(action):
        autofocus = AutoFocusHandler.autofocus

        try:
            # TODO: filter=action.filter,
            autofocus.focus (exptime=action.exptime,
                             binning=action.binning,
                             window=action.window,
                             start=action.start,
                             end=action.end,
                             step=action.step)
        except Exception, e:
            printException(e)
            raise ProgramExecutionException("Error while autofocusing")
Example #11
0
    def test_times(self):

        site = self.manager.getProxy(Site)

        try:
            print()
            print("local:", site.localtime())
            print("UT   :", site.ut())
            print("JD   :", site.JD())
            print("MJD  :", site.MJD())
            print("LST  :", site.LST())
            print("GST  :", site.GST())
        except Exception as e:
            printException(e)
Example #12
0
    def test_times (self):

        site = self.manager.getProxy(Site)

        try:
            print
            print "local:", site.localtime()
            print "UT   :", site.ut()
            print "JD   :", site.JD()
            print "MJD  :", site.MJD()
            print "LST  :", site.LST()
            print "GST  :", site.GST()
        except Exception, e:
            printException(e)
Example #13
0
    def process(action):
        autofocus = AutoFocusHandler.autofocus

        try:
            autofocus.focus(exptime=action.exptime,
                            binning=action.binning,
                            window=action.window,
                            start=action.start,
                            end=action.end,
                            step=action.step,
                            filter=action.filter)
        except Exception as e:
            printException(e)
            raise ProgramExecutionException("Error while autofocusing")
Example #14
0
    def process(action):
        autoflat = AutoFlatHandler.autoflat

        if action.binning is None:
            request = {"binning": "1x1"}
        else:
            request = {"binning": action.binning}

        try:
            autoflat.getFlats(action.filter,
                              n_flats=action.frames,
                              request=request)
        except Exception as e:
            printException(e)
            raise ProgramExecutionException("Error trying to take flats")
Example #15
0
    def checkPointing(self):
        """
        This method *chooses* a field to verify the telescope pointing.
        Then it does the pointing and verifies it.
        If unsuccesfull e-mail the operator for help
        isto em portugues eh chamado calagem

        Choice is based on some catalog (Landolt here)
        We choose the field closest to zenith
        """
        # find where the zenith is
        site = self.getManager().getProxy("/Site/0")
        lst = site.LST()
        lat = site["latitude"]
        coords = Position.fromRaDec(lst, lat)

        self.log.info(
            "Check pointing - Zenith coordinates: %f %f" % (lst, lat))

        tel = self.getTel()

        # use the Vizier catalogs to see what Landolt field is closest to
        # zenith
        self.log.debug("Calling landolt")
        fld = Landolt()
        fld.useTarget(coords, radius=45)
        obj = fld.find(limit=self["max_fields"])

        print "Objects returned from Landolt", obj
        # get ra, dec to call pointVerify
        ra = obj[self.currentField]["RA"]
        dec = obj[self.currentField]["DEC"]
        name = obj[self.currentField]["ID"]
        print "Current object ", ra, dec, name

        self.log.info("Chose %s %f %f" % (name, ra, dec))
        tel.slewToRaDec(Position.fromRaDec(ra, dec))
        try:
            self.pointVerify()
        except Exception, e:
            printException(e)
            raise CantSetScopeException(
                "Can't set scope on field %s %f %f we are in trouble, call for help" % 
                (name, ra, dec))
Example #16
0
    def checkPointing(self):
        """
        This method *chooses* a field to verify the telescope pointing.
        Then it does the pointing and verifies it.
        If unsuccesfull e-mail the operator for help
        isto em portugues eh chamado calagem

        Choice is based on some catalog (Landolt here)
        We choose the field closest to zenith
        """
        # find where the zenith is
        site = self.getManager().getProxy("/Site/0")
        lst = site.LST()
        lat = site["latitude"]
        coords = Position.fromRaDec(lst, lat)

        self.log.info("Check pointing - Zenith coordinates: %f %f" %
                      (lst, lat))

        tel = self.getTel()

        # use the Vizier catalogs to see what Landolt field is closest to zenith
        self.log.debug("Calling landolt")
        fld = Landolt()
        fld.useTarget(coords, radius=45)
        obj = fld.find(limit=self["max_fields"])

        print "Objects returned from Landolt", obj
        # get ra, dec to call pointVerify
        ra = obj[self.currentField]["RA"]
        dec = obj[self.currentField]["DEC"]
        name = obj[self.currentField]["ID"]
        print "Current object ", ra, dec, name

        self.log.info("Chose %s %f %f" % (name, ra, dec))
        tel.slewToRaDec(Position.fromRaDec(ra, dec))
        try:
            self.pointVerify()
        except Exception, e:
            printException(e)
            raise CantSetScopeException(
                "Can't set scope on field %s %f %f we are in trouble, call for help"
                % (name, ra, dec))
Example #17
0
    def expose(self):

        camera = self.getCamera()

        durationSpin = self.module.builder.get_object("durationSpin")
        duration = durationSpin.get_value()

        framesSpin = self.module.builder.get_object("framesSpin")
        frames = framesSpin.get_value()

        shutterOpen = self.module.builder.get_object("shutterOpen")

        if (shutterOpen.get_active()):
            shutterState = "OPEN"
        else:
            shutterState = "CLOSE"

        filters = self.module.builder.get_object(
            "filtersBox").get_children()[1].get_children()
        current = None
        for f in filters:
            if f.get_active():
                current = f

        filterName = current.get_label()

        self.module.view.begin(duration, frames)

        if self.getWheel().getFilter() != filterName:
            self.module.view.beginFilterChange(filterName)
            self.getWheel().setFilter(filterName)
            self.module.view.endFilterChange(filterName)

        try:
            camera.expose({
                "exptime": duration,
                "frames": frames,
                "shutter": shutterState
            })
        except Exception, e:
            printException(e)
Example #18
0
    def expose(self):

        camera = self.getCamera()

        durationSpin = self.module.builder.get_object("durationSpin")
        duration = durationSpin.get_value()

        framesSpin = self.module.builder.get_object("framesSpin")
        frames = framesSpin.get_value()

        shutterOpen = self.module.builder.get_object("shutterOpen")

        if(shutterOpen.get_active()):
            shutterState = "OPEN"
        else:
            shutterState = "CLOSE"

        filters = self.module.builder.get_object(
            "filtersBox").get_children()[1].get_children()
        current = None
        for f in filters:
            if f.get_active():
                current = f

        filterName = current.get_label()

        self.module.view.begin(duration, frames)

        if self.getWheel().getFilter() != filterName:
            self.module.view.beginFilterChange(filterName)
            self.getWheel().setFilter(filterName)
            self.module.view.endFilterChange(filterName)

        try:
            camera.expose({"exptime": duration,
                           "frames": frames,
                           "shutter": shutterState})
        except Exception, e:
            printException(e)
Example #19
0
    def test_astros(self):

        site = self.manager.getProxy(Site)

        try:
            print()
            print("local   :", site.localtime())
            print()
            print("moonrise  :", site.moonrise())
            print("moonset   :", site.moonset())
            print("moon pos  :", site.moonpos())
            print("moon phase:", site.moonphase())
            print()
            print("sunrise:", site.sunrise())
            print("sunset :", site.sunset())
            print("sun pos:", site.sunpos())
            print()

            sunset_twilight_begin = site.sunset_twilight_begin()
            sunset_twilight_end = site.sunset_twilight_end()
            sunset_twilight_duration = relativedelta(sunset_twilight_end,
                                                     sunset_twilight_begin)

            sunrise_twilight_begin = site.sunrise_twilight_begin()
            sunrise_twilight_end = site.sunrise_twilight_end()
            sunrise_twilight_duration = relativedelta(sunrise_twilight_end,
                                                      sunrise_twilight_begin)

            print("next sunset twilight begins at:", sunset_twilight_begin)
            print("next sunset twilight ends   at:", sunset_twilight_end)
            print("sunset twilight duration      :", sunset_twilight_duration)
            print()
            print("next sunrise twilight begins at:", sunrise_twilight_begin)
            print("next sunrise twilight ends   at:", sunrise_twilight_end)
            print("sunrise twilight duration      :",
                  sunrise_twilight_duration)

        except Exception as e:
            printException(e)
Example #20
0
    def test_astros (self):

        site = self.manager.getProxy(Site)

        try:
            print
            print "local   :", site.localtime()
            print
            print "moonrise  :", site.moonrise()
            print "moonset   :", site.moonset()
            print "moon pos  :", site.moonpos()
            print "moon phase:", site.moonphase()
            print
            print "sunrise:", site.sunrise()
            print "sunset :", site.sunset()
            print "sun pos:", site.sunpos()
            print

            sunset_twilight_begin = site.sunset_twilight_begin()
            sunset_twilight_end   = site.sunset_twilight_end()
            sunset_twilight_duration = relativedelta(sunset_twilight_end, sunset_twilight_begin)
            
            sunrise_twilight_begin = site.sunrise_twilight_begin()
            sunrise_twilight_end = site.sunrise_twilight_end()
            sunrise_twilight_duration = relativedelta(sunrise_twilight_end, sunrise_twilight_begin)            
            
            print "next sunset twilight begins at:", sunset_twilight_begin
            print "next sunset twilight ends   at:", sunset_twilight_end
            print "sunset twilight duration      :", sunset_twilight_duration
            print
            print "next sunrise twilight begins at:", sunrise_twilight_begin
            print "next sunrise twilight ends   at:", sunrise_twilight_end
            print "sunrise twilight duration      :", sunrise_twilight_duration            

        except Exception, e:
            printException(e)
Example #21
0
 def _move(self, method, offset):
     try:
         offset = float(offset.replace("arcsec", ""))
         method(offset)
     except Exception, e:
         printException(e)
Example #22
0
 def slew(self):
     az = self.module.view.azEntry.get_text()
     try:
         self.dome.slewToAz(az)
     except Exception, e:
         printException(e)
Example #23
0
 def _add (self, location, path, start):
     try:
         self.manager.addLocation(location, path, start)
     except Exception, e:
         printException(e)
Example #24
0
 def _move(self, method, offset):
     try:
         offset = float(offset.replace("arcsec", ""))
         method(offset)
     except Exception, e:
         printException(e)
Example #25
0
class TelescopeController:
    def __init__(self, module):
        self.telescope = None
        self.site = None

        self.module = module

    def setSite(self, site):
        self.site = site

    def setTelescope(self, telescope):
        self.telescope = telescope
        self.module.view.startStatusUpdate()

        @callback(self.module.manager)
        def slewBegin(target):
            self.module.view.slewBegin(target)

        @callback(self.module.manager)
        def slewComplete(target, status):
            self.module.view.slewComplete(target)

        @callback(self.module.manager)
        def parkComplete():
            self.module.view.updateParkStatus()

        @callback(self.module.manager)
        def unparkComplete():
            self.module.view.updateParkStatus()

        self.telescope.slewBegin += slewBegin
        self.telescope.slewComplete += slewComplete
        self.telescope.parkComplete += parkComplete
        self.telescope.unparkComplete += unparkComplete

    def getSite(self):
        # transfer to current thread and return (a hacky way to reuse Proxies)
        self.site._transferThread()
        return self.site

    def getTelescope(self):
        # transfer to current thread and return (a hacky way to reuse Proxies)
        self.telescope._transferThread()
        return self.telescope

    def slew(self):

        slewFunction = None
        target = None

        currentPage = self.module.view.slewOptions.get_current_page()

        if currentPage == 0:
            raHour = self.module.view.raHourSpin.get_value()
            raMinute = self.module.view.raMinuteSpin.get_value()
            raSec = self.module.view.raSecSpin.get_value()

            decDegree = self.module.view.decDegreeSpin.get_value()
            decMinute = self.module.view.decMinuteSpin.get_value()
            decSec = self.module.view.decSecSpin.get_value()

            ra = "%2d:%2d:%2d" % (raHour, raMinute, raSec)
            dec = "%2d:%2d:%2d" % (decDegree, decMinute, decSec)

            epochStr = str(
                self.module.view.epochCombo.child.get_text()).lower()

            if epochStr == "j2000":
                epoch = Epoch.J2000
            elif epochStr == "b1950":
                epoch = Epoch.B1950
            elif epochStr == "now":
                epoch = Epoch.Now
            else:
                # FIXME
                epoch = epochStr

            target = Position.fromRaDec(ra, dec, epoch=epoch)
            slewFunction = self.telescope.slewToRaDec

        elif currentPage == 1:

            altDegree = self.module.view.altDegreeSpin.get_value()
            altMinute = self.module.view.altMinuteSpin.get_value()
            altSec = self.module.view.altSecSpin.get_value()

            azDegree = self.module.view.azDegreeSpin.get_value()
            azMinute = self.module.view.azMinuteSpin.get_value()
            azSec = self.module.view.azSecSpin.get_value()

            alt = "%2d:%2d:%2d" % (altDegree, altMinute, altSec)
            az = "%2d:%2d:%2d" % (azDegree, azMinute, azSec)

            target = Position.fromAltAz(alt, az)
            slewFunction = self.telescope.slewToAltAz

        elif currentPage == 2:
            target = str(self.module.view.objectNameCombo.child.get_text())
            slewFunction = self.telescope.slewToObject

        self.module.view.slewBeginUi()

        try:
            slewFunction(target)
        except ObjectNotFoundException, e:
            self.module.view.showError(
                "Object %s was not found on our catalogs." % target)
        except Exception, e:
            printException(e)
Example #26
0
print m.doMethod("bar")

# event

@callback(manager)
def doEventClbk (result):
    print result

m.eventDone += doEventClbk
m.doEvent()

# exception
try:
    m.doRaise()
except MinimoException, e:
    printException(e)

# static method
print m.doStatic()

# class method
print m.doClass()

# configuration
print "option1 =>", m['option1']
print "option2 =>", m['option2']

m += {"option1": "new value 1",
      "option2": "new value 2"}

print "option1 =>", m['option1']
Example #27
0
 def _add(self, location, path, start):
     try:
         self.manager.addLocation(location, path, start)
     except Exception as e:
         printException(e)
Example #28
0
 def slew(self):
     az = self.module.view.azEntry.get_text()
     try:
         self.dome.slewToAz(az)
     except Exception, e:
         printException(e)
Example #29
0
# event


@callback(manager)
def doEventClbk(result):
    print result


m.eventDone += doEventClbk
m.doEvent()

# exception
try:
    m.doRaise()
except MinimoException, e:
    printException(e)

# static method
print m.doStatic()

# class method
print m.doClass()

# configuration
print "option1 =>", m['option1']
print "option2 =>", m['option2']

m += {"option1": "new value 1", "option2": "new value 2"}

print "option1 =>", m['option1']
print "option2 =>", m['option2']