コード例 #1
0
def mass_stat(args):
    files = os.listdir(args.im_folder)
    with open(args.data_file_name, 'a') as data_file:
        for filename in files:
            if filename.startswith(args.stem) and (filename.endswith(".fit") or filename.endswith(".fits")):
                im_path = args.im_folder + filename
                image = fits.open(im_path)
                date = image[0].header['DATE-OBS']
                dt = sidereal.parseDatetime(date)
                st = SidTime(sidereal.SiderealTime.fromDatetime(dt).lst(-2.05393104))
                data_file.write(date + '     ' + str(st) +  imutil.imstat(im_path, Stdout=1)[1] + '\n')
コード例 #2
0
def main(args):
    if args.mode == 'sex':
        sex(args)
        return
    if args.mode == 'mass':
        mass_solve(args)
        return
    if args.mode == 'stat':
        mass_stat(args)
        return
    
    key = 'vsrjqdfgoomarrpf'
    ra = -117.68158
    dec = 34.38183

    #solve_arg = 'python {client} --apikey {key} --parity 0 --downsample 1 --ra {{ra}} --dec {dec} --upload {{file}} --wcs {{new_file}}'.format(client=client_path, key=key, dec=dec)
    solve_arg = 'python {client} --apikey {key} --downsample 1  --upload {{file}} --wcs {{new_file}}'.format(client=client_path, key=key, dec=dec)
    if not os.path.isdir(args.im_folder + 'wcs/'):
        os.mkdir(args.im_folder + 'wcs/')
    processes = []
    files = os.listdir(args.im_folder)

    while files:
        filename = files.pop()
        print(filename)
        if filename.endswith(".fit") or filename.endswith(".fits"):
            path = args.im_folder + filename
            wcs_folder = args.im_folder + 'wcs/'
            image = fits.open(path)
            date = image[0].header['DATE-OBS']
            dt = sidereal.parseDatetime(date)
            st = SidTime(sidereal.SiderealTime.fromDatetime(dt).lst(-2.05393104))
            wcs_path = wcs_folder+st.rounded_str()+'.fit'
            if not os.path.isfile(wcs_path):
                #full_arg = solve_arg.format(ra=sidereal, file=path, new_file='wcs-'+filename)
                full_arg = solve_arg.format(file=path, new_file=wcs_path)
                print(full_arg) 
                print(processes) 
                while len(processes) >= args.threads:
                    processes = [p for p in processes if p.poll() == None]
                    time.sleep(1)
                if not args.sterile:
                    p = subprocess.Popen([full_arg], shell=True)
                    processes.append(p)
    for p in processes:
        p.wait()
コード例 #3
0
def mass_solve(args):
    if not os.path.isdir(args.im_folder + '/solved'):
        os.mkdir(args.im_folder + '/solved')
    files = os.listdir(args.im_folder)
    for filename in files:
        if filename.startswith(args.stem) and (filename.endswith(".fit") or filename.endswith(".fits")):
            im_path = args.im_folder + filename
            image = fits.open(im_path)
            date = image[0].header['DATE-OBS']
            dt = sidereal.parseDatetime(date)
            st = SidTime(sidereal.SiderealTime.fromDatetime(dt).lst(-2.05393104))
            
            if args.lower_sid_bound <= st.rounded_mins() <= args.upper_sid_bound:
                ref_path = args.ref_folder + st.rounded_str() + '.fit'
                if os.path.isfile(ref_path): 
                    immatch.wcscopy(im_path, ref_path)
                    shutil.copy2(im_path, args.im_folder + '/solved/' + filename)
コード例 #4
0
ファイル: jd.py プロジェクト: michaeljtbrooks/astrorobot
def  argCheck():
    """Check and convert the command line argument(s).
    """
    #-- 1 --
    # [ argList  :=  the command line arguments ]
    argList  =  sys.argv[1:]

    #-- 2 --
    # [ if (len(argList)==1) and argList[0] is a valid
    #   date-time string ->
    #     dt  :=  that date-time as a datetime.datetime instance
    #   else if (len(argList)==2) and (argList[0] is a valid
    #   date) and (argList[1] is a valid time) ->
    #     dt  :=  a datetime.datetime representing that date
    #             and time
    #   else ->
    #     sys.stderr  +:=  error message
    #     stop execution ]
    if  len(argList) == 1:
        try:
            dt  =  sidereal.parseDatetime ( argList[0] )
        except SyntaxError, detail:
            usage ( "Invalid date-time: %s" % detail )
コード例 #5
0
def argCheck():
    """Check and convert the command line argument(s).
    """
    #-- 1 --
    # [ argList  :=  the command line arguments ]
    argList = sys.argv[1:]

    #-- 2 --
    # [ if (len(argList)==1) and argList[0] is a valid
    #   date-time string ->
    #     dt  :=  that date-time as a datetime.datetime instance
    #   else if (len(argList)==2) and (argList[0] is a valid
    #   date) and (argList[1] is a valid time) ->
    #     dt  :=  a datetime.datetime representing that date
    #             and time
    #   else ->
    #     sys.stderr  +:=  error message
    #     stop execution ]
    if len(argList) == 1:
        try:
            dt = sidereal.parseDatetime(argList[0])
        except SyntaxError, detail:
            usage("Invalid date-time: %s" % detail)
