Trying to quantify seeing/image-quality

Scripts and programs to automate Astroart
Post Reply
User avatar
Rudi
Posts: 152
Joined: 08 Jan 2019, 04:47

Trying to quantify seeing/image-quality

Post by Rudi » 14 Feb 2021, 07:20

I am trying to quantify the seeing from fits files.
Usually, I find starts in an image, look in the stars window and order decending by FWHM x, and then multiply the value with image resolution.

It would be very helpfull, if Astroart could show the average FWHM for non saturated weak, but not too weak, stars.
I have seen from a fellow amateur astronomer, that CCD Inspector has a neat function for doing just this.

First, I tried to make a script, that ran through fit files and simply printed the Astroart script function Image.FWHM.

Code: Select all

wx,wy = Image.FWHM
aaFWHM = sqr(wx*wx + wy*wy)
print "Astroart FWHM for the image = " ; aaFWHM * imageRes ; " arcsec/pixel"
In this script, the variable imageRes is set to the image resolution in arcsec per pixel.

Question 1)
Is it possible to deduce the image resolution in arcsec per pixel from the Astroart script functions?

Question 2)
I then made a script, that finds stars in the image, and calculates the average FWHM from the stars found.
The script gets lower values than the Image.FWHM returns, how can that be?

While experimenting with the script, I also noticed, that the stars peak value is not 2^16-1 = 65535 as expected for a 16 bit fit file, but somewhere in the region of 65500.
I modified the script to look at stars only below a given treshold and then I get some values, that I find more realistic.

The script I made is here, and an example output is shown below that.

Script output:

Code: Select all

Folder =  C:\Main\astro\2021\0213\ngc2300\
File mask =  *?1?_L.fit
Image resolution =  1.2  arcsec/pixel
Calculating average FWHM for stars with peak value less than  32000  from the  1000  brightest stars found

NGC2300_017_L.fit ; UTC =  2021 02 14   00 33 15 ; N stars =  731  stars; avgFWHM =  6.5  arcsec; Astroart FWHM =  15.6
NGC2300_018_L.fit ; UTC =  2021 02 14   00 35 26 ; N stars =  716  stars; avgFWHM =  6.1  arcsec; Astroart FWHM =  15.36
NGC2300_019_L.fit ; UTC =  2021 02 14   00 37 36 ; N stars =  689  stars; avgFWHM =  5.6  arcsec; Astroart FWHM =  15.72
NGC2300_113_L.fit ; UTC =  2021 02 14   04 19 52 ; N stars =  730  stars; avgFWHM =  6.2  arcsec; Astroart FWHM =  14.76
NGC2300_114_L.fit ; UTC =  2021 02 14   04 22 00 ; N stars =  724  stars; avgFWHM =  6.2  arcsec; Astroart FWHM =  15.24
NGC2300_115_L.fit ; UTC =  2021 02 14   04 24 07 ; N stars =  682  stars; avgFWHM =  5.4  arcsec; Astroart FWHM =  15
NGC2300_116_L.fit ; UTC =  2021 02 14   04 26 15 ; N stars =  700  stars; avgFWHM =  5.8  arcsec; Astroart FWHM =  15
The script:

Code: Select all

'Image resolution, seconds per pixel
imageRes = 1.2
NStarsToFind = 1000
MAXPeakValue = 32000
folderName = "C:\Users\Bruger\Rudi Dropbox\Main\astro\2021\0213\ngc2300\"
fileMask = "*?1?_L.fit"

print "Folder = " ; folderName
print "File mask = " ; fileMask
print "Image resolution = " ; imageRes ; " arcsec/pixel"
print "Calculating average FWHM for stars with peak value less than " ; MAXPeakValue ; " from the " ; NStarsToFind ; " brightest stars found"
print ""

foundFiles = FindFiles(folderName, fileMask)
NFiles =  Count(foundFiles)
for f = 1 to NFiles
  FindFWHMOfStars(imageRes, NStarsToFind, MAXPeakValue, folderName, foundFiles{f})
