class ObsMaker: def __init__(self): try: project_infos = get_project_settings() self.eof = EphemObserverFactory() try: self.obs = self.eof.create_observer( longitude=project_infos[0][1], latitude=project_infos[0][0], elevation=project_infos[1][0]) 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) self.sun_elevation = "{:.2f}".format( float(math.degrees(sun_alt))) self.moon_elevation = "{:.2f}".format( float(math.degrees(moon_alt))) self.moon_phase = "{0:.2f}".format(frac * 100) except Exception as e: print("ephem update -> {}".format(e)) except Exception as e: print("run append_camera_settings() -> {}".format(e))
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)
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)
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()
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()
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)
class SThread(QtCore.QThread): """ Threads são fluxos de programas que executam em paralelo dentro de uma aplicação, isto é,\ uma ramificação de uma parte da aplicação que é executada de forma independente e\ escalonada independentemente do fluxo inicial da aplicação. Fonte: http://imasters.com.br/artigo/20127/py/threads-em-python/?trace=1519021197&source=single """ def __init__(self): super(SThread, self).__init__() self.prefix = None self.exposure_time = None self.binning = None self.get_level1 = None self.get_level2 = None self.get_axis_xi = None self.get_axis_xf = None self.get_axis_yi = None self.get_axis_yf = None self.get_ignore_crop = None self.console = ConsoleThreadOutput() self.get_image_tif = None self.get_image_fit = None self.get_image_png = None self.temperatura = None self.eof = EphemObserverFactory() self.obs = None self.path = None self.tempo = None self.info_matrix = None self.img = None self.new_image_name = None self.selected_filter = None self.dark_or_open = "Closed" self.one_photo = None self.for_headers_dic = {} self.lock = Locker() self.info_matrix = [] self.filter_split_label = None self.count_aux = 0 self.kwargs = None self.message_console_one_photo = None self.roda_filtros = FilterControl() def set_config_take_image(self): """ seta as configuracoes para se tirar uma foto """ try: info_cam = get_camera_settings() self.for_headers_dic['Set Temperature'] = info_cam[0] self.for_headers_dic['????Tempo de espera'] = info_cam[1] info_image = get_image_settings() try: self.get_level1 = float(info_image[0]) except Exception as e: # print("self.get_level1 = 0.1 -> {}".format(e)) self.get_level1 = 0.1 try: self.get_level2 = float(info_image[1]) except Exception as e: # print("self.get_level2 = 0.99 -> {}".format(e)) self.get_level2 = 0.99 try: self.get_axis_xi = float(info_image[2]) except Exception as e: # print("self.get_axis_xi = 0 -> {}".format(e)) self.get_axis_xi = 0 try: self.get_axis_xf = float(info_image[3]) except Exception as e: # print("self.get_axis_xf = 0 -> {}".format(e)) self.get_axis_xf = 0 try: self.get_axis_yi = float(info_image[4]) except Exception as e: # print("self.get_axis_yi = 0 -> {}".format(e)) self.get_axis_yi = 0 try: self.get_axis_yf = float(info_image[5]) except Exception as e: # print("self.get_axis_yf = 0 -> {}".format(e)) self.get_axis_yf = 0 try: self.get_ignore_crop = info_image[6] except Exception as e: print("self.get_ignore_crop = True -> {}".format(e)) self.get_ignore_crop = True try: self.get_image_png = info_image[7] except Exception as e: print("self.get_image_png = True -> {}".format(e)) self.get_image_png = True try: self.get_image_tif = info_image[8] except Exception as e: print("self.get_image_tif = True -> {}".format(e)) self.get_image_tif = True try: self.get_image_fit = info_image[9] except Exception as e: print("self.get_image_fit = True -> {}".format(e)) self.get_image_fit = True try: self.filter_split_label = get_filter_settings() except Exception as e: print("get_filter_settings() -> {}".format(e)) try: self.append_camera_settings() except Exception as e: print( "self.append_camera_settings() in set_config_take_image -> {}" .format(e)) except Exception as e: print("Try ini definitive -> {}".format(e)) def recebe_argumento(self, kwargs): self.kwargs = kwargs def args_one_photo(self, filter_args, kwargs): self.selected_filter = filter_args if kwargs == "Closed": self.kwargs = 1 else: self.kwargs = 0 self.one_photo = True def run(self): if self.kwargs == 0: try: self.create_image_open() except Exception as e: print("self.create_image_open() -> {}".format(e)) else: try: self.create_image_close() except Exception as e: print("self.create_image_close() -> {}".format(e)) def create_image_open(self): self.roda_filtros.open_shutter() self.set_config_take_image() self.lock.set_acquire() my_list = get_wish_filters_settings() # list of schedule try: if self.count_aux < len(my_list): if self.one_photo: index_of_dic = self.selected_filter else: index_of_dic = str(my_list[self.count_aux]) self.valores_principais_wish_filter(index_of_dic) self.count_aux += 1 else: self.count_aux = 0 if self.one_photo: index_of_dic = self.selected_filter else: index_of_dic = str(my_list[self.count_aux]) self.valores_principais_wish_filter(index_of_dic) self.count_aux += 1 except Exception as e: print("Try filter ini -> {}".format(e)) project_infos = get_project_settings() name_observatory = project_infos[2][1] self.path, self.tempo = set_path() self.new_image_name = str( self.prefix) + "_" + str(name_observatory) + "_" + str(self.tempo) new_image_name = self.path + str(self.new_image_name) try: self.info_matrix = SbigDriver.photoshoot(self.exposure_time, self.binning, 0) except Exception as e: print("self.info_matrix = SbigDriver.photoshoot ERROR -> " + str(e)) self.for_headers_dic['Open or close shutter'] = "OPEN" self.save_image_format(new_image_name) self.for_headers_dic = {} self.one_photo = False self.init_image() self.lock.set_release() def create_image_close(self): self.roda_filtros.close_shutter() my_list = get_wish_filters_settings() # list of schedule my_list = set(my_list) my_list = sorted(my_list) count_aux = 0 while count_aux < len(my_list): self.set_config_take_image() self.lock.set_acquire() if self.one_photo: index_of_dic = self.selected_filter count_aux = 100 else: index_of_dic = str(my_list[count_aux]) self.valores_principais_wish_filter(index_of_dic) project_infos = get_project_settings() name_observatory = project_infos[2][1] self.path, self.tempo = set_path() self.new_image_name = "DARK-" + str( self.prefix) + "_" + str(name_observatory) + "_" + str( self.tempo) new_image_name = self.path + str(self.new_image_name) try: self.info_matrix = SbigDriver.photoshoot( self.exposure_time, self.binning, 1) except Exception as e: print("self.info_matrix = SbigDriver.photoshoot ERROR -> " + str(e)) self.for_headers_dic['Open or close shutter'] = "CLOSED" self.save_image_format(new_image_name) self.for_headers_dic = {} count_aux += 1 self.init_image() self.lock.set_release() self.one_photo = False def filter_wheel_control(self, wish_filter_int): try: sleep(1) wish_filter_int = int(wish_filter_int) self.roda_filtros.filter_wheel_control(wish_filter_int) sleep(1) except Exception as e: self.roda_filtros.home_reset() print(e) def save_image_format(self, new_image_name): if not os.path.isdir(self.path): os.makedirs(self.path) if self.one_photo: print(self.path) self.for_headers_dic['Start Time'] = self.tempo try: self.temperatura = SbigDriver.get_temperature() self.temperatura = "{0:.2f}".format(float(self.temperatura[3])) # self.temperatura = "25" self.for_headers_dic['Temperature'] = self.temperatura except Exception as e: print("Exception self.temperatura -> {}".format(e)) self.for_headers_dic['Temperature'] = "???" if self.get_image_png: try: save_png(self.info_matrix, new_image_name, self.for_headers_dic) except Exception as e: print("Exception save_png() -> {}".format(e)) if self.get_image_tif: try: save_tif(self.info_matrix, new_image_name) if self.one_photo: print(new_image_name) except Exception as e: print("Exception save_tif() -> {}".format(e)) if self.get_image_fit: try: save_fit(self.info_matrix, new_image_name, self.for_headers_dic) except Exception as e: print("Exception save_fit() -> {}".format(e)) if not self.get_image_fit and not self.get_image_tif and not self.get_image_fit: try: save_png(self.info_matrix, new_image_name, self.for_headers_dic) except Exception as e: print("Exception save_png() -> {}".format(e)) def valores_principais_wish_filter(self, index_of_dic): aux = self.filter_split_label[str(index_of_dic)][0] aux = list(aux) ''' aux[0] = self.prefix aux[2] = self.exposure_time aux[3] = self.binning aux[4] = wish filter ''' self.prefix = str(aux[0]) self.exposure_time = float(aux[2]) if self.exposure_time <= 0.12: self.exposure_time = 0.12 * 100 elif self.exposure_time >= 3600: self.exposure_time = 3600 * 100 else: self.exposure_time = float(aux[2]) * 100 self.exposure_time = int(self.exposure_time) self.binning = int(aux[3]) self.filter_wheel_control(int(aux[4])) self.append_filters_settings(aux) def append_camera_settings(self): try: project_infos = get_project_settings() try: self.obs = self.eof.create_observer( longitude=project_infos[0][1], latitude=project_infos[0][0], elevation=project_infos[1][0]) 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) except Exception as e: print("ephem update -> {}".format(e)) self.for_headers_dic['Latitude'] = str(project_infos[0][0]) self.for_headers_dic['Longitude'] = str(project_infos[0][1]) self.for_headers_dic['Elevation(m)'] = str(project_infos[0][2]) self.for_headers_dic['Pressure(mb)'] = str(project_infos[0][3]) self.for_headers_dic['Sun Elevation'] = str(sun_elevation) self.for_headers_dic['Ignore Lunar Position'] = str( project_infos[1][1]) self.for_headers_dic['Moon Elevation'] = str(moon_elevation) self.for_headers_dic['Moon Phase'] = str(moon_phase) self.for_headers_dic['Name'] = str(project_infos[2][0]) self.for_headers_dic['Observatory'] = str(project_infos[2][1]) self.for_headers_dic['Imager ID'] = str(project_infos[2][2]) self.for_headers_dic['get_level1'] = str(self.get_level1) self.for_headers_dic['get_level2'] = str(self.get_level2) self.for_headers_dic['get_axis_xi'] = str(self.get_axis_xi) self.for_headers_dic['get_axis_xf'] = str(self.get_axis_xf) self.for_headers_dic['get_axis_yi'] = str(self.get_axis_yi) self.for_headers_dic['get_axis_yf'] = str(self.get_axis_yf) self.for_headers_dic['get_ignore_crop'] = str(self.get_ignore_crop) except Exception as e: print("run append_camera_settings() -> {}".format(e)) def append_filters_settings(self, aux): try: self.for_headers_dic['Filter Label'] = str(aux[0]) self.for_headers_dic['Filter Wavelength'] = str(aux[1]) self.for_headers_dic['Exposure'] = str(self.exposure_time) self.for_headers_dic['Binning'] = str(aux[3]) self.for_headers_dic['Filter Position'] = str(aux[4]) except Exception as e: print("run append_filters_settings() -> {}".format(e)) def get_new_image_name(self, local_name_image): self.console.raise_text( "Image saved in " + str(local_name_image) + ".png", 1) def init_image(self): try: print("\nAAAAAAAAAAAAAAAAAAAAAA\n") # for i in self.info_matrix: # print(i) self.img = Image(self.path, self.new_image_name) except Exception as e: print("Image('', '') -> {}".format(e)) self.img = Image('', '') return self.img def get_image_info(self): return self.img