Ejemplo n.º 1
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
Ejemplo n.º 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
Ejemplo n.º 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
Ejemplo n.º 4
0
    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)
Ejemplo n.º 5
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)
Ejemplo n.º 6
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)
Ejemplo n.º 7
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
Ejemplo n.º 8
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))
Ejemplo n.º 9
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()
        # 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()

    def set_layout(self):
        self.setLayout(set_wvbox(self.site, self.moon))
Ejemplo n.º 10
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
Ejemplo n.º 11
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
Ejemplo n.º 12
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