Page 1 of 1

Copying a single line

Posted: 22 Apr 2025, 10:15
by AdamR
Hi, Ive been using AA since version 2, it is totally excellent and I use for casual imaging as well as astrometry and analysis.

But have come across a need i have never had before and I am stumped for a solution.

I am carrying out a spectrographic survey of stars (as part of a uni-project) using a grism based spectrograph
Typically i get a spectrum shown here . I can work with this technicallly - no problem.
However, what I would like to do is select a single x-line of pixels across a single y pixel value hence producing an image 1 or 2 pixels high like this And then copy the lines upwards to duplicate the line across say 50image y pixels. Hence enabling the spectrum to be seen as a proper uniform banded image.

I have trawled through manual and posts and I cannot see a way to do this?
Does anyone have any ideas?

Thanks in advance

Adam

Re: Copying a single line

Posted: 22 Apr 2025, 13:17
by fabdev
Hello, it could be done with a script.
By the way, the original spectrum is 3-4 pixels tall, I would use all those pixels for a good S/N.

Here is an example which requires to select manually a point in the middle (y) of the spectrum:

Code: Select all

if Image.Points.Count <> 1 then
   Warning("Please select a point over the spectrum")
   Script.Stop
end if
cy = Image.Points.GetY(1)
Image.Crop(0, cy-1, Image.Width-1, cy+1)
Image.BinningYAverage(0, 2)
Image.Resize(Image.Width, 200)
Where 3 rows are averaged: cy-1, cy, cy+1 , before resizing the image.

and here is a more complex script where the brightest row is found automatically analyzing the image:

Code: Select all

cy = FindBrightestY
Image.Crop(0, cy-1, Image.Width-1, cy+1)
Image.BinningYAverage(0, 2)
Image.Resize(Image.Width, 200)

function LineBrightness(y)
  x1 = Round(Image.Width * 0.40)
  x2 = Round(Image.Width * 0.60)
  sum = 0
  for x = x1 to x2
    sum = sum + Image.GetPixel(x,y)
  next x
  return sum
end function

function FindBrightestY
  bestY = 0
  bestSum = 0
  for y = 0 to Image.Height-1
    curr = LineBrightness(y)
    if curr > bestSum then
       bestSum = curr
       bestY = y
    end if
  next y
  return bestY
end function

Re: Copying a single line

Posted: 22 Apr 2025, 16:42
by AdamR
Wow !
Thanks! What an amazingly quick response.
Yeah, i have played with some scripts but had not appreciated that they can do quite this much.
Thats smashing thank you !
Adam