示例#1
0
    def __init__(self):

        super(EphemerisShooter, self).__init__()

        self.ObserverFactory = EphemObserverFactory()
        # self.continuousShooterThread = ContinuousShooterThread(int(info_cam[4]))
        self.continuousShooterThread = ContinuousShooterThread(0)
        self.console = ConsoleThreadOutput()
        self.config = ConfigProject()

        info = self.config.get_geographic_settings()
        info_sun = self.config.get_moonsun_settings()

        self.latitude = info[0]  # '-45.51'
        self.longitude = info[1]  # '-23.12'
        self.elevation = info[2]  # 350

        self.max_solar_elevation = info_sun[0]  # -12
        self.ignore_lunar_position = info_sun[1]
        self.max_lunar_elevation = info_sun[2]  # 8
        self.max_lunar_phase = info_sun[3]  # 1
        self.wait_temperature = False

        self.shootOn = False
        self.controller = True
        self.count = 1
示例#2
0
def set_path(pre):
    tempo = datetime.utcnow().strftime('%Y%m%d_%H%M%S')

    data = tempo[0:4] + "_" + tempo[4:6] + tempo[6:8]
    # hora = tempo[9:11]+":"+tempo[11:13]+":"+tempo[13:15]

    from src.business.configuration.configSystem import ConfigSystem
    cs = ConfigSystem()
    path = str(cs.get_image_path()) + "/"

    from src.business.configuration.configProject import ConfigProject
    ci = ConfigProject()
    name_observatory = str(ci.get_site_settings())
    name_observatory = get_observatory(name_observatory)

    if int(tempo[9:11]) > 12:
        path = path + name_observatory + "_" + data + "/"
    else:
        day = int(tempo[6:8])
        if 0 < day < 10:
            day = "0" + str(day - 1)
        else:
            day = str(day - 1)

        path = path + name_observatory + "_" + tempo[0:4] + "_" + tempo[4:6] + day + "/"

    return path, tempo
示例#3
0
def set_path():
    tempo = datetime.utcnow().strftime('%Y%m%d_%H%M%S')

    data = tempo[0:4] + "_" + tempo[4:6] + tempo[6:8]

    from src.business.configuration.configSystem import ConfigSystem
    cs = ConfigSystem()
    path = str(cs.get_image_path()) + "/"

    from src.business.configuration.configProject import ConfigProject
    ci = ConfigProject()
    name_observatory = str(ci.get_site_settings())
    name_observatory = Image_Processing.get_observatory(name_observatory)

    if int(tempo[9:11]) > 12:
        path = path + name_observatory + "_" + data + "/"
    else:
        ano = tempo[0:4]
        mes = tempo[4:6]
        dia = tempo[6:8]
        abs_julian_day = jd_to_date(date_to_jd(ano, mes, int(dia)) - 1)

        mes = abs_julian_day[1]
        dia = abs_julian_day[2]
        ano = abs_julian_day[0]

        if 0 < int(dia) < 10:
            dia = "0" + str(dia)
        if 0 < int(mes) < 10:
            mes = "0" + str(mes)

        path = path + name_observatory + "_" + str(ano) + "_" + str(mes) + str(
            dia) + "/"

    return path, tempo
示例#4
0
def get_project_settings():
    """
    name_geographic_settings[0] = Latitude
    name_geographic_settings[1] = Longitude
    name_geographic_settings[2] = Elevation(m)
    name_geographic_settings[3] = Pressure(mb)
    name_geographic_settings[4] = Temperature(?)

    name_set_moonsun_settings[0] = Solar Elevation
    name_set_moonsun_settings[1] = Ignore Lunar Position
    name_set_moonsun_settings[2] = Lunar Elevation
    name_set_moonsun_settings[3] = Lunar Phase

    name_site_settings[0] = Name
    name_site_settings[1] = Observatory
    name_site_settings[2] = Imager ID
    """

    from src.business.configuration.configProject import ConfigProject
    ci = ConfigProject()

    name_geographic_settings = ci.get_geographic_settings()
    name_set_moonsun_settings = ci.get_moonsun_settings()
    name_site_settings = ci.get_site_settings()

    return name_geographic_settings, name_set_moonsun_settings, name_site_settings
示例#5
0
def result():
    config = ConfigProject()

    info = config.get_geographic_settings()
    infosun = config.get_moonsun_settings()

    max_solar_elevation = float(infosun[0])  # -12
    max_lunar_elevation = float(infosun[2])  # 8
    # max_lunar_phase = infosun[3]

    now_datetime = datetime.datetime.utcnow().replace(hour=12).replace(
        minute=00).replace(second=0)
    obs = ephem.Observer()

    obs.lat = info[0]
    obs.lon = info[1]
    obs.elevation = float(info[2])
    obs.date = ephem.date(now_datetime)

    sun = ephem.Sun()
    sun.compute(obs)
    moon = ephem.Moon()
    moon.compute(obs)
    j = 0
    flag = 0
    for i in range(1, 3000):

        obs.date = ephem.date(now_datetime)
        sun = ephem.Sun()
        sun.compute(obs)

        moon = ephem.Moon()
        moon.compute(obs)
        frac = moon.moon_phase

        ag_s = float(repr(sun.alt))
        s_ag = math.degrees(ag_s)
        ag_m = float(repr(moon.alt))
        m_ag = math.degrees(ag_m)

        if float(s_ag) < max_solar_elevation and float(
                m_ag) < max_lunar_elevation:
            if flag == 0:
                flag = 1
                start = now_datetime
        elif (float(s_ag) > max_solar_elevation
              or float(m_ag) > max_lunar_elevation) and flag == 1:
            flag = 0
            end = now_datetime
            break

        now_datetime += timedelta(minutes=j)

        j += 1

    obs_time = end - start

    return start, end, obs_time
示例#6
0
 def save_settings(self):
     try:
         st = ConfigProject()
         self.save_site(st)
         self.save_geo(st)
         self.save_sun(st)
         st.save_settings()
     except Exception as e:
         print(e)
示例#7
0
 def save_settings(self):
     try:
         st = ConfigProject()
         self.save_site(st)
         self.save_geo(st)
         self.save_sun(st)
         st.save_settings()
     except Exception as e:
         print(e)
示例#8
0
    def __init__(self):
        self.config = ConfigProject()
        info = self.config.get_geographic_settings()
        self.latitude = info[0]  #'-45.51'
        self.longitude = info[1]  #'-23.12'
        self.elev = info[2]  #350
        self.shootOn = False

        t = Thread(target=self.check_all)
        t.start()
示例#9
0
文件: logger.py 项目: hiyoku/ccd10
    def run(self):
        try:
            tempo = datetime.utcnow().strftime('%Y%m%d_%H%M%S')
            data = tempo[0:4] + "_" + tempo[4:6] + tempo[6:8]

            data_log = datetime.utcnow().strftime('[%Y-%m-%d @ %H:%M:%S UTC]')

            from src.business.configuration.configSystem import ConfigSystem
            log_folder = ConfigSystem()

            if str(log_folder.get_log_path()) == "None":
                if log_folder():
                    name_log_folder = str(log_folder.get_log_path())
                else:
                    name_log_folder = 'Log_folder'
                    os.mkdir(name_log_folder)
            else:
                name_log_folder = str(log_folder.get_log_path())

            from src.business.configuration.configProject import ConfigProject
            ci = ConfigProject()
            name_observatory = str(ci.get_site_settings())
            name_observatory = SbigDriver.get_observatory(name_observatory)

            if int(tempo[9:11]) > 12:
                name_log = name_log_folder + "/LOG_" + name_observatory + "_" + data + '.txt'
                log = open(str(name_log), 'a')
                log.write(str(data_log) + " - " + str(self.text) + "\n")
                log.close()
            else:
                tempo = datetime.utcnow().strftime('%Y%m%d_%H%M%S')
                ano = tempo[0:4]
                mes = tempo[4:6]
                dia = tempo[6:8]
                abs_julian_day = SbigDriver.jd_to_date(
                    SbigDriver.date_to_jd(ano, mes, int(dia)) - 1)

                if 0 < abs_julian_day[2] < 10:
                    name_log = name_log_folder + "/LOG_" + name_observatory + "_" + str(
                        abs_julian_day[0]) + "_" + str(
                            abs_julian_day[1]) + "0" + str(
                                abs_julian_day[2]) + '.txt'
                    log = open(str(name_log), 'a')
                    log.write(str(data_log) + " - " + str(self.text) + "\n")
                    log.close()
                else:
                    name_log = name_log_folder + "/LOG_" + name_observatory + "_" + str(
                        abs_julian_day[0]) + "_" + str(
                            abs_julian_day[1]) + str(
                                abs_julian_day[2]) + '.txt'
                    log = open(str(name_log), 'a')
                    log.write(str(data_log) + " - " + str(self.text) + "\n")
                    log.close()
        except Exception as e:
            print(e)
