Example #1
0
 def collection():
     global gps_times,lats,lons,alts
     global lati,loni,alti
     global lastlen
     global tmin,tmax,dt
     global counts,tbins#,weights
     global yourThread
     with dataLock: # Wait for lock on current thread
         gps_times,lats,lons,alts = get_data(opts.gps_file,filetype='gps')
         lati,loni,alti = interp_pos(gps_times.gps[:,0],lats,lons,alts)
         currlen = gps_times.shape[0]
         if currlen == lastlen:
             sleep(POOL_TIME)
         elif currlen > lastlen:
             lastlen = currlen
             tmin,tmax = gps_times.gps.min(),gps_times.gps.max()
             # Create weights array for check of GPS data when user queries server
             counts,tbins = np.histogram(gps_times.gps,bins=int((tmax-tmin)/dt))
     # Start the next thread
     yourThread = threading.Timer(POOL_TIME, collection, ())
     yourThread.start()
Example #2
0
 def collection():
     global gps_times, lats, lons, alts
     global lati, loni, alti
     global lastlen
     global tmin, tmax, dt
     global counts, tbins  #,weights
     global yourThread
     with dataLock:  # Wait for lock on current thread
         gps_times, lats, lons, alts = get_data(opts.gps_file,
                                                filetype='gps')
         lati, loni, alti = interp_pos(gps_times.gps[:, 0], lats, lons,
                                       alts)
         currlen = gps_times.shape[0]
         if currlen == lastlen:
             sleep(POOL_TIME)
         elif currlen > lastlen:
             lastlen = currlen
             tmin, tmax = gps_times.gps.min(), gps_times.gps.max()
             # Create weights array for check of GPS data when user queries server
             counts, tbins = np.histogram(gps_times.gps,
                                          bins=int((tmax - tmin) / dt))
     # Start the next thread
     yourThread = threading.Timer(POOL_TIME, collection, ())
     yourThread.start()
Example #3
0
        global yourThread
        # Create your thread
        yourThread = threading.Timer(POOL_TIME, collection, ())
        yourThread.start()

    # Initiate
    initialize()
    # When you kill Flask (SIGTERM), clear the trigger for the next thread
    atexit.register(interrupt)

    # Return app with get function
    return app


# Global variables
gps_times, lats, lons, alts = get_data(opts.gps_file, filetype='gps')
print gps_times.shape, lats.shape, lons.shape, alts.shape
lati, loni, alti = interp_pos(gps_times.gps[:, 0], lats, lons, alts)

# Get current number of GPS data points for monitoring of opts.gps_file
lastlen = gps_times.shape[0]
tmin, tmax = gps_times.gps.min(), gps_times.gps.max()

# Create weights array for check of GPS data when user queries server
dt = opts.dt
counts, tbins = np.histogram(gps_times.gps, bins=int((tmax - tmin) / dt))

# Create Lock object to access variables on an individual thread
dataLock = threading.Lock()

# Thread handler
Example #4
0
o = optparse.OptionParser()
o.set_description("Queries ground station server for interpolated GPS position")
o.add_option("--spec_file", type=str, help="Accumulated file for plotting")
o.add_option("--freq", type=float, default=137.5, help="Peak frequency to look for in data")
o.add_option("--width", type=int, default=500, help="Number of channels to include in spectrum analysis")
opts, args = o.parse_args(sys.argv[1:])


fmin, fmax = int(opts.freq) - 1, int(opts.freq) + 1  # MHz; for plotting
time_range = 200
rmswindow = 10
start_ind = 0

# Get initial data from Signal Hound
spec_times, spec_raw, freqs, freq_chan = get_data(opts.spec_file, filetype="sh", freq=opts.freq, width=opts.width)
print spec_times.shape, spec_raw.shape, freqs.shape
freq_chan = np.where(np.abs(freqs - opts.freq).min() == np.abs(freqs - opts.freq))[0]
print "\nReading %s..." % opts.spec_file
print "Frequency plotting: %.3f" % freqs[freq_chan]
# freqs -= 0.005
# print freqs.shape,spec_raw.shape
if spec_times.shape[0] == 0:  # Ensure data in inFile
    print "Invalid data: array with zero dimension\nExiting...\n"
    sys.exit()

# Initialize plotting figure
fig = plt.figure(figsize=(16, 9), dpi=80, facecolor="w", edgecolor="w")
# mng = plt.get_current_fig_manager() # Make figure full screen
fig.suptitle("ECHO Realtime Spectrum: %s" % opts.spec_file, fontsize=16)
Example #5
0
        global yourThread
        # Create your thread
        yourThread = threading.Timer(POOL_TIME, collection, ())
        yourThread.start()

    # Initiate
    initialize()
    # When you kill Flask (SIGTERM), clear the trigger for the next thread
    atexit.register(interrupt)

    # Return app with get function
    return app


# Global variables
gps_times,lats,lons,alts = get_data(opts.gps_file,filetype='gps')
print gps_times.shape,lats.shape,lons.shape,alts.shape
lati,loni,alti = interp_pos(gps_times.gps[:,0],lats,lons,alts)

# Get current number of GPS data points for monitoring of opts.gps_file
lastlen = gps_times.shape[0]
tmin,tmax = gps_times.gps.min(),gps_times.gps.max()

# Create weights array for check of GPS data when user queries server
dt = opts.dt
counts,tbins = np.histogram(gps_times.gps,bins=int((tmax-tmin)/dt))

# Create Lock object to access variables on an individual thread
dataLock = threading.Lock()

# Thread handler
Example #6
0
             default=137.5,
             help='Peak frequency to look for in data')
o.add_option('--width',
             type=int,
             default=500,
             help='Number of channels to include in spectrum analysis')
opts, args = o.parse_args(sys.argv[1:])

fmin, fmax = int(opts.freq) - 1, int(opts.freq) + 1  # MHz; for plotting
time_range = 200
rmswindow = 10
start_ind = 0

# Get initial data from Signal Hound
spec_times, spec_raw, freqs, freq_chan = get_data(opts.spec_file,
                                                  filetype='sh',
                                                  freq=opts.freq,
                                                  width=opts.width)
print spec_times.shape, spec_raw.shape, freqs.shape
freq_chan = np.where(
    np.abs(freqs - opts.freq).min() == np.abs(freqs - opts.freq))[0]
print '\nReading %s...' % opts.spec_file
print 'Frequency plotting: %.3f' % freqs[freq_chan]
#freqs -= 0.005
#print freqs.shape,spec_raw.shape
if spec_times.shape[0] == 0:  # Ensure data in inFile
    print 'Invalid data: array with zero dimension\nExiting...\n'
    sys.exit()

# Initialize plotting figure
fig = plt.figure(figsize=(16, 9), dpi=80, facecolor='w', edgecolor='w')
#mng = plt.get_current_fig_manager() # Make figure full screen