Exemplo n.º 1
0
def load_file(filename):
    spec = s6fits.s6dataspec_t()
    spec.filename = filename
    spec.sortby_rfreq = 0
    spec.sortby_time = 0
    spec.sortby_bors = 0
    #spec.sortby_ifreq = 0
    # Setting up this mode will remove all those hits which shows change of RF due to
    # smart frequency switching experiment. It only reads those hits which occur maximum number of time.
    spec.filterby_rf_center_mode = 1
    #Get hits from file
    s6fits.get_s6data(spec)

    hitnum = int(s6fits.get_hits_over_file(spec.filename))

    m_rfreq = []
    m_unix_time = []
    m_meanpower = []

    base_filename = ntpath.basename(spec.filename)

    start_time = spec.s6hits[0].unix_time
    #MARK for i in range(0,hitnum-1):
    for i in range(hitnum):
        if spec.s6hits[i].unix_time == start_time:
            m_rfreq.append(spec.s6hits[i].rfreq)
            m_unix_time.append(spec.s6hits[i].unix_time)
            m_meanpower.append(spec.s6hits[i].mean_power)
        else:
            break
    sort_rfreq_index = np.argsort(m_rfreq)
    sort_rfreq = np.array(m_rfreq)[sort_rfreq_index]
    sort_meanpower = np.array(m_meanpower)[sort_rfreq_index]

    return sort_meanpower, sort_rfreq, base_filename
Exemplo n.º 2
0
def get_size_and_hits(filename, file_list):
  hits_size_file = []
  spec = s6fits.s6dataspec_t()
  spec.filename = filename  
  s6fits.get_s6data(spec)
  total_hits = 0
  for hit in spec.s6hits:
    total_hits += 1 
  hits_size_file = [filename, 
                    (os.stat(filename).st_size/(1024*1024)),
                    total_hits]
  file_list.append(hits_size_file)  
  return file_list
Exemplo n.º 3
0
def get_size_and_hits(filename, file_list):
    hits_size_file = []
    spec = s6fits.s6dataspec_t()
    spec.filename = filename
    s6fits.get_s6data(spec)
    total_hits = 0
    for hit in spec.s6hits:
        total_hits += 1
    hits_size_file = [
        filename, (os.stat(filename).st_size / (1024 * 1024)), total_hits
    ]
    file_list.append(hits_size_file)
    return file_list
Exemplo n.º 4
0
def plot_multi_with_gnuplot(filelist):
	spec = s6fits.s6dataspec_t()
	
#	return sort_meanpower[:q], sort_ifreq[:q], base_filename
	sort_meanpower = []
	sort_ifreq = []
	base_filename = ''
	for filename in filelist:
		sort_meanpower_, sort_ifreq_, base_filename_ = load_file(filename,spec)
		sort_meanpower.append(sort_meanpower_)
		sort_ifreq.append(sort_ifreq_)
		base_filename = base_filename + base_filename_ + ','
		# Set a break points
		#pdb.set_trace()

	# Set breakpoint
	#pdb.set_trace()

	meanpower = np.hstack(sort_meanpower)
	ifreq = np.hstack(sort_ifreq)
	base_filename = base_filename[:-1]
	assert len(ifreq.shape) == 1,'ifreq should be of shape (n,)'
	
	data_filename = base_filename+".bb_data"
	plot_filename = base_filename+".bb.png"
	 	
	data_f=open(data_filename, 'w')
	for x in range(len(ifreq)):
		print >> data_f, meanpower[x], ifreq[x]	
	data_f.close()
	cmd = 'set term png; set out "%s";                \
			set title "%s"; unset key;                \
		   	set xl "ifreq"; set yl "Mean Power"; \
			plot "%s" using 2:1 with line;'           \
			% (plot_filename, base_filename, data_filename)
	cmd_f=open("baseband_gnuplot_cmds", 'w')
	print >> cmd_f, cmd
	cmd_f.close()
	os.system('gnuplot baseband_gnuplot_cmds')
	os.remove("baseband_gnuplot_cmds")
Exemplo n.º 5
0
def main():
  if sys.argv is None:
    print "provide a valid fits file to run this"
    exit()
  """
  initialize your dataspec_t object. For now you must initialize it with no
  arguments and fill them in subsequent lines. If you only specify filename, the
  program will assume you want all the hits in the file you provide.
  """ 
  dataspec = s6fits.s6dataspec_t()
  dataspec.filename = sys.argv[1]
  dataspec.sortby_bors = 0
  dataspec.sortby_time = 0
  dataspec.sortby_ifreq = 0
  dataspec.sortby_rfreq = 0
  """
  get_s6data() will either create a new s6fits vector, or if your dataspec
  includes a vector, it will add hits to it. Right now we have no vector of hits
  we want to add to so we'll just leave it empty.
  """  
  s6fits.get_s6data(dataspec)
  s6fits.print_hits_table(dataspec.s6hits)
Exemplo n.º 6
0
def main():
  if sys.argv is None:
    print "provide a valid fits file to run this"
    exit()
  """
  initialize your dataspec_t object. For now you must initialize it with no
  arguments and fill them in subsequent lines. If you only specify filename, the
  program will assume you want all the hits in the file you provide.
  """ 
  dataspec = s6fits.s6dataspec_t()
  dataspec.filename = sys.argv[1]
  dataspec.sortby_bors = 0
  dataspec.sortby_time = 0
  dataspec.sortby_ifreq = 0
  dataspec.sortby_rfreq = 0
  dataspec.filterby_rf_reference_mode = 1
  """
  get_s6data() will either create a new s6fits vector, or if your dataspec
  includes a vector, it will add hits to it. Right now we have no vector of hits
  we want to add to so we'll just leave it empty.
  """  
  s6fits.get_s6data(dataspec)
  s6fits.print_hits_table(dataspec.s6hits)
Exemplo n.º 7
0
    #plt.plot(y,x,marker='.',)
    start_time = time.time()
    plt.hist(x, bins=1000)
    end_time = time.time()
    print("make plot was %g seconds" % (end_time - start_time))

    plt.xticks(np.arange(min(x), max(x) + 1, 10, dtype=int))

    start_time = time.time()
    plt.show()
    end_time = time.time()
    print("show plot was %g seconds" % (end_time - start_time))


if __name__ == "__main__":
    spec = s6fits.s6dataspec_t()

    spec.filename = sys.argv[1]

    #Set various data spec
    spec.sortby_rfreq = 0
    spec.sortby_time = 0
    spec.sortby_bors = 0
    spec.sortby_ifreq = 0

    # Setting up this mode will remove all those hits which shows change of RF due to
    # smart frequency switching experiment. It only reads those hits which occur maximum number of time.

    spec.filterby_rf_center_mode = 1

    #Get hits from file
Exemplo n.º 8
0
def s6fits_test(filename):
  spec = s6fits.s6dataspec_t()
  spec.filename = filename
  s6fits.get_s6data(spec)
Exemplo n.º 9
0
def run_s6(filename):
  spec = s6fits.s6dataspec_t()
  spec.filename = filename  
  s6fits.get_s6data(spec)
Exemplo n.º 10
0
def s6fits_test(filename):
    spec = s6fits.s6dataspec_t()
    spec.filename = filename
    s6fits.get_s6data(spec)
Exemplo n.º 11
0
import s6fits

a = s6fits.s6dataspec_t()
a.filename = "serendip6_eth2_AO_ALFA_2820_20150609_130436.fits"
s6fits.get_s6data(a)
vec = a.s6hits

for i in vec:
  print (i.ra)