예제 #1
0
 def track(self):
     self.dish.home()
     self.set_lo(lo_amp, lo_freq)
     self.point()
     takespec.takeSpec(args)
     
     
     
 
     
예제 #2
0
파일: test.py 프로젝트: kevinyu/mag-stream
def main():
    """Records 1 minute of test data from the Leuschner dish.
    """
    parser = argparse.ArgumentParser(description="Record test data from the dish.")
    parser.add_argument(
        "--home", action="store_true", default=False, help="run homing routine (warning, takes a few minutes)"
    )
    parser.add_argument("--verbose", action="store_true", default=True, help="print verbose output")
    parser.add_argument("--lon", type=float, default=220, help="LO frequency.")
    args = parser.parse_args()

    # Set lat and long (for Leuschner from Google Maps), and date
    obs = ephem.Observer()
    obs.lat = 37.919481 * np.pi / 180
    obs.long = -122.153435 * np.pi / 180

    # Compute number of spectra to record (integration time=1 min)
    length = 60  # integration time in seconds
    num_spec = length / 3

    print "Observing galactic coordinates long=%s, lat=0" % (str(args.lon))
    point_gal = ephem.Galactic(args.lon * np.pi / 180, 0)
    point_eq = ephem.Equatorial(point_gal)

    # Compute az alt
    point = ephem.FixedBody()
    point._ra = point_eq.ra
    point._dec = point_eq.dec

    # Create synthesizer interface
    s = dish_synth.Synth(verbose=args.verbose)
    s.set_freq(1272.4)  # frequency in MHZ
    s.set_amp(10)  # amplitude in dbM

    # Create dish interface
    d = dish.Dish(verbose=args.verbose)
    d.noise_off()
    if args.home:
        d.home()

    obs.date = ephem.now()
    point.compute(obs)
    print "RA: " + str(point.ra)
    print "DEC: " + str(point.dec)
    d.point(point.alt * 180 / np.pi, point.az * 180 / np.pi)

    # Record spectra noise off
    takespec.takeSpec("test_" + str(args.lon) + "_0_noise_off", numSpec=num_spec)

    d.noise_on()

    # Record spectra noise on
    takespec.takeSpec("test_" + str(args.lon) + "_0_noise_on", numSpec=num_spec)

    # Record spectra with LO set 4MHz lower and noise off
    s.set_freq(1268.4)  # frequency in MHZ
    d.noise_off()
    takespec.takeSpec("test_" + str(args.lon) + "_0_noise_off_low", numSpec=num_spec)
예제 #3
0
def main():
    """Quick script to point telescope and stuff"""
    obs = cat.obs_leuschner()
    target = cat.make_lbdeg_obj(300, 60)  # l, b
    obs.date = ephem.now()
    target.compute(obs)

    d = dish.Dish(verbose=True)
    # d.home()
    s = dish_synth.Synth(verbose=True)
    s.set_amp(10)
    s.set_freq(1270)  # Usually 1270, just to match Vikram's LO freq

    print 'Alt, az of target: %s, %s' % (target.alt, target.az)
    canpnt = check_pnt(obs, target, d)
    print 'Can point? %s' % canpnt

    if canpnt:
        pnt_obj(obs, target, d)
        started = datetime.now()
        takespec.takeSpec('single_pnt_test', numSpec=60)
        ended = datetime.now()
        print 'Time elapsed: %s' % (ended - started)