next f


function FindFWHMOfStars(imageRes, NStarsToFind, MAXPeakValue, folderName, fileName)

' open file and find stars, they are ordered decending by ADU
Image.Open(folderName + fileName)
NFound = Image.Stars.Find(NStarsToFind)

wx,wy = Image.FWHM
aaFWHM = Round(sqr(wx*wx + wy*wy),1) * imageRes

sumFWHM = 0
sumADU = 0
N = 0
for i = 1 to NFound

  'get the pixel value at centre, to ignore stars that are close to saturation
  starCenterValue = Image.GetPixel(Image.Stars.X(i),Image.Stars.Y(i))
  if (starCenterValue < MAXPeakValue) then
    fwX = Image.Stars.FwhmX(i)
    fwY = Image.Stars.FwhmY(i)
    fw = sqr(fwX * fwX + fwY * fwY)
    sumFWHM = fw + sumFWHM
    N = N + 1
  endif
next i


avgFWHM = Round(sumFWHM / N  * imageRes,1)
avgADU = Round(sumADU / N,0)
print fileName ; "; UTC = " ; Date(Image.JD) ; " " ; Time(Image.JD) ; "; N stars = " ; n ; " stars; avgFWHM = " ; avgFWHM ; " arcsec; Astroart FWHM = " ; aaFWHM

Image.Close

end function
/Rudi

User avatar
Rudi
Posts: 152
Joined: 08 Jan 2019, 04:47

Re: Trying to quantify seeing/image-quality

Post by Rudi » 19 Feb 2021, 07:28

I've updated the script a bit.

Code: Select all

'Image resolution, seconds per pixel
imageRes = 1.2
NStarsToFind = 1000
MAXPeakValue = 32000
folderName = "C:\Users\rbr\Dropbox\Main\astro\2021\0213\LBN777\"
fileMask = "*?1?_L.fit"

'print column headers
print "File; Filter; UTC; n_stars; FWHM; aspectratio; background;"

'analyzeImages("C:\Users\rbr\Dropbox\Main\astro\2021\0211\LBN777\", "*.fit")
'analyzeImages("C:\Users\rbr\Dropbox\Main\astro\2021\0212\LBN777\", "*.fit")
'analyzeImages("C:\Users\rbr\Dropbox\Main\astro\2021\0213\LBN777\", "*.fit")
'analyzeImages("C:\Users\rbr\Dropbox\Main\astro\2021\0211\M45\", "*.fit")
analyzeImages("C:\Users\rbr\Desktop\LBN777\", "*.fit")

function analyzeImages(folderName, fileMask)
  foundFiles = FindFiles(folderName, fileMask)
  NFiles =  Count(foundFiles)
  for f = 1 to NFiles
    FindFWHMOfStars(imageRes, NStarsToFind, MAXPeakValue, folderName, foundFiles{f})
  next f
end function

function FindFWHMOfStars(imageRes, NStarsToFind, MAXPeakValue, folderName, fileName)

' open file and find stars, they are ordered decending by ADU
Image.Open(folderName + fileName)
NFound = Image.Stars.Find(NStarsToFind)

wx,wy = Image.FWHM
aaFWHM = Round(sqr(wx*wx + wy*wy),1) * imageRes

sumFWHM = 0
sumADU = 0
sumFWx = 0
sumFWy = 0
N = 0
for i = 1 to NFound

  'get the pixel value at centre, to ignore stars that are close to saturation
  starCenterValue = Image.GetPixel(Image.Stars.X(i),Image.Stars.Y(i))
  if (starCenterValue < MAXPeakValue) then
    fwX = Image.Stars.FwhmX(i)
    fwY = Image.Stars.FwhmY(i)
    sumFWx = fwX + sumFWx
    sumFWy = fwY + sumFWy
    fw = sqr(fwX * fwX + fwY * fwY)
    sumFWHM = fw + sumFWHM
    N = N + 1
  endif
next i

if (N > 0) then
  avgFWHM = Round(sumFWHM / N  * imageRes,1)
  avgADU = Round(sumADU / N,0)
  avgFWx = sumFWx / N
  avgFWy = sumFWy / N
  if (avgFWx > avgFWy) then
    aspect = avgFWx / avgFWy
  else
    aspect = avgFWy / avgFWx
  endif
  print folderName + fileName ; "; " ; Image.GetKey("FILTER") ; "; "; Date(Image.JD) ; " " ; Time(Image.JD) ; "; " ; n ; "; " ; avgFWHM ; "; " ; Round(aspect, 3) ; "; " ; Image.background
else
  print folderName + fileName ; "; " ; Image.GetKey("FILTER") ; "; "; Date(Image.JD) ; " " ; Time(Image.JD) ; "; 0; n/a; n/a; n/a"
endif


Image.Close

end function
I then copy the output to a spreadsheet, and order by Filter, background.
Then I try to decide, where to cut "bad" images, based on background level, FWHM andstar elongation.

@Fabio: Is there some how to automate this in Astroart? I already use the "Stars elongation" option to reject bad images, but it would be extremely help full with some kind of analysis tool, that could look at all images with the same filter and order a list by parameters as shown above. And even a small fit file preview in the same analysis tool.

Excel sheet: https://www.dropbox.com/s/wncezifypb8jn ... .xlsx?dl=0
Image
/Rudi

fabdev
Posts: 461
Joined: 03 Dec 2018, 21:43

Re: Trying to quantify seeing/image-quality

Post by fabdev » 20 Feb 2021, 13:56

Interesting! About the questions:

1) There's the command Image.RaDec(x,y) which could be called for two adjacent pixels.

