예제 #1
0
    def set_pointing_track(self, param=0, sender=""):
        ### Checks if object is above x degrees over the horizon. If not telescope will not move.
        if int(param) > 0:
            star_handle = song_star_checker.star_pos(site=1)
            sun_handle = song_star_checker.sun_pos(site=1)
            ra_object = gettsi.get_object_equatorial_ra(sender="Mads")
            dec_object = gettsi.get_object_equatorial_dec(sender="Mads")

            sun_dist = float(
                str(sun_handle.sun_dist(ra_object, dec_object)).split(":")[0])
            sun_alt = float(str(sun_handle.sun_alt()).split(":")[0])

            #			if sun_alt >= 0.0 and sun_dist < 45.0:
            #				print "The Sun is too close to the pointing position... the telescope will not go there...!!!"
            #				return "Sun too close"

            object_alt = int(
                str(star_handle.star_alt(ra_object, dec_object)).split(":")[0])
            if object_alt < m_conf.telescope_min_altitude:  # Hardcoded limit... because of the cooling unit.
                return "Object too low"

        value = ''
        try:
            value = self.server.set_pointing_track(sender, param)
            if value != '':
                return_value = value
        except Exception, e:
            print 'Could not set pointing track!'
            return_value = e
예제 #2
0
    def __init__(self):

        #gc.disable()
        #gc.enable()
        #gc.get_threshold

        self.check_handle = central_song_checker.Checker(
        )  # Add posibility to select site to checker.
        self.check_star = song_star_checker.star_pos(site=conf.song_site)
        self.sun_handle = song_star_checker.sun_pos(
            site=conf.song_site)  # Tenerife sun handle
        self.hostname = socket.gethostname()
    def object_check2(self,
                      object_ra,
                      object_dec,
                      high_wind,
                      last_wind_dir,
                      site=site_param):
        """
		@brief: This function will determine whether or not an object is observable at the moment. 
	"""
        object_value = 0

        if float(
                str(
                    song_star_checker.star_pos(site).star_alt(
                        object_ra, object_dec)).split(':')
            [0]) < m_conf.telescope_min_altitude:
            object_value = 1
        elif float(
                str(
                    song_star_checker.star_pos(site).star_alt(
                        object_ra,
                        object_dec)).split(':')[0]) >= m_conf.max_alt_auto:
            object_value = 4

    #### Check if wind is too high coming from the star position:
        object_az = song_star_checker.star_pos(site=1).star_az(
            star_ra=object_ra, star_dec=object_dec)
        object_az = float(str(object_az).split(":")[0])

        if high_wind == 1 and (numpy.abs(object_az - float(last_wind_dir)) <=
                               (song_checker_config.angle_into +
                                song_checker_config.insert_margin) or
                               numpy.abs(object_az - float(last_wind_dir)) >=
                               (360.0 - song_checker_config.angle_into -
                                song_checker_config.insert_margin)):
            object_value = object_value + 2

        return object_value
예제 #4
0
    def object_check(self, object_ra, object_dec, site=site_param):
        """
		@brief: This function will determine whether or not an object is observable at the moment. 
	"""
        imp.reload(song_checker_config)
        object_value = 0

        if float(
                str(
                    song_star_checker.star_pos(site).star_alt(
                        object_ra, object_dec)).split(':')
            [0]) < m_conf.telescope_min_altitude:
            object_value = 1
        elif float(
                str(
                    song_star_checker.star_pos(site).star_alt(
                        object_ra,
                        object_dec)).split(':')[0]) >= m_conf.max_alt_auto:
            object_value = 4

    #### Check if wind is too high coming from the stars position:
        object_az = song_star_checker.star_pos(site=1).star_az(
            star_ra=object_ra, star_dec=object_dec)
        object_az = float(str(object_az).split(":")[0])

        try:
            conn = psycopg2.connect(
                "host='%s' dbname='%s' user='******' password='******'" %
                (m_conf.db_host, m_conf.data_db, m_conf.db_user,
                 m_conf.db_password))
            curr = conn.cursor()
            wind_data = self.get_fields_time_int(curr, "weather_station", [
                "wxt520_wind_avg", "wxt520_wind_speed", "wxt520_wind_avgdir",
                "ins_at"
            ], 20)  # search for high wind speeds in last 20 minutes
        except Exception, e:
            print clock.timename(), " Error: ", e
