Ejemplo n.º 1
0
    def key_press_callback(self, event):
        'whenever a key is pressed'
        if not event.inaxes:
            return (None)

        if event.key == 'n':
            print('Next star')
            self.star_index += 1
            self.name = self.star_catalog.stars_tot[self.star_index].name
            self.azim = self.star_catalog.stars_tot[self.star_index].azimuth
            self.alti = self.star_catalog.stars_tot[self.star_index].altit_real
            px, py = horiz2xy(self.azim,
                              self.alti,
                              self.image_info,
                              derotate=True)
            self.preliminary_star.remove()
            self.preliminary_star = \
                self.skyimage.scatter(
                    px, py, marker='o', c='yellow', alpha=0.5)
            print('Name: %s, Az: %s, Alt: %s' %
                  (self.name, self.azim, self.alti))
        elif event.key == 'p':
            print('Previous star')
            self.preliminary_star.remove()
            self.scatter_stars[-1].remove()
            self.label_stars[-1].remove()
            self.scatter_stars.pop()
            self.label_stars.pop()
            self.identified_stars.pop()
            self.star_index -= 1
            self.name = self.star_catalog.stars_tot[self.star_index].name
            self.azim = self.star_catalog.stars_tot[self.star_index].azimuth
            self.alti = self.star_catalog.stars_tot[self.star_index].altit_real
            px, py = horiz2xy(self.azim,
                              self.alti,
                              self.image_info,
                              derotate=True)
            self.preliminary_star = \
                self.skyimage.scatter(
                    px, py, marker='o', c='yellow', alpha=0.5)
            self.skyfigure.canvas.draw()
            self.skyfigure.canvas.flush_events()
            print('Name: %s, Az: %s, Alt: %s' %
                  (self.name, self.azim, self.alti))

        if event.key == 'q':
            print('End')
            self.skyfigure.canvas.mpl_disconnect(self.cid_mouse)
            self.skyfigure.canvas.mpl_disconnect(self.cid_keyboard)
            print(self.identified_stars)
            plt.close()

        self.astrometry_optimizer(full=(self.star_index > 3))

        return (None)
Ejemplo n.º 2
0
    def key_press_callback(self, event):
        'whenever a key is pressed'
        if not event.inaxes:
            return(None)

        if event.key == 'n':
            print('Next star')
            self.star_index += 1
            self.name = self.star_catalog.stars_tot[self.star_index].name
            self.azim = self.star_catalog.stars_tot[self.star_index].azimuth
            self.alti = self.star_catalog.stars_tot[
                self.star_index].altit_real
            px, py = horiz2xy(
                self.azim, self.alti, self.image_info, derotate=True)
            self.preliminary_star.remove()
            self.preliminary_star = \
                self.skyimage.scatter(
                    px, py, marker='o', c='yellow', alpha=0.5)
            print('Name: %s, Az: %s, Alt: %s' %
                  (self.name, self.azim, self.alti))
        elif event.key == 'p':
            print('Previous star')
            self.preliminary_star.remove()
            self.scatter_stars[-1].remove()
            self.label_stars[-1].remove()
            self.scatter_stars.pop()
            self.label_stars.pop()
            self.identified_stars.pop()
            self.star_index -= 1
            self.name = self.star_catalog.stars_tot[self.star_index].name
            self.azim = self.star_catalog.stars_tot[self.star_index].azimuth
            self.alti = self.star_catalog.stars_tot[
                self.star_index].altit_real
            px, py = horiz2xy(
                self.azim, self.alti, self.image_info, derotate=True)
            self.preliminary_star = \
                self.skyimage.scatter(
                    px, py, marker='o', c='yellow', alpha=0.5)
            self.skyfigure.canvas.draw()
            self.skyfigure.canvas.flush_events()
            print('Name: %s, Az: %s, Alt: %s' %
                  (self.name, self.azim, self.alti))

        if event.key == 'q':
            print('End')
            self.skyfigure.canvas.mpl_disconnect(self.cid_mouse)
            self.skyfigure.canvas.mpl_disconnect(self.cid_keyboard)
            print(self.identified_stars)
            plt.close()

        self.astrometry_optimizer(full=(self.star_index > 3))

        return(None)