2) The command Image.FWHM uses the 30 brightest stars of the image, so it could give a different result if compared with 500+ stars. Maybe it's better to exclude also the faint ones:

if (starCenterValue < MAXPeakValue) and (starCenterValue > MINPeakValue) ...

maybe it's even better to use the command Image.Focus(method) which uses the same methods of full frame autofocus.

Probably only a script could do it, may you write more about this task? Why you need to exclude the "worse" images? Maybe there are other solutions.

User avatar
Rudi
Posts: 152
Joined: 08 Jan 2019, 04:47

Re: Trying to quantify seeing/image-quality

Post by Rudi » 20 Feb 2021, 15:59

I need to be able to select only the best images for stacking in a simple way.
For example, I had almost 300 lights from the previous weekend on the same target, and it is a cumbersome task to open and analyse one image at the time in AstroArt.
There are some images that I need to discard, mainly due to clouds and bad tracking/guiding.

One of my friends showed me “SubFrameSelector” in PixInsight, a really smart way of handling this:
SubframeSelector

Update: sorry- link was missing
/Rudi

fabdev
Posts: 461
Joined: 03 Dec 2018, 21:43

Re: Trying to quantify seeing/image-quality

Post by fabdev » 21 Feb 2021, 03:18

Try the option "Confirm all images" with the option "Multithreading", prepare the left hand on the ESC key and the right hand on the RETURN key, usually it's possible to select/discard manually images quite quickly, I'd say that 300 images can be selected in 200 seconds.

The options for automatic rejection are instead "FWHM max" and "Star elongation" inside the box "Reject bad images", it's possible to see how many images have been rejected in the Log of the Preprocessing.

User avatar
Rudi
Posts: 152
Joined: 08 Jan 2019, 04:47

Re: Trying to quantify seeing/image-quality

Post by Rudi » 21 Feb 2021, 07:48

Thanks Fabio. I’ll give that a try
/Rudi

User avatar
Rudi
Posts: 152
Joined: 08 Jan 2019, 04:47

Re: Trying to quantify seeing/image-quality

Post by Rudi » 14 Mar 2021, 09:25

Hi again Fabio,