예제 #5
0
        sys.path.append(song_checker_config.o_star_dir)
        o_star_filename = o_star_name + "_o-star.py"

        try:
            template_config = __import__(str(o_star_filename).split('.')[0])
        except Exception, e:
            print e
            return 4

        object_value = 0

        if float(
                str(
                    song_star_checker.star_pos(site).star_alt(
                        template_config.ostar_ra_hours,
                        template_config.ostar_dec_degrees)).split(':')
            [0]) < m_conf.telescope_min_altitude:
            object_value = 1

    #### Check if wind is too high coming from the stars position:
        object_az = song_star_checker.star_pos(site=1).star_az(
            star_ra=template_config.ostar_ra_hours,
            star_dec=template_config.ostar_dec_degrees)
        object_az = float(str(object_az).split(":")[0])

        try:
            conn = psycopg2.connect(
                "host='%s' dbname='%s' user='******' password='******'" %
                (m_conf.db_host, m_conf.data_db, m_conf.db_user,
                 m_conf.db_password))
예제 #6
0
        # The barycentric velocity correction for the midtime of the exposure. (km/s)

        leap_s = ephem.delta_t("%i/%i/%i" %
                               (date_obs.year, date_obs.month, date_obs.day))

        #      try:
        #		BJD, BVC = barcor_song_mfa.getbar_song2(epoch, ra_h, ra_m, ra_s, dec_d, dec_arcm, dec_arcs, site_lon, site_lat, site_elev, int(date_obs.year), int(date_obs.month), int(date_obs.day), int(date_obs.hour), int(date_obs.minute), float(date_obs_UT_sec), float(exptime), float(leap_s), 1,1 )
        #      except Exception, e:
        #		print e
        #		BJD = 0
        #		BVC = 0

        ############################### Here values for object, Sun and Moon is calculated ####################################
        moon_handle = song_star_checker.moon_pos(site=site_value)
        sun_handle = song_star_checker.sun_pos(site=site_value)
        star_handle = song_star_checker.star_pos(site=site_value)

        moon_alt = moon_handle.moon_alt()
        moon_az = moon_handle.moon_az()
        moon_phase = moon_handle.moon_phase()
        if object_name_1.lower() not in ["", "flat", "bias", "flati2"
                                         ] or object_name.lower() != "unknown":
            object_alt = star_handle.star_alt(ra_object, dec_object)
            object_az = star_handle.star_az(ra_object, dec_object)
            moon_dist = moon_handle.moon_dist(ra_object, dec_object)
            sun_dist = sun_handle.sun_dist(ra_object, dec_object)
        else:
            object_alt = ""
            object_az = ""
            moon_dist = ""
            sun_dist = ""
    def object_check(self, object_ra, object_dec, site=site_param):
        """
		@brief: This function will determine whether or not an object is observable at the moment. 
	"""
        object_value = 0

        if float(
                str(
                    song_star_checker.star_pos(site).star_alt(
                        object_ra, object_dec)).split(':')
            [0]) < m_conf.telescope_min_altitude:
            object_value = 1
        elif float(
                str(
                    song_star_checker.star_pos(site).star_alt(
                        object_ra,
                        object_dec)).split(':')[0]) >= m_conf.max_alt_auto:
            object_value = 4

    #### Check if wind is too high coming from the stars position:
        object_az = song_star_checker.star_pos(site=1).star_az(
            star_ra=object_ra, star_dec=object_dec)
        object_az = float(str(object_az).split(":")[0])

        test = False
        if test == False:
            try:
                conn = psycopg2.connect(
                    "host='%s' dbname='%s' user='******' password='******'" %
                    (m_conf.db_c_host, m_conf.data_db, m_conf.db_user,
                     m_conf.db_password))
                curr = conn.cursor()
                wind_data = self.get_fields_time_int(curr, "weather_station", [
                    "wxt520_wind_avg", "wxt520_wind_speed",
                    "wxt520_wind_avgdir", "ins_at"
                ], 20)  # search for high wind speeds in last 20 minutes
            except Exception, e:
                print clock.timename(), " Error: ", e
            else:
                curr.close()
                conn.close()
        #	print wind_data["wxt520_wind_avg"]

        #	print len(numpy.where(numpy.array(wind_data["wxt520_wind_avg"],dtype=float) >= song_checker_config.max_w_speed_into)[0])
        #	print numpy.where(numpy.array(wind_data["wxt520_wind_avg"],dtype=float) >= song_checker_config.max_w_speed_into)[0]
        #	print float(wind_data["wxt520_wind_avgdir"][-1])
        #	print object_az
        #	print numpy.abs(object_az - float(wind_data["wxt520_wind_avgdir"][-1]))

            if len(
                    numpy.where(
                        numpy.array(wind_data["wxt520_wind_avg"], dtype=float)
                        >= song_checker_config.max_w_speed_into)
                [0]) >= song_checker_config.wind_blow_events and (
                    numpy.abs(object_az -
                              float(wind_data["wxt520_wind_avgdir"][-1])) <=
                    (song_checker_config.angle_into +
                     song_checker_config.insert_margin)
                    or numpy.abs(object_az -
                                 float(wind_data["wxt520_wind_avgdir"][-1])) >=
                    (360.0 - song_checker_config.angle_into -
                     song_checker_config.insert_margin)):
                object_value = object_value + 2