Example #1
2
def track():

    if time.localtime()[4]+time.localtime()[5]/60. == t:
        print 'Home! - at ' +  str(time.localtime()[3]) + ':' + str(time.localtime()[4])
        rlb.pntHome()
        rlb.pntTo(rot_func_pnt.convert()[1]*180./np.pi, rot_func_pnt.convert()[0]*180./np.pi)

        time.sleep(30)
        rlb.pntTo(rot_func_pnt.convert()[1]*180./np.pi, rot_func_pnt.convert()[0]*180./np.pi)

        time.sleep(30)
        rlb.pntTo(rot_func_pnt.convert()[1]*180./np.pi, rot_func_pnt.convert()[0]*180./np.pi)

    else:
        time.sleep(30)
        rlb.pntTo(rot_func_pnt.convert()[1]*180./np.pi, rot_func_pnt.convert()[0]*180./np.pi)
Example #2
0
def main():
    """Records interferometer data and saves data to data/sun_DD-MM-YY_HHMMSS.
    Logs stored in logs/sun_DD-MM-YY_HHMMSS.
    """
    # Parse arguments
    parser = argparse.ArgumentParser(description='Record solar fringe  data using the interferometer.')
    parser.add_argument('repoint_freq', type=float, help='time to wait before repointing (s)')
    parser.add_argument('record_len', type=float, help='total time to record (s)')
    parser.add_argument('-p', '--plot', action='store_true', default=False, help='show real time plot')
    parser.add_argument('-v', '--verbose', action='store_true', default=False, help='print  voltage measurements')
    args = parser.parse_args()

    # Log observer and sun position
    logger.debug('Observer Lat: %s',  str(obs.lat))
    logger.debug('Observer Long: %s', str(obs.long))
    logger.debug('Observer Date: %s', str(obs.date))
    logger.debug('Sun alt: %s', str(sun.alt))
    logger.debug('Sun az: %s',  str(sun.az))

    # Start telescopes at home position
    logger.debug('Set to home position')
    radiolab.pntHome()

    # Create a thread that periodically re-points the telescope
    controllerd = threading.Thread(target = controller,
            args = (args.repoint_freq,))

    # Create thread to log data
    datad = threading.Thread(target = recordData,
           args = ('data/'+OBSERVATION, True, False, args.record_len+10,
               args.verbose, args.plot))

    #Set threads as a daemons, will close automatically
    controllerd.daemon = True
    datad.daemon = True

    # Start controller
    logger.debug('Start position controller')
    controllerd.start()

    # Wait 5 seconds for telescopes to move and start recording
    time.sleep(7)
    datad.start()

    # Sleep for t seconds to gather data
    time.sleep(args.record_len+10)
    logger.debug('Exiting')
Example #3
0
def pnt_home(obs, target):
    """Verbose version of ral.pntHome() + pnt back to target"""
    print '\nStart pntHome: %s (JD: %s)' % (pdt(ephem.now()), ral.getJulDay())
    ral.pntHome()
    pnt_obj(obs,target)
    print 'Finish pnthome: %s (JD: %s)\n' % (pdt(ephem.now()), ral.getJulDay())
Example #4
0
 def point_home(self):
     """Wrapper around point home"""
     logger.warning("Start pointing home.")
     self.last_home = time.time()
     radiolab.pntHome()
     logger.warning("Finished pointing.")