示例#10
0
 def refresh_all_fields(self):
     try:
         st = ConfigProject()
         infoSite = st.get_site_settings()
         self.site.set_site_info(infoSite[0], infoSite[1], infoSite[2])
         infoGeo = st.get_geographic_settings()
         self.geo.set_geography(infoGeo[0], infoGeo[1], infoGeo[2], infoGeo[3], infoGeo[4])
         infoSun = st.get_moonsun_settings()
         self.sun.set_sun(str(infoSun[0]), infoSun[1], str(infoSun[2]), str(infoSun[3]))
     except Exception as e:
         print(e)
示例#11
0
 def refresh_all_fields(self):
     try:
         st = ConfigProject()
         infoSite = st.get_site_settings()
         self.site.set_site_info(infoSite[0], infoSite[1], infoSite[2])
         infoGeo = st.get_geographic_settings()
         self.geo.set_geography(infoGeo[0], infoGeo[1], infoGeo[2], infoGeo[3], infoGeo[4])
         infoSun = st.get_moonsun_settings()
         self.sun.set_sun(str(infoSun[0]), infoSun[1], str(infoSun[2]), str(infoSun[3]))
     except Exception as e:
         print(e)
示例#12
0
    def get_info(self):
        # Criando uma instância do ConfigProject
        self.config = ConfigProject()

        # Recebendo as informações
        info = self.config.get_geographic_settings()

        # Atribuindo valor as variáveis de geolocalização
        self.latitude = info[0]  # '-45.51'
        self.longitude = info[1]  # '-23.12'
        self.elevation = info[2]  # 350
示例#13
0
def crop(dark_photo, pre, get_axis_xi, get_axis_xf, get_axis_yi, get_axis_yf,
         ignore_crop, img):
    path, tempo = set_path()

    # path, tempo = "/home/hiyoku/Imagens/images/", time.strftime('%Y%m%d_%H%M%S')

    if not os.path.isdir(path):
        os.makedirs(path)

    from src.business.configuration.configProject import ConfigProject
    ci = ConfigProject()
    site_id_name = str(ci.get_site_settings())

    site_id_name = Image_Processing.get_observatory(site_id_name)

    if dark_photo == 1:
        fn = pre + "-DARK" + "_" + site_id_name + "_" + tempo
        name = path + fn
        tifname = name + '.tif'
        tifname_final = fn + '.tif'
        fitname = name + '.fit'
        fitname_final = fn + '.fit'
    else:
        fn = pre + "_" + site_id_name + "_" + tempo
        name = path + fn
        tifname = name + '.tif'
        tifname_final = fn + '.tif'
        fitname = name + '.fit'
        fitname_final = fn + '.fit'

    try:
        os.unlink(tifname)
    except OSError:
        pass
    '''
    Create a new FITS file using the supplied data/header.
    Crop fit image
    '''
    try:
        if not ignore_crop:
            # x = width
            # y = height
            print("Cropping image.")
            print("Width: xi = " + str(get_axis_xi) + " xf = " +
                  str(get_axis_xf))
            print("Height: yi = " + str(get_axis_yi) + " yf = " +
                  str(get_axis_yf))
            img = img[get_axis_yi:get_axis_yf,
                      get_axis_xi:get_axis_xf]  # cropping image
    except Exception as e:
        print("Not possible cropping image ->" + str(e))

    return path, tifname_final, fitname_final, fitname, tifname, site_id_name, tempo, img
示例#14
0
    def __init__(self):
        super(EphemerisShooter, self).__init__()
        self.camconfig = SettingsCamera()
        self.camconfig.setup_settings()
        infocam = self.camconfig.get_camera_settings()

        self.ObserverFactory = EphemObserverFactory()
        self.continuousShooterThread = ContinuousShooterThread(int(infocam[4]))
        self.console = ConsoleThreadOutput()
        self.config = ConfigProject()

        info = self.config.get_geographic_settings()
        infosun = self.config.get_moonsun_settings()

        self.latitude = info[0]  # '-45.51'
        self.longitude = info[1]  # '-23.12'
        self.elevation = info[2]  # 350

        self.max_solar_elevation = infosun[0]  # -12
        self.ignore_lunar_position = infosun[1]
        self.max_lunar_elevation = infosun[2]  # 8
        self.max_lunar_phase = infosun[3]  # 1
        self.t = False

        print(int(infocam[4]))
        try:
            self.s = int(infocam[4])
            self.continuousShooterThread.set_sleep_time(self.s)
        except Exception as e:
            self.s = 5

        self.shootOn = False
        self.controller = True
        self.count = 1
示例#15
0
    def __init__(self, parent=None):
        super(ConfigsInfo, self).__init__(parent)

        # Initing Widgets
        p = cs()
        self.confs = ConfigProject()

        # Init Widget Site Info
        infoSite = self.confs.get_site_settings()
        infoGeo = self.confs.get_geographic_settings()
        # infoGeo[2], infoGeo[3]
        self.site = SiteInfo(infoSite[1], infoSite[2], infoGeo[0], infoGeo[1])

        infoMoon = self.confs.get_moonsun_settings()
        self.moon = EphemInfo(infoMoon[0], infoMoon[2], infoMoon[3])

        self.set_layout()
示例#16
0
class QThreadSunMoon(QtCore.QThread):
    signal_update_sun_moon = QtCore.pyqtSignal([list],
                                               name="signalUpdateSunMoon")

    def __init__(self):
        super(QThreadSunMoon, self).__init__()
        self.eof = EphemObserverFactory()
        self.latitude = None
        self.longitude = None
        self.elevation = None
        self.config = None

        self.obs = None

    def get_info(self):
        # Criando uma instância do ConfigProject
        self.config = ConfigProject()

        # Recebendo as informações
        info = self.config.get_geographic_settings()

        # Atribuindo valor as variáveis de geolocalização
        self.latitude = info[0]  # '-45.51'
        self.longitude = info[1]  # '-23.12'
        self.elevation = info[2]  # 350

    def set_observer(self, longitude, latitude, elevation):
        """ Essa função cria um Observatório do PyEphem para utilizar nos cálculos """
        self.obs = self.eof.create_observer(longitude=longitude,
                                            latitude=latitude,
                                            elevation=elevation)

    def run(self):
        # Pegando as informações
        self.get_info()

        # Criando um Observatório
        self.set_observer(self.longitude, self.latitude, self.elevation)

        while True:
            now_datetime = datetime.utcnow()
            self.obs.date = ephem.date(now_datetime)

            sun = ephem.Sun(self.obs)

            moon = ephem.Moon(self.obs)
            frac = moon.moon_phase

            sun_alt = ephem.degrees(sun.alt)
            moon_alt = ephem.degrees(moon.alt)

            sun_elevation = "{:.2f}º".format(float(math.degrees(sun_alt)))
            moon_elevation = "{:.2f}º".format(float(math.degrees(moon_alt)))
            moon_phase = "{0:.2f}%".format(frac * 100)

            self.signal_update_sun_moon.emit(
                [sun_elevation, moon_elevation, moon_phase])
            time.sleep(1)
