Clustering¶
In [1]:
Copied!
import astropy
import starfinder
import numpy as np
import matplotlib.pyplot as plt
import matplotlib
print(starfinder.__version__)
import astropy
import starfinder
import numpy as np
import matplotlib.pyplot as plt
import matplotlib
print(starfinder.__version__)
0.1.dev13+g78f20f7.d20250204
In [2]:
Copied!
%matplotlib ipympl
%matplotlib ipympl
We begin by reading in the file, thresholding, setting the usable region, and estimating the background
In [3]:
Copied!
image_file = "data/ngc744-0001_60s_v.fit"
sf = starfinder.StarField(image_file)
sf.n_ij = sf.threshold_hot_pixels(sf.n_ij, 0.999)
sf.set_usable_region()
sf.estimate_background()
image_file = "data/ngc744-0001_60s_v.fit"
sf = starfinder.StarField(image_file)
sf.n_ij = sf.threshold_hot_pixels(sf.n_ij, 0.999)
sf.set_usable_region()
sf.estimate_background()
INFO:starfinder:Reading file data/ngc744-0001_60s_v.fit INFO:starfinder:Background file data/ngc744-0001_60s_v.fit_151_0_bkg.fit exists: using this
Now, we find clusters and process them
In [4]:
Copied!
sf.find_clusters()
sf.process_cluster_list()
sf.find_clusters()
sf.process_cluster_list()
INFO:starfinder:Image ngc744-0001_60s_v.fit has 16033 clusters
Stars for image data/ngc744-0001_60s_v.fit Number numPix Flux mu_x mu_y sigma_x sigma_y rho_xy 0 1406 281687.0 1001.65 452.05 4.394 4.183 0.004 1 925 241086.9 1043.11 669.80 4.501 4.423 0.019 2 815 192031.0 878.62 567.88 4.334 4.215 0.030 3 841 184070.7 110.94 359.09 4.259 4.189 -0.007 4 742 181149.6 193.75 818.75 4.255 4.229 0.012 5 711 165470.0 953.17 734.49 4.234 4.105 0.041 6 692 146322.0 105.43 782.99 4.099 4.073 0.014 7 608 116496.9 683.31 561.58 4.003 3.924 0.027 8 628 100311.2 838.76 215.14 3.941 3.901 0.019 9 543 94525.8 814.82 546.93 3.920 3.833 0.029 10 560 92923.7 379.31 894.68 3.839 3.824 0.025 11 620 92021.9 218.98 263.28 3.933 3.895 0.012 12 564 81392.1 966.29 290.77 3.910 3.824 0.030 13 633 76342.3 929.31 481.35 4.062 3.985 -0.066 14 562 65305.2 222.01 102.90 3.948 3.931 0.029 15 421 61131.4 733.07 831.79 3.811 3.733 0.048 16 462 56190.6 1005.48 635.80 3.890 3.799 0.086 17 477 50010.0 1085.35 323.10 4.060 3.819 0.012 18 404 42392.4 1357.28 257.64 3.960 3.904 0.005 19 388 42362.6 517.50 710.23 3.830 3.781 0.037 20 382 40535.0 650.88 539.66 3.874 3.787 0.027 21 356 37982.0 976.11 516.82 3.856 3.755 0.071 22 379 36308.1 726.65 427.32 3.915 3.823 0.021 23 407 36151.4 1348.27 593.44 3.947 3.994 -0.075 24 393 34791.7 54.30 468.41 3.925 3.888 0.018 25 314 31073.0 1225.26 902.24 3.749 3.781 0.036 26 348 30508.1 1329.86 110.68 3.897 3.795 0.030 27 333 30222.0 250.06 767.81 3.819 3.776 0.015 28 308 28360.3 1375.59 560.80 3.813 3.717 0.068 29 311 26521.6 1179.53 574.94 3.843 3.693 0.022 30 288 26158.8 477.69 917.02 3.729 3.744 0.016 31 281 26007.6 942.02 964.88 3.747 3.742 0.088 32 288 20818.2 477.68 404.48 3.867 3.770 0.005 33 258 20085.2 1333.55 613.64 3.817 3.655 0.076 34 260 18974.4 239.32 415.14 3.829 3.811 0.000 35 281 18306.8 781.61 340.67 3.973 3.806 -0.031 36 235 18235.8 914.08 894.57 3.751 3.656 0.051 37 248 17029.7 469.99 255.01 3.903 3.744 0.008 38 233 16963.4 984.24 673.64 3.808 3.645 0.083 39 252 16784.3 445.53 626.29 3.803 3.827 0.001 40 226 15022.5 812.82 477.76 3.857 3.712 0.051 41 219 14790.1 970.86 569.43 3.742 3.663 0.023 42 215 12938.1 1037.77 520.02 3.867 3.708 0.030 43 208 12682.5 1395.70 240.03 3.842 3.825 0.041 44 202 12202.7 652.82 457.77 3.886 3.767 0.029 45 196 12121.1 1136.78 529.78 3.821 3.711 0.039 46 187 11942.8 780.46 621.54 3.851 3.736 0.048 47 199 11902.9 1286.60 178.35 3.874 3.750 0.071 48 182 11613.2 1372.40 336.77 3.788 3.642 0.084 49 180 10606.6 508.43 687.60 3.889 3.749 0.058 50 168 10505.1 1464.45 710.48 3.688 3.662 0.057 51 186 10492.3 622.91 587.32 3.877 3.807 0.057 52 188 9985.9 520.79 112.32 3.984 3.866 -0.055 53 181 9707.4 657.88 690.61 3.846 3.846 0.002 54 151 9098.3 222.66 611.81 3.645 3.804 0.025 55 153 8375.7 1356.61 120.60 3.818 3.795 0.043 56 150 8130.1 93.69 675.78 3.718 3.764 -0.007 57 147 7735.0 1439.85 593.81 3.897 3.681 0.055 58 142 7690.0 907.09 915.46 3.724 3.755 0.050 59 145 7642.4 449.85 606.24 3.933 3.882 -0.024 60 149 7504.7 214.69 188.03 3.893 3.801 -0.036 61 145 7154.7 757.12 421.08 3.922 3.869 0.061 62 135 6764.8 1262.90 215.29 3.893 3.830 0.025 63 137 6640.6 594.00 288.66 3.788 3.680 -0.016 64 123 6304.2 859.10 535.48 3.732 3.631 0.038 65 127 6278.6 1166.74 849.54 3.766 3.609 0.051 66 116 5688.3 244.68 665.20 3.751 3.677 -0.067 67 116 5470.9 144.64 494.88 3.775 3.860 0.018 68 113 5364.2 1274.24 687.07 3.722 3.692 0.015 69 110 5227.7 316.26 920.52 3.874 3.549 -0.016 70 110 5067.4 190.79 233.77 3.813 3.785 -0.016 71 108 4935.8 917.59 221.22 3.647 3.788 -0.001 72 89 3892.5 112.39 206.46 3.683 3.752 0.026 73 88 3626.1 810.70 432.38 3.901 3.891 0.032 74 84 3617.4 737.56 609.75 3.727 3.652 -0.098 75 79 3289.1 947.26 196.08 4.071 3.710 0.008 76 57 2393.8 603.09 775.24 3.662 3.570 0.029 77 55 2334.5 774.79 854.59 3.857 3.519 0.065 78 58 2217.7 826.03 181.34 3.861 3.958 0.064 79 56 2188.5 972.57 714.36 3.940 3.986 0.025 80 50 2029.6 841.08 821.95 3.692 3.748 -0.000 81 48 1876.4 375.44 685.15 3.788 3.653 -0.093 82 45 1865.4 878.05 752.17 3.739 3.678 0.046 83 48 1807.8 94.98 235.22 3.902 3.800 -0.035 84 44 1799.7 647.21 819.07 3.774 3.768 0.041 85 48 1795.7 976.34 437.13 4.052 3.842 0.072 86 43 1728.8 525.08 215.52 3.853 3.757 -0.054 87 45 1710.3 529.85 550.32 3.750 3.827 -0.083 88 41 1572.6 416.57 312.17 3.738 3.822 0.023 89 37 1334.7 688.95 596.24 3.877 3.575 0.033 90 29 1040.1 686.27 752.65 3.766 3.659 -0.054 91 29 994.6 697.34 329.05 4.101 3.993 0.094 92 26 951.8 1163.23 650.58 3.682 3.552 0.044 93 22 877.4 1375.99 809.50 4.001 3.513 -0.096 94 21 814.6 750.70 505.11 3.772 3.952 -0.030 95 21 744.3 611.85 816.70 3.868 3.753 0.041 96 15 533.2 1063.27 756.38 3.807 3.828 0.088 97 12 436.8 557.02 918.22 3.697 3.896 0.028 98 12 378.5 1018.01 189.82 4.119 3.994 -0.082 99 9 290.8 610.17 813.02 3.787 4.006 -0.002 100 7 272.0 1020.44 568.19 3.571 3.578 0.012 101 7 259.2 696.30 324.48 4.080 3.870 0.014 102 8 258.6 1150.05 965.01 3.720 3.647 0.070 103 7 252.3 549.97 697.01 4.069 3.532 0.075 104 7 249.0 779.33 667.24 3.821 4.102 0.010 105 7 247.1 781.20 516.49 3.935 3.639 -0.071 106 6 230.7 1246.09 765.33 3.537 3.893 0.018 107 7 230.2 239.79 405.06 4.035 4.816 0.043 108 7 216.0 529.24 325.28 4.223 4.037 0.095 109 6 206.7 1014.68 188.03 3.882 3.894 0.070 110 6 202.9 548.37 694.51 3.906 4.142 0.066 111 6 198.8 1246.29 768.01 3.502 3.876 0.006 112 6 192.2 396.98 824.46 4.086 3.933 0.094
Finally, we can add marks to our plot to show all of the stars found:
In [5]:
Copied!
residual = sf.n_ij - sf.b_ij
fig, ax = plt.subplots()
vmax = np.quantile(residual, 0.99)
cbar = ax.imshow(residual, origin="upper", vmax=vmax)
ax.set(xlabel="Pixels", ylabel="Pixels")
ax.scatter(sf.mux_list, sf.muy_list, s=3, color='r')
plt.colorbar(cbar, shrink=0.7, label="Counts")
plt.show()
residual = sf.n_ij - sf.b_ij
fig, ax = plt.subplots()
vmax = np.quantile(residual, 0.99)
cbar = ax.imshow(residual, origin="upper", vmax=vmax)
ax.set(xlabel="Pixels", ylabel="Pixels")
ax.scatter(sf.mux_list, sf.muy_list, s=3, color='r')
plt.colorbar(cbar, shrink=0.7, label="Counts")
plt.show()