I've written a module to construct "photometric superflats" and would like to make it available to fellow PixInsight enthusiasts. The module is currently "beta" quality (being generous) but I think it's far enough along to be useful.
Photometric superflats are flat field correction frames constructed using the known fluxes of photometrically calibrated stars in the field. In general, photometric superflats are useful as "delta flats" after an initial correction using twilight or dome flats, and you would only use them if you wish to do really precise flat fielding of your data. The photometric superflats account for residual multiplicative flat-fielding errors, and after applying them residual errors will be additive in nature (and can be dealt with using other approaches, such as by subtracting off a model). You can read more about photometric superflats here:
http://www.adass.org/adass/proceedings/adass00/P1-03/If you'd like to test the module out, you can grab the source code here:
https://github.com/robertoabraham/PhotometricSuperflatThe module reads a table produced by the AperturePhotometry script, fits a polynomial surface (of degree up to 4) to the data and produces a photometric superflat frame as well as a couple of plots showing the relative flux errors in the calibration stars with and without the application of the flat. Here is a screenshot showing it in use:
https://dl.dropboxusercontent.com/u/110230258/SuperflatScreenshot.pngThe easiest way to test it out is with simulated data. To do this, generate a fake image using the CatalogStarGenerator script, then modify this image with some function using the PixelMath module. (It's obviously important that you modify the image using some sort of multiplicative process and not an additive process). Run the AperturePhotometry script on the simulated image to generate a catalog. Then fire up the PhotometricSuperflat process and click on the button to select the catalog (whose filename will end with "_WCS.csv"). Then drag the process icon onto the image you have just photometered to generate the Superflat and diagnostic plots.
Caveats: It works for me, and I'm using it as part of my research, but it may not work for you. I'll attempt to gradually improve this module, and would be happy to receive bug reports and requests for new features. That said, I'm relatively new to PixInsight and I'm not a professional programmer and this is my first attempt at doing anything non-trivial in C++ (although I have done a lot of C programming and a fair bit of Objective-C hacking). There are likely to be some ugly things in the code, and I'm sure there are also big gaps in my understanding of the optimal way to code modules for PixInsight. Again, suggestions for improvements are very welcome, and I'll do what I can to make the module better.
Known Deficiencies in the PhotometricSuperflat Module:
1. It's not OS-independent because it calls the built-in gnuplot executable to draw the diagnostic plots, and I haven't figured out how to find the location of the gnuplot executable programmatically. So unless you're running it on Mac OS X you'll need to modify line 173 in the PolynomialSurface.h file so it points to the gnuplot executable in the PixInsight distro. Right now it reads:
ExternalProcess().ExecuteProgram("/Applications/PixInsight.app/Contents/MacOS/gnuplot " + gnuFilepath);
2. There is no documentation (yet).
3. The ID of the created superflat window is simply "Superflat". I think this should probably be something more sensible, like the ID of the window I dragged the process icon onto with _Superflat appended.
4. I have not yet implemented any code to enable the command line interface.
5. I should probably include a check to allow the user to disable production of the diagnostic plots.
6. The AperturePhotometry table is reloaded each time the process icon is dragged onto the image. I did this on purpose but now I think it should be loaded only once at the beginning (as soon as the user navigates to the table file with the file selector).
7. I've got the important classes all defined in a single header file (PolynomialSurface.h). In future I'll organize the source a bit better into separate .h and .cpp files for the various classes.
I hope somebody finds this module useful,
Bob
P.S. In case you're curious, I developed this code to try to improve flat fielding as part of a project I've recently embarked upon to do some ultra-low surface brightness imaging. You can read about this project here:
http://adsabs.harvard.edu/abs/2014arXiv1401.5473Ahttp://adsabs.harvard.edu/abs/2014arXiv1401.5467V(Juan - if you are tracking papers which have made use of PixInsight, you can add these two to your list. The first just appeared in PASP, and the second is coming out as an ApJ letter).
P. P. S. Juan: I'm not an expert in open-source licenses, but when prompted by GitHub I picked the 2-clause BSD license because it seemed very unrestrictive and I figured it might make things easy for you if you'd like to someday distribute this module. If you would prefer an alternative license just let me know. Also, I based the non-numerical component of the module (parameter setting and serialization, GUI, etc) on the Sandbox module, and for the source files that are basically based on Sandbox I just substituted the new module name in the boilerplate license text at the start of the files, leaving the "Copyright (c) 2003-2013, Pleiades Astrophoto S.L. All Rights Reserved" stuff there. Is that the accepted procedure? If not, just let me know what you'd like it to say and I'll make the changes.