示例#17
0
class QThreadSunMoon(QtCore.QThread):
    signal_update_sun_moon = QtCore.pyqtSignal([list], name="signalUpdateSunMoon")

    def __init__(self):
        super(QThreadSunMoon, self).__init__()
        self.eof = EphemObserverFactory()
        self.latitude = None
        self.longitude = None
        self.elevation = None
        self.config = None

        self.obs = None

    def get_info(self):
        # Criando uma instância do ConfigProject
        self.config = ConfigProject()

        # Recebendo as informações
        info = self.config.get_geographic_settings()

        # Atribuindo valor as variáveis de geolocalização
        self.latitude = info[0]  # '-45.51'
        self.longitude = info[1]  # '-23.12'
        self.elevation = info[2]  # 350

    def set_observer(self, longitude, latitude, elevation):
        """ Essa função cria um Observatório do PyEphem para utilizar nos cálculos """
        self.obs = self.eof.create_observer(longitude=longitude,
                                            latitude=latitude,
                                            elevation=elevation)

    def run(self):
        # Pegando as informações
        self.get_info()

        # Criando um Observatório
        self.set_observer(self.longitude, self.latitude, self.elevation)

        while True:
            now_datetime = datetime.utcnow()
            self.obs.date = ephem.date(now_datetime)

            sun = ephem.Sun(self.obs)

            moon = ephem.Moon(self.obs)
            frac = moon.moon_phase

            sun_alt = ephem.degrees(sun.alt)
            moon_alt = ephem.degrees(moon.alt)

            sun_elevation = "{:.2f}º".format(float(math.degrees(sun_alt)))
            moon_elevation = "{:.2f}º".format(float(math.degrees(moon_alt)))
            moon_phase = "{0:.2f}%".format(frac * 100)

            self.signal_update_sun_moon.emit([sun_elevation, moon_elevation, moon_phase])
            time.sleep(1)
示例#18
0
文件: Ephemeris.py 项目: hiyoku/ccd10
    def __init__(self):
        self.config = ConfigProject()
        info = self.config.get_geographic_settings()
        self.latitude = info[0] #'-45.51'
        self.longitude = info[1] #'-23.12'
        self.elev = info[2] #350
        self.shootOn = False

        t = Thread(target=self.check_all)
        t.start()
示例#19
0
    def get_info(self):
        # Criando uma instância do ConfigProject
        self.config = ConfigProject()

        # Recebendo as informações
        info = self.config.get_geographic_settings()

        # Atribuindo valor as variáveis de geolocalização
        self.latitude = info[0]  # '-45.51'
        self.longitude = info[1]  # '-23.12'
        self.elevation = info[2]  # 350
示例#20
0
class ConfigsInfo(QtWidgets.QFrame):
    def __init__(self, parent=None):
        super(ConfigsInfo, self).__init__(parent)

        # Initing Widgets
        p = cs()
        self.confs = ConfigProject()

        # Init Widget Site Info
        infoSite = self.confs.get_site_settings()
        infoGeo = self.confs.get_geographic_settings()
        self.site = SiteInfo(infoSite[1], infoSite[2], infoGeo[0], infoGeo[1], infoGeo[2], infoGeo[3])

        infoMoon = self.confs.get_moonsun_settings()
        self.moon = EphemInfo(infoMoon[0], infoMoon[2], infoMoon[3])

        self.set_layout()

    def set_layout(self):
        self.setLayout(set_wvbox(self.site, self.moon))
示例#21
0
def set_path(pre):
    '''
    :param pre:
    :return: gera nome da pasta e consequente do arquivo fit e png.
    '''
    tempo = datetime.utcnow().strftime('%Y%m%d_%H%M%S')

    data = tempo[0:4] + "_" + tempo[4:6] + tempo[6:8]

    from src.business.configuration.configSystem import ConfigSystem
    cs = ConfigSystem()
    path = str(cs.get_image_path()) + "/"

    from src.business.configuration.configProject import ConfigProject
    ci = ConfigProject()
    name_observatory = str(ci.get_site_settings())
    name_observatory = get_observatory(name_observatory)

    if int(tempo[9:11]) > 12:
        path = path + name_observatory + "_" + data + "/"
    else:
        tempo = datetime.utcnow().strftime('%Y%m%d_%H%M%S')
        ano = tempo[0:4]
        mes = tempo[4:6]
        dia = tempo[6:8]
        abs_julian_day = jd_to_date(date_to_jd(ano, mes, int(dia)) - 1)

        if 0 < abs_julian_day[2] < 10:
            path = path + name_observatory + "_" + str(
                abs_julian_day[0]) + "_" + str(abs_julian_day[1]) + "0" + str(
                    abs_julian_day[2]) + "/"
        else:
            path = path + name_observatory + "_" + str(
                abs_julian_day[0]) + "_" + str(abs_julian_day[1]) + str(
                    abs_julian_day[2]) + "/"

    return path, tempo
示例#22
0
    def __init__(self):

        super(EphemerisShooter, self).__init__()
        self.camconfig = SettingsCamera()
        self.camconfig.setup_settings()
        infocam = self.camconfig.get_camera_settings()

        self.ObserverFactory = EphemObserverFactory()
        self.continuousShooterThread = ContinuousShooterThread(int(infocam[4]))
        self.console = ConsoleThreadOutput()
        self.config = ConfigProject()

        info = self.config.get_geographic_settings()

        self.latitude = info[0]  # '-45.51'
        self.longitude = info[1]  # '-23.12'
        self.elevation = info[2]  # 350

        info_sun = self.config.get_moonsun_settings()
        self.max_solar_elevation = float(info_sun[0])  # -12
        self.ignore_lunar_position = info_sun[1]
        self.max_lunar_elevation = float(info_sun[2])  # 8
        self.max_lunar_phase = float(info_sun[3])  # 1

        self.wait_temperature = False

        print(int(infocam[4]))
        try:
            self.s = int(infocam[4])
            self.continuousShooterThread.set_sleep_time(self.s)
        except Exception as e:
            self.s = 5

        self.shootOn = False
        self.controller = True
        self.count = 1
