Author Topic: PSFEstimation script  (Read 63362 times)

Offline mschuster

  • PTeam Member
  • PixInsight Jedi
  • *****
  • Posts: 1087
Re: PSFEstimation script
« Reply #15 on: 2012 April 14 08:22:20 »
Thank you Hans. These things sound good and are doable I think.
Mike

Offline mschuster

  • PTeam Member
  • PixInsight Jedi
  • *****
  • Posts: 1087
Re: PSFEstimation script
« Reply #16 on: 2012 May 05 14:18:26 »
I posted an update for Hans. It runs faster, has more options and generates fewer windows. It is still limited to a single image however, I hope to work on a batch version soon.

Thanks,
Mike

PS: I added a visualization for azimuth (DynamicPSF's theta parameter), the position angle of the median PSF FWHM major axis. The optics used for this example have a bit of astigmatism that shows up as a small elongation with varying position angle along on the left side of the frame. A visualization for background is new also.
« Last Edit: 2012 May 05 18:35:08 by mschuster »

Hans Pleijsier

  • Guest
Re: PSFEstimation script
« Reply #17 on: 2012 May 08 13:32:30 »
Mike,

This special treatment is much appreciated.

... and testing ....

Hans

Offline vetenskapsman

  • Newcomer
  • Posts: 14
    • Cilice Astophotography
Re: PSFEstimation script
« Reply #18 on: 2012 May 25 21:24:08 »
Let me add my thanks and admiration of this extremely useful script.  I have wanted something like this to
characterize my camera lens behavior for a long time.  I'm afraid I may now spend more time testing and
doing experiments than gathering data for an image!

One question tho ... what is the meaning background in this context?

-carl

Offline mschuster

  • PTeam Member
  • PixInsight Jedi
  • *****
  • Posts: 1087
Re: PSFEstimation script
« Reply #19 on: 2012 May 25 22:25:23 »
Thank you Carl. Credit goes to the PI team for all their hard work on PI functionality.

Although Background is somewhat unrelated to PSF, I included it at Hans' request. It is the image's median value expressed in normalized real values from 0 to 1, scaled by the exponent given in the title text. When mosaic size is 1, background equals the Median value given by the Statistics process. The plot attempts to show how the median value varies across the image.

Background then is probably some sort of mix of sky flux, extended object structure flux, optical vignetting and reflections, ccd pattern noise, etc and their variations across the image. It may or may not be something that turns out to be useful.

If you can think of improvements, to background or anything else, please let me know. Hans' other suggestions, batching and some sort of image grading, are on my to do list.

Mike

Offline vetenskapsman

  • Newcomer
  • Posts: 14
    • Cilice Astophotography
Re: PSFEstimation script
« Reply #20 on: 2012 May 26 14:12:50 »
Since you asked ...  :D   Would it be useful to take the results and make a synthetic PSF image like the
DynamicPSF process does?  I know that can be used in the Deconvolution process, maybe others.

Ultimately, it seems that it would be possible to have a evaluation/measurement script like yours to
feed into a star "fixer" script (or deconvolution) to address problems by zone.  I'm not suggesting this
for your script ... I'm just thinking out loud.

Thanks for the explanation of background.  I'll have to puzzle a bit how I would use that information to
judge sub quality.  I'm not at the point where I am tossing out subs anyway - all of mine are equally poor :)

Offline mschuster

  • PTeam Member
  • PixInsight Jedi
  • *****
  • Posts: 1087
Re: PSFEstimation script
« Reply #21 on: 2012 May 26 15:50:01 »
Looking at the DynamicPSF script documentation, I don't see a way to export the synthetic PSF. Maybe a wish list item?

FYI something to check out: I found this an interesting paper on CCD calibration for the Cassini mission. Rather involved residual bulk image and flat field processing and a complex model function.

astro.cornell.edu/~mmhedman/papers_published/ISS_calibration_PSS.pdf

Quote
all of mine are equally poor

I can relate. I tried to collimate a fast catadioptric recently. It is way worse now than what I started with.  :-[
« Last Edit: 2012 May 26 15:55:02 by mschuster »

Offline mschuster

  • PTeam Member
  • PixInsight Jedi
  • *****
  • Posts: 1087
Re: PSFEstimation script
« Reply #22 on: 2012 September 03 15:38:11 »
I posted a new version of this script, see the head post. Primary changes are (1) switched to median deviation (MedDev) instead of average deviation (AvgDev) for robustness, (2) added MRS noise and SNR weight values.

MSR noise is the same value produced by the Noise Evaluation script. It is a measure of noise in the image's structure free regions. To convert to electrons (e-) multiply this value by 65535 * gain. I like to compare this value to that of a dark with the same exposure.

SNR weight is the value (MedDev / MSRNoise)^2. SNR weight is an unnormalized estimate of the weight used by ImageIntegration's Noise Evaluation method. (ImageIntegration currently uses AvgDev clipped to (0.0, 0.98] rather than an unclipped MedDev). You can estimate II's weight via the ratio of the SNR weights of the target and reference. The intuition behind this formula is this (assuming equally exposed subs): Smaller MRSNoise values are better (less light pollution and air glow). Larger MedDev values are better (better transparency and contrast).

On the issue of sub evaluation, here is what I am doing now. All my evaluations are done on calibrated but unregistered subs.

I discard subs with relatively poor FWHM. What is poor? For this example set I consider a FWHM 10% or more larger than the best FWHM in the set poor. So subs 1 and 24 got discarded. (These are undersampled subs, hence the small FWHM in pixels.)



I discard subs with poor Eccentricity. Collimation and tracking is usually good on my setup, eccentricities are usually smaller than 0.43, which is OK in my opinion. None got discarded.



I discard subs with relatively poor SNR weight. Sub 4 is an obvious outliner (heavy smoke from forest fire), it got discarded. Actually all subs were smoke affected, but not too badly.



Finally, for integration weighting purposes, I use the SNR weights (or Noise Evaluation weights) of the calibrated but unregistered subs. This avoids weighting artifacts due to undersampled sub interpolation.

Regards,
Mike

« Last Edit: 2012 September 03 15:47:18 by mschuster »

Offline Juan Conejero

  • PTeam Member
  • PixInsight Jedi Grand Master
  • ********
  • Posts: 7111
    • http://pixinsight.com/
Re: PSFEstimation script
« Reply #23 on: 2012 September 06 10:35:10 »
Hi Mike,

First of all congratulations on this nice script. You're doing a really excellent work.

In second place, please forgive me for overlooking it, even after having asked you some time (months!) ago if we could release it as an official update. Now I have to ask you if we can include this script in the official 1.8 release :)

Quote
I don't see a way to export the synthetic PSF. Maybe a wish list item?

There's no way to export it from a DynamicPSF instance. However, the synthetic PSF is just a rescaled accumulation of a set of PSF fits. You can use the following snippet to perform the same operation in JavaScript:

Code: [Select]
/*
 * Define the columns of the DynamicPSF.psf output table parameter.
 */
#define PSF_starIndex  0
#define PSF_function   1
#define PSF_circular   2
#define PSF_status     3
#define PSF_B          4
#define PSF_A          5
#define PSF_cx         6
#define PSF_cy         7
#define PSF_sx         8
#define PSF_sy         9
#define PSF_theta     10
#define PSF_beta      11
#define PSF_mad       12

/*
 * Render all PSF fits in a DynamicPSF instance as a grayscale image.
 *
 * This function performs the same operation as the 'Export synthetic PSF'
 * routine of the DynamicPSF interface.
 */
function renderSyntheticPSF( DPSF_instance )
{
   var R = new Matrix;

   for ( var i = 0; i < DPSF_instance.psf.length; ++i )
   {
      var psf = DPSF_instance.psf[i];
      var r;
      if ( psf[PSF_function] == DynamicPSF.prototype.Function_Gaussian )
         r = Matrix.gaussianFilterBySize( psf[PSF_sx], 0.01, psf[PSF_sy]/psf[PSF_sx], Math.rad( psf[PSF_theta] ) );
      else // Moffat PSF
         r = Matrix.moffatFilterBySize( psf[PSF_sx], psf[PSF_beta], 0.01, psf[PSF_sy]/psf[PSF_sx], Math.rad( psf[PSF_theta] ) );

      if ( R.rows < r.rows )
         R.swap( r );

      for ( var i0 = 0, k = (R.rows-r.rows)>>1, i = k; i0 < r.rows; ++i0, ++i )
         for ( var j0 = 0, j = k; j0 < r.cols; ++j0, ++j )
            R.at( i, j, R.at( i, j ) + r.at( i0, j0 ) );
   }

   var I = R.toImage();
   I.rescale();
   return I;
}

The renderSyntheticPSF function above returns an Image object that you can use in your script. It works with the list of PSF fits returned by a DynamicPSF instance as its psf output table parameter. However, the routine is very easy to adapt to other data structures, if necessary. You can also use goodness-of-fit values (the PSF_mad column) to filter out bad fits. Disclaimer: I have not tested the code, but it should work without problems. Let me know if you find it useful.

« Last Edit: 2012 September 06 10:46:56 by Juan Conejero »
Juan Conejero
PixInsight Development Team
http://pixinsight.com/

Offline mschuster

  • PTeam Member
  • PixInsight Jedi
  • *****
  • Posts: 1087
Re: PSFEstimation script
« Reply #24 on: 2012 September 07 12:29:18 »
Thank you Juan. I will try your PSF rendering code with a bad fit filter. Please feel free to use the script. I will put together a testing project for you like bitli did for VaryParams when I return from my dark sky week.

A follow-up question on II Noise Evaluation weights: does the MRSNoise used by this weighting clip to (0, 0.98] like ADev?

Mike

Offline vetenskapsman

  • Newcomer
  • Posts: 14
    • Cilice Astophotography
Re: PSFEstimation script
« Reply #25 on: 2012 September 30 13:02:24 »
Revisiting your great script ... wonderful additions!  Silly question in case I'm overlooking something.  On your sub evaluation exercise did you need to run the script on each sub (separately or in a process container) and write down/copy/cut the values and then plot outside PI?  Or is there a way to work with all your subs and generate a tabulation for easy observation/graphing?

-carl

Offline marekc

  • PixInsight Addict
  • ***
  • Posts: 177
Re: PSFEstimation script
« Reply #26 on: 2012 September 30 13:25:33 »
Hi Mike,

Sorry to pile on the questions, but I'm experimenting with using your script's output as the *input* for Deconvolution. The PI Deconvolution module has an input slider for the `Shape' of the PSF. They say this is the kurtosis of the PSF. Apparently the kurtosis of a Gaussian model PSF is 2.0.

What is the kurtosis of a different model fit, such as a Moffatt4 model? Should the `Shape' slider be set to 4 in that case?

- Marek

Offline mschuster

  • PTeam Member
  • PixInsight Jedi
  • *****
  • Posts: 1087
Re: PSFEstimation script
« Reply #27 on: 2012 September 30 15:46:31 »
Thank you Carl. The script only does one image and I do copy values. However, I am working on a new batch version. I hope to have it ready by the end of October.

Hi Marek, I don't know. It may be that the Moffats can only be approximated, but what value is best I don't know. I have not Deconed so I have not faced this issue.

Mike
 
« Last Edit: 2012 September 30 16:02:51 by mschuster »

Offline vetenskapsman

  • Newcomer
  • Posts: 14
    • Cilice Astophotography
Re: PSFEstimation script
« Reply #28 on: 2012 September 30 21:18:29 »
Awesome!  I look forward to it.   The script is incredibly useful as it.  Batch functionality will bring it to
another level.  Another experiment I'll be looking forward to trying is learning how star sizes and shapes
vary through focus and f ratio (I image with camera lenses).  You can see why I might be interested
in the batch feature  :P

-carl

Offline dayers

  • PixInsight Addict
  • ***
  • Posts: 201
    • The Orlop
Re: PSFEstimation script
« Reply #29 on: 2012 October 01 13:47:23 »
Mike, is the version 0.33 download the latest (from the link in the first post of the thread)?

Dave
Dave Ayers
  Stellarvue 80 mm refractor on CG-5 mount, Orion 50mm guide scope. Imaging camera SBIG STF-8300M, guide camera ASI120mm. PHD Guiding. Sequence Generator Pro, PixInsight.