Ejemplo n.º 3
0
 def mouse_press_callback(self,event):
     ''' Coordinate input '''
     if event.button == 3:
         ix, iy = event.xdata, event.ydata
         print('x = %d, y = %d'%(ix, iy))
         self.identified_stars.append([self.name,self.azim,self.alti,ix,iy])
         self.star_index +=1
         self.astrometry_optimizer(full=(self.star_index>3))
         self.scatter_stars.append(\
             self.skyimage.scatter(ix,iy,marker='o',c='red',alpha=0.2))
         self.label_stars.append(\
             self.skyimage.annotate(\
                 self.name,xy=(ix,iy), \
                 xycoords='data',xytext=(0, 3),\
                 textcoords='offset points',fontsize=8,alpha=0.8))
         
         self.name=self.StarCatalog.StarList_Tot[self.star_index].name
         self.azim=self.StarCatalog.StarList_Tot[self.star_index].azimuth
         self.alti=self.StarCatalog.StarList_Tot[self.star_index].altit_real
         px,py = horiz2xy(self.azim,self.alti,self.ImageInfo,derotate=True)
         
         try: self.preliminary_star.remove()
         except: pass
         
         self.preliminary_star = \
             self.skyimage.scatter(px,py,marker='o',c='yellow',alpha=0.5)
         print('Name: %s, Az: %s, Alt: %s' %(self.name,self.azim,self.alti))
         self.skyfigure.canvas.draw()
         self.skyfigure.canvas.flush_events()
     
     return(None)
Ejemplo n.º 4
0
    def draw_polar_axes(self):
        ''' Draws meridian and altitude isolines. '''

        zenith_xy = zenith_position(self.image_info)

        for each_altitude in np.arange(0, 90, 15):
            coord_altitude_0 = horiz2xy(0, each_altitude, self.image_info)
            radius = math.sqrt((coord_altitude_0[0] - zenith_xy[0])**2 +
                               (coord_altitude_0[1] - zenith_xy[1])**2)
            self.skyimage.add_patch(
                mpp.Circle((zenith_xy[0], zenith_xy[1]),
                           radius,
                           facecolor='k',
                           fill=False,
                           alpha=0.2,
                           label='_nolegend_'))
            self.skyimage.annotate(str(each_altitude),
                                   xy=(radius + zenith_xy[0], zenith_xy[1]),
                                   alpha=0.2,
                                   fontsize=10)

        key_azimuths = {0: "N", 90: "E", 180: "S", 270: "W"}

        for each_azimuth in np.arange(0, 360, 30):
            coord_azimuth_0 = horiz2xy(each_azimuth, 0, self.image_info)
            self.skyimage.plot(
                [zenith_xy[0], coord_azimuth_0[0]],
                [zenith_xy[1], coord_azimuth_0[1]],
                color='k',
                alpha=0.2,
            )

            if each_azimuth in key_azimuths:
                azimuth_label = str(key_azimuths[each_azimuth])
            else:
                azimuth_label = str(each_azimuth)
            self.skyimage.annotate(azimuth_label,
                                   xy=horiz2xy(each_azimuth,
                                               self.image_info.min_altitude,
                                               self.image_info),
                                   color='k',
                                   alpha=0.2,
                                   fontsize=10)