コード例 #6
0
ファイル: aard.py プロジェクト: michaeljtbrooks/astrorobot
    #   else ->
    #     sys.stderr  +:=  error message
    #     stop execution ]
    try:
        lon  =  sidereal.parseLon ( rawLon )
    except SyntaxError, detail:
        usage ( "Invalid longitude: %s" % detail )

    #-- 5 --
    # [ if rawDT is a valid date-time string ->
    #     dt  :=  that date-time as a datetime.datetime instance
    #   else ->
    #     sys.stderr  +:=  error message
    #     stop execution ]
    try:
        dt  =  sidereal.parseDatetime ( rawDT )
    except SyntaxError, detail:
        usage ( "Invalid timestamp: %s" % detail )

    #-- 6 --
    latLon  =  sidereal.LatLon ( lat, lon )
    return  (altAz, latLon, dt)
# - - -   u s a g e

def usage ( *L ):
    """Print a usage message and stop.

      [ L is a list of strings ->
          sys.stderr  +:=  (usage message) + (elements of L,
                           concatenated)
          stop execution ]
コード例 #7
0
ファイル: aard.py プロジェクト: fjankowsk/ionFR
    #   else ->
    #     sys.stderr  +:=  error message
    #     stop execution ]
    try:
        lon = sidereal.parseLon(rawLon)
    except SyntaxError, detail:
        usage("Invalid longitude: %s" % detail)

    #-- 5 --
    # [ if rawDT is a valid date-time string ->
    #     dt  :=  that date-time as a datetime.datetime instance
    #   else ->
    #     sys.stderr  +:=  error message
    #     stop execution ]
    try:
        dt = sidereal.parseDatetime(rawDT)
    except SyntaxError, detail:
        usage("Invalid timestamp: %s" % detail)

    #-- 6 --
    latLon = sidereal.LatLon(lat, lon)
    return (altAz, latLon, dt)


# - - -   u s a g e


def usage(*L):
    """Print a usage message and stop.

      [ L is a list of strings ->
コード例 #8
0
ファイル: rdalaz.py プロジェクト: fjankowsk/ionFR
def checkArgs(ti):
    """Process all command line arguments.

      [ if sys.argv[1:] is a valid set of command line arguments ->
          return (raDec, latLon, dt) where raDec is a set of
          celestial coordinates as a sidereal.RADec instance,
          latLon is position as a sidereal.LatLon instance, and
          dt is a datetime.datetime instance
        else ->
          sys.stderr  +:=  error message
          stop execution ]
    """
    #-- 1 --
    # [ if sys.argv[1:] has exactly four elements ->
    #     rawRADec, rawLat, rawLon, rawDT  :=  those elements
    #   else ->
    #     sys.stderr  +:=  error message
    #     stop execution ]
    argList = sys.argv[1:]
    if len(argList) != 5:
        usage("Incorrect command line argument count.")
    else:
        rawRADec, rawLat, rawLon, rawDT, fileIONEXTEC = argList
        rawDT = str(ti)

    #-- 2 --
    # [ if rawRADec is a valid set of equatorial coordinates ->
    #     raDec  :=  those coordinates as a sidereal.RADec instance
    #   else ->
    #     sys.stderr  +:=  error message
    #     stop execution ]
    raDec = checkRADec(rawRADec)

    #-- 3 --
    # [ if rawLat is a valid latitude ->
    #     lat  :=  that latitude in radians
    #   else ->
    #     sys.stderr  +:=  error message
    #     stop execution ]
    try:
        lat = sidereal.parseLat(rawLat)
    except SyntaxError as detail:
        usage("Invalid latitude: %s" % detail)

    #-- 4 --
    # [ if rawLon is a valid longitude ->
    #     lon  :=  that longitude in radians
    #   else ->
    #     sys.stderr  +:=  error message
    #     stop execution ]
    try:
        lon = sidereal.parseLon(rawLon)
    except SyntaxError as detail:
        usage("Invalid longitude: %s" % detail)

    #-- 5 --
    # [ if rawDT is a valid date-time string ->
    #     dt  :=  that date-time as a datetime.datetime instance
    #   else ->
    #     sys.stderr  +:=  error message
    #     stop execution ]
    try:
        dt = sidereal.parseDatetime(rawDT)
    except SyntaxError as detail:
        usage("Invalid timestamp: %s" % detail)

    #-- 6 --
    latLon = sidereal.LatLon(lat, lon)
    return (raDec, latLon, dt)
コード例 #9
0
ファイル: time_service.py プロジェクト: SAAO/time_for_pi
	no_gps_fix()
	try:
		gpsp.start() # start it up
		while True:
			previous_option=IO(previous_option)
			#It may take a second or two to get good data
			#print gpsd.fix.latitude,', ',gpsd.fix.longitude,'  Time: ',gpsd.utc
			if gpsd.fix.mode==MODE_3D:
				fix_flag=True
				GPIO.output(gps_stat, True)   # switch on gps status led if it has a 3d fix
				#==========================================================calculate sidereal time from gps time
				gpsNow = gpsd.utc
				gpsNow = gpsNow.replace('Z', 'UTC')
				ctLong = gpsd.fix.longitude
				ctLat = gpsd.fix.latitude
				gpsNow = sid.parseDatetime(gpsNow)
				GST = sid.SiderealTime.fromDatetime(gpsNow)
				LST =GST.hours+(ctLong/15)
				h, m, s = dech(LST)

				#=========================================================get SAST
				timeNow = dt.datetime.now()
				HOURS = timeNow.hour
				MINUTES = timeNow.minute
				SECONDS = timeNow.second						
				gps_fix_status=str(gpsd.fix.mode) + "D Fix"
				
				gps_data(gpsNow, gps_fix_status, ctLong, ctLat, "2014")
				
				#LCD strings
				#sidereal string