示例#23
0
def photoshoot(etime, pre, binning):
    # open_driver()
    # open_deviceusb()
    # establishinglink()

    for ccd in SbigLib.CCD_INFO_REQUEST.CCD_INFO_IMAGING.value, SbigLib.CCD_INFO_REQUEST.CCD_INFO_TRACKING.value:

        cin = SbigStructures.ReadOutInfo
        cout = SbigStructures.GetCCDInfoResults0
        udrv.SBIGUnivDrvCommand.argtypes = [c_ushort, POINTER(cin), POINTER(cout)]
        cin = cin(request=ccd)
        cout = cout()
        udrv.SBIGUnivDrvCommand(SbigLib.PAR_COMMAND.CC_GET_CCD_INFO.value, byref(cin), byref(cout))
        # print("Ret: ", ret, "\nFV: ", cout.firmwareVersion, "\nCt:",
        #       cout.cameraType, "\nname", cout.name, "\nReadoutModes: ", cout.readoutModes)

        for i_mode in range(cout.readoutModes):

            # print(cout.readoutInfo[i_mode].mode, cout.readoutInfo[i_mode].width, cout.readoutInfo[i_mode].height,
            #       cout.readoutInfo[i_mode].width, cout.readoutInfo[i_mode].gain, cout.readoutInfo[i_mode].pixel_width,
            #       cout.readoutInfo[i_mode].pixel_height)
            if ccd == SbigLib.CCD_INFO_REQUEST.CCD_INFO_IMAGING.value and i_mode == 0:
                readout_mode = [
                    cout.readoutInfo[i_mode].mode, cout.readoutInfo[i_mode].width, cout.readoutInfo[i_mode].height,
                    cout.readoutInfo[i_mode].width, cout.readoutInfo[i_mode].gain, cout.readoutInfo[i_mode].pixel_width,
                    cout.readoutInfo[i_mode].pixel_height]  # STORE FIRST MODE OF IMAGING CCD FOR EXPOSURE TEST

                # Setting the Gain and Bining with Width and Height

    v_read = 0
    v_h = readout_mode[2]
    v_w = readout_mode[1]
    if binning == 1:
        v_read = 1
        v_h = int(v_h / 2)
        v_w = int(v_w / 2)
    elif binning == 2:
        v_read = 2
        v_h = int(v_h / 3)
        v_w = int(v_w / 3)

    print("Binning = " + str(v_read))
    print("Height = " + str(v_h))
    print("Width = " + str(v_w))

    print("GRAB IMAGE - Start Exposure")
    cin = SbigStructures.StartExposureParams2
    cout = None
    udrv.SBIGUnivDrvCommand.argtypes = [c_ushort, POINTER(cin), POINTER(cout)]
    cin = cin(ccd=SbigLib.CCD_REQUEST.CCD_IMAGING.value, exposureTime=etime,
              openShutter=SbigLib.SHUTTER_COMMAND.SC_OPEN_SHUTTER.value, readoutMode=v_read, top=0, left=0,
              height=v_h, width=v_w)
    print("Readout Height: " + str(v_h))
    print("Readout Width: " + str(v_w))
    ret = udrv.SBIGUnivDrvCommand(SbigLib.PAR_COMMAND.CC_START_EXPOSURE2.value, byref(cin), cout)
    print("Ret: ", ret)

    print("GRAB IMAGE - Query Command Status")

    t0 = time.time()
    status = 2
    while status == 2:
        cin = SbigStructures.QueryCommandStatusParams
        cout = SbigStructures.QueryCommandStatusResults
        udrv.SBIGUnivDrvCommand.argtypes = [c_ushort, POINTER(cin), POINTER(cout)]
        cin = cin(command=SbigLib.PAR_COMMAND.CC_START_EXPOSURE2.value)
        cout = cout()
        udrv.SBIGUnivDrvCommand(SbigLib.PAR_COMMAND.CC_QUERY_COMMAND_STATUS.value, byref(cin), byref(cout))

        status = cout.status
        print("Status: %3.2f sec - %s" % (time.time() - t0, status))
        time.sleep(0.01)

    print("GRAB IMAGE - End Exposure")

    cin = SbigStructures.EndExposureParams
    cout = None
    udrv.SBIGUnivDrvCommand.argtypes = [c_ushort, POINTER(cin), POINTER(cout)]
    cin = cin(ccd=SbigLib.CCD_REQUEST.CCD_IMAGING.value)
    udrv.SBIGUnivDrvCommand(SbigLib.PAR_COMMAND.CC_END_EXPOSURE.value, byref(cin), cout)

    print("GRAB IMAGE - Start Readout")

    cin = SbigStructures.StartReadoutParams
    cout = None
    udrv.SBIGUnivDrvCommand.argtypes = [c_ushort, POINTER(cin), POINTER(cout)]

    cin = cin(command=SbigLib.PAR_COMMAND.CC_START_EXPOSURE2.value, readoutMode=v_read, top=0, left=0,
              height=v_h, width=v_w)
    ret = udrv.SBIGUnivDrvCommand(SbigLib.PAR_COMMAND.CC_START_READOUT.value, byref(cin), cout)
    print("ret: ", ret)
    print(SbigLib.PAR_COMMAND.CC_START_READOUT.value)

    print("GRAB IMAGE - Readout Lines")

    img = np.zeros((v_h, v_w))

    for i_line in range(v_h):
        cin = SbigStructures.ReadoutLineParams
        cout = c_ushort * v_w
        udrv.SBIGUnivDrvCommand.argtypes = [c_ushort, POINTER(cin), POINTER(cout)]
        cin = cin(ccd=SbigLib.CCD_REQUEST.CCD_IMAGING.value, readoutMode=v_read, pixelStart=0,
                  pixelLength=v_w)
        cout = cout()
        udrv.SBIGUnivDrvCommand(SbigLib.PAR_COMMAND.CC_READOUT_LINE.value, byref(cin), byref(cout))
        img[i_line] = cout

    path, tempo = set_path(pre)

    # path, tempo = "/home/hiyoku/Imagens/images/", time.strftime('%Y%m%d_%H%M%S')

    if not os.path.isdir(path):
        os.makedirs(path)

    from src.business.configuration.configProject import ConfigProject
    ci = ConfigProject()
    site_id_name = str(ci.get_site_settings())

    site_id_name = get_observatory(site_id_name)

    fn = pre + "_" + site_id_name + "_" + tempo
    name = path + fn
    fitsname = name + '.fits'
    pngname = name + '.png'
    fitsname_final = fn + '.fits'
    pngname_final = fn + '.png'

    try:
        os.unlink(fitsname)
    except OSError:
        pass

    fits.writeto(fitsname, img)
    #src.utils.camera.SbigDriver.site
    print("\nGRAB IMAGE - End Readout\n")

    cin = SbigStructures.EndReadoutParams
    cout = None
    udrv.SBIGUnivDrvCommand.argtypes = [c_ushort, POINTER(cin), POINTER(cout)]
    cin = cin(ccd=SbigLib.CCD_REQUEST.CCD_IMAGING.value)
    ret = udrv.SBIGUnivDrvCommand(SbigLib.PAR_COMMAND.CC_END_READOUT.value, byref(cin), cout)
    print("ret", ret)

    # cmd(SbigLib.PAR_COMMAND.CC_CLOSE_DEVICE.value, None, None)

    # cmd(SbigLib.PAR_COMMAND.CC_CLOSE_DRIVER.value, None, None)

    print("Call set_header")
    set_header(fitsname)
    print("Call set_png")
    set_png(fitsname, pngname)

    data, hora = get_date_hour(tempo)
    print("End of process")
    return path, pngname_final, fitsname_final, data, hora