예제 #4
0
                    except (ValueError):
                        lst_now = rlab.getLST()  # Local Sidereal Time
                        if isup[0] - lst_now < .2 and isup[
                                0] - lst_now > 0:  # If point rises in 10 minutes
                            print 'Waiting for point to rise'
                            time.sleep(600)  # Waiting 10 minutes
                        else:
                            condition2 = False
                            print 'ValueError returned, moving to next point!'

                if not condition2: continue

                ## Finishing to check. If waited 10 min or ValueError returned,
                ## breaks code and move on to next point. Else, takes spectra (next).

                takespec.takeSpec('specON/bubbleON' + str(j) + ',' + str(i),
                                  numSpec=128)
                print
                print 'Spectra taken!'

                while True:  # Retry for noise
                    try:
                        d.noise_on()
                        break
                    except:
                        print 'Noise set failed... trying again'

                d.point(alt, az)
                takespec.takeSpec('noiseON/bubbleNOISE_ON' + str(j) + ',' +
                                  str(i),
                                  numSpec=32)
                    except (ValueError):
                        lst_now =  rlab.getLST() # Local Sidereal Time
                        if isup[0] - lst_now < .2 and isup[0] - lst_now > 0: # If point rises in 10 minutes
                            print 'Waiting for point to rise'
                            time.sleep(600) # Waiting 10 minutes
                        else:
                            condition2 = False
                            print 'ValueError returned, moving to next point!'

                if not condition2: continue

                ## Finishing to check. If waited 10 min or ValueError returned,
                ## breaks code and move on to next point. Else, takes spectra (next).

                takespec.takeSpec('specON/bubbleON' + str(j) + ','+ str(i), numSpec = 128)
                print
                print 'Spectra taken!'

                while True: # Retry for noise
                    try:
                        d.noise_on()
                        break
                    except:
                        print 'Noise set failed... trying again'

                d.point(alt, az)
                takespec.takeSpec('noiseON/bubbleNOISE_ON' + str(j) + ',' + str(i), numSpec = 32)

                print
                print 'Noise taken!'
예제 #6
0
def data_taker():
    #update date               
    date = 'Apr_30'
    d = dish.Dish(verbose=True)
    s = dish_synth.Synth()
    obs = ephem.Observer()
    obs.lat = 37.832*np.pi/180 
    obs.long = -122.2573*np.pi/180
    #d.home() 
    b_lat = np.loadtxt('gal_lat_b.gz') 
    l_long = np.loadtxt('gal_long_l.gz')     
    for i in range (0, len(l_long), 1):
        #update log name    
        sys.stdout = open('obs_log_Apr_30_6_to_10pm.txt', 'a')
        b = b_lat[i]
        l = l_long[i]
        #lower LO frequency 
        s.set_freq(1272.4)
        s.set_amp(10.0) 
        try:         
            az, alt= gal_to_eq(b_lat[i], l_long[i])
            d.point(az, alt, validate=True)
        except ValueError: 
            print 'invalid pointing, skipping point'
            continue 
        #if pointing fails, will move on to the next pointing (go back to for loop) 
        while True:
            try: 
                d.point(az, alt)
                break
            except:
                print 'Pointing failed, trying again'
        while True:
            try:
                d.noise_off() 
                break
            except:
                print "Turning noise off failed, trying again"
        obs.date = ephem.now()
        LST = obs.sidereal_time()
        takespec.takeSpec('spec_low_freq_noise_off_%s_%s_%s_%s.gz' % (b, l, LST, date), numSpec=120)
        print 'low freq noise off spectra done, b = %s, l = %s' % (b, l) 
        while True:
            try:
                d.noise_on() 
                break
            except:
                print "Turning noise on failed, trying again"        
        obs.date = ephem.now() 
        LST = obs.sidereal_time()
        takespec.takeSpec('spec_low_freq_noise_on_%s_%s_%s_%s.gz' % (b, l, LST, date), numSpec=40)
        print 'low freq noise on spectra done, b = %s, l = %s' % (b, l)  

        #higher LO frequency                   
        s.set_freq(1268.4) 
        s.set_amp(10.0)
        try:
            az, alt= gal_to_eq(b_lat[i], l_long[i])
            d.point(az, alt,validate=True)
        except ValueError:
            print "invalid pointing, skipping point"
            continue 
        while True:
            try:
                d.point(az, alt)
                break
            except:
                print "Pointing failed, trying again"
        while True:
            try:
                d.noise_off()
                break
            except:
                print "Turning noise off failed, trying again"
        obs.date = ephem.now()
        LST = obs.sidereal_time()
        takespec.takeSpec('spec_up_freq_noise_off_%s_%s_%s_%s.gz' % (b, l, LST, date), numSpec=120)
        print 'upper lo freq noise off spectra done, b = %s, l = %s' % (b, l) 
        while True:
            try:
                d.noise_on()
                break
            except:
                print "Turning noise on failed, trying again"
        obs.date = ephem.now()         
        LST = obs.sidereal_time()
        takespec.takeSpec('spec_up_freq_noise_on_%s_%s_%s_%s.gz' % (b, l, LST, date), numSpec=40)
        print 'upper lo freq noise on spectra done, b = %s, l = %s' % (b, l) 
