# ymin = 460 # ymax = 500 # xmin = 1490 # xmax = 1540 ymin = 1306 ymax = 1356 xmin = 1636 xmax = 1706 large_aperture = bias_subtracted_im1[ymin:ymax, xmin:xmax] # convert object to electron units from count large_aperture = large_aperture * gain # Background subtract the object large_aperture, mask, background_dev = background_subtract(large_aperture) # calculate the deviation on each pixel # defined as the sqrt of the sum of squares of pixel and background deviation # pixel deviation is defined as sqrt of pixel value in electrons # background deviation should include any read noise and bias noise # show an image of the aperture from astropy.visualization import SqrtStretch from astropy.visualization.mpl_normalize import ImageNormalize norm = ImageNormalize(stretch=SqrtStretch()) # plt.figure() f1, axisarg = plt.subplots(2, 1)
current_aperture = current_aperture*gain aperture_list.append(current_aperture) """calculate the centroid for each aperture""" n = 0 # counting variable # generate each curve fit from scipy.optimize import curve_fit for aperture in aperture_list: print('---------------------') print('Region ' + str(n+1) + ': ' + selected_regions[n].region_def) n += 1 # background subtract the aperture aperture, mask, background_dev = background_subtract(aperture) # generate the associated pixel error aperture_err = np.sqrt(aperture + background_dev**2) # plot the aperture and mask used to background subtract norm = ImageNormalize(stretch=SqrtStretch()) f1, axisarg = plt.subplots(3, 2, figsize=(10, 10)) aperture_im = axisarg[0][0].imshow(aperture, norm=norm, origin='lower', cmap='viridis') f1.colorbar(aperture_im, ax=axisarg[0][0]) axisarg[0][0].set_title('Object, with colorscale intensity') mask_im = axisarg[1][0].imshow(mask, origin='lower', cmap='viridis') axisarg[1][0].set_title('Mask used in background calculations') aperture_hist = axisarg[1][1].hist(aperture.flatten(),bins=500, range=[-100, 5000]) axisarg[1][1].set_title('Object histogram after background subtraction')
# this object has a low eccentricity # ymin = 1306 # ymax = 1356 # xmin = 1636 # xmax = 1706 # trying with a different object ymin = 1777 ymax = 1822 xmin = 252 xmax = 302 real_boy = bias_subtracted_im1[ymin:ymax, xmin:xmax] # Background subtract the object real_boy, mask, background_dev = background_subtract(real_boy) # make a fit ####### # generate a best guess y_guess = real_boy.shape[0] / 2 x_guess = real_boy.shape[1] / 2 flux1_guess = np.sum(real_boy) flux2_guess = flux1_guess / 10 beta1_guess = 7 beta2_guess = 2 alpha1_guess = 2 alpha2_guess = 2 offset_guess = 0 guess = [ flux1_guess, flux2_guess, alpha1_guess, alpha2_guess, beta1_guess,
# Centroid detection: # arbitrarily chosen object, section manually entered # ymin = 1545 # ymax = 1595 # xmin = 1745 # xmax = 1795 ymin = 455 ymax = 505 xmin = 1490 xmax = 1540 object1_data = bias_subtracted_im1[ymin:ymax, xmin:xmax] # Background subtract the object object1_data, mask, background_dev = background_subtract(object1_data) # centroid techniques: need to learn the difference3s # print('Centroids:') # x1, y1 = centroid_com(object1_data) # print((x1, y1)) # x2, y2 = centroid_1dg(object1_data) # print((x2, y2)) # x3, y3 = centroid_2dg(object1_data) # print((x3, y3)) # show an image of the aperture from astropy.visualization import SqrtStretch from astropy.visualization.mpl_normalize import ImageNormalize