I am still using my analysis script, most recently on almost 600 images taken over several nights - it would be an almost impossible task to go through all images manually one by one.

Here's the output put into an excel sheet, showing the background levels.
I use this to quickly determine which treshold values to use, and then again from the excel generate a list of images to stack.
Image


It would be extremely helpfull, if Astroart could implement this in some way or another.
I have made a rough mockup of my thoughts here as inspiration for you.
More treshold parameters should probably be added, s/n, elongation (not x and y, this will be erratic if the elongation is 45° or 135°)
Image
/Rudi

pask
Posts: 2
Joined: 02 Apr 2019, 17:10

Re: Trying to quantify seeing/image-quality

Post by pask » 15 Mar 2021, 23:34

Hi Rudi,
I also have / had your problem because I often shoot more than 1000 or 1500 frames. The option to do everything manually is not the best thing. But I also really liked the "subframeselector".
So, I have studied and researched a lot and in the end I proceed in this way ...
First of all I evaluate the background which must never exceed 10-15% of the maximum range allowed by my sensor. Having analyzed this, I move on to analyze the other parameters that I calculate for each frames and that is FWHM, Eccentricity and N / S.

The formula I found and use is the following (I don't know if I can put the link here from where I found it but I found it in more than one site/blog):
(A * (1- (FWHM-FWHM_min) / (FWHM_max-FWHM_min)) + B * (1- (Ecc-Ecc_min) / (Ecc_max-Ecc_min)) + C * (1- (S/N-S/N_min) / (S/N_max-S/N_min))) + 50
Parameters A, B and C are the weights, in terms of percentage that you give to the 3 parameters chosen and mentioned above.

At the end you find a value that varies between 50 and 100, depending on the weights you have given but the formula really does good results.
So, I examine these values ​​first in an excel file and then later, once I have decided the minimum acceptable threshold, or the minimum acceptable thresholds, with a script I select levels thanks to which in the end I have separate folders where I find inside the image files to be discarded (or to be chek) and the files to be used for integration.
About the paramaters A,B and C:
FWHM => A = 50%
Ecc => B = 30%
S/N => C = 20%

I don't know if I've been clear enough but let me know if you need more details.
Best Regards,
Pasquale
P.S.: Fabio, I think that such a script could help all those who do "lucky imaging" or simply, like me, imaging from sites with light pollution such as the city center and have to keep times low but take a lot of images.

User avatar
Rudi
Posts: 152
Joined: 08 Jan 2019, 04:47

Re: Trying to quantify seeing/image-quality

Post by Rudi » 16 Mar 2021, 05:39

Hi @pask,

Thanks for the formula. That's a clever way to give one single value for an image. I have also been searching for such a formula.

I wonder, if it is possible to get the "true" elongation with a script function, perhaps even also the angle? Not just the x and y components. If the elongation is near 45° or 135°, x and y will be almost identical, even for a substantial star elongation.
/Rudi

pask
Posts: 2
Joined: 02 Apr 2019, 17:10

Re: Trying to quantify seeing/image-quality

Post by pask » 18 Mar 2021, 06:57

Hi Rudi,
I don't think this is difficult to calculate.
If we consider the values of FWHMy and FWHMx as sin (alpha) and cos (alpha) the "alpha" angle is given by:

alfa = arctang (sin (alpha) / cos (alpha))

If I understand correctly how the x and y heats of the FWHM are calculated it should be like this.

About the true elongation it is not clear to me what you mean because what Astroart gives you is the elongation in pixels, if you multiply it by the sampling you get the elongation in seconds of arc.

Pasquale

User avatar
Rudi
Posts: 152
Joined: 08 Jan 2019, 04:47

Re: Trying to quantify seeing/image-quality

Post by Rudi » 18 Mar 2021, 07:27

Pascale,

If the star is elongated at an angle of 45°, 135°, 225° or 315°, then |sin alpha|=|cos alpha| and Astroart's x and y components are equal.
/Rudi

Post Reply