Script for fast moving objects

Scripts and programs to automate Astroart
Post Reply
Forum_2016
Posts: 219
Joined: 08 Dec 2018, 13:30

Script for fast moving objects

Post by Forum_2016 »

Hello, here is a script for taking several images of moving objects, where the telescope must be moved every N images to recenter the object.

-- TUTORIAL --
(you can test it indoor using the camera and telescope simulator).

1) Go to an ephemeris service web site, for example the MPC:
http://www.minorplanetcenter.net/iau/MPEph/MPEph.html

2) Fill the data as written in the image below, remember to change the option about "Display RA/Dec" and Coordinate format.
Here we will use the asteroid 2015 XD130 at 2016/6/23 02:00 UT. This should be the approximate date/time when you'll actually take the sequence.
3) Get the ephemeris from the web site:
Select a suitable time (for example 02:00) and copy that date/time to the script:

YearInit = 2016
MonthInit = 6
DayInit = 23
HourInit = 02
MinuteInit = 00

Copy the ra/dec data into the script:

RaInit = 21.4718
DeInit = 37.623
RaMotion = -1.40
DeMotion = 1.44

4) That's all, when you launch the script it will take:

NumExposures = 10
ExposureTime = 5.0
TelescopeCenter = 3
Folder = "C:\Temp\"
ObjectName = "2015XD130"

10 exposures, with an exposure time of 5 seconds, with a telescope recenter every 3 images. You may verify that with the simulators.

Code: Select all

' Ephemeris in Universal Time
' example: www.minorplanetcenter.net/iau/MPEph/MPEph.html
' Change these Options:
' 1) "Display R.A./Decl" = decimal units
' 2) "Separate R.A. and Decl. coordinate motion"

YearInit = 2016
MonthInit = 6
DayInit = 23
HourInit = 02
MinuteInit = 00

RaInit = 21.4718
DeInit = 37.623
RaMotion = -1.40
DeMotion = 1.44

NumExposures = 10
ExposureTime = 5.0
TelescopeCenter = 3
Folder = "C:\Temp\"
ObjectName = "2015XD130"

DayInit = DayInit + HourInit/24 + MinuteInit/60/24 
JDInit = DateToJd(YearInit, MonthInit, DayInit)
RaMotion = RaMotion*60*24 / 3600  'Degrees per day 
DeMotion = DeMotion*60*24 / 3600  'Degrees per day

For i = 1 to NumExposures
  ra,de = CalcCoords(JDInit,RaInit,DeInit,RaMotion,DeMotion)
  If Round(i mod TelescopeCenter) = 1 then
     Print "Moving telescope: " ; ra ; " " ; de
     Telescope.Goto(ra,de)
     Telescope.Wait
  End If
  Print "Exposure #" ; i
  TakeImage(i)
Next i

'--------------- Subrotines ---------------

Sub TakeImage(index)
  Camera.Start(ExposureTime)
  Camera.Wait
  fileName = ObjectName + "_" + Format(index,"000")+ ".fit"
  Image.Save(Folder + fileName)
  Image.Close
End Sub

Sub CalcCoords(JDIn,RaIn,DeIn,RaMot,DeMot)
  dJ = JD() - JDIn
  CRa = RaIn + RaMot*dJ / 15
  if CRa >= 24 then CRa = CRa - 24
  if CRa < 0 then CRa = Cra + 24
  CDe = DeIn + DeMot*dJ
  Return CRa,CDe
End Sub

Sub DateToJd(dYear,dMonth,dDay)
  if dMonth <= 2 then
     dYear = dYear - 1
     dMonth = dMonth + 12
  End If
  a = Int(dYear / 100)
  b = 2 - a + Int(a / 4) - 1524.5 + dDay
  r = b + Int(30.6001 * (dMonth+1)) + Int(365.25 * (dYear+4716))
  return r
End Sub

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

Re: Script for fast moving objects

Post by fabdev » 08 Jan 2020, 15:07

The previous script was quite simple: every N# exposures the telescope was recentered on the minor planet.

An improved script would calculate automatically when to recenter the telescope, knowing the object speed and the field of view of the camera.
The following script does that, after the user has defined in the code a central region of the image.
In this example the central region is defined as 40% ("0.4" in the code)

