astromatic / sextractor

Extract catalogs of sources from astronomical images
http://astromatic.net/software/sextractor
GNU General Public License v3.0
153 stars 44 forks source link

How should I edit default.psf for psf photometry #35

Open xiaoguaishoubaobao opened 2 years ago

xiaoguaishoubaobao commented 2 years ago

How to edit default.psf When I use default.psf to PSF photometry On SDSS's PSF_FLUX, I found that the PSF photometry of Sextractor's metering will increase with the increase of the sdss PSF_FLUX. like this:

image

The defalut.psf is: image

Thanks very much!

xiaoguaishoubaobao commented 2 years ago

Can anyone answer my question?

xiaoguaishoubaobao commented 2 years ago

Can anyone answer my question?

hbouy commented 2 years ago

It's hard to tell without seeing the data but I suggest that you play with the different parameters of PSFex and adapt them to your data. Refer to the manual for more information.

kirxkirx commented 1 year ago

I would expect the flux measurement results to match exactly between the two measurement methods (SDSS data processing and SExtractor+PSFEx) only if the measurements are done on the same images with the same software having exactly the same settings, or if the software is different but implements exactly the same algorithm with the same tunable parameters. This is clearly not the case here. The description of SDSS PSF magnitude looks totally different from how SExtractor+PSFEx works. The results match approximately (because apparently the brightness of the same stars is measured), but the match is not exact because the measurement techniques are not the same.

As far as I understand, default.psf is normally not supposed to be edited manually. This is the FITS file containing PSF model created by PSFEx from your data (that file can be used by SExtractor to do PSF-fitting photometry). The behavior of PSFEx is controlled by the settings in default.psfex text file (the same way default.sex controls SExtractor).

xiaoguaishoubaobao commented 1 year ago

Thank you for your reply. I'm sorry I still don't understand. How to edit default.psf When I use default.psf to PSF photometry? Those parameters should I edit? Can you give an example?

kirxkirx commented 1 year ago

Do not edit default.psf (the FITS file) - edit default.psfex (the text file).

A PSF-fititing photometry measurement with SExtractor+PSFEx may look like this:

# Do a preliminary SExtractor run on your image to extract cutouts of star images from which PSFEx will construct a PSF model
sex -PARAMETERS_NAME example.cat.psfex_param -CATALOG_TYPE FITS_LDAC -CATALOG_NAME image00001.cat.psfex_input_cat ../sample_data/myimage-001r.fit

# Run PSFEx to construct PSF model for that image (typically each ground-based image needs its own PSF model due to seeing changes and telescope tracking errors)
psfex image00001.cat.psfex_input_cat

# The main SExtractor run that will do PSF-fitting photometry. One still needs to set a reasonable aperture (6.8 pixels diameter in this example) as the aperture photometry is needed to set PSF-photometry zero-point
sex -PARAMETERS_NAME psfex_sextractor_2nd_pass_flag.param -PSF_NAME image00001.cat.psf -PHOT_APERTURES 6.8 -CATALOG_NAME image00001.cat ../sample_data/myimage-001r.fit

# In this example I override from the command line some of the options normally set in default.sex configuration file (PARAMETERS_NAME, CATALOG_TYPE, etc.)

The example SExtractor output parameters files used in the two steps are attached: example.psfex_param.txt psfex_sextractor_2nd_pass_flag.param.txt

