My differential ensemble PSF photometry program

American Association of Variable Star Observers (AAVSO)
Fri, 04/09/2021 - 08:34

Hi All,

I would like to share a small program I wrote, currently called MetroPSF for the lack of better name, for differential ensemble PSF-fitting photometry. Initially wrote a small script to double-check the results I was getting through Astrometrica for the SN 2021gmj, however, thought it may be useful for public, so releasing the source code. It's a prototype, so the code quality is pretty low, but the results it produces should be ready for analysis. I would appreciate any feedback and suggestions. I thought I'd check if this is of interest to public at all by making a preliminary "alpha" release.

The READ ME file with a brief description and installation instructions:

The program files are here:

MetroPSF works with VizieR and for retrieving catalogs and solving, and the READ ME file describes a quick use case to familiarize with the interface. The screen shot of the program in action is here:


American Association of Variable Star Observers (AAVSO)


This is very cool. It was easy to install and run from an Anaconda3 cmd prompt.

I look forward to exploring this!


American Association of Variable Star Observers (AAVSO)
Thanks, George. Note I've…

Thanks, George. Note I've updated it to version 0.13:

    • Added ensemble limit option.
    • Added Gaia DR2 to comparison catalogs.
    • Added non-linear image stretching via square root, log and asinh.
    • Added ability to remove AAVSO VSX stars from the ensemble.
    • Sources with AAVSO VSX match are plotted with yellow circles.
    • Added reporting of nearby VSX sources.
    • Added matching radius setting.
    • Fixed loading of 16-bit FITS files.

Latest User Manual:

MetroPSF 0.13, released April 11, 2021:


American Association of Variable Star Observers (AAVSO)
Happy to announce the latest…

Happy to announce the latest version of MetroPSF, 0.15. Lots of new stuff:

• Aperture photometry.

This is similar to common aperture photometry algorithms found in other software except that a 2D model of the background is subtracted from the image, so sky annuli are not used.

• AAVSO report generation.

MetroPSF can now generate AAVSO-compatible report files.

• Automatic reporting on all VSX sources in the image.

MetroPSF can generate reports on all VSX sources found in the image. It cycles through each VSX variable and builds a report file. Although I would not recommend to do automatic reports and submit them blindly (unless you know what exactly you are doing) this is helpful when you need to process multiple FITS files to create a report on a single object or multiple objects with, say, similar magnitudes.

• Batch processing of all FITS files in a folder.

Now it is possible to do photometric series, as MetroPSF can process multiple FITS files in a folder at once...

• Light curve generation from BAA reports.

...and display a light curve from all the report files generated.

• Added ability to remove outliers from the fit - by ensemble limit and maximum separation.

Much more precise photometry, as you can set it up to automatically exclude comparison stars farther than R arcseconds from the target, or that are not fitting well into the comparison ensemble, e.g. limit ensemble to N stars.

Convenience changes:
• Reporting number of ensemble stars on the linear regression fit plot.

• Object name in the left panel is now automatically set from VSX catalog for matching sources.

• Display next VSX source.

Can easily cycle through all known variables in your image.

• Mouse click now reports time in ISO UTC format along with photometry result.

To copy-paste in forums and discussions.

Other changes:
• Increased Astrometry.Net default solve timeout from 120 to 360 s.
• Linear regression fit error is now based on standard deviation.
• MetroPSF now writes a log to metropsf.log.
• URL and API key setting in the interface.
• PSF fitting algorithm setting.
• FITS crop option.

Latest manual:

MetroPSF program and manual:


American Association of Variable Star Observers (AAVSO)
nice work

Thanks for this work. I have been interested in trying out some psf calculations and this seems to be what I was looking for. I like easy access to the APASS 9 data. I'm also interested in using Sloan filters and I found I could get to the Sloan data in APASS 9 by changing the ' to a _, so the g' data could be found using g_ for the filter name. I'm still getting my observing equipment together so I'm not completely sure how my work flow is going to end up, but one thing that might be useful is allowing for comps and VSX stars to be read in from a VPhot sequence file. It is obviously more work to create a sequence file, but you have more control, you can use APASS 10 data, and you can do comparisons to VPhot calculations with exactly the same comp stars. I might even give that bit a programming a try myself.