예제 #7
0
def record_pointing(d, s, l, b, point, file_name='raw/'+time.strftime("%m-%d-%Y_%H%M%S"),
        int_time=150, repoint_freq=30):
    """Records data from a point on the sky for a specified integration time.
    Spectra for an observation at two different LO frequencies and a separate
    10 second observation with the noise diode on are saved in the specified
    files.

    Args:
        d (dish.Dish): an interface to the Leuschner dish
        s (dish_synth.Synth): an interface to the synthesizer used to set the LO
          frequency
        file_name (String, optional): file name prefix to save the data
        int_time (float, optional): integration time (in seconds).
    """
    logger = logging.getLogger('leuschner')
    logger.debug('Recording data')
    status = 0

    # lets us keep data from this pointing in unique directory,
    # since each time we point we will have different noise/background spectrums
    record_id = time.strftime("%m-%d-%Y_%H%M%S")

    # Compute number of spectra to record (integration time/3)
    num_spec = int(int_time*3)
    num_spec_noise = 5 * 3

    OBS.date = ephem.now()
    point.compute(OBS)
    d.point(np.rad2deg(point.alt), np.rad2deg(point.az))

    # Take measurement with noise diode off at the higher LO frequency (ON frequency)
    s.set_freq(LO_ON)
    s.set_amp(10.0)
    d.noise_off()
    try:
        takespec.takeSpec(file_name+'_ON', numSpec=num_spec)
    except IOError:
        logger.error('%s not saved or averaged.' % (file_name+'_ON'))
        status = -1
    else:
        # Only want to average if the takespec was successful!
        averager.average(file_name+'_ON0.log', lo=LO_ON, l=l, b=b, record_id=record_id)

    # Take 10 second measurement with the noise diode on at the ON frequency
    d.noise_on()
    try:
        takespec.takeSpec(file_name+'_ON_noise', numSpec=num_spec_noise)
    except IOError:
        logger.error('%s not saved or averaged.' % (file_name+'_ON_noise'))
        status = -1
    else:
        averager.average(file_name+'_ON_noise0.log', lo=LO_ON, l=l, b=b, record_id=record_id, noise=True)

    # repoint for the second half of the measurement
    OBS.date = ephem.now()
    point.compute(OBS)
    d.point(np.rad2deg(point.alt), np.rad2deg(point.az))

    # Take 10 second measurement with the noise diode on at the OFF frequency
    s.set_freq(LO_OFF)
    s.set_amp(10.0)
    try:
        takespec.takeSpec(file_name+'_OFF_noise', numSpec=num_spec_noise)
    except IOError:
        logger.error('%s not saved or averaged.' % (file_name+'_OFF_noise'))
        status = -1
    else:
        averager.average(file_name+'_OFF_noise0.log', lo=LO_OFF, l=l, b=b, record_id=record_id, noise=True)

    d.noise_off()

    # Take measurement with noise diode off at the lower LO frequency (OFF frequency)
    s.set_freq(LO_OFF)
    s.set_amp(10.0)
    d.noise_off()
    try:
        takespec.takeSpec(file_name+'_OFF', numSpec=num_spec)
    except IOError:
        logger.error('%s not saved or averaged.' % (file_name+'_OFF'))
        status = -1
    else:
        averager.average(file_name+'_OFF0.log', lo=LO_OFF, l=l, b=b, record_id=record_id)

    logger.debug('Finished recording data')