The three steps above are repeated for each image one wants to measure. (If it's more than one image it make sense to do it from a script, of course.) For the processing to work well, one needs to set parameters in default.sex and default.psfex that are appropriate for the dataset at hand. Typically, once set these settings should remain the same for processing all images taken with a given telescope+camera combination. The questions that affect the choice of source detection and PSF extraction parameters:

An optimal choice of configuration parameters based on these and other considerations is a topic worthy of prolonged and heated debate. A detailed description of the parameters may be found in SExtractor and PSFEx manuals...

xiaoguaishoubaobao commented 1 year ago

Thank you very much for your reply After a few days of research, I have solved the problem in accordance with your method Thank you again for your reply I wish you a happy life

xiaoguaishoubaobao commented 1 year ago

Do not edit default.psf (the FITS file) - edit default.psfex (the text file).

A PSF-fititing photometry measurement with SExtractor+PSFEx may look like this:

# Do a preliminary SExtractor run on your image to extract cutouts of star images from which PSFEx will construct a PSF model
sex -PARAMETERS_NAME example.cat.psfex_param -CATALOG_TYPE FITS_LDAC -CATALOG_NAME image00001.cat.psfex_input_cat ../sample_data/myimage-001r.fit

# Run PSFEx to construct PSF model for that image (typically each ground-based image needs its own PSF model due to seeing changes and telescope tracking errors)
psfex image00001.cat.psfex_input_cat

# The main SExtractor run that will do PSF-fitting photometry. One still needs to set a reasonable aperture (6.8 pixels diameter in this example) as the aperture photometry is needed to set PSF-photometry zero-point
sex -PARAMETERS_NAME psfex_sextractor_2nd_pass_flag.param -PSF_NAME image00001.cat.psf -PHOT_APERTURES 6.8 -CATALOG_NAME image00001.cat ../sample_data/myimage-001r.fit

# In this example I override from the command line some of the options normally set in default.sex configuration file (PARAMETERS_NAME, CATALOG_TYPE, etc.)

The example SExtractor output parameters files used in the two steps are attached: example.psfex_param.txt psfex_sextractor_2nd_pass_flag.param.txt

The three steps above are repeated for each image one wants to measure. (If it's more than one image it make sense to do it from a script, of course.) For the processing to work well, one needs to set parameters in default.sex and default.psfex that are appropriate for the dataset at hand. Typically, once set these settings should remain the same for processing all images taken with a given telescope+camera combination. The questions that affect the choice of source detection and PSF extraction parameters:

  • How big are the stars compared to (hot) pixels?
  • How much does the PSF change across the image?
  • How many stars are typically detected on an image (and are available to track PSF changes across the image)?

An optimal choice of configuration parameters based on these and other considerations is a topic worthy of prolonged and heated debate. A detailed description of the parameters may be found in SExtractor and PSFEx manuals...

Hello, There is a mask.fits file without background and only one point Can I calculate the psf for a single point? The psfex prompt says `> ----- PSFEx 3.21.1 started on 2022-12-14 at 20:52:09 with 8 threads

----- 1 input catalogues: example.cat.psfex_pa: "no ident " 1 extension 1 detection

Initializing contexts... Computing optimum PSF sampling steps... Reading data from example.cat... Computing final PSF model for example.cat...

WARNING: 1st context group-degree lowered (not enough samples)

WARNING: 1st context group removed (not enough samples)

filename [ext] accepted/total samp. chi2/dof FWHM ellip. resi. asym.

Computing diagnostics for example.cat... example.cat 0/0 0.00 0.00 0.00 0.00 1.00 1.00 Saving CHECK-image #1... Saving CHECK-image #2... Saving CHECK-image #3... Saving CHECK-image #4... Saving CHECK-image #5... Saving CHECK-image #6... Saving CHECK-image #7... Saving CHECK-image #8... Saving PSF model and metadata for example.cat... Writing XML file...

All done (in 0.0 s)

WARNING: Image contains mainly constant data; I'll try to cope with that... `

The fits file: 链接:https://pan.baidu.com/s/17Mz3ukNp1AiDGC9PPl9cBQ 提取码:3fnw

Looking forward to your reply Thank you

kirxkirx commented 1 year ago

From the file name mask.fits and the description of its content I'm guessing this is not an image of the sky with stars/galaxies that one would like to measure using PSF photometry. Instead mask.fits is likely an auxiliary service file that is meant to be used together with another FITS file that would contain an actual image if the sky. One typical use of such auxiliary file may be to mark bad pixels on the sky image. In this case the mask image may have the same dimensions as the sky image but in each pixel have just one of the two values 0 - if this pixel is good and the value in the same pixel on the sky image should be trusted or 1 - if this pixel on the sky image is bad an should be disregarded/interpolated over/ whatever the software that is meant to take both the sky and mask images as an input is designed to do with bad pixels.

In summary - most likely you don't need to calculate PSF for mask.fits as this file does not contain a sky image.

xiaoguaishoubaobao commented 1 year ago

Thanks for your reply This is a mask.fits file with many layers, each layer contains the position of each star/galaxy and the outline information. The reason I use this mask.fits file to measure Psf is because it is an image without background, and I know that the flux from it is more accurate because there is no interference from the background. And then the warning mentioned above appears Can I calculate the PSF of a point separately when there is only one point in an image? If so how should I set it up?

I also have a question When I measure the psf img_r.fits flux with sextractor+psfex I found that with the same settings and the same input fits file (simulated by phosim with the same parameters), some images all predictions is normal and some images all predictions is comparatively largeas shown in the figure below image The horizontal axis is the correct value The vertical axis is the sextractor+psfex predicted value The same parameter settings are correct for the real database. What is the problem? image

I've got the fits file and the coordinate information and the configuration file all packed up.

url:https://pan.baidu.com/s/128YPhDgT8vJVZuvgHejXHg pwd:wpvr

Thanks again for your help!

Eririf commented 2 months ago

galsim.DES_PSFEx can do it