and in this example the region is only 20%:

The telescope is moved so that the object is placed on the "initial" edge of the region, then when the object reaches the other edge, the telescope is moved again. Meanwhile a sequence of images is taken, for a total session time of "TotalTimeMinutes".

Code: Select all

' Ephemeris in Universal time
' http://www.minorplanetcenter.net/iau/MPEph/MPEph.html
' Options:
' 1) "Display R.A./Decl" = decimal units
' 2) "Separate R.A. and Decl. coordinate motion"

Ephe_Year = 2017
Ephe_Month = 11
Ephe_Day = 08
Ephe_Hour = 23
Ephe_Minute = 00
Ephe_Ra = 18.0902
Ephe_De = 53.578
Ephe_CMotion_Ra = -8.98
Ephe_CMotion_De = -2.69
ObjectName = "2017 RR15"
Exposure = 30.0
TotalTimeMinutes = 60
Subframe = 0.4

Folder = "C:\Temp\"
CCDField_Ra = 13  'ArcMinutes
CCDField_De = 13  'ArcMinutes

'--------------- Start of script --------------

Ephe_Day = Ephe_Day + Ephe_Hour/24 + Ephe_Minute/60/24
Ephe_JD = DateToJd(Ephe_Year, Ephe_Month, Ephe_Day)
Ephe_CMotion_Ra = Ephe_CMotion_Ra*60*24 / 3600  'Degrees per day
Ephe_CMotion_De = Ephe_CMotion_De*60*24 / 3600  'Degrees per day
DaysField = CalcJDMotion(CCDField_Ra, CCDField_De, Ephe_CMotion_Ra, Ephe_CMotion_De, Ephe_De)
DaysFieldFrac = DaysField * Subframe / 2

if Abs(JD - Ephe_JD) > 0.5 then
   Warning("Ephemeris are obsolete")
   end
end if

CntImages = 0
CntField = 0
JDNextField = 0
JDEndSession = JD + TotalTimeMinutes/60/24
while true
  if JD > JDNextField then
     CntField = CntField + 1
     JDNextField = JD + DaysFieldFrac*2
     ra,de = CalcCoords(JD+DaysFieldFrac, Ephe_JD, Ephe_Ra, Ephe_De, Ephe_CMotion_Ra, Ephe_CMotion_De)
     print "Telescope GOTO field #" ; CntField ; " -> " ; RaToString(ra) ; DecToString(de) ;
     Telescope.Goto(ra,de)
     Telescope.Wait
  end if
  Pause(1)
  CntImages = CntImages + 1
  Print "Exposure #" ; CntImages ; " field #" ; CntField;
  TakeAndSaveImage(CntField, CntImages)
  if JD > JDEndSession then break
end while

Message("End of script")
end

' --------------- end of script -------------

sub TakeAndSaveImage(field,index)
  Camera.Start(Exposure)
  Camera.Wait
  fileName = ObjectName + "_" + Format(field,"00") + "_" + Format(index,"000")+ ".fit"
  Image.Save(Folder + fileName)
  if index > 1 then Image.ClosePrevious
end sub

function CalcCoords(JDTarget,JDIn,RaIn,DeIn,RaMot,DeMot)
  dJ = JDTarget - JDIn
  CRa = RaIn + RaMot*dJ / 15
  if CRa >= 24 then CRa = CRa - 24
  if CRa < 0 then CRa = Cra + 24
  CDe = DeIn + DeMot*dJ
  return CRa,CDe
end function

function CalcJDMotion(raCCD, deCCD, raMot, deMot, de)
  fRa = raCCD/60 / Abs(raMot) / Cos(DegToRad(de))
  fDe = deCCD/60 / Abs(deMot)
  if fRa < fDe then return fRa else return fDe
end function

function DateToJd(dYear,dMonth,dDay)
  if dMonth <= 2 then
     dYear = dYear - 1
     dMonth = dMonth + 12
  end If
  a = Int(dYear / 100)
  b = 2 - a + Int(a / 4) - 1524.5 + dDay
  r = b + Int(30.6001 * (dMonth+1)) + Int(365.25 * (dYear+4716))
  return r
end function


Post Reply