示例#1
0
def test_line_plot():
    """check the line plot function."""
    plots = Imexamine()
    plots.set_data(test_data)
    plots.plot_line(50, 50)
    f = plt.gca()
    xplot, yplot = f.lines[0].get_xydata().T
    assert_equal(yplot, test_data[:, 50])
    plt.close()
示例#2
0
def test_column_plot():
    """Check the column plot function."""
    plots = Imexamine()
    plots.set_data(test_data)
    plots.plot_column(50, 50)
    f = plt.gca()
    xplot, yplot = f.lines[0].get_xydata().T
    assert_equal(yplot, test_data[50, :])
    plt.close()
示例#3
0
def test_column_fit():
    """Fit a Gaussian1D column to the data."""
    plots = Imexamine()
    plots.set_data(test_data)
    fit = plots.column_fit(50, 50, form='Gaussian1D', genplot=False)
    amp = 2.8285560281694115
    mean = 49.42625526973088
    stddev = 12.791137635400535

    assert_allclose(amp, fit.amplitude, 1e-6)
    assert_allclose(mean, fit.mean, 1e-6)
    assert_allclose(stddev, fit.stddev, 1e-6)
示例#4
0
def test_line_fit():
    """Fit a Gaussian1D line to the data."""
    plots = Imexamine()
    plots.set_data(test_data)
    fit = plots.line_fit(50, 50, form='Gaussian1D', genplot=False)
    amp = 2.8152269683542137
    mean = 49.45671107821953
    stddev = 13.051081779478146

    assert_allclose(amp, fit.amplitude, 1e-6)
    assert_allclose(mean, fit.mean, 1e-6)
    assert_allclose(stddev, fit.stddev, 1e-6)
示例#5
0
def test_line_fit():
    """Fit a Gaussian1D line to the data."""
    plots = Imexamine()
    plots.set_data(test_data)
    fit = plots.line_fit(50, 50, form='Gaussian1D', genplot=False)
    amp = 2.8152269683542137
    mean = 49.45671107821953
    stddev = 13.051081779478146

    assert_allclose(amp, fit.amplitude, 1e-6)
    assert_allclose(mean, fit.mean, 1e-6)
    assert_allclose(stddev, fit.stddev, 1e-6)
示例#6
0
def test_column_fit():
    """Fit a Gaussian1D column to the data."""
    plots = Imexamine()
    plots.set_data(test_data)
    fit = plots.column_fit(50, 50, form='Gaussian1D', genplot=False)
    amp = 2.8285560281694115
    mean = 49.42625526973088
    stddev = 12.791137635400535

    assert_allclose(amp, fit.amplitude, 1e-6)
    assert_allclose(mean, fit.mean, 1e-6)
    assert_allclose(stddev, fit.stddev, 1e-6)
示例#7
0
def test_column_fit():
    """Fit a Gaussian1D column to the data."""
    plots = Imexamine()
    in_amp = 3.
    in_mean = 50.
    in_stddev = 2.
    in_const = 20.
    # Set all the columns to be Gaussians
    col_gauss = in_const + in_amp * np.exp(-0.5 * ((yy - in_mean) / in_stddev)**2)
    plots.set_data(col_gauss)
    fit = plots.column_fit(50, 50, form='Gaussian1D', genplot=False)

    assert_allclose(in_amp, fit.amplitude_0, 1e-6)
    assert_allclose(in_mean, fit.mean_0, 1e-6)
    assert_allclose(in_stddev, fit.stddev_0, 1e-6)
    assert_allclose(in_const, fit.c0_1, 1e-6)
示例#8
0
def test_column_fit():
    """Fit a Gaussian1D column to the data."""
    plots = Imexamine()
    in_amp = 3.
    in_mean = 50.
    in_stddev = 2.
    in_const = 20.
    # Set all the columns to be Gaussians
    col_gauss = in_const + in_amp * np.exp(-0.5 * ((yy - in_mean) / in_stddev)**2)
    plots.set_data(col_gauss)
    fit = plots.column_fit(50, 50, form='Gaussian1D', genplot=False)

    assert_allclose(in_amp, fit.amplitude_0, 1e-6)
    assert_allclose(in_mean, fit.mean_0, 1e-6)
    assert_allclose(in_stddev, fit.stddev_0, 1e-6)
    assert_allclose(in_const, fit.c0_1, 1e-6)
示例#9
0
    def __init__(self, fv, fitsimage):
        # superclass defines some variables for us, like logger
        super(Imexam, self).__init__(fv, fitsimage)

        # get Imexam preferences
        prefs = self.fv.get_preferences()
        self.settings = prefs.createCategory('plugin_Imexam')
        self.settings.addDefaults(font='Courier',
                                  fontsize=12,
                                  plots_in_workspace=False)
        self.settings.load(onError='silent')

        self.layertag = 'imexam-canvas'
        self.imexam_active = False

        # this is our imexamine object
        self.imex = Imexamine()
        self.out_f = StringIO()

        self.dc = fv.get_draw_classes()
        canvas = self.dc.DrawingCanvas()
        canvas.set_callback('key-press', self.key_press_cb)
        canvas.set_surface(self.fitsimage)
        canvas.register_for_cursor_drawing(self.fitsimage)
        canvas.enable_draw(False)
        canvas.name = 'Imexam-canvas'
        self.canvas = canvas

        self._plot = None
        self._plot_w = None
        self._plot_idx = 0
        self._plots_in_ws = self.settings.get('plots_in_workspace', False)
        self.w = Bunch.Bunch()