示例#24
0
class Ephemeris:
    def __init__(self):
        self.config = ConfigProject()
        info = self.config.get_geographic_settings()
        self.latitude = info[0]  #'-45.51'
        self.longitude = info[1]  #'-23.12'
        self.elev = info[2]  #350
        self.shootOn = False

        t = Thread(target=self.check_all)
        t.start()

    def refresh_data(self):
        info = self.config.get_geographic_settings()
        self.latitude = info[0]  # '-45.51'
        self.longitude = info[1]  # '-23.12'
        self.elev = info[2]  # 350

    def print_time_elapsed(self):
        init_time = datetime.datetime.utcnow()

        while True:
            now_datetime = datetime.datetime.utcnow()
            sys.stdout.write(
                "\r Time elapsed from init: {}".format(now_datetime -
                                                       init_time))
            sys.stdout.flush()
            sleep(1)

    def check_all(self):
        log = open('logging.txt', 'a')

        tTime = Thread(target=self.print_time_elapsed)
        tTime.start()

        try:
            while True:
                now_datetime = datetime.datetime.utcnow()
                obs = ephem.Observer()
                obs.lon = self.longitude
                obs.lat = self.latitude
                obs.elevation = self.elev
                obs.date = ephem.date(now_datetime)

                sun = ephem.Sun()
                sun.compute(obs)

                moon = ephem.Moon()
                moon.compute(obs)
                frac = moon.moon_phase

                a = ephem.degrees(str(sun.alt))
                b = ephem.degrees(str(moon.alt))
                if degrees(a) < -12 and degrees(b) < 10:
                    self.shootOn = True
                else:
                    self.shootOn = False

                # Creating a log
                log.write("{} - {} - ".format(self.shootOn, now_datetime))
                log.write("Sun: {:.4f}  Moon: {:.4f}\n".format(
                    degrees(a), degrees(b)))

                # Printing on the stdout
                # sys.stdout.write("\rShooting: {}".format(str(self.shootOn)))
                # sys.stdout.flush()
                sleep(60)
        except Exception as e:
            print(e)
            log.close()

    '''
示例#25
0
文件: Ephemeris.py 项目: hiyoku/ccd10
class Ephemeris():
    def __init__(self):
        self.config = ConfigProject()
        info = self.config.get_geographic_settings()
        self.latitude = info[0] #'-45.51'
        self.longitude = info[1] #'-23.12'
        self.elev = info[2] #350
        self.shootOn = False

        t = Thread(target=self.check_all)
        t.start()

    def refresh_data(self):
        info = self.config.get_geographic_settings()
        self.latitude = info[0]  # '-45.51'
        self.longitude = info[1]  # '-23.12'
        self.elev = info[2]  # 350


    def print_time_elapsed(self):
        init_time = datetime.datetime.utcnow()

        while True:
            now_datetime = datetime.datetime.utcnow()
            sys.stdout.write("\r Time elapsed from init: {}".format(now_datetime - init_time))
            sys.stdout.flush()
            sleep(1)

    def check_all(self):
        log = open('logging.txt', 'a')

        tTime = Thread(target=self.print_time_elapsed)
        tTime.start()

        try:
            while True:
                now_datetime = datetime.datetime.utcnow()
                obs = ephem.Observer()
                obs.lon = self.longitude
                obs.lat = self.latitude
                obs.elevation = self.elev
                obs.date = ephem.date(now_datetime)

                sun = ephem.Sun()
                sun.compute(obs)

                moon = ephem.Moon()
                moon.compute(obs)
                frac=moon.moon_phase

                a = ephem.degrees(str(sun.alt))
                b = ephem.degrees(str(moon.alt))
                if(degrees(a) < -12 and degrees(b) < 10):
                    self.shootOn = True
                else:
                    self.shootOn = False

                # Creating a log
                log.write("{} - {} - ".format(self.shootOn, now_datetime))
                log.write("Sun: {:.4f}  Moon: {:.4f}\n".format(degrees(a), degrees(b)))

                # Printing on the stdout
                # sys.stdout.write("\rShooting: {}".format(str(self.shootOn)))
                # sys.stdout.flush()
                sleep(60)
        except Exception as e:
            print(e)
            log.close()
示例#26
0
class EphemerisShooter(QtCore.QThread):
    signal_started_shooting = QtCore.pyqtSignal(name="signalStartedShooting")
    signal_temp = QtCore.pyqtSignal(name="signalTemp")

    def __init__(self):
        super(EphemerisShooter, self).__init__()
        self.camconfig = SettingsCamera()
        self.camconfig.setup_settings()
        infocam = self.camconfig.get_camera_settings()

        self.ObserverFactory = EphemObserverFactory()
        self.continuousShooterThread = ContinuousShooterThread(int(infocam[4]))
        self.console = ConsoleThreadOutput()
        self.config = ConfigProject()

        info = self.config.get_geographic_settings()
        infosun = self.config.get_moonsun_settings()

        self.latitude = info[0]  # '-45.51'
        self.longitude = info[1]  # '-23.12'
        self.elevation = info[2]  # 350

        self.max_solar_elevation = infosun[0]  # -12
        self.ignore_lunar_position = infosun[1]
        self.max_lunar_elevation = infosun[2]  # 8
        self.max_lunar_phase = infosun[3]  # 1
        self.t = False

        print(int(infocam[4]))
        try:
            self.s = int(infocam[4])
            self.continuousShooterThread.set_sleep_time(self.s)
        except Exception as e:
            self.s = 5

        self.shootOn = False
        self.controller = True
        self.count = 1

    def refresh_data(self):
        try:
            info = self.config.get_geographic_settings()
            self.latitude = info[0]  # '-45.51'
            self.longitude = info[1]  # '-23.12'
            self.elevation = info[2]  # 350

            infosun = self.config.get_moonsun_settings()
            self.max_solar_elevation = float(infosun[0])  # -12
            self.ignore_lunar_position = infosun[1]
            self.max_lunar_elevation = float(infosun[2])  # 8
            self.max_lunar_phase = float(infosun[3])  # 1

        except Exception as e:
            self.console.raise_text("Exception thrown to acquire information\n"
                                    "Please set an observatory information on settings\n" + str(e), level=3)
            self.latitude = 0
            self.longitude = 0
            self.elevation = 0
            self.max_solar_elevation = 0
            self.max_lunar_elevation = 0
            self.max_lunar_phase = 0

        infocam = self.camconfig.get_camera_settings()

        try:
            self.s = int(infocam[4])
        except Exception as e:
            self.s = 0

    def calculate_moon(self, obs):
        aux = obs
        aux.compute_pressure()
        aux.horizon = '8'
        moon = ephem.Moon(aux)
        return aux.previous_setting(moon), aux.next_rising(moon)

    def calculate_sun(self, obs):
        aux = obs
        aux.compute_pressure()
        aux.horizon = '-12'
        sun = ephem.Sun(aux)
        return aux.previous_setting(sun), aux.next_rising(sun)

    def set_solar_and_lunar_parameters(self, maxSolarElevation, maxLunarElevation, maxLunarPhase):
        self.max_solar_elevation = maxSolarElevation
        self.max_lunar_elevation = maxLunarElevation
        self.max_lunar_phase = maxLunarPhase

    def run(self):
        self.refresh_data()

        obs = self.ObserverFactory.create_observer(longitude=self.longitude,
                                                   latitude=self.latitude,
                                                   elevation=self.elevation)

        self.controller = True
        self.shootOn = False
        c = 0
        try:
            while self.controller:
                obs.date = ephem.date(datetime.datetime.utcnow())

                sun = ephem.Sun(obs)
                moon = ephem.Moon(obs)

                frac = moon.moon_phase

                a = ephem.degrees(sun.alt)
                b = ephem.degrees(str(moon.alt))

                # Variavel de controle do shooter
                t = 1

                if float(math.degrees(a)) < self.max_solar_elevation or t == 1:
                    if (self.ignore_lunar_position == False and float(math.degrees(b)) < self.max_lunar_elevation
                            and frac < self.max_lunar_phase) or self.ignore_lunar_position:


                        if not self.shootOn:
                            if not c:
                                self.signal_started_shooting.emit()
                                c = 1
                            self.signal_temp.emit()
                            time.sleep(5)

                            if self.t:
                                # Iniciar as Observações
                                self.start_taking_photo()
                                self.shootOn = True

                else:
                    if self.shootOn:
                        # Finalizar as Observações
                        self.stop_taking_photo()
                        c = 0
                        self.shootOn = False

                time.sleep(5)
        except Exception as e:
            self.console.raise_text("Exception no Ephemeris Shooter -> " + str(e))

    def stop_shooter(self):
        self.controller = False
        self.continuousShooterThread.stop_continuous_shooter()

    def start_taking_photo(self):
        self.continuousShooterThread.set_sleep_time(self.s)
        self.continuousShooterThread.start_continuous_shooter()
        self.continuousShooterThread.start()

    def stop_taking_photo(self):
        self.continuousShooterThread.stop_continuous_shooter()
示例#27
0
class EphemerisShooter(QtCore.QThread):
    '''
        classe para modo automatico
    '''

    signal_started_shooting = QtCore.pyqtSignal(name="signalStartedShooting")
    signal_temp = QtCore.pyqtSignal(name="signalTemp")

    def __init__(self):

        super(EphemerisShooter, self).__init__()

        self.ObserverFactory = EphemObserverFactory()
        # self.continuousShooterThread = ContinuousShooterThread(int(info_cam[4]))
        self.continuousShooterThread = ContinuousShooterThread(0)
        self.console = ConsoleThreadOutput()
        self.config = ConfigProject()

        info = self.config.get_geographic_settings()
        info_sun = self.config.get_moonsun_settings()

        self.latitude = info[0]  # '-45.51'
        self.longitude = info[1]  # '-23.12'
        self.elevation = info[2]  # 350

        self.max_solar_elevation = info_sun[0]  # -12
        self.ignore_lunar_position = info_sun[1]
        self.max_lunar_elevation = info_sun[2]  # 8
        self.max_lunar_phase = info_sun[3]  # 1
        self.wait_temperature = False

        self.shootOn = False
        self.controller = True
        self.count = 1

    def refresh_data(self):
        try:
            info = self.config.get_geographic_settings()
            self.latitude = info[0]  # '-45.51'
            self.longitude = info[1]  # '-23.12'
            self.elevation = info[2]  # 350

            info_sun = self.config.get_moonsun_settings()
            self.max_solar_elevation = float(info_sun[0])  # -12
            self.ignore_lunar_position = info_sun[1]
            self.max_lunar_elevation = float(info_sun[2])  # 8
            self.max_lunar_phase = float(info_sun[3])  # 1

        except Exception as e:
            self.console.raise_text(
                "Exception thrown to acquire information\n"
                "Please set an observatory information on settings\n" + str(e),
                level=3)
            self.latitude = 0
            self.longitude = 0
            self.elevation = 0
            self.max_solar_elevation = 0
            self.max_lunar_elevation = 0
            self.max_lunar_phase = 0

    def calculate_moon(self, obs):
        aux = obs
        aux.compute_pressure()
        aux.horizon = '8'
        moon = ephem.Moon(aux)
        return aux.previous_setting(moon), aux.next_rising(moon)

    def calculate_sun(self, obs):
        aux = obs
        aux.compute_pressure()
        aux.horizon = '-12'
        sun = ephem.Sun(aux)
        return aux.previous_setting(sun), aux.next_rising(sun)

    def set_solar_and_lunar_parameters(self, maxSolarElevation,
                                       maxLunarElevation, maxLunarPhase):
        self.max_solar_elevation = maxSolarElevation
        self.max_lunar_elevation = maxLunarElevation
        self.max_lunar_phase = maxLunarPhase

    def run(self):
        self.refresh_data()

        obs = self.ObserverFactory.create_observer(longitude=self.longitude,
                                                   latitude=self.latitude,
                                                   elevation=self.elevation)

        self.controller = True
        self.shootOn = False
        c = 0
        try:
            while self.controller:
                obs.date = ephem.date(datetime.datetime.utcnow())

                sun = ephem.Sun(obs)
                moon = ephem.Moon(obs)

                frac = moon.moon_phase

                a = ephem.degrees(sun.alt)
                b = ephem.degrees(str(moon.alt))

                # Variavel de controle do shooter
                t = 0

                if float(math.degrees(a)) < self.max_solar_elevation or t == 1:
                    if (not self.ignore_lunar_position and
                            float(math.degrees(b)) < self.max_lunar_elevation
                            and frac < self.max_lunar_phase
                        ) or self.ignore_lunar_position:

                        if not self.shootOn:
                            if not c:
                                self.signal_started_shooting.emit()
                                c = 1

                            self.signal_temp.emit()
                            time.sleep(5)
                            if self.wait_temperature:
                                # Iniciar as Observações
                                self.start_taking_photo()
                                self.shootOn = True

                else:
                    if self.shootOn:
                        # Finalizar as Observações
                        self.stop_taking_photo()
                        c = 0
                        self.t = False
                        self.shootOn = False

                time.sleep(5)
        except Exception as e:
            self.console.raise_text("Exception no Ephemeris Shooter -> " +
                                    str(e))

    def stop_shooter(self):
        self.controller = False
        self.continuousShooterThread.stop_continuous_shooter()

    def start_taking_photo(self):
        self.continuousShooterThread.start_continuous_shooter()
        self.continuousShooterThread.start()

    def stop_taking_photo(self):
        self.continuousShooterThread.stop_continuous_shooter()
示例#28
0
def result():
    config = ConfigProject()

    info = config.get_geographic_settings()
    infosun = config.get_moonsun_settings()

    max_solar_elevation = float(infosun[0])
    max_lunar_elevation = float(infosun[2])
    max_lunar_phase = float(infosun[3])
    ignorar_lua = infosun[1]

    now_datetime = datetime.datetime.utcnow().replace(hour=12).replace(minute=00).replace(second=0)
    obs = ephem.Observer()

    obs.lat = info[0]
    obs.lon = info[1]
    obs.elevation = float(info[2])
    obs.date = ephem.date(now_datetime)

    sun = ephem.Sun()
    sun.compute(obs)
    moon = ephem.Moon()
    moon.compute(obs)
    j = 0
    flag = 0
    ephem_out = False

    while not ephem_out:

        obs.date = ephem.date(now_datetime)
        sun = ephem.Sun()
        sun.compute(obs)

        moon = ephem.Moon()
        moon.compute(obs)
        frac = float(moon.moon_phase) * 100.0

        ag_s = float(repr(sun.alt))
        s_ag = math.degrees(ag_s)
        ag_m = float(repr(moon.alt))
        m_ag = math.degrees(ag_m)

        if ignorar_lua:
            if (float(s_ag) <= max_solar_elevation) and (flag == 0):
                flag = 1
                start = now_datetime
            if (float(s_ag) > max_solar_elevation) and (flag == 1):
                flag = 0
                end = now_datetime
                ephem_out = True
        else:
            if (frac < max_lunar_phase):

                if (float(s_ag) <= max_solar_elevation) and (float(m_ag) <= max_lunar_elevation) and (flag == 0):
                    flag = 1
                    start = now_datetime
                if (float(s_ag) > max_solar_elevation or float(m_ag) > max_lunar_elevation) and (flag == 1):
                    flag = 0
                    end = now_datetime
                    ephem_out = True
            else:
                if (float(s_ag) <= max_solar_elevation) and (float(m_ag) <= float(5.0)) and (flag == 0):
                    flag = 1
                    start = now_datetime
                if (float(s_ag) > max_solar_elevation or float(m_ag) > float(5.0)) and (flag == 1):
                    flag = 0
                    end = now_datetime
                    ephem_out = True
        now_datetime = datetime.datetime.utcnow().replace(hour=12).replace(minute=00).replace(second=0) + timedelta(
            minutes=j)

        j += 1

    obs_time = end - start

    return start, end, obs_time
示例#29
0
class EphemerisShooter(QtCore.QThread):
    '''
        classe para modo automatico
    '''

    signal_started_shooting = QtCore.pyqtSignal(name="signalStartedShooting")
    signal_temp = QtCore.pyqtSignal(name="signalTemp")

    def __init__(self):

        super(EphemerisShooter, self).__init__()
        self.camconfig = SettingsCamera()
        self.camconfig.setup_settings()
        infocam = self.camconfig.get_camera_settings()

        self.ObserverFactory = EphemObserverFactory()
        self.continuousShooterThread = ContinuousShooterThread(int(infocam[4]))
        self.console = ConsoleThreadOutput()
        self.config = ConfigProject()

        info = self.config.get_geographic_settings()

        self.latitude = info[0]  # '-45.51'
        self.longitude = info[1]  # '-23.12'
        self.elevation = info[2]  # 350

        info_sun = self.config.get_moonsun_settings()
        self.max_solar_elevation = float(info_sun[0])  # -12
        self.ignore_lunar_position = info_sun[1]
        self.max_lunar_elevation = float(info_sun[2])  # 8
        self.max_lunar_phase = float(info_sun[3])  # 1

        self.wait_temperature = False

        print(int(infocam[4]))
        try:
            self.s = int(infocam[4])
            self.continuousShooterThread.set_sleep_time(self.s)
        except Exception as e:
            self.s = 5

        self.shootOn = False
        self.controller = True
        self.count = 1

    def refresh_data(self):
        try:
            info = self.config.get_geographic_settings()
            self.latitude = info[0]  # '-45.51'
            self.longitude = info[1]  # '-23.12'
            self.elevation = info[2]  # 350

            infosun = self.config.get_moonsun_settings()
            self.max_solar_elevation = float(infosun[0])  # -12
            self.ignore_lunar_position = infosun[1]
            self.max_lunar_elevation = float(infosun[2])  # 8
            self.max_lunar_phase = float(infosun[3])  # 1

        except Exception as e:
            self.console.raise_text("Exception thrown to acquire information\n"
                                    "Please set an observatory information on settings\n" + str(e), level=3)
            self.latitude = 0
            self.longitude = 0
            self.elevation = 0
            self.max_solar_elevation = 0
            self.max_lunar_elevation = 0
            self.max_lunar_phase = 0

        infocam = self.camconfig.get_camera_settings()

        try:
            self.s = int(infocam[4])
        except Exception as e:
            self.s = 0

    def calculate_moon(self, obs):
        aux = obs
        aux.compute_pressure()
        aux.horizon = '8'
        moon = ephem.Moon(aux)
        return aux.previous_setting(moon), aux.next_rising(moon)

    def calculate_sun(self, obs):
        aux = obs
        aux.compute_pressure()
        aux.horizon = '-12'
        sun = ephem.Sun(aux)
        return aux.previous_setting(sun), aux.next_rising(sun)

    def set_solar_and_lunar_parameters(self, maxSolarElevation, maxLunarElevation, maxLunarPhase):
        self.max_solar_elevation = maxSolarElevation
        self.max_lunar_elevation = maxLunarElevation
        self.max_lunar_phase = maxLunarPhase

    def run(self):
        self.refresh_data()

        obs = self.ObserverFactory.create_observer(longitude=self.longitude,
                                                   latitude=self.latitude,
                                                   elevation=self.elevation)

        self.controller = True
        self.shootOn = False
        c = 0
        flag = 0
        try:
            while self.controller:
                obs.date = ephem.date(datetime.datetime.utcnow())
                sun = ephem.Sun(obs)
                moon = ephem.Moon(obs)

                # frac = moon.moon_phase
                frac = float(moon.moon_phase) * 100.0

                a = ephem.degrees(sun.alt)
                b = ephem.degrees(str(moon.alt))

                # Variavel de controle do shooter
                t = 0

                # print("\n\n")
                # print("math.degrees(a) = " + str(math.degrees(a)))
                # print("self.max_solar_elevation = " + str(self.max_solar_elevation))
                # print("self.ignore_lunar_position = " + str(self.ignore_lunar_position))
                # print("math.degrees(b) = " + str(math.degrees(b)))
                # print("self.max_lunar_elevation = " + str(self.max_lunar_elevation))
                # print("self.max_lunar_phase = " + str(self.max_lunar_phase))
                # print("\n\n")
                '''
                obs.date = ephem.date(now_datetime)
                sun = ephem.Sun()
                sun.compute(obs)

                moon = ephem.Moon()
                moon.compute(obs)
                frac = float(moon.moon_phase) * 100.0

                ag_s = float(repr(sun.alt))
                s_ag = math.degrees(ag_s)
                ag_m = float(repr(moon.alt))
                m_ag = math.degrees(ag_m)
                '''
                # flag = 0
                ephem_out = False

                # **************************************** Ephem Loop ****************************************

                if self.ignore_lunar_position:
                    if (float(math.degrees(a)) <= self.max_solar_elevation) and (flag == 0):

                        if not self.shootOn:
                            if not c:
                                self.signal_started_shooting.emit()
                                c = 1
                                # flag = 1
                            self.signal_temp.emit()
                            time.sleep(5)
                            if self.wait_temperature:
                                # Iniciar as Observações
                                self.start_taking_photo()
                                self.shootOn = True
                                self.log_ephem_infos()
                                flag = 1

                    if (float(math.degrees(a)) > self.max_solar_elevation) and (flag == 1):

                        if self.shootOn:
                            # Finalizar as Observações
                            self.stop_taking_photo()
                            c = 0
                            flag = 0
                            self.t = False
                            self.shootOn = False
                else:
                    if frac < self.max_lunar_phase:
                        if (float(math.degrees(a)) <= self.max_solar_elevation) and (float(math.degrees(b)) <= self.max_lunar_elevation) and (flag == 0):
                            if not self.shootOn:
                                if not c:
                                    self.signal_started_shooting.emit()
                                    c = 1
                                    # flag = 1
                                self.signal_temp.emit()
                                time.sleep(5)
                                if self.wait_temperature:
                                    # Iniciar as Observações
                                    self.start_taking_photo()
                                    self.shootOn = True
                                    self.log_ephem_infos()
                                    flag = 1

                        if (float(math.degrees(a)) > self.max_solar_elevation or float(math.degrees(b)) > self.max_lunar_elevation) and (flag == 1):

                            if self.shootOn:
                                # Finalizar as Observações
                                self.stop_taking_photo()
                                c = 0
                                flag = 0
                                self.t = False
                                self.shootOn = False
                    else:
                        if (float(math.degrees(a)) <= self.max_solar_elevation) and (float(math.degrees(b)) <= float(5.0)) and (flag == 0):
                            if not self.shootOn:
                                if not c:
                                    self.signal_started_shooting.emit()
                                    c = 1
                                    # flag = 1
                                self.signal_temp.emit()
                                time.sleep(5)
                                if self.wait_temperature:
                                    # Iniciar as Observações
                                    self.start_taking_photo()
                                    self.shootOn = True
                                    self.log_ephem_infos()
                                    flag = 1

                        if (float(math.degrees(a)) > self.max_solar_elevation or float(math.degrees(b)) > float(5.0)) and (flag == 1):
                            if self.shootOn:
                                # Finalizar as Observações
                                self.stop_taking_photo()
                                c = 0
                                flag = 0
                                self.t = False
                                self.shootOn = False

                # **************************************** Ephem Loop ****************************************

                '''
                if float(math.degrees(a)) < self.max_solar_elevation or t == 1:
                    if (not self.ignore_lunar_position and float(math.degrees(b)) < self.max_lunar_elevation
                            and frac < self.max_lunar_phase) or self.ignore_lunar_position:

                        if not self.shootOn:
                            if not c:
                                self.signal_started_shooting.emit()
                                c = 1

                            self.signal_temp.emit()
                            time.sleep(5)
                            if self.wait_temperature:
                                # Iniciar as Observações
                                self.start_taking_photo()
                                self.shootOn = True

                else:
                    if self.shootOn:
                        # Finalizar as Observações
                        self.stop_taking_photo()
                        c = 0
                        self.t = False
                        self.shootOn = False

                time.sleep(5)
                '''
        except Exception as e:
            self.console.raise_text("Exception no Ephemeris Shooter -> " + str(e))

    def stop_shooter(self):
        self.controller = False
        if self.continuousShooterThread.isRunning():
            self.continuousShooterThread.stop_continuous_shooter()
        """
        if not self.continuousShooterThread.wait_temperature:
                self.continuousShooterThread.stop_continuous_shooter()
        """

    def start_taking_photo(self):
        self.continuousShooterThread.set_sleep_time(self.s)
        self.continuousShooterThread.start_continuous_shooter()
        self.continuousShooterThread.start()

    def stop_taking_photo(self):
        self.continuousShooterThread.stop_continuous_shooter()

    def log_ephem_infos(self):
        info_start_end = result()
        start_time = str(info_start_end[0])
        start_field = start_time[:-10] + " UTC"
        end_time = str(info_start_end[1])
        end_field = end_time[:-10] + " UTC"
        '''
        time_obs_time = str(info_start_end[2]).split(":")
        time_obs_time = [z.split(".")[0] for z in time_obs_time]
        time_obs_field = time_obs_time[0] + ":" + time_obs_time[1] + " Hours"
        '''
        # self.console.raise_text("Start Time: " + start_field + "; End Time: " + end_field, 2)
        self.console.save_log("Start Time: " + start_field + "; End Time: " + end_field)
示例#30
0
def photoshoot(etime, pre, binning, dark_photo, get_level1, get_level2):
    '''
    :param etime: tempo de exposição
    :param pre: prefixo do nome do arquivo
    :param binning: redução da imagem
    :param dark_photo: shooter fechado = 1 ou aberto = 0
    :param get_level1: limite inferior para auto contraste
    :param get_level2: limite superior para auto contraste
    '''
    # open_driver()
    # open_deviceusb()
    # establishinglink()
    if 0.0 < float(get_level1) < 1.0:
        get_level1 = float(get_level1)
    else:
        get_level1 = 0.1

    if 0.0 < float(get_level2) < 1.0:
        get_level2 = float(get_level2)
    else:
        get_level2 = 0.99

    for ccd in SbigLib.CCD_INFO_REQUEST.CCD_INFO_IMAGING.value, SbigLib.CCD_INFO_REQUEST.CCD_INFO_TRACKING.value:

        cin = SbigStructures.ReadOutInfo
        cout = SbigStructures.GetCCDInfoResults0
        udrv.SBIGUnivDrvCommand.argtypes = [
            c_ushort, POINTER(cin), POINTER(cout)
        ]
        cin = cin(request=ccd)
        cout = cout()
        udrv.SBIGUnivDrvCommand(SbigLib.PAR_COMMAND.CC_GET_CCD_INFO.value,
                                byref(cin), byref(cout))
        # print("Ret: ", ret, "\nFV: ", cout.firmwareVersion, "\nCt:",
        #       cout.cameraType, "\nname", cout.name, "\nReadoutModes: ", cout.readoutModes)

        for i_mode in range(cout.readoutModes):

            # print(cout.readoutInfo[i_mode].mode, cout.readoutInfo[i_mode].width, cout.readoutInfo[i_mode].height,
            #       cout.readoutInfo[i_mode].width, cout.readoutInfo[i_mode].gain, cout.readoutInfo[i_mode].pixel_width,
            #       cout.readoutInfo[i_mode].pixel_height)
            if ccd == SbigLib.CCD_INFO_REQUEST.CCD_INFO_IMAGING.value and i_mode == 0:
                readout_mode = [
                    cout.readoutInfo[i_mode].mode,
                    cout.readoutInfo[i_mode].width,
                    cout.readoutInfo[i_mode].height,
                    cout.readoutInfo[i_mode].width,
                    cout.readoutInfo[i_mode].gain,
                    cout.readoutInfo[i_mode].pixel_width,
                    cout.readoutInfo[i_mode].pixel_height
                ]  # STORE FIRST MODE OF IMAGING CCD FOR EXPOSURE TEST

                # Setting the Gain and Bining with Width and Height

    v_read = 0
    v_h = readout_mode[2]
    v_w = readout_mode[1]
    if binning == 1:
        v_read = 1
        v_h = int(v_h / 2)
        v_w = int(v_w / 2)
    elif binning == 2:
        v_read = 2
        v_h = int(v_h / 3)
        v_w = int(v_w / 3)

    print("Binning = " + str(v_read))
    print("Height = " + str(v_h))
    print("Width = " + str(v_w))

    print("GRAB IMAGE - Start Exposure")
    cin = SbigStructures.StartExposureParams2
    cout = None
    udrv.SBIGUnivDrvCommand.argtypes = [c_ushort, POINTER(cin), POINTER(cout)]

    try:
        if dark_photo == 1:
            cin = cin(
                ccd=SbigLib.CCD_REQUEST.CCD_IMAGING.value,
                exposureTime=etime,
                openShutter=SbigLib.SHUTTER_COMMAND.SC_CLOSE_SHUTTER.value,
                readoutMode=v_read,
                top=0,
                left=0,
                height=v_h,
                width=v_w)
        else:
            cin = cin(
                ccd=SbigLib.CCD_REQUEST.CCD_IMAGING.value,
                exposureTime=etime,
                openShutter=SbigLib.SHUTTER_COMMAND.SC_OPEN_SHUTTER.value,
                readoutMode=v_read,
                top=0,
                left=0,
                height=v_h,
                width=v_w)
    except Exception:
        cin = cin(ccd=SbigLib.CCD_REQUEST.CCD_IMAGING.value,
                  exposureTime=etime,
                  openShutter=SbigLib.SHUTTER_COMMAND.SC_OPEN_SHUTTER.value,
                  readoutMode=v_read,
                  top=0,
                  left=0,
                  height=v_h,
                  width=v_w)

    print("Readout Height: " + str(v_h))
    print("Readout Width: " + str(v_w))
    ret = udrv.SBIGUnivDrvCommand(SbigLib.PAR_COMMAND.CC_START_EXPOSURE2.value,
                                  byref(cin), cout)
    print("Ret: ", ret)

    print("GRAB IMAGE - Query Command Status")

    t0 = time.time()
    status = 2
    while status == 2:
        cin = SbigStructures.QueryCommandStatusParams
        cout = SbigStructures.QueryCommandStatusResults
        udrv.SBIGUnivDrvCommand.argtypes = [
            c_ushort, POINTER(cin), POINTER(cout)
        ]
        cin = cin(command=SbigLib.PAR_COMMAND.CC_START_EXPOSURE2.value)
        cout = cout()
        udrv.SBIGUnivDrvCommand(
            SbigLib.PAR_COMMAND.CC_QUERY_COMMAND_STATUS.value, byref(cin),
            byref(cout))

        status = cout.status
        print("Status: %3.2f sec - %s" % (time.time() - t0, status))
        time.sleep(0.01)

    print("GRAB IMAGE - End Exposure")

    cin = SbigStructures.EndExposureParams
    cout = None
    udrv.SBIGUnivDrvCommand.argtypes = [c_ushort, POINTER(cin), POINTER(cout)]
    cin = cin(ccd=SbigLib.CCD_REQUEST.CCD_IMAGING.value)
    udrv.SBIGUnivDrvCommand(SbigLib.PAR_COMMAND.CC_END_EXPOSURE.value,
                            byref(cin), cout)

    print("GRAB IMAGE - Start Readout")

    cin = SbigStructures.StartReadoutParams
    cout = None
    udrv.SBIGUnivDrvCommand.argtypes = [c_ushort, POINTER(cin), POINTER(cout)]

    cin = cin(command=SbigLib.PAR_COMMAND.CC_START_EXPOSURE2.value,
              readoutMode=v_read,
              top=0,
              left=0,
              height=v_h,
              width=v_w)
    ret = udrv.SBIGUnivDrvCommand(SbigLib.PAR_COMMAND.CC_START_READOUT.value,
                                  byref(cin), cout)
    print("ret: ", ret)
    print(SbigLib.PAR_COMMAND.CC_START_READOUT.value)

    print("GRAB IMAGE - Readout Lines")

    img = np.zeros((v_h, v_w))

    for i_line in range(v_h):
        cin = SbigStructures.ReadoutLineParams
        cout = c_ushort * v_w
        udrv.SBIGUnivDrvCommand.argtypes = [
            c_ushort, POINTER(cin), POINTER(cout)
        ]
        cin = cin(ccd=SbigLib.CCD_REQUEST.CCD_IMAGING.value,
                  readoutMode=v_read,
                  pixelStart=0,
                  pixelLength=v_w)
        cout = cout()
        udrv.SBIGUnivDrvCommand(SbigLib.PAR_COMMAND.CC_READOUT_LINE.value,
                                byref(cin), byref(cout))
        img[i_line] = cout

    path, tempo = set_path(pre)

    # path, tempo = "/home/hiyoku/Imagens/images/", time.strftime('%Y%m%d_%H%M%S')

    if not os.path.isdir(path):
        os.makedirs(path)

    from src.business.configuration.configProject import ConfigProject
    ci = ConfigProject()
    site_id_name = str(ci.get_site_settings())

    site_id_name = get_observatory(site_id_name)

    if dark_photo == 1:
        fn = pre + "-DARK" + "_" + site_id_name + "_" + tempo
        name = path + fn
        fitsname = name + '.fit'
        pngname = name + '.png'
        fitsname_final = fn + '.fit'
        pngname_final = fn + '.png'
    else:
        fn = pre + "_" + site_id_name + "_" + tempo
        name = path + fn
        fitsname = name + '.fit'
        pngname = name + '.png'
        fitsname_final = fn + '.fit'
        pngname_final = fn + '.png'

    try:
        os.unlink(fitsname)
    except OSError:
        pass

    fits.writeto(fitsname, img)
    #src.utils.camera.SbigDriver.site
    print("\nGRAB IMAGE - End Readout\n")

    cin = SbigStructures.EndReadoutParams
    cout = None
    udrv.SBIGUnivDrvCommand.argtypes = [c_ushort, POINTER(cin), POINTER(cout)]
    cin = cin(ccd=SbigLib.CCD_REQUEST.CCD_IMAGING.value)
    ret = udrv.SBIGUnivDrvCommand(SbigLib.PAR_COMMAND.CC_END_READOUT.value,
                                  byref(cin), cout)
    print("ret", ret)

    # cmd(SbigLib.PAR_COMMAND.CC_CLOSE_DEVICE.value, None, None)

    # cmd(SbigLib.PAR_COMMAND.CC_CLOSE_DRIVER.value, None, None)

    print("Call set_header")
    set_header(fitsname)
    print("Call set_png")
    set_png(fitsname, pngname, get_level1, get_level2)

    data, hora = get_date_hour(tempo)
    print("End of process")
    return path, pngname_final, fitsname_final, data, hora