Thanks again,


American Association of Variable Star Observers (AAVSO)
Using natural log for inst mag derivation?


I am happy you wrote this program. 

I noticed the following:

From line 443 in metropsf.pyw; version 0.15:

                # Calculate instrumental magnitudes
                self.results_tab_df["inst_mag"] = -2.5 * np.log(self.results_tab_df["flux_fit"] / exptime) + 25
                self.results_tab_df["inst_mag_min"] = -2.5 * np.log((self.results_tab_df["flux_fit"] - self.results_tab_df["flux_unc"]) / exptime) + 25
                self.results_tab_df["inst_mag_max"] = -2.5 * np.log((self.results_tab_df["flux_fit"] + self.results_tab_df["flux_unc"]) / exptime) + 25
                self.photometry_results_plotted = True

Example data::

0       3148.928680
1       4463.721887
2       9748.519141
3       3851.394268
4      37552.279625
91      5139.908163
92     14996.714167
93    171136.789864
94      3185.920025
95      6251.668110
Name: flux_fit, Length: 96, dtype: float64

np.log(self.results_tab_df["flux_fit"] / exptime)
0     3.960473<----------------------------------------------------------should be 1.720
1     4.309394
2     5.090526
3     4.161846
4     6.439145
91    4.450446
92    5.521242
93    7.955874
94    3.972152
95    4.646259
Name: flux_fit, Length: 96, dtype: float64



np.log is not base 10, its the natural log (ln); it should be np.log10;  Correct?


Pierre "Pete" Fleurant



Vereniging Voor Sterrenkunde, Werkgroep Veranderlijke Sterren (Belgium) (VVS)
Trying to get metropsf installed on Win 10

Hi Max,

I am trying to install your metropsf programm on my Win0 machine. I have downloaded Python, extracted the MetroPSF distribution and tried to run pip install...

However neither in Python nor in the WIn 10 Command line programm it will run this pip command. 

Any help is appreciated.



American Association of Variable Star Observers (AAVSO)
MetroPSF ------> MAOPhot 0.1

Welcome to MAOPhot 0.1, a PSF Photometry tool using Astropy and Photutils.psf


This program was derived from MetroPSF by Maxym Usatov. 


It has been redesigned for AAVSO reporting only and includes, but not limited

to the following enhancements:

- Generation of Two-Color Photometry (B, V), (V, R) or (V, I), and Single Image

Photometry reports in AAVSO extended format

- Use of telescope Transformation Coefficients (needed for Two Color Photometry)

- Image display shows comp star AAVSO label number and name of any found VSX

objects in image field

- Generation of Effective PSF model, and ability to create a ‘rejection list.’

- option to use an Integrated Gaussian PRF (Pixel Response Function) as model

- PSF Photometry using an iterative algorithm to perform point spread function

 photometry in crowded fields

- Photometry using an ensemble of comparison stars or a single comp star

- Intermediate results are saved as .csv files

- User can optionally enter a AAVSO Chart ID when retrieving comparison star data

- User can specify check star and list of comp stars to use


MAOPhot calculates stellar magnitudes from 2 dimensional digital photographs.

It produces an extended AAVSO (American Association of Variable Star Observers)

report which can be submitted to the AAVSO using the online tool WebObs (

There are many photometry measuring programs available such as VPhot

( and AstroImageJ (University of Louisville).

VPhot uses the aperture photometry method.

MAOPhot uses the PSF Photometry method exclusively. PSF (point spread function)

modeling is well suited for measuring stellar magnitudes in crowded fields, or

the magnitude of a star that has a close companion, e.g., Z Tau.



MAOPhot is written in Python. It uses many Python 'astropy'

( libraries. The astropy package contains key

functionality and common tools for performing astronomy and astrophysics with

Python. Included in the package is Photutils.psf. See "PSF Photometry"

( which describes many of

the classes and methods used in MAOPhot.




Pierre Fleurant