Page 1 of 1

Trying to quantify seeing/image-quality

Posted: 14 Feb 2021, 07:20
by Rudi
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

Re: Trying to quantify seeing/image-quality

Posted: 19 Feb 2021, 07:28
by Rudi
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

Re: Trying to quantify seeing/image-quality

Posted: 20 Feb 2021, 13:56
by fabdev
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.

Re: Trying to quantify seeing/image-quality

Posted: 20 Feb 2021, 15:59
by Rudi
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

Re: Trying to quantify seeing/image-quality

Posted: 21 Feb 2021, 03:18
by fabdev
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.

Re: Trying to quantify seeing/image-quality

Posted: 21 Feb 2021, 07:48
by Rudi
Thanks Fabio. I’ll give that a try