Example #5
0
def main():
    """Records interferometer data and saves data to data/sun_DD-MM-YY_HHMMSS.
    Logs stored in logs/sun_DD-MM-YY_HHMMSS.
    """
    # Parse arguments
    parser = argparse.ArgumentParser(
        description='Record solar fringe  data using the interferometer.')
    parser.add_argument('source',
                        choices=SOURCES.keys(),
                        help='a source to observe')
    parser.add_argument('repoint_freq',
                        type=float,
                        default=30.0,
                        help='time to wait before repointing (s)')
    parser.add_argument('record_len',
                        type=float,
                        default=3600.0,
                        help='total time to record (s)')
    parser.add_argument(
        '-p',
        '--plot',
        action='store_true',
        default=False,
        help='show real time plot (requires X11 to be enabled)')

    parser.add_argument('-v',
                        '--verbose',
                        action='store_true',
                        default=False,
                        help='print  voltage measurements')
    args = parser.parse_args()

    if args.repoint_freq <= 12:
        raise argparse.ArgumentTypeError(
            "Can't repoint more often than every 12 seconds.")

    if args.record_len <= 0:
        raise argparse.ArgumentTypeError(
            "Can't record for less than 0 seconds.")

    # Select the source to observe
    source = SOURCES[args.source]

    # Initialize point source RA and DEC
    initSource(args.source, source)

    # Create standard file name for log and data files
    observation = args.source + "_" + time.strftime("%m-%d-%Y_%H%M%S")

    # Start logging
    logger = initLog(observation)

    # Compute source position
    source.compute(OBS)

    # Log observer and sun position
    logger.debug('Calculating position of %s', args.source)
    logger.debug('Observer Lat: %s', str(OBS.lat))
    logger.debug('Observer Long: %s', str(OBS.long))
    logger.debug('Observer Date: %s', str(OBS.date))
    logger.debug('%s alt: %s', args.source, str(ephem.degrees(source.alt)))
    logger.debug('%s az: %s', args.source, str(ephem.degrees(source.az)))

    # Start telescopes at home position
    logger.debug('Set to home position')
    radiolab.pntHome()

    # Create a thread that periodically re-points the telescope
    controllerd = threading.Thread(target=controller,
                                   args=(source, args.repoint_freq))

    # Create thread to log data
    sun = (args.source == 'sun')
    moon = (args.source == 'moon')
    datad = threading.Thread(target=recordData,
                             args=('data/' + observation, sun, moon,
                                   args.record_len + 10, args.verbose,
                                   args.plot))

    # Set threads as daemons, will cause them to close automatically
    controllerd.daemon = True
    datad.daemon = True

    # Start controller
    logger.debug('Start position controller')
    controllerd.start()

    # Wait 8 seconds for telescopes to move and start recording
    time.sleep(8)
    datad.start()

    # Sleep for t seconds to gather data
    time.sleep(args.record_len + 10)
    logger.debug('Exiting')
Example #6
0
def main():
    """Records interferometer data and saves data to data/sun_DD-MM-YY_HHMMSS.
    Logs stored in logs/sun_DD-MM-YY_HHMMSS.
    """
    # Parse arguments
    parser = argparse.ArgumentParser(description='Record solar fringe  data using the interferometer.')
    parser.add_argument('source', choices=SOURCES.keys(), help='a source to observe')
    parser.add_argument('repoint_freq', type=float, default=30.0, help='time to wait before repointing (s)')
    parser.add_argument('record_len', type=float, default=3600.0, help='total time to record (s)')
    parser.add_argument('-p', '--plot', action='store_true', default=False,help='show real time plot (requires X11 to be enabled)')

    parser.add_argument('-v', '--verbose', action='store_true', default=False, help='print  voltage measurements')
    args = parser.parse_args()

    if args.repoint_freq <= 12:
        raise argparse.ArgumentTypeError("Can't repoint more often than every 12 seconds.")

    if args.record_len <= 0:
        raise argparse.ArgumentTypeError("Can't record for less than 0 seconds.")

    # Select the source to observe
    source = SOURCES[args.source]

    # Initialize point source RA and DEC
    initSource(args.source, source)

    # Create standard file name for log and data files
    observation = args.source + "_" + time.strftime("%m-%d-%Y_%H%M%S")

    # Start logging
    logger = initLog(observation)

    # Compute source position
    source.compute(OBS)

    # Log observer and sun position
    logger.debug('Calculating position of %s', args.source)
    logger.debug('Observer Lat: %s',  str(OBS.lat))
    logger.debug('Observer Long: %s', str(OBS.long))
    logger.debug('Observer Date: %s', str(OBS.date))
    logger.debug('%s alt: %s', args.source, str(ephem.degrees(source.alt)))
    logger.debug('%s az: %s',  args.source, str(ephem.degrees(source.az)))

    # Start telescopes at home position
    logger.debug('Set to home position')
    radiolab.pntHome()

    # Create a thread that periodically re-points the telescope
    controllerd = threading.Thread(target = controller,
            args = (source, args.repoint_freq))

    # Create thread to log data
    sun  = (args.source == 'sun')
    moon = (args.source == 'moon')
    datad = threading.Thread(target = recordData,
           args = ('data/'+observation, sun, moon, args.record_len+10,
               args.verbose, args.plot))

    # Set threads as daemons, will cause them to close automatically
    controllerd.daemon = True
    datad.daemon = True

    # Start controller
    logger.debug('Start position controller')
    controllerd.start()

    # Wait 8 seconds for telescopes to move and start recording
    time.sleep(8)
    datad.start()

    # Sleep for t seconds to gather data
    time.sleep(args.record_len+10)
    logger.debug('Exiting')