def getKnownPlaneTracks(ignore_planes=[]):
    '''
    Given the plane information outlines in loadKnownPlaneDict this will return
    a compisite dtype array with information about lat, lon, alt, and timing for
    each unique reported position of each plane in loadKnownPlaneDict.

    This can then be interpolated by the user at timestamps to get expected
    position corresponding to events in a run. 
    '''
    try:
        known_planes = info.loadKnownPlaneDict(ignore_planes=ignore_planes)
        output_tracks = {}
        calibrated_trigtime = {}
        for key in list(known_planes.keys()):
            runs = numpy.unique(known_planes[key]['eventids'][:, 0])
            calibrated_trigtime[key] = numpy.zeros(
                len(known_planes[key]['eventids'][:, 0]))
            for run in runs:
                run_cut = known_planes[key]['eventids'][:, 0] == run
                reader = Reader(os.environ['BEACON_DATA'], run)
                eventids = known_planes[key]['eventids'][run_cut, 1]
                try:
                    filename = createFile(
                        reader
                    )  #Creates an analysis file if one does not exist.  Returns filename to load file.
                    with h5py.File(filename, 'r') as file:
                        calibrated_trigtime[key][run_cut] = file[
                            'calibrated_trigtime'][...][eventids]
                except Exception as e:
                    print(e)
                    exc_type, exc_obj, exc_tb = sys.exc_info()
                    fname = os.path.split(
                        exc_tb.tb_frame.f_code.co_filename)[1]
                    print(exc_type, fname, exc_tb.tb_lineno)
                    print('Calculating calibrated trig times.')
                    calibrated_trigtime[key][run_cut] = getEventTimes(
                        reader, plot=False, smooth_window=101)[eventids]

            known_flight = known_planes[key]['known_flight']
            all_vals = getTracks(min(calibrated_trigtime[key]),
                                 max(calibrated_trigtime[key]),
                                 1000,
                                 hour_window=12)[1]
            vals = all_vals[all_vals['names'] == known_planes[key]
                            ['known_flight']]
            vals = vals[numpy.unique(vals['timestamps'], return_index=True)[1]]
            output_tracks[key] = vals
        return known_planes, calibrated_trigtime, output_tracks
    except Exception as e:
        print('Error in getKnownPlaneTracksLatLon.')
        print(e)
        exc_type, exc_obj, exc_tb = sys.exc_info()
        fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
        print(exc_type, fname, exc_tb.tb_lineno)
示例#2
0
        save = True
        plot = False
        reader = Reader(datapath, run)
        try:
            print(reader.status())
        except Exception as e:
            print('Status Tree not present.  Returning Error.')
            print('\nError in %s' % inspect.stack()[0][3])
            print(e)
            exc_type, exc_obj, exc_tb = sys.exc_info()
            fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
            print(exc_type, fname, exc_tb.tb_lineno)
            sys.exit(1)

        filename = createFile(
            reader
        )  #Creates an analysis file if one does not exist.  Returns filename to load file.

        if filename is not None:
            with h5py.File(filename, 'a') as file:
                tdc = TimeDelayCalculator(
                    reader,
                    final_corr_length=final_corr_length,
                    crit_freq_low_pass_MHz=crit_freq_low_pass_MHz,
                    crit_freq_high_pass_MHz=crit_freq_high_pass_MHz,
                    low_pass_filter_order=low_pass_filter_order,
                    high_pass_filter_order=high_pass_filter_order,
                    waveform_index_range=(None, None),
                    plot_filters=False,
                    apply_phase_response=apply_phase_response)
                if sine_subtract:
示例#3
0
        print(exc_type, fname, exc_tb.tb_lineno)
        sys.exit(1)


if __name__ == '__main__':
    plt.close('all')
    if len(sys.argv) == 2:
        run = int(sys.argv[1])
    else:
        run = 1700
    datapath = os.environ['BEACON_DATA']
    normalize_by_window_index = True

    for run in [1721]:
        reader = Reader(datapath, run)
        filename = createFile(reader)
        print(filename)
        with h5py.File(filename, 'r') as file:
            try:
                load_cut = file['trigger_type'][...] == 2
                calibrated_trig_time = file['calibrated_trigtime'][load_cut]
                randomized_times = numpy.sort(
                    numpy.random.uniform(low=calibrated_trig_time[0],
                                         high=calibrated_trig_time[-1],
                                         size=(len(calibrated_trig_time), )))

                if False:
                    for window_s in [1, 5, 10, 20, 60, 120, 360]:
                        metric_true = diffFromPeriodic(
                            calibrated_trig_time,
                            window_s=window_s,