J2000 <-> JNOW conversion & sidereal time

Discussions on extending SharpCap using the built in Python scripting functionality
SteveP
Posts: 16
Joined: Thu Feb 23, 2023 10:06 pm

Re: J2000 <-> JNOW conversion & sidereal time

#11

Post by SteveP »

I tried accessing several different ASCOM namespace previously but could not find the answer. Just now, I get the following error message in the scripting console:

>>> clr.AddReference("ASCOM.AstrometryTools")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
OSError: [Errno -2146232800] Could not add reference to assembly ASCOM.AstrometryTools
>>>

I am using version 4.1.12342 of Sharpcap.

Steve
Jean-Francois
Posts: 636
Joined: Sun Oct 13, 2019 10:52 am
Location: Germany

Re: J2000 <-> JNOW conversion & sidereal time

#12

Post by Jean-Francois »

Hello Steve,

You need first import clr module ... "import clr" and then the other commands :-)

Jean-Francois
User avatar
admin
Site Admin
Posts: 15625
Joined: Sat Feb 11, 2017 3:52 pm
Location: Vale of the White Horse, UK
Contact:

Re: J2000 <-> JNOW conversion & sidereal time

#13

Post by admin »

Hi,

you are quite out-of-date in terms of SharpCap version - latest is 4.1.12802. I would suggest updating and then try.

cheers,

Robin
SteveP
Posts: 16
Joined: Thu Feb 23, 2023 10:06 pm

Re: J2000 <-> JNOW conversion & sidereal time

#14

Post by SteveP »

OK. The reference to AstrometryTools now works. I should be able to do some testing now.

I had mistakenly assumed any version of 4.1 would include these tools. I should have updated first. My apologies.

Thanks,
Steve
Jean-Francois
Posts: 636
Joined: Sun Oct 13, 2019 10:52 am
Location: Germany

Re: J2000 <-> JNOW conversion & sidereal time

#15

Post by Jean-Francois »

Hello Steve,

I mentioned in a preceding message that the ASCOM changed.

You can insert this in your code:

Code: Select all

SharpCap_version = SharpCap.AppName.Split("v")[1].Split(",")[0]

if (SharpCap_version.CompareTo("4.1") == -1):           # if version below 4.1, use old ASCOM driver
    clr.AddReference("ASCOM.DriverAccess")
    clr.AddReference("ASCOM.Astrometry")
    from ASCOM.DriverAccess import *
    from ASCOM.Astrometry import *
else:                                                   # if version 4.1 or above, use new ASCOM driver
    clr.AddReference("ASCOM.Com")
    #clr.AddReference("ASCOM.Tools")
    clr.AddReference("ASCOM.AstrometryTools")
    from ASCOM.Com import *
    from ASCOM.Tools import *
It is fine as long as the function does not change his name (or parameters).

Regards,
Jean-Francois
Astrojunk
Posts: 11
Joined: Sat Jul 21, 2018 12:21 pm
Location: Australia
Contact:

Re: J2000 <-> JNOW conversion & sidereal time

#16

Post by Astrojunk »

Hi Jean-Francois,

I added a pre-point function to your script using exactly the methodology you mentioned, simply goto the pre-point position, platesolve it and stop the scope. It seems to work well but I really need to properly test it before I send the code back to you. I have found it particularly useful as my sky is limited in an irregular way and difficult to know for certain if a target is visible or not. At the beginning of a session I just pre-point to all of the targets and eliminate those which are obstructed.

For autonomous capture I was thinking of developing a routine where the scope started tracking once the target was central so that a normal tracked video was captured rather than a drift through, but I have found myself busy on so many other things of late...

Given how poor my python skills are, here is the code for review!

Code: Select all

#Prepoint
#-------
#Drift events are very useful for unattended stations. This code simply calculates the
#the teme left to the event, ie the predicted time minus the current time, and subtracts it from
#the Star RA. This offset is the position where the target will ultimately be when it occurs.
#Recommended Workfow:    
#   1. Prepoint will slew to prepoint position
#   2. Plate Solve to confirm and recentre
#   3. Prepoint again to finesse the position - the mount should move only the tiniest ammount
#   4. STOP the mount from tracking.
            
    def PrePoint(self, sender, args):
        global Star_RA, Star_DEC, Star_Prepoint_RA, Prepoint_Offset, Prepointed_Flag
        SharpCap.Mounts.SelectedMount.Tracking = True
        if (self.buttonPrePoint.Text == "Pre Point"): 
            self.buttonPrePoint.Text = "STOP"
            self.buttonPrePoint.BackColor = Color.Red
            self.buttonPrePoint.ForeColor = Color.White  
            Prepoint_Offset = (datetime.strptime(PredictTime,"%H:%M:%S")-datetime.utcnow())
            print(Siderial_Offset)
            print("Pre-Point offset initial", Prepoint_Offset)
            #Next line is for testing only
            Star_Prepoint_RA = datetime.strftime(datetime.strptime(Star_RA,"%Hh %Mm %Ss") - Prepoint_Offset, "%H:%M:%S")
            print("Star Prepoint RA unadjusted: " + Star_Prepoint_RA )
            Prepoint_Offset = timedelta(seconds=int(Prepoint_Offset.seconds) * Siderial_Offset)
            Star_Prepoint_RA = datetime.strftime(datetime.strptime(Star_RA,"%Hh %Mm %Ss") - Prepoint_Offset, "%H:%M:%S")  
            coordinates = CoordinateParser.Parse(Star_Prepoint_RA + ";" + Star_DEC, True)
            print("radp: ", coordinates)
            print("Pre-Point offset final", Prepoint_Offset)
            print("Star RA : " + Star_RA.replace("\n", ""))
            print("Star Prepoint RA Adjusted: " + Star_Prepoint_RA )
            print("Star DEC: " + Star_DEC.replace("\n", "") + ", " + str("%.6f" % round(coordinates.Declination,6)))
            print("Slew to target")
            SharpCap.Mounts.SelectedMount.SlewTo(coordinates)
            Prepointed_Flag = "Yes"

            time.sleep(2)       #do not delete ! important for the STOP text
            SharpCap.Mounts.SelectedMount.Tracking = False
        else:
            SharpCap.Mounts.SelectedMount.Stop()
            print("Stop the GOTO")
Jonathan Bradshaw
Quaerens veritatem de umbrae
Post Reply