Ejemplo n.º 5
0
    def draw_polar_axes(self):
        ''' Draws meridian and altitude isolines. '''

        zenith_xy = zenith_position(self.image_info)

        for each_altitude in np.arange(0, 90, 15):
            coord_altitude_0 = horiz2xy(0, each_altitude, self.image_info)
            radius = math.sqrt(
                (coord_altitude_0[0] - zenith_xy[0]) ** 2 +
                (coord_altitude_0[1] - zenith_xy[1]) ** 2)
            self.skyimage.add_patch(
                mpp.Circle((zenith_xy[0], zenith_xy[1]), radius,
                           facecolor='k', fill=False, alpha=0.2, label='_nolegend_'))
            self.skyimage.annotate(
                str(each_altitude),
                xy=(radius + zenith_xy[0], zenith_xy[1]),
                alpha=0.2,
                fontsize=10)

        key_azimuths = {0: "N", 90: "E", 180: "S", 270: "W"}

        for each_azimuth in np.arange(0, 360, 30):
            coord_azimuth_0 = horiz2xy(each_azimuth, 0, self.image_info)
            self.skyimage.plot(
                [zenith_xy[0], coord_azimuth_0[0]],
                [zenith_xy[1], coord_azimuth_0[1]],
                color='k',
                alpha=0.2,)

            if each_azimuth in key_azimuths:
                azimuth_label = str(key_azimuths[each_azimuth])
            else:
                azimuth_label = str(each_azimuth)
            self.skyimage.annotate(
                azimuth_label,
                xy=horiz2xy(
                    each_azimuth, self.image_info.min_altitude, self.image_info),
                color='k',
                alpha=0.2,
                fontsize=10)
Ejemplo n.º 6
0
        def horiz2xy_chi2(sol, az, alt, x, y):
            self.image_info.radial_factor = sol[0]
            self.image_info.azimuth_zeropoint = sol[1]
            if (full == True):
                self.image_info.delta_x = sol[2]
                self.image_info.delta_y = sol[3]
                self.image_info.latitude_offset = sol[4]
                self.image_info.longitude_offset = sol[5]
            else:
                self.image_info.delta_x = 0
                self.image_info.delta_y = 0
                self.image_info.latitude_offset = 0
                self.image_info.longitude_offset = 0

            xf, yf = horiz2xy(az, alt, self.image_info, derotate=True)
            return(np.sum((xf - x) ** 2 + (yf - y) ** 2))
Ejemplo n.º 7
0
        def horiz2xy_chi2(sol, az, alt, x, y):
            self.image_info.radial_factor = sol[0]
            self.image_info.azimuth_zeropoint = sol[1]
            if (full == True):
                self.image_info.delta_x = sol[2]
                self.image_info.delta_y = sol[3]
                self.image_info.latitude_offset = sol[4]
                self.image_info.longitude_offset = sol[5]
            else:
                self.image_info.delta_x = 0
                self.image_info.delta_y = 0
                self.image_info.latitude_offset = 0
                self.image_info.longitude_offset = 0

            xf, yf = horiz2xy(az, alt, self.image_info, derotate=True)
            return (np.sum((xf - x)**2 + (yf - y)**2))
Ejemplo n.º 8
0
    def mouse_press_callback(self, event):
        """Coordinate input """
        if event.button == 3:
            ix, iy = event.xdata, event.ydata
            print('x = %d, y = %d' % (ix, iy))
            self.identified_stars.append(
                [self.name, self.azim, self.alti, ix, iy])
            self.star_index += 1
            self.astrometry_optimizer(full=(self.star_index > 3))
            self.scatter_stars.append(
                self.skyimage.scatter(ix, iy, marker='o', c='red', alpha=0.2))
            self.label_stars.append(
                self.skyimage.annotate(self.name,
                                       xy=(ix, iy),
                                       xycoords='data',
                                       xytext=(0, 3),
                                       textcoords='offset points',
                                       fontsize=8,
                                       alpha=0.8))

            self.name = self.star_catalog.stars_tot[self.star_index].name
            self.azim = self.star_catalog.stars_tot[self.star_index].azimuth
            self.alti = self.star_catalog.stars_tot[self.star_index].altit_real
            px, py = horiz2xy(self.azim,
                              self.alti,
                              self.image_info,
                              derotate=True)

            try:
                self.preliminary_star.remove()
            except:
                pass

            self.preliminary_star = \
                self.skyimage.scatter(
                    px, py, marker='o', c='yellow', alpha=0.5)
            print('Name: %s, Az: %s, Alt: %s' %
                  (self.name, self.azim, self.alti))
            self.skyfigure.canvas.draw()
            self.skyfigure.canvas.flush_events()

        return (None)