예제 #1
0
파일: lc.py 프로젝트: apodemus/grafico
 def chronify(Rates, Times=None):
     '''impute time data'''
     if Times is None:
         return grid_like(Rates)[int(Rates.ndim > 1)] #Times = #NOTE: may be 1D
         #return Times
     else:
         nTimes = np.empty_like(Rates)
         nTimes[:] = Times                   #duplicates the Times
         return nTimes
예제 #2
0
파일: gui.py 프로젝트: apodemus/obstools
    def _on_click(self, event):

        # TODO: ignore method here....

        print(vars(event))

        if event.inaxes != self.image.axes:
            return

        if event.button == 3:
            return

        # Middle mouse restarts the selection process
        if event.button == 2:
            self.restart()
            return

        # Double click to fit stars
        if not event.dblclick:
            return

        x, y = event.xdata, event.ydata
        xs, ys = self.snap(x, y)  # coordinates of maximum intensity within window around click position

        # print( '!'*100, xs, ys )
        if not (xs and ys):
            return
        else:
            print("\n\nSNAPPED", xs, ys, "\n\n")

            # TODO: NEW METHOD HERE??

            # Fitting
            data, index = self.snap.zoom(xs, ys)  # retrieve zoomed image of the star

            grid = Y, X = grid_like(data)
            params = self.fit(grid, data)
            Z = self.psf(params, X, Y)

            if params is None:
                return

            ##try:
            # update fit plots
            self.fitplotter.update(X, Y, Z, data)
            # except:

            # get dict of fit descriptors from params
            info = self.psf.get_description(params, index[::-1])
            _, sky_sigma = self.psf.background_estimate.cache  # cached upon call to self.fit
            wslice = tuple(map(slice, index, index + data.shape))  # 2D window slice

            # Add star to collection
            stars = self.stars
            star = stars.append(
                sky_sigma=sky_sigma,
                slice=wslice,
                image=data,
                # rmax           =       self.rphotmax,
                **info
            )

            # remove star from image by subtracting model
            bg = info["sky_mean"]  # background value from fit
            try:
                self.snap.clean(Z - bg)
            except:
                pyqtRemoveInputHook()
                embed()
                pyqtRestoreInputHook()
            # Check apertures and colourise
            # TODO:  ONLY trigger checks on second draw...........
            psfaps, photaps, skyaps = self.stars.apertures
            skyaps.auto_colour(check="all", cross=psfaps, edge=self.image_data.shape)
            photaps.auto_colour(check="all", cross=psfaps, edge=self.image_data.shape)

            # pyqtRemoveInputHook()
            # embed()
            # pyqtRestoreInputHook()

            stars.model.update(self.fit.get_params_from_cache(), stars.mean_radial_profile(), self.rsky, self.rphotmax)

            # stars.model.apertures.phot.radii = [self.rphotmax]

            # stars.model.update_plots()

            # print( stars.photaps.get_ec() )
            # print( 'x'*100 )

            # Redraw & blit
            # self.canvas.restore_region( self.canvas.background )
            # stars.draw_all()
            # stars.model.draw()
            # self.canvas.blit( self.figure.bbox )

            self.canvas.draw()