Пример #1
0
def create_sync_servo(servo_file, offsets, utcc, ut, sci_cc, freq):
    """Create synchronized servo data

    Parameters
    ----------
    servo_file : srt
        filename of servo data
    offsets : ndarray
        CC offsets computed from gpstime, see find_clock_offsets_from_gpstime
    utcc : ndarray
        CC array related to UT
    ut : ndarray
        UT array
    sci_cc : ndarray
        CC array of scientific data
    freq : int
        frequency
    """

    print("Create synchronized servo data to %dGHz" % freq)
    filename = '%s_%dGHz_servo.fits' % (os.path.basename(servo_file).split('.')[0], freq)
    print('Writing ' + filename)
    f = fits.create(filename)
    ext = OrderedDict()
    ext['COMPUTERCLOCK'] = sci_cc
    ext['UT'] = np.interp(sci_cc, utcc, ut)
    f.write_HDU('TIME', ext)
    for device in DEVICES:
        print('Processing ' + device)
        raw_data = fits.read(servo_file, device)
        ext = OrderedDict()
        cc = apply_cc_offsets(raw_data['COMPUTERCLOCK'], offsets)
        for colname, colarray in raw_data.iteritems():
            if colname != 'COMPUTERCLOCK':
                print('Column ' + colname)
                ext[colname] = np.interp(sci_cc, cc, colarray)
        f.write_HDU(device, ext)
    f.close()
Пример #2
0
def create_sync_servo(servo_file, offsets, utcc, ut, sci_cc, freq):
    """Create synchronized servo data

    Parameters
    ----------
    servo_file : srt
        filename of servo data
    offsets : ndarray
        CC offsets computed from gpstime, see find_clock_offsets_from_gpstime
    utcc : ndarray
        CC array related to UT
    ut : ndarray
        UT array
    sci_cc : ndarray
        CC array of scientific data
    freq : int
        frequency
    """

    print("Create synchronized servo data to %dGHz" % freq)
    filename = '%s_%dGHz_servo.fits' % (os.path.basename(servo_file).split('.')[0], freq)
    print('Writing ' + filename)
    f = fits.create(filename)
    ext = OrderedDict()
    ext['COMPUTERCLOCK'] = sci_cc
    ext['UT'] = np.interp(sci_cc, utcc, ut)
    f.write_HDU('TIME', ext)
    for device in DEVICES:
        print('Processing ' + device)
        raw_data = fits.read(servo_file, device)
        ext = OrderedDict()
        cc = apply_cc_offsets(raw_data['COMPUTERCLOCK'], offsets)
        for colname, colarray in raw_data.iteritems():
            if colname != 'COMPUTERCLOCK':
                print('Column ' + colname)
                ext[colname] = np.interp(sci_cc, cc, colarray)
        f.write_HDU(device, ext)
    f.close()
servo_lon = np.degrees(servo_file['GYRO_HID'].read_column('HYBRIDLONGITUDE'))
good_lon = servo_good & (servo_lon > -114) & (servo_lon < -86)
lon = np.radians(np.interp(ut, servo_ut[good_lon], servo_lon[good_lon]))

def conv(i, azimuth, elevation, utc):
    observer = ephem.Observer()
    observer.lon = lon[i]
    observer.lat = lat[i]
    observer.elevation = alt[i]  
    observer.date = utc
    return observer.radec_of(azimuth, elevation)

out_filename = 'data/eq_pointing_%d.fits' % (freq)
if mag:
    out_filename = out_filename.replace('.fits','_mag.fits')
with fits.create(out_filename) as f:
    f.write_HDU("TIME", OrderedDict({'UT': ut}))
    for pnt_ch in channels:
        print("Channel %d" % pnt_ch)
        az = np.radians(pointing_file[0].read_column('az%d' % pnt_ch)[good])
        el = np.radians(pointing_file[0].read_column('el%d' % pnt_ch)[good])

        ra = []
        dec = []
        for i in range(0, len(ut)):
            if i % 100000 == 0:
                print("%.1d perc" % (i * 100./len(ut)))
            ra_i, dec_i = conv(i, az[i], el[i], START_DATE+datetime.timedelta(ut[i]/24.))
            ra.append(ra_i)
            dec.append(dec_i)
import sys
import os
import glob
from demodulation import demodulate_dat

sys.path.append(os.path.join(os.path.dirname(__file__),'..'))
from cofe_io import fits

folder = sys.argv[1]
refs = sorted(glob.glob(os.path.join(folder, '*.dat')))
n_files = len(refs)

import pycfitsio

for n, ref in enumerate(refs):
    print("Processing %d/%d: %s" % (n, n_files, ref))
    fname = ref.replace('.dat','.fits')

    f = pycfitsio.create(fname)
    f.write_HDU('DATA', demodulate_dat(ref))
    f.close()
Пример #5
0
servo_lon = np.degrees(servo_file['GYRO_HID'].read_column('HYBRIDLONGITUDE'))
good_lon = servo_good & (servo_lon > -114) & (servo_lon < -86)
lon = np.radians(np.interp(ut, servo_ut[good_lon], servo_lon[good_lon]))

def conv(i, azimuth, elevation, utc):
    observer = ephem.Observer()
    observer.lon = lon[i]
    observer.lat = lat[i]
    observer.elevation = alt[i]  
    observer.date = utc
    return observer.radec_of(azimuth, elevation)

out_filename = 'data/eq_pointing_%d.fits' % (freq)
if mag:
    out_filename = out_filename.replace('.fits','_mag.fits')
with fits.create(out_filename) as f:
    f.write_HDU("TIME", OrderedDict({'UT': ut}))
    for pnt_ch in channels:
        print("Channel %d" % pnt_ch)
        az = np.radians(pointing_file[0].read_column('az%d' % pnt_ch)[good])
        el = np.radians(pointing_file[0].read_column('el%d' % pnt_ch)[good])

        ra = []
        dec = []
        for i in range(0, len(ut)):
            if i % 100000 == 0:
                print("%.1d perc" % (i * 100./len(ut)))
            ra_i, dec_i = conv(i, az[i], el[i], START_DATE+datetime.timedelta(ut[i]/24.))
            ra.append(ra_i)
            dec.append(dec_i)