示例#10
0
def test_radial_profile_background():
    """Test the radial profile function
    With background subtraction
    Cummulative pixels """
    from astropy.convolution import Gaussian2DKernel
    data = Gaussian2DKernel(1.5, x_size=25, y_size=25)
    xx, yy = np.meshgrid(np.arange(25), np.arange(25))
    x0, y0 = np.where(data.array == data.array.max())

    rad_in = np.sqrt((xx - x0)**2 + (yy - y0)**2)
    rad_in = rad_in.ravel()
    flux_in = data.array.ravel()

    order = np.argsort(rad_in)
    rad_in = rad_in[order]
    flux_in = flux_in[order]

    plots = Imexamine()
    plots.set_data(data.array)
    # check the binned results
    plots.radial_profile_pars['pixels'][0] = False
    plots.radial_profile_pars['background'][0] = True
    rad_out, flux_out = plots.radial_profile(x0, y0, genplot=False)

    good = np.where(rad_in <= np.max(rad_out))
    rad_in = rad_in[good]
    flux_in = flux_in[good]

    flux_in = np.bincount(rad_in.astype(np.int), flux_in)

    assert_array_equal(np.arange(flux_in.size), rad_out)
    assert_allclose(flux_in - flux_out, flux_out * 0, atol=1e-5)
示例#11
0
def test_radial_profile():
    """Test the radial profile function without background subtraction"""
    from astropy.convolution import Gaussian2DKernel
    data = Gaussian2DKernel(1.5, x_size=25, y_size=25)
    plots = Imexamine()
    plots.set_data(data.array)
    # check the binned results
    plots.radial_profile_pars['pixels'][0] = False
    x, y = plots.radial_profile(12, 12, genplot=False)

    rad = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
    flux = [4.53542348e-02,   3.00703719e-01,   3.54889792e-01,
            1.95806071e-01,   7.56662018e-02,   2.46976310e-02,
            2.54073324e-03,   1.51802506e-04,   1.08323362e-06,
            3.65945812e-10]

    assert_array_equal(rad, x)
    assert_allclose(flux, y, 1e-7)
示例#12
0
def test_curve_of_growth():
    """Test the cog functionality."""
    from astropy.convolution import Gaussian2DKernel
    data = Gaussian2DKernel(1.5, x_size=25, y_size=25)
    plots = Imexamine()
    plots.set_data(data.array)
    x, y = plots.curve_of_growth(12, 12, genplot=False)

    rad = [1, 2, 3, 4, 5, 6, 7, 8]
    flux = [0.04535423476987057,
            0.34605795394960859,
            0.70094774639729907,
            0.89675381769455764,
            0.97242001951216395,
            0.99711765053819645,
            0.99965838382174854,
            0.99998044756724924]

    assert_array_equal(rad, x)
    assert_allclose(flux, y, 1e-6)
示例#13
0
def test_gauss_center():
    """Check the gaussian center fitting."""
    # make a 2d dataset with a gaussian at the center
    from astropy.convolution import Gaussian2DKernel
    gaussian_2D_kernel = Gaussian2DKernel(10)
    plots = Imexamine()
    plots.set_data(gaussian_2D_kernel.array)
    a, xx, yy, xs, ys = plots.gauss_center(37, 37)

    amp = 0.0015915494309189533
    xc = 40.0
    yc = 40.0
    xsig = 10.0
    ysig = 10.0

    assert_allclose(amp, a, 1e-6)
    assert_allclose(xc, xx, 1e-4)
    assert_allclose(yc, yy, 1e-4)
    assert_allclose(xsig, xs, 0.01)
    assert_allclose(ysig, ys, 0.01)
示例#14
0
def test_gauss_center():
    """Check the gaussian center fitting."""
    # make a 2d dataset with a gaussian at the center
    from astropy.convolution import Gaussian2DKernel
    gaussian_2D_kernel = Gaussian2DKernel(10)
    plots = Imexamine()
    plots.set_data(gaussian_2D_kernel.array)
    a, xx, yy, xs, ys = plots.gauss_center(37, 37)

    amp = 0.0015915494309189533
    xc = 40.0
    yc = 40.0
    xsig = 10.0
    ysig = 10.0

    assert_allclose(amp, a, 1e-6)
    assert_allclose(xc, xx, 1e-4)
    assert_allclose(yc, yy, 1e-4)
    assert_allclose(xsig, xs, 0.01)
    assert_allclose(ysig, ys, 0.01)
示例#15
0
def test_curve_of_growth():
    """Test the cog functionality."""
    from astropy.convolution import Gaussian2DKernel
    data = Gaussian2DKernel(1.5, x_size=25, y_size=25)
    plots = Imexamine()
    plots.set_data(data.array)
    x, y = plots.curve_of_growth(12, 12, genplot=False)

    rad = [1, 2, 3, 4, 5, 6, 7, 8]
    flux = [0.04535423476987057,
            0.34605795394960859,
            0.70094774639729907,
            0.89675381769455764,
            0.97242001951216395,
            0.99711765053819645,
            0.99965838382174854,
            0.99998044756724924]

    assert_array_equal(rad, x)
    assert_allclose(flux, y, 1e-6)
示例#16
0
def test_gauss_center():
    """Check the gaussian center fitting."""

    from astropy.convolution import Gaussian2DKernel

    # This creates a 2D normalized gaussian kernal with
    # a set amplitude. Guess off-center
    amp = 0.0015915494309189533
    size = 81.0
    sigma = 10.0

    gaussian_2D_kernel = Gaussian2DKernel(sigma, x_size=size, y_size=size)
    plots = Imexamine()
    plots.set_data(gaussian_2D_kernel.array)
    a, xx, yy, xs, ys = plots.gauss_center(37, 37)

    assert_allclose(amp, a, 1e-6)
    assert_allclose(size // 2, xx, 1e-6)
    assert_allclose(size // 2, yy, 1e-6)
    assert_allclose(sigma, xs, 0.01)
    assert_allclose(sigma, ys, 0.01)
示例#17
0
def test_curve_of_growth():
    """Test the cog functionality."""
    from astropy.convolution import Gaussian2DKernel
    data = Gaussian2DKernel(1.5, x_size=25, y_size=25)
    plots = Imexamine()
    plots.set_data(data.array)
    rad_out, flux_out = plots.curve_of_growth(12, 12, genplot=False)

    rads = [1, 2, 3, 4, 5, 6, 7, 8]
    flux = []
    # Run the aperture phot on this to build up the expected fluxes
    plots.aper_phot_pars['genplot'][0] = False
    plots.aper_phot_pars['subsky'][0] = False

    for rad in rads:
        plots.aper_phot_pars['radius'][0] = rad
        plots.aper_phot(12, 12)
        flux.append(plots.total_flux)

    assert_array_equal(rads, rad_out)
    assert_allclose(flux, flux_out, 1e-6)
示例#18
0
def test_gauss_center():
    """Check the gaussian center fitting."""

    from astropy.convolution import Gaussian2DKernel

    # This creates a 2D normalized gaussian kernal with
    # a set amplitude. Guess off-center
    amp = 0.0015915494309189533
    size = 81.0
    sigma = 10.0

    gaussian_2D_kernel = Gaussian2DKernel(sigma, x_size=size, y_size=size)
    plots = Imexamine()
    plots.set_data(gaussian_2D_kernel.array)
    a, xx, yy, xs, ys = plots.gauss_center(37, 37)

    assert_allclose(amp, a, 1e-6)
    assert_allclose(size // 2, xx, 1e-6)
    assert_allclose(size // 2, yy, 1e-6)
    assert_allclose(sigma, xs, 0.01)
    assert_allclose(sigma, ys, 0.01)
示例#19
0
def test_xy_coords(capsys):
    """Make sure xy coords are printed with the correct location and value."""
    plots = Imexamine()
    plots.set_data(test_data)
    out_text = """50 50  3.0"""
    plots.show_xy_coords(50, 50)
    out, err = capsys.readouterr()
    assert (out.strip() == out_text)
示例#20
0
def test_column_plot():
    """Check the column plot function."""
    plots = Imexamine()
    plots.set_data(test_data)
    plots.plot_column(50, 50)
    f = plt.gca()
    xplot, yplot = f.lines[0].get_xydata().T
    assert_equal(yplot, test_data[50, :])
    plt.close()
示例#21
0
def test_line_plot():
    """check the line plot function."""
    plots = Imexamine()
    plots.set_data(test_data)
    plots.plot_line(50, 50)
    f = plt.gca()
    xplot, yplot = f.lines[0].get_xydata().T
    assert_equal(yplot, test_data[:, 50])
    plt.close()
示例#22
0
def test_curve_of_growth():
    """Test the curve of growth functionality."""
    from astropy.convolution import Gaussian2DKernel
    data = Gaussian2DKernel(1.5, x_size=25, y_size=25)
    plots = Imexamine()
    plots.set_data(data.array)
    rad_out, flux_out = plots.curve_of_growth(12, 12, genplot=False)

    rads = [1, 2, 3, 4, 5, 6, 7, 8]
    flux = []

    # Run the aperture phot on this to build up the expected fluxes
    plots.aper_phot_pars['genplot'][0] = False
    plots.aper_phot_pars['subsky'][0] = False

    for rad in rads:
        plots.aper_phot_pars['radius'][0] = rad
        plots.aper_phot(12, 12)
        flux.append(plots.total_flux)

    assert_array_equal(rads, rad_out)
    assert_allclose(flux, flux_out, 1e-6)
示例#23
0
def test_aper_phot(capsys):
    """Make sure aper phot executes and returns expected text."""
    out_text = """xc=49.500000	yc=49.500000
x              y              radius         flux           mag(zpt=25.00)                 sky           fwhm
49.50          49.50          5              134.73         19.68                         1.34           27.54
"""
    plots = Imexamine()
    plots.set_data(test_data)
    plots.aper_phot(50, 50)
    out, err = capsys.readouterr()
    print(out)
    print(out_text)
    assert out == out_text
示例#24
0
def test_radial_profile_background():
    """Test the radial profile function with background subtraction"""
    from astropy.convolution import Gaussian2DKernel
    data = Gaussian2DKernel(1.5, x_size=25, y_size=25)
    plots = Imexamine()
    plots.set_data(data.array)
    # check the binned results
    plots.radial_profile_pars['pixels'][0] = False
    plots.radial_profile_pars['background'][0] = True
    x, y = plots.radial_profile(12, 12, genplot=False)

    rad = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
    flux = [4.535423e-02, 3.007037e-01, 3.548898e-01, 1.958061e-01,
            7.566620e-02, 2.469763e-02, 2.540733e-03, 1.518025e-04,
            1.083221e-06, 3.605551e-10]

    assert_array_equal(rad, x)
    assert_allclose(flux, y, 1e-6)
示例#25
0
def test_radial_profile_cumulative():
    """Test the radial profile function
    without background subtraction
    with each pixel integer binned
    """
    from astropy.convolution import Gaussian2DKernel
    ksize = 25
    data = Gaussian2DKernel(1.5, x_size=ksize, y_size=ksize)
    xx, yy = np.meshgrid(np.arange(ksize), np.arange(ksize))
    x0, y0 = np.where(data.array == data.array.max())
    rad_in = np.sqrt((xx - x0)**2 + (yy - y0)**2)

    rad_in = rad_in.ravel()
    flux_in = data.array.ravel()

    indices = np.argsort(rad_in)
    rad_in = rad_in[indices]
    flux_in = flux_in[indices]

    # now bin the radflux like we expect
    rad_in = rad_in.astype(np.int)
    flux_in = np.bincount(rad_in, flux_in) / np.bincount(rad_in)
    rad_in = np.arange(len(flux_in))
    assert (data.array[x0, y0] == flux_in[0])

    # check the binned results
    plots = Imexamine()
    plots.set_data(data.array)
    plots.radial_profile_pars['pixels'][0] = False
    plots.radial_profile_pars['background'][0] = False
    plots.radial_profile_pars['clip'][0] = False
    rad_out, flux_out = plots.radial_profile(x0, y0, genplot=False)

    # The default measurement size is not equal
    assert (len(rad_in) >= len(rad_out))
    good = [rad_in[i] for i in rad_out if rad_out[i] == rad_in[i]]

    assert_array_equal(rad_in[good], rad_out[good])
    assert_allclose(flux_in[good], flux_out[good], atol=1e-7)
示例#26
0
def test_radial_profile():
    """Test the radial profile function
    No background subtraction
    individual pixel results used
    """
    from astropy.convolution import Gaussian2DKernel
    data = Gaussian2DKernel(1.5, x_size=25, y_size=25)
    xx, yy = np.meshgrid(np.arange(25), np.arange(25))
    x0, y0 = np.where(data.array == data.array.max())

    rad_in = np.sqrt((xx - x0)**2 + (yy - y0)**2)
    rad_in = rad_in.ravel()
    flux_in = data.array.ravel()

    order = np.argsort(rad_in)
    rad_in = rad_in[order]
    flux_in = flux_in[order]

    plots = Imexamine()
    plots.set_data(data.array)

    plots.radial_profile_pars['pixels'][0] = True
    plots.radial_profile_pars['background'][0] = False
    plots.radial_profile_pars['clip'][0] = False
    rad_out, flux_out = plots.radial_profile(x0, y0, genplot=False)

    order2 = np.argsort(rad_out)
    rad_out = rad_out[order2]
    flux_out = flux_out[order2]

    # the radial profile is done on a smaller cutout by default
    # and may have a fractional center radius calculation. This
    # looks at the first few hundred data points in both arrays
    assert (len(rad_out) < len(rad_in))
    good = 150
    assert_allclose(rad_in[:good], rad_out[:good], atol=1e-14)
    assert_allclose(flux_in[:good], flux_out[:good], atol=1e-14)
示例#27
0
    def __init__(self,
                 target=None,
                 path=None,
                 viewer="ds9",
                 wait_time=10,
                 quit_window=True,
                 port=None):
        """Initialize the imexam control object."""
        _possible_viewers = []

        if have_xpa:
            _possible_viewers.append("ds9")

        self._viewer = viewer.lower()

        if (self._viewer not in _possible_viewers
                or len(_possible_viewers) == 0):
            warnings.warn("**Unsupported viewer, check your installed "
                          "packages**\n")
            raise NotImplementedError

        # init sets empty data array until we can load or check viewer
        self.exam = Imexamine()

        if 'ds9' in self._viewer:
            self.window = ds9(target=target,
                              path=path,
                              wait_time=wait_time,
                              quit_ds9_on_del=quit_window)
            self._event_driven_exam = False  # use the imexam loop

            # alter the exam.imexam_option_funcs{} here through the viewer code
            # if you want to change key+function associations
            # self.window._reassign_keys(imexam_dict)

        self.logfile = 'imexam_log.txt'  # default logfile name
        self.log = set_logging()  # points to the package logger
        self._current_slice = None
        self._current_frame = None
示例#28
0
def test_radial_profile_cumulative():
    """Test the radial profile function
    without background subtraction
    with each pixel integer binned
    """
    from astropy.convolution import Gaussian2DKernel
    ksize = 25
    data = Gaussian2DKernel(1.5, x_size=ksize, y_size=ksize)
    xx, yy = np.meshgrid(np.arange(ksize), np.arange(ksize))
    x0, y0 = np.where(data.array == data.array.max())
    rad_in = np.sqrt((xx - x0)**2 + (yy - y0)**2)

    rad_in = rad_in.ravel()
    flux_in = data.array.ravel()

    indices = np.argsort(rad_in)
    rad_in = rad_in[indices]
    flux_in = flux_in[indices]

    # now bin the radflux like we expect
    rad_in = rad_in.astype(np.int)
    flux_in = np.bincount(rad_in, flux_in) / np.bincount(rad_in)
    rad_in = np.arange(len(flux_in))
    assert (data.array[x0, y0] == flux_in[0])

    # check the binned results
    plots = Imexamine()
    plots.set_data(data.array)
    plots.radial_profile_pars['pixels'][0] = False
    plots.radial_profile_pars['background'][0] = False
    plots.radial_profile_pars['clip'][0] = False
    rad_out, flux_out = plots.radial_profile(x0, y0, genplot=False)

    # The default measurement size is not equal
    assert (len(rad_in) >= len(rad_out))
    good = [rad_in[i] for i in rad_out if rad_out[i] == rad_in[i]]

    assert_array_equal(rad_in[good], rad_out[good])
    assert_allclose(flux_in[good], flux_out[good], atol=1e-7)
示例#29
0
def test_radial_profile():
    """Test the radial profile function
    No background subtraction
    individual pixel results used
    """
    from astropy.convolution import Gaussian2DKernel
    data = Gaussian2DKernel(1.5, x_size=25, y_size=25)
    xx, yy = np.meshgrid(np.arange(25), np.arange(25))
    x0, y0 = np.where(data.array == data.array.max())

    rad_in = np.sqrt((xx - x0)**2 + (yy - y0)**2)
    rad_in = rad_in.ravel()
    flux_in = data.array.ravel()

    order = np.argsort(rad_in)
    rad_in = rad_in[order]
    flux_in = flux_in[order]

    plots = Imexamine()
    plots.set_data(data.array)

    plots.radial_profile_pars['pixels'][0] = True
    plots.radial_profile_pars['background'][0] = False
    plots.radial_profile_pars['clip'][0] = False
    rad_out, flux_out = plots.radial_profile(x0, y0, genplot=False)

    order2 = np.argsort(rad_out)
    rad_out = rad_out[order2]
    flux_out = flux_out[order2]

    # the radial profile is done on a smaller cutout by default
    # and may have a fractional center radius calculation. This
    # looks at the first few hundred data points in both arrays
    assert (len(rad_out) < len(rad_in))
    good = 150
    assert_allclose(rad_in[:good], rad_out[:good], atol=1e-14)
    assert_allclose(flux_in[:good], flux_out[:good], atol=1e-14)
示例#30
0
def test_radial_profile_pixels():
    """Test the radial profile function
    without background subtraction
    with each pixel unsummed
    """
    from astropy.convolution import Gaussian2DKernel
    data = Gaussian2DKernel(1.5, x_size=25, y_size=25)
    xx, yy = np.meshgrid(np.arange(25), np.arange(25))
    x0, y0 = np.where(data.array == data.array.max())

    rad_in = np.sqrt((xx - x0)**2 + (yy - y0)**2)

    # It's going to crop things down apparently.
    plots = Imexamine()
    datasize = int(plots.radial_profile_pars["rplot"][0])
    icentery = 12
    icenterx = 12
    rad_in = rad_in[icentery - datasize:icentery + datasize,
                    icenterx - datasize:icenterx + datasize]
    flux_in = data.array[icentery - datasize:icentery + datasize,
                         icenterx - datasize:icenterx + datasize]

    rad_in = rad_in.ravel()
    flux_in = flux_in.ravel()

    order = np.argsort(rad_in)
    rad_in = rad_in[order]
    flux_in = flux_in[order]

    plots.set_data(data.array)
    # check the unbinned results
    plots.radial_profile_pars['pixels'][0] = True
    out_radius, out_flux = plots.radial_profile(x0, y0, genplot=False)
    good = np.where(rad_in <= np.max(out_radius))
    rad_in = rad_in[good]
    flux_in = flux_in[good]

    assert_allclose(rad_in, out_radius, 1e-7)
    assert_allclose(flux_in, out_flux, 1e-7)
示例#31
0
import pyregion
from pathlib import Path
from imexam.imexamine import Imexamine
from imexam.math_helper import mfwhm, gfwhm
from astropy.io import ascii
test = 0
while test == 0:
    try:
        filename = Path(input("Enter path to file: "))
        rfile = Path(input("enter path to region file: "))
    except (KeyError, TypeError, FileNotFoundError):
        filename = str(input("perhaps a typo, try again"))

    images = sorted(filename.glob('indiir1_20*.fits'))
    region_name = sorted(rfile.glob('indiir1_*.coo'))
    plots = Imexamine()

    for names, stars in zip(images, region_name):
        data = fits.getdata(names)
        plots.set_data(data)
        starlist = ascii.read(stars, data_start=3)
        plots.line_fit_pars['func'] = ['Moffat1D']
        plots.column_fit_pars['func'] = ['Moffat1D']
        results = dict()
        yresults = dict()
        for star in starlist:

            sid, x, y, a4, a5, a6, a7 = star
            moff = plots.line_fit(x, y, genplot=False)
            ymoff = plots.column_fit(x, y, genplot=False)
            #            print(moff)
示例#32
0
def test_radial_profile_pixels():
    """Test the radial profile function without background subtraction"""
    from astropy.convolution import Gaussian2DKernel
    data = Gaussian2DKernel(1.5, x_size=25, y_size=25)
    plots = Imexamine()
    plots.set_data(data.array)
    # check the unbinned results
    plots.radial_profile_pars['pixels'][0] = True
    x, y = plots.radial_profile(12, 12, genplot=False)

    rad = [1.00485917e-14,   1.00000000e+00,   1.00000000e+00,
           1.00000000e+00,   1.00000000e+00,   1.41421356e+00,
           1.41421356e+00,   1.41421356e+00,   1.41421356e+00,
           2.00000000e+00,   2.00000000e+00,   2.00000000e+00,
           2.00000000e+00,   2.23606798e+00,   2.23606798e+00,
           2.23606798e+00,   2.23606798e+00,   2.23606798e+00,
           2.23606798e+00,   2.23606798e+00,   2.23606798e+00,
           2.82842712e+00,   2.82842712e+00,   2.82842712e+00,
           2.82842712e+00,   3.00000000e+00,   3.00000000e+00,
           3.00000000e+00,   3.00000000e+00,   3.16227766e+00,
           3.16227766e+00,   3.16227766e+00,   3.16227766e+00,
           3.16227766e+00,   3.16227766e+00,   3.16227766e+00,
           3.16227766e+00,   3.60555128e+00,   3.60555128e+00,
           3.60555128e+00,   3.60555128e+00,   3.60555128e+00,
           3.60555128e+00,   3.60555128e+00,   3.60555128e+00,
           4.00000000e+00,   4.00000000e+00,   4.00000000e+00,
           4.00000000e+00,   4.12310563e+00,   4.12310563e+00,
           4.12310563e+00,   4.12310563e+00,   4.12310563e+00,
           4.12310563e+00,   4.12310563e+00,   4.12310563e+00,
           4.24264069e+00,   4.24264069e+00,   4.24264069e+00,
           4.24264069e+00,   4.47213595e+00,   4.47213595e+00,
           4.47213595e+00,   4.47213595e+00,   4.47213595e+00,
           4.47213595e+00,   4.47213595e+00,   4.47213595e+00,
           5.00000000e+00,   5.00000000e+00,   5.00000000e+00,
           5.00000000e+00,   5.00000000e+00,   5.00000000e+00,
           5.00000000e+00,   5.00000000e+00,   5.00000000e+00,
           5.00000000e+00,   5.00000000e+00,   5.00000000e+00,
           5.09901951e+00,   5.09901951e+00,   5.09901951e+00,
           5.09901951e+00,   5.09901951e+00,   5.09901951e+00,
           5.09901951e+00,   5.09901951e+00,   5.38516481e+00,
           5.38516481e+00,   5.38516481e+00,   5.38516481e+00,
           5.38516481e+00,   5.38516481e+00,   5.38516481e+00,
           5.38516481e+00,   5.65685425e+00,   5.65685425e+00,
           5.65685425e+00,   5.65685425e+00,   5.83095189e+00,
           5.83095189e+00,   5.83095189e+00,   5.83095189e+00,
           5.83095189e+00,   5.83095189e+00,   5.83095189e+00,
           5.83095189e+00,   6.00000000e+00,   6.00000000e+00,
           6.00000000e+00,   6.00000000e+00,   6.08276253e+00,
           6.08276253e+00,   6.08276253e+00,   6.08276253e+00,
           6.08276253e+00,   6.08276253e+00,   6.08276253e+00,
           6.08276253e+00,   6.32455532e+00,   6.32455532e+00,
           6.32455532e+00,   6.32455532e+00,   6.32455532e+00,
           6.32455532e+00,   6.32455532e+00,   6.32455532e+00,
           6.40312424e+00,   6.40312424e+00,   6.40312424e+00,
           6.40312424e+00,   6.40312424e+00,   6.40312424e+00,
           6.40312424e+00,   6.40312424e+00,   6.70820393e+00,
           6.70820393e+00,   6.70820393e+00,   6.70820393e+00,
           6.70820393e+00,   6.70820393e+00,   6.70820393e+00,
           6.70820393e+00,   7.00000000e+00,   7.00000000e+00,
           7.07106781e+00,   7.07106781e+00,   7.07106781e+00,
           7.07106781e+00,   7.07106781e+00,   7.07106781e+00,
           7.07106781e+00,   7.07106781e+00,   7.21110255e+00,
           7.21110255e+00,   7.21110255e+00,   7.21110255e+00,
           7.21110255e+00,   7.21110255e+00,   7.21110255e+00,
           7.21110255e+00,   7.28010989e+00,   7.28010989e+00,
           7.28010989e+00,   7.28010989e+00,   7.61577311e+00,
           7.61577311e+00,   7.61577311e+00,   7.61577311e+00,
           7.81024968e+00,   7.81024968e+00,   7.81024968e+00,
           7.81024968e+00,   7.81024968e+00,   7.81024968e+00,
           7.81024968e+00,   7.81024968e+00,   8.06225775e+00,
           8.06225775e+00,   8.06225775e+00,   8.06225775e+00,
           8.48528137e+00,   8.48528137e+00,   8.48528137e+00,
           8.48528137e+00,   8.60232527e+00,   8.60232527e+00,
           8.60232527e+00,   8.60232527e+00,   9.21954446e+00,
           9.21954446e+00,   9.21954446e+00,   9.21954446e+00,
           9.89949494e+00]

    flux = [1.19552465e-02,   2.32856406e-02,   2.32856406e-02,
            3.93558331e-03,   3.93558331e-03,   4.53542348e-02,
            7.66546959e-03,   7.66546959e-03,   1.29556643e-03,
            2.90802459e-02,   2.90802459e-02,   8.30691786e-04,
            8.30691786e-04,   5.66405848e-02,   5.66405848e-02,
            9.57301302e-03,   9.57301302e-03,   1.61796667e-03,
            1.61796667e-03,   2.73457911e-04,   2.73457911e-04,
            7.07355303e-02,   2.02059585e-03,   2.02059585e-03,
            5.77193322e-05,   2.32856406e-02,   2.32856406e-02,
            1.12421908e-04,   1.12421908e-04,   4.53542348e-02,
            4.53542348e-02,   7.66546959e-03,   7.66546959e-03,
            2.18967977e-04,   2.18967977e-04,   3.70085038e-05,
            3.70085038e-05,   5.66405848e-02,   5.66405848e-02,
            1.61796667e-03,   1.61796667e-03,   2.73457911e-04,
            2.73457911e-04,   7.81146217e-06,   7.81146217e-06,
            1.19552465e-02,   1.19552465e-02,   9.75533570e-06,
            9.75533570e-06,   2.32856406e-02,   2.32856406e-02,
            3.93558331e-03,   3.93558331e-03,   1.90007994e-05,
            1.90007994e-05,   3.21138811e-06,   3.21138811e-06,
            4.53542348e-02,   2.18967977e-04,   2.18967977e-04,
            1.05716645e-06,   2.90802459e-02,   2.90802459e-02,
            8.30691786e-04,   8.30691786e-04,   2.37291269e-05,
            2.37291269e-05,   6.77834392e-07,   6.77834392e-07,
            2.32856406e-02,   2.32856406e-02,   3.93558331e-03,
            3.93558331e-03,   1.12421908e-04,   1.12421908e-04,
            1.90007994e-05,   1.90007994e-05,   5.42767351e-07,
            5.42767351e-07,   9.17349095e-08,   9.17349095e-08,
            7.66546959e-03,   7.66546959e-03,   1.29556643e-03,
            1.29556643e-03,   1.05716645e-06,   1.05716645e-06,
            1.78675206e-07,   1.78675206e-07,   9.57301302e-03,
            9.57301302e-03,   2.73457911e-04,   2.73457911e-04,
            1.32024112e-06,   1.32024112e-06,   3.77133487e-08,
            3.77133487e-08,   1.19552465e-02,   9.75533570e-06,
            9.75533570e-06,   7.96023526e-09,   7.66546959e-03,
            7.66546959e-03,   3.70085038e-05,   3.70085038e-05,
            1.05716645e-06,   1.05716645e-06,   5.10394673e-09,
            5.10394673e-09,   8.30691786e-04,   8.30691786e-04,
            1.93626789e-08,   1.93626789e-08,   1.61796667e-03,
            1.61796667e-03,   2.73457911e-04,   2.73457911e-04,
            3.77133487e-08,   3.77133487e-08,   6.37405811e-09,
            6.37405811e-09,   2.02059585e-03,   2.02059585e-03,
            5.77193322e-05,   5.77193322e-05,   4.70982729e-08,
            4.70982729e-08,   1.34538575e-09,   1.34538575e-09,
            3.93558331e-03,   3.93558331e-03,   3.21138811e-06,
            3.21138811e-06,   5.42767351e-07,   5.42767351e-07,
            4.42891556e-10,   4.42891556e-10,   1.61796667e-03,
            1.61796667e-03,   7.81146217e-06,   7.81146217e-06,
            3.77133487e-08,   3.77133487e-08,   1.82078162e-10,
            1.82078162e-10,   1.12421908e-04,   1.12421908e-04,
            1.29556643e-03,   2.18967977e-04,   2.18967977e-04,
            3.70085038e-05,   3.70085038e-05,   1.78675206e-07,
            1.78675206e-07,   2.46415996e-11,   8.30691786e-04,
            8.30691786e-04,   6.77834392e-07,   6.77834392e-07,
            1.93626789e-08,   1.93626789e-08,   1.57997104e-11,
            1.57997104e-11,   2.73457911e-04,   2.73457911e-04,
            7.81146217e-06,   7.81146217e-06,   2.18967977e-04,
            2.18967977e-04,   1.05716645e-06,   1.05716645e-06,
            2.73457911e-04,   2.73457911e-04,   3.77133487e-08,
            3.77133487e-08,   6.37405811e-09,   6.37405811e-09,
            8.79064260e-13,   8.79064260e-13,   1.12421908e-04,
            1.12421908e-04,   9.17349095e-08,   9.17349095e-08,
            5.77193322e-05,   1.34538575e-09,   1.34538575e-09,
            3.13597326e-14,   3.70085038e-05,   3.70085038e-05,
            5.10394673e-09,   5.10394673e-09,   7.81146217e-06,
            7.81146217e-06,   1.82078162e-10,   1.82078162e-10,
            1.05716645e-06]

    assert_allclose(rad, x, 1e-7)
    assert_allclose(flux, y, 1e-7)
示例#33
0
def test_radial_profile_pixels():
    """Test the radial profile function without background subtraction"""
    from astropy.convolution import Gaussian2DKernel
    data = Gaussian2DKernel(1.5, x_size=25, y_size=25)
    plots = Imexamine()
    plots.set_data(data.array)
    # check the unbinned results
    plots.radial_profile_pars['pixels'][0] = True
    x, y = plots.radial_profile(12, 12, genplot=False)

    rad = [1.00485917e-14,   1.00000000e+00,   1.00000000e+00,
           1.00000000e+00,   1.00000000e+00,   1.41421356e+00,
           1.41421356e+00,   1.41421356e+00,   1.41421356e+00,
           2.00000000e+00,   2.00000000e+00,   2.00000000e+00,
           2.00000000e+00,   2.23606798e+00,   2.23606798e+00,
           2.23606798e+00,   2.23606798e+00,   2.23606798e+00,
           2.23606798e+00,   2.23606798e+00,   2.23606798e+00,
           2.82842712e+00,   2.82842712e+00,   2.82842712e+00,
           2.82842712e+00,   3.00000000e+00,   3.00000000e+00,
           3.00000000e+00,   3.00000000e+00,   3.16227766e+00,
           3.16227766e+00,   3.16227766e+00,   3.16227766e+00,
           3.16227766e+00,   3.16227766e+00,   3.16227766e+00,
           3.16227766e+00,   3.60555128e+00,   3.60555128e+00,
           3.60555128e+00,   3.60555128e+00,   3.60555128e+00,
           3.60555128e+00,   3.60555128e+00,   3.60555128e+00,
           4.00000000e+00,   4.00000000e+00,   4.00000000e+00,
           4.00000000e+00,   4.12310563e+00,   4.12310563e+00,
           4.12310563e+00,   4.12310563e+00,   4.12310563e+00,
           4.12310563e+00,   4.12310563e+00,   4.12310563e+00,
           4.24264069e+00,   4.24264069e+00,   4.24264069e+00,
           4.24264069e+00,   4.47213595e+00,   4.47213595e+00,
           4.47213595e+00,   4.47213595e+00,   4.47213595e+00,
           4.47213595e+00,   4.47213595e+00,   4.47213595e+00,
           5.00000000e+00,   5.00000000e+00,   5.00000000e+00,
           5.00000000e+00,   5.00000000e+00,   5.00000000e+00,
           5.00000000e+00,   5.00000000e+00,   5.00000000e+00,
           5.00000000e+00,   5.00000000e+00,   5.00000000e+00,
           5.09901951e+00,   5.09901951e+00,   5.09901951e+00,
           5.09901951e+00,   5.09901951e+00,   5.09901951e+00,
           5.09901951e+00,   5.09901951e+00,   5.38516481e+00,
           5.38516481e+00,   5.38516481e+00,   5.38516481e+00,
           5.38516481e+00,   5.38516481e+00,   5.38516481e+00,
           5.38516481e+00,   5.65685425e+00,   5.65685425e+00,
           5.65685425e+00,   5.65685425e+00,   5.83095189e+00,
           5.83095189e+00,   5.83095189e+00,   5.83095189e+00,
           5.83095189e+00,   5.83095189e+00,   5.83095189e+00,
           5.83095189e+00,   6.00000000e+00,   6.00000000e+00,
           6.00000000e+00,   6.00000000e+00,   6.08276253e+00,
           6.08276253e+00,   6.08276253e+00,   6.08276253e+00,
           6.08276253e+00,   6.08276253e+00,   6.08276253e+00,
           6.08276253e+00,   6.32455532e+00,   6.32455532e+00,
           6.32455532e+00,   6.32455532e+00,   6.32455532e+00,
           6.32455532e+00,   6.32455532e+00,   6.32455532e+00,
           6.40312424e+00,   6.40312424e+00,   6.40312424e+00,
           6.40312424e+00,   6.40312424e+00,   6.40312424e+00,
           6.40312424e+00,   6.40312424e+00,   6.70820393e+00,
           6.70820393e+00,   6.70820393e+00,   6.70820393e+00,
           6.70820393e+00,   6.70820393e+00,   6.70820393e+00,
           6.70820393e+00,   7.00000000e+00,   7.00000000e+00,
           7.07106781e+00,   7.07106781e+00,   7.07106781e+00,
           7.07106781e+00,   7.07106781e+00,   7.07106781e+00,
           7.07106781e+00,   7.07106781e+00,   7.21110255e+00,
           7.21110255e+00,   7.21110255e+00,   7.21110255e+00,
           7.21110255e+00,   7.21110255e+00,   7.21110255e+00,
           7.21110255e+00,   7.28010989e+00,   7.28010989e+00,
           7.28010989e+00,   7.28010989e+00,   7.61577311e+00,
           7.61577311e+00,   7.61577311e+00,   7.61577311e+00,
           7.81024968e+00,   7.81024968e+00,   7.81024968e+00,
           7.81024968e+00,   7.81024968e+00,   7.81024968e+00,
           7.81024968e+00,   7.81024968e+00,   8.06225775e+00,
           8.06225775e+00,   8.06225775e+00,   8.06225775e+00,
           8.48528137e+00,   8.48528137e+00,   8.48528137e+00,
           8.48528137e+00,   8.60232527e+00,   8.60232527e+00,
           8.60232527e+00,   8.60232527e+00,   9.21954446e+00,
           9.21954446e+00,   9.21954446e+00,   9.21954446e+00,
           9.89949494e+00]

    flux = [1.19552465e-02,   2.32856406e-02,   2.32856406e-02,
            3.93558331e-03,   3.93558331e-03,   4.53542348e-02,
            7.66546959e-03,   7.66546959e-03,   1.29556643e-03,
            2.90802459e-02,   2.90802459e-02,   8.30691786e-04,
            8.30691786e-04,   5.66405848e-02,   5.66405848e-02,
            9.57301302e-03,   9.57301302e-03,   1.61796667e-03,
            1.61796667e-03,   2.73457911e-04,   2.73457911e-04,
            7.07355303e-02,   2.02059585e-03,   2.02059585e-03,
            5.77193322e-05,   2.32856406e-02,   2.32856406e-02,
            1.12421908e-04,   1.12421908e-04,   4.53542348e-02,
            4.53542348e-02,   7.66546959e-03,   7.66546959e-03,
            2.18967977e-04,   2.18967977e-04,   3.70085038e-05,
            3.70085038e-05,   5.66405848e-02,   5.66405848e-02,
            1.61796667e-03,   1.61796667e-03,   2.73457911e-04,
            2.73457911e-04,   7.81146217e-06,   7.81146217e-06,
            1.19552465e-02,   1.19552465e-02,   9.75533570e-06,
            9.75533570e-06,   2.32856406e-02,   2.32856406e-02,
            3.93558331e-03,   3.93558331e-03,   1.90007994e-05,
            1.90007994e-05,   3.21138811e-06,   3.21138811e-06,
            4.53542348e-02,   2.18967977e-04,   2.18967977e-04,
            1.05716645e-06,   2.90802459e-02,   2.90802459e-02,
            8.30691786e-04,   8.30691786e-04,   2.37291269e-05,
            2.37291269e-05,   6.77834392e-07,   6.77834392e-07,
            2.32856406e-02,   2.32856406e-02,   3.93558331e-03,
            3.93558331e-03,   1.12421908e-04,   1.12421908e-04,
            1.90007994e-05,   1.90007994e-05,   5.42767351e-07,
            5.42767351e-07,   9.17349095e-08,   9.17349095e-08,
            7.66546959e-03,   7.66546959e-03,   1.29556643e-03,
            1.29556643e-03,   1.05716645e-06,   1.05716645e-06,
            1.78675206e-07,   1.78675206e-07,   9.57301302e-03,
            9.57301302e-03,   2.73457911e-04,   2.73457911e-04,
            1.32024112e-06,   1.32024112e-06,   3.77133487e-08,
            3.77133487e-08,   1.19552465e-02,   9.75533570e-06,
            9.75533570e-06,   7.96023526e-09,   7.66546959e-03,
            7.66546959e-03,   3.70085038e-05,   3.70085038e-05,
            1.05716645e-06,   1.05716645e-06,   5.10394673e-09,
            5.10394673e-09,   8.30691786e-04,   8.30691786e-04,
            1.93626789e-08,   1.93626789e-08,   1.61796667e-03,
            1.61796667e-03,   2.73457911e-04,   2.73457911e-04,
            3.77133487e-08,   3.77133487e-08,   6.37405811e-09,
            6.37405811e-09,   2.02059585e-03,   2.02059585e-03,
            5.77193322e-05,   5.77193322e-05,   4.70982729e-08,
            4.70982729e-08,   1.34538575e-09,   1.34538575e-09,
            3.93558331e-03,   3.93558331e-03,   3.21138811e-06,
            3.21138811e-06,   5.42767351e-07,   5.42767351e-07,
            4.42891556e-10,   4.42891556e-10,   1.61796667e-03,
            1.61796667e-03,   7.81146217e-06,   7.81146217e-06,
            3.77133487e-08,   3.77133487e-08,   1.82078162e-10,
            1.82078162e-10,   1.12421908e-04,   1.12421908e-04,
            1.29556643e-03,   2.18967977e-04,   2.18967977e-04,
            3.70085038e-05,   3.70085038e-05,   1.78675206e-07,
            1.78675206e-07,   2.46415996e-11,   8.30691786e-04,
            8.30691786e-04,   6.77834392e-07,   6.77834392e-07,
            1.93626789e-08,   1.93626789e-08,   1.57997104e-11,
            1.57997104e-11,   2.73457911e-04,   2.73457911e-04,
            7.81146217e-06,   7.81146217e-06,   2.18967977e-04,
            2.18967977e-04,   1.05716645e-06,   1.05716645e-06,
            2.73457911e-04,   2.73457911e-04,   3.77133487e-08,
            3.77133487e-08,   6.37405811e-09,   6.37405811e-09,
            8.79064260e-13,   8.79064260e-13,   1.12421908e-04,
            1.12421908e-04,   9.17349095e-08,   9.17349095e-08,
            5.77193322e-05,   1.34538575e-09,   1.34538575e-09,
            3.13597326e-14,   3.70085038e-05,   3.70085038e-05,
            5.10394673e-09,   5.10394673e-09,   7.81146217e-06,
            7.81146217e-06,   1.82078162e-10,   1.82078162e-10,
            1.05716645e-06]

    assert_allclose(rad, x, 1e-7)
    assert_allclose(flux, y, 1e-7)