Пример #1
0
def test_guppi():
    gr = GuppiRaw(voyager_raw)
    h1, data_block_x1, data_block_y1 = gr.read_next_data_block_int8()
    h2, data_block_x2, data_block_y2 = gr.read_next_data_block_int8()

    assert not np.array_equal(data_block_x1, data_block_x2) and not np.array_equal(data_block_y1, data_block_y2) \
        , "Data read from two blocks should not be equal"

    gr = GuppiRaw(voyager_raw)
    h1, data_block_1 = gr.read_next_data_block()

    data_block_reference_1 = np.load(voyager_block1)

    assert np.array_equal(data_block_1[:, :1000, :], data_block_reference_1) \
        , "Data read should be consistent with previous versions"

    data_block_casted_1 = np.append(data_block_x1, data_block_y1, axis=2).astype('float32').view('complex64')

    assert np.array_equal(data_block_1, data_block_casted_1) \
        , "Reading as int8 then casting should be equal to reading directly as complex64"
Пример #2
0
#--------------------------------------
# Fun
#--------------------------------------

start_time = time.time()

#os.system('rm '+outfile)
#if output_bool:
#	print('Saving replaced data to '+outfile)
#	os.system('cp '+infile+' '+outfile)
#	out_rawFile = open(outfile,'rb+')

#load file and copy
print('Opening file: ' + infile)
rawFile = GuppiRaw(infile)
print('Loading copy...')
#assuming python3 here

numblocks = rawFile.find_n_data_blocks()
print('File has ' + str(numblocks) + ' data blocks')

for block in range(numblocks):
    print('------------------------------------------')
    print('Block: ' + str(block))
    if block == 0:
        header, headersize = rawFile.read_header()
        print('Header size: {} bytes'.format(headersize))
    header, data = rawFile.read_next_data_block()

    #print header for the first block
Пример #3
0
#pulls from my scratch directory if full path not given
if sys.argv[1][0] != '/':
    inputFileName = my_dir + sys.argv[1]
else:
    inputFileName = sys.argv[1]

outdir = my_dir + sys.argv[2] + '/'
os.system('mkdir ' + outdir)

#-----------------------------
# Science
#-----------------------------

print('Opening file: ' + inputFileName)
rawFile = GuppiRaw(inputFileName)

numblocks = rawFile.find_n_data_blocks()
print('File has ' + str(numblocks) + ' data blocks')

for blockNumber in range(numblocks):
    print('---------------------')
    print('Block ' + str(blockNumber + 1) + ' of ' + str(numblocks))

    header, data = rawFile.read_next_data_block(blockNumber)
    if blockNumber == 0:
        print('Datatype: ' + str(type(data[0, 0, 0])))
        for line in header:
            print(line + ':  ' + str(header[line]))

    if blockNumber < 10:
Пример #4
0
def todo_test_guppi():
    filename = 'blc1_guppi_57388_HIP113357_0010.0002.raw'

    guppi = GuppiRaw(filename)

    print(guppi)

    header = guppi.read_first_header()

    pprint(header)

    guppi.read_header()
    guppi.find_n_data_blocks()
    header, idx = guppi.read_header()
    header, data = guppi.read_next_data_block()
    header, data = guppi.read_next_data_block()
    header, data = guppi.read_next_data_block()
    guppi.reset_index()
Пример #5
0
#array to hold spectrum results
spect_orig_p1 = []
spect_orig_p2 = []
spect_excised_p1 = []
spect_excised_p2 = []

#--------------------------------------
# Fun
#--------------------------------------

start_time = time.time()

#load file and copy
print('Opening file: ' + infile_orig)
rawFile_orig = GuppiRaw(infile_orig)
print('Opening file: ' + infile_excised)
rawFile_yeet = GuppiRaw(infile_excised)

numblocks = rawFile_orig.find_n_data_blocks()
print('File has ' + str(numblocks) + ' data blocks')

for block in range(numblocks):
    print('#--------------------------------------')
    print('Block: ' + str(block))
    if block == 0:
        header, headersize = rawFile_orig.read_header()
        print('Header size: {} bytes'.format(headersize))
    header, data = rawFile_orig.read_next_data_block()
    header, yeet = rawFile_yeet.read_next_data_block()
Пример #6
0
import sys, os
import numpy as np
import matplotlib.pyplot as plt
import time

from blimpy import GuppiRaw

out_dir = '/home/scratch/esmith/'
out_filename = out_dir + 'test_ps.npy'

in_dir = '/data/rfimit/unmitigated/rawdata/'

#ON scan
ON_filename_1 = sys.argv[1]
print('Loading ON scan...')
ON_file = GuppiRaw(in_dir + ON_filename_1)

#OFF scan
OFF_filename_1 = sys.argv[2]
print('Loading OFF scan...')
OFF_file = GuppiRaw(in_dir + OFF_filename_1)

out_dir = '/home/scratch/esmith/'
out_filename = out_dir + '16.npy'

numblocks = ON_file.find_n_data_blocks()
print('Files have ' + str(numblocks) + ' data blocks')

for block in range(numblocks):
    print('------------------------------------------')
    print('Block: ' + str(block))
Пример #7
0
#simply reads the header of a BTL/GUPPI raw file data block for basic file info

import sys, os
from blimpy import GuppiRaw
import numpy as np

my_dir = '/home/scratch/esmith/RFI_MIT/'

#pulls from my scratch directory if full path not given
if sys.argv[1][0] != '/':
    inputFileName = my_dir + sys.argv[1]
else:
    inputFileName = sys.argv[1]

print('Reading in GUPPI raw file...')
r = GuppiRaw(inputFileName)

print('Parsing Header...')
hdr, data = r.read_header()

print('----------------------------------')
for line in hdr:
    print(line + ':  ' + str(hdr[line]))
print('----------------------------------')

print('Number of blocks: ' + str(r.find_n_data_blocks()))
print('Reading data shape...')
print('This may take a while, feel free to kill the process')

#hdr,data = r.read_next_data_block(0)