astropy / photutils

Astropy package for source detection and photometry. Maintainer: @larrybradley
https://photutils.readthedocs.io
BSD 3-Clause "New" or "Revised" License
240 stars 134 forks source link

Photutils - SExtractor aperture_photometry FLUX_APER differences #1411

Closed xiaoguaishoubaobao closed 1 year ago

xiaoguaishoubaobao commented 2 years ago

i note this [issues](https://github.com/astropy/photutils/issues/407)

larrybradley commented 2 years ago

SourceExtractor performs aperture photometry by subsampling pixels by a factor of 5. The photutils aperture-photometry default uses the exact aperture overlap. As noted in the docs (https://photutils.readthedocs.io/en/latest/aperture.html#aperture-and-pixel-overlap), you can set method='subpixel', subpixels=5 to use SourceExtractor's approximation. Also note that there is a SourceExtractor configuration parameter called MASK_TYPE for dealing with neighboring sources that can affect its results.

xiaoguaishoubaobao commented 2 years ago

Thank you very much for your reply I've used both of the 2 points you mentioned, but it doesn't work, it's still different I didn't describe the problem very clearly, I'll re-describe it

this is in Photutils ` aperture = CircularAperture(positions, r=3.) phot_table = aperture_photometry(gt_mask_value[:, :], aperture,method='subpixel', subpixels=5) id xcenter ycenter aperture_sum_0

` image

this is in SourceExtractor

` "#-------------------------------- Catalog ------------------------------------\n" "\n" "CATALOG_NAME test.cat # name of the output catalog\n" "CATALOG_TYPE ASCII_HEAD # NONE,ASCII,ASCII_HEAD, ASCII_SKYCAT,\n" " # ASCII_VOTABLE, FITS_1.0 or FITS_LDAC\n" "PARAMETERS_NAME default.param # name of the file containing catalog contents\n" " \n" "#------------------------------- Extraction ----------------------------------\n" " \n" "DETECT_TYPE CCD # CCD (linear) or PHOTO (with gamma correction)\n" "DETECT_MINAREA 10 # min. # of pixels above threshold\n" "DETECT_THRESH 0.5 # or , in mag.arcsec-2\ 1.2接近界面软件的预测结果n" "ANALYSIS_THRESH 0.5 # or , in mag.arcsec-2\n" " \n" "FILTER Y # apply filter for detection (Y or N)?\n" "FILTER_NAME default.conv # name of the file containing the filter\n" " \n" "DEBLEND_NTHRESH 64 # Number of deblending sub-thresholds\n" "DEBLEND_MINCONT 0.0003 # Minimum contrast parameter for deblending\n" " \n" "CLEAN Y # Clean spurious detections? (Y or N)?\n" "CLEAN_PARAM 1.0 # Cleaning efficiency\n" " \n" "MASK_TYPE BLANK # type of detection MASKing: can be one of\n" " # NONE, BLANK or CORRECT\n" "\n" "#------------------------------ Photometry -----------------------------------\n" " \n"

"PHOT_APERTURES 6 # MAG_APER aperture diameter(s) in pixels\n"

    "PHOT_APERTURES   3              # MAG_APER aperture diameter(s) in pixels\n"
    "PHOT_AUTOPARAMS  2.5,4.0       # MAG_AUTO parameters: <Kron_fact>,<min_radius>\n"
    "PHOT_PETROPARAMS 2.0,4.0       # MAG_PETRO parameters: <Petrosian_fact>,\n"
    "                                # <min_radius>\n"
    "\n"
    "SATUR_LEVEL      50000.0        # level (in ADUs) at which arises saturation\n"
    "SATUR_KEY        SATURATE       # keyword for saturation level (in ADUs)\n"
    " \n"
    "MAG_ZEROPOINT    0.0            # magnitude zero-point\n"
    "MAG_GAMMA        4.0            # gamma of emulsion (for photographic scans) \n"
    "GAIN             0.0            # detector gain in e-/ADU\n"
    "GAIN_KEY         GAIN           # keyword for detector gain in e-/ADU\n"
    "PIXEL_SCALE      0            # size of pixel in arcsec (0=use FITS WCS info)这个很坑 直接用默认0就行\n"
    " \n"
    "#------------------------- Star/Galaxy Separation ----------------------------\n"
    " \n"
    "SEEING_FWHM      0.8            # stellar FWHM in arcsec\n"
    "STARNNW_NAME     default.nnw    # Neural-Network_Weight table filename\n"
    " \n"
    "#------------------------------ Background -----------------------------------\n"
    " \n"
    "BACK_SIZE        64             # Background mesh: <size> or <width>,<height>\n"
    "BACK_FILTERSIZE  3              # Background filter: <size> or <width>,<height>\n"
    " \n"
    "BACKPHOTO_TYPE   LOCAL         # can be GLOBAL or LOCAL\n"
    " \n"
    "#------------------------------ Check Image ----------------------------------\n"
    " \n"
    "CHECKIMAGE_TYPE  SEGMENTATION   # can be NONE, BACKGROUND, BACKGROUND_RMS,\n"
    "                                # MINIBACKGROUND, MINIBACK_RMS, -BACKGROUND,\n"
    "                                # FILTERED, OBJECTS, -OBJECTS, SEGMENTATION,\n"
    "                                # or APERTURES\n"
    "CHECKIMAGE_NAME  sextractor_check.fits     # Filename for the check-image\n"
    " \n"
    "#--------------------- Memory (change with caution!) -------------------------\n"
    " \n"
    "MEMORY_OBJSTACK  3000           # number of objects in stack\n"
    "MEMORY_PIXSTACK  300000         # number of pixels in stack\n"
    "MEMORY_BUFSIZE   1024           # number of lines in buffer\n"
    " \n"
    "#----------------------------- Miscellaneous ---------------------------------\n"
    " \n"
    "VERBOSE_TYPE     QUIET          # can be QUIET, NORMAL or FULL\n"
    "HEADER_SUFFIX    .head          # Filename extension for additional headers\n"
    "WRITE_XML        N              # Write XML file (Y/N)?\n"
    "XML_NAME         sex.xml        # Filename for XML output\n"
    "\n"
    "#----------------------------- ASSOC parameters ---------------------------------\n"
    "\n"
    "ASSOC_NAME       sky.list       # name of the ASCII file to ASSOCiate, the expected pixel \n"
    "                                # coordinates list given as [id, xpos, ypos]\n"
    "ASSOC_DATA       0             # columns of the data to replicate (0=all), replicate id\n"
    "                                # of the object in the SExtractor output file\n"
    "ASSOC_PARAMS     2,3            # columns of xpos,ypos[,mag] in the expected pixel\n"
    "                                # coordinates list\n"
    "ASSOC_RADIUS     2.0            # cross-matching radius (pixels)\n"
    "ASSOC_TYPE       NEAREST        # ASSOCiation method: FIRST, NEAREST, MEAN,\n"
    "                                # MAG_MEAN, SUM, MAG_SUM, MIN or MAX\n"
    "ASSOCSELEC_TYPE  ALL        # ASSOC selection type: ALL, MATCHED or -MATCHED\n"

` image

and the input data is phosim mask.fits data with nobackground

mask.fits have 145 objects ,I used index 7 object

image image

I extract except the object whose index is 8

链接:https://pan.baidu.com/s/1XliU3tg2rvtoXns5uBYm_A 提取码:qwsy

please help me thanks a lot for your reply

xiaoguaishoubaobao commented 2 years ago

The results I used are basically the same as those of APT. Explain that the photometric result of photoutils is correct Sex should be a setting problem but I don't know what is the problem ,hahahah

larrybradley commented 2 years ago

You are subtracting a local background in SourceExtractor, but you are not doing that in photutils. To do a direct comparison, you would need to turn off background subtraction in SourceExtractor:

BACK_TYPE MANUAL
BACK_VALUE 0.0

You can easily test the correctness of photutils aperture photometry by performing photometry on an array of all ones. You will get back the area of the aperture.

xiaoguaishoubaobao commented 2 years ago

Sorry I still get the same result when I use the parameters you said There is no background in the mask file. Why do you need to remove the background in sex? Below is my config file `

-------------------------------- Catalog ------------------------------------

CATALOG_NAME test.cat # name of the output catalog CATALOG_TYPE ASCII_HEAD # NONE,ASCII,ASCII_HEAD, ASCII_SKYCAT,

ASCII_VOTABLE, FITS_1.0 or FITS_LDAC

PARAMETERS_NAME default.param # name of the file containing catalog contents

------------------------------- Extraction ----------------------------------

DETECT_TYPE CCD # CCD (linear) or PHOTO (with gamma correction) DETECT_MINAREA 10 # min. # of pixels above threshold DETECT_THRESH 0.6 # or , in mag.arcsec-2\ 1.2接近界面软件的预测结果nANALYSIS_THRESH 0.6 # or , in mag.arcsec-2

FILTER Y # apply filter for detection (Y or N)? FILTER_NAME default.conv # name of the file containing the filter

DEBLEND_NTHRESH 64 # Number of deblending sub-thresholds DEBLEND_MINCONT 0.0003 # Minimum contrast parameter for deblending

CLEAN Y # Clean spurious detections? (Y or N)? CLEAN_PARAM 1.0 # Cleaning efficiency

MASK_TYPE BLANK # type of detection MASKing: can be one of

NONE, BLANK or CORRECT

------------------------------ Photometry -----------------------------------

PHOT_APERTURES 3 # MAG_APER aperture diameter(s) in pixels PHOT_AUTOPARAMS 2.5,4.0 # MAG_AUTO parameters: , PHOT_PETROPARAMS 2.0,4.0 # MAG_PETRO parameters: ,

SATUR_LEVEL 50000.0 # level (in ADUs) at which arises saturation SATUR_KEY SATURATE # keyword for saturation level (in ADUs)

MAG_ZEROPOINT 0.0 # magnitude zero-point MAG_GAMMA 4.0 # gamma of emulsion (for photographic scans) GAIN 0.0 # detector gain in e-/ADU GAIN_KEY GAIN # keyword for detector gain in e-/ADU PIXEL_SCALE 0 # size of pixel in arcsec (0=use FITS WCS info)这个很坑 直接用默认0就行

------------------------- Star/Galaxy Separation ----------------------------

SEEING_FWHM 0.8 # stellar FWHM in arcsec STARNNW_NAME default.nnw # Neural-Network_Weight table filename

------------------------------ Background -----------------------------------

BACK_TYPE MANUAL # can be GLOBAL or LOCAL BACK_VALUE 0.0 # can be GLOBAL or LOCAL BACK_SIZE 64 # Background mesh: or , BACK_FILTERSIZE 3 # Background filter: or , BACKPHOTO_TYPE LOCAL # can be GLOBAL or LOCAL

------------------------------ Check Image ----------------------------------

CHECKIMAGE_TYPE SEGMENTATION # can be NONE, BACKGROUND, BACKGROUND_RMS,

MINIBACKGROUND, MINIBACK_RMS, -BACKGROUND,

                            # FILTERED, OBJECTS, -OBJECTS, SEGMENTATION,
                            # or APERTURES

CHECKIMAGE_NAME sextractor_check.fits # Filename for the check-image

--------------------- Memory (change with caution!) -------------------------

MEMORY_OBJSTACK 3000 # number of objects in stack MEMORY_PIXSTACK 300000 # number of pixels in stack MEMORY_BUFSIZE 1024 # number of lines in buffer

----------------------------- Miscellaneous ---------------------------------

VERBOSE_TYPE QUIET # can be QUIET, NORMAL or FULL HEADER_SUFFIX .head # Filename extension for additional headers WRITE_XML N # Write XML file (Y/N)? XML_NAME sex.xml # Filename for XML output

----------------------------- ASSOC parameters ---------------------------------

ASSOC_NAME set_0.list # name of the ASCII file to ASSOCiate, the expected pixel

coordinates list given as [id, xpos, ypos]

ASSOC_DATA 0 # columns of the data to replicate (0=all), replicate id

of the object in the SExtractor output file

ASSOC_PARAMS 2,3 # columns of xpos,ypos[,mag] in the expected pixel

coordinates list

ASSOC_RADIUS 2.0 # cross-matching radius (pixels) ASSOC_TYPE NEAREST # ASSOCiation method: FIRST, NEAREST, MEAN,

MAG_MEAN, SUM, MAG_SUM, MIN or MAX

ASSOCSELEC_TYPE ALL # ASSOC selection type: ALL, MATCHED or -MATCHED

` image

xiaoguaishoubaobao commented 1 year ago

Looking forward to your reply

xiaoguaishoubaobao commented 1 year ago

I found some new problems When I set the aperture directly to a larger size, like 12 18 The flux obtained in the three software is the same, which means that it has nothing to do with the background But when the aperture is relatively small, the flux obtained by sextractor is obviously smaller than that of the other two softwares I suspected that the center point was different, but after I set the same center point, the result is still the same I now suspect that the aperture of the sextractor is smaller than the other 2 software after setting the same value. For example, 3,5,7 will actually become 2,4,6. can you help me

xiaoguaishoubaobao commented 1 year ago

The problem is solved. Sex uses the diameter, and the other two software uses the radius. It is the same when they are unified.