Exemplo n.º 1
0
def filePaths_by_stationName(timeID, raw_data_loc=None):
    """Given a timeID, and a location of raw data (default set in utilities.py), return a dictionary.
    The keys of the dictionary are antenna names, the values are lists of file paths to data files that contain that station."""

    data_file_path = util.raw_data_dir(timeID, raw_data_loc)
    h5_files = [f for f in os.listdir(data_file_path) if f[-6:] == 'tbb.h5']

    ret = {}
    for fname in h5_files:
        Fpath = data_file_path + '/' + fname
        junk, sname, junk, junk = util.Fname_data(Fpath)

        if sname not in ret:
            ret[sname] = []

        ret[sname].append(Fpath)

    return ret
Exemplo n.º 2
0
def eventData_filePaths(timeID, raw_data_loc=None):
    """Given a timeID, and a location of raw data (default set in utilities.py), return a list of file paths of data files"""
    data_file_path = util.raw_data_dir(timeID, raw_data_loc)
    return [f for f in os.listdir(data_file_path) if f[-6:] == 'tbb.h5']
Exemplo n.º 3
0
        datetime.fromtimestamp(TBB_data.get_timestamp()), max_dt)
    print()
    print(len(revisions), 'calibration revisions')

    if len(revisions) == 0:
        quit()

    best_revision = None
    best_RMS = np.inf
    for rev_i, revision in enumerate(revisions):
        ## load new calibrations
        print()
        print(revision, '(', rev_i + 1, '/', len(revisions), ')')
        get_phase_callibration(station,
                               revision,
                               raw_data_dir(timeID),
                               mode,
                               force=True)

        new_delays = TBB_data.get_timing_callibration_delays()
        diff = new_delays - file_delays
        diff *= diff
        RMS = np.average(diff)
        print("  RMS:", RMS)

        if RMS < best_RMS:
            best_revision = revision
            best_RMS = RMS

    print()
    print("setting best revision:", best_revision)
Exemplo n.º 4
0
if __name__ == "__main__":
    #### a full working example of opening a file, checking if it needs metadata, and downloading if necisary
    
    timeID = "D20180308T170417.500Z"
    history_folder = "./svn_phase_cal_history"
    get_all_timings = True ## if false, only gets ones needed
    mode = 'LBA_OUTER' ## set to None to get ALL files.
    
    skip = [] ##stations to skip
    
    
    if not isdir(history_folder):
        mkdir(history_folder)
        
    fpaths = filePaths_by_stationName(timeID)
    stations = fpaths.keys()
    
    for station in stations:
        if station in skip:
            continue
    
        TBB_data = MultiFile_Dal1( fpaths[station] )
        timestamp = datetime.fromtimestamp( TBB_data.get_timestamp() )
        
        if get_all_timings or TBB_data.needs_metadata():
            print("downloading for station:", station)
            download_phase_callibrations(station, history_folder, timestamp, utils.raw_data_dir(timeID), mode )
            
        print( station)
        print( TBB_data.get_timing_callibration_delays() )
Exemplo n.º 5
0
    from LoLIM.definitions import definitions
    D = definitions()

    timeID = D.timeID
    history_folder = "./svn_phase_cal_history"
    get_all_timings = True  ## if false, only gets ones needed

    skip = []  ##stations to skip

    if not isdir(history_folder):
        mkdir(history_folder)

    fpaths = filePaths_by_stationName(timeID)
    stations = fpaths.keys()

    for station in stations:
        if station in skip:
            continue

        TBB_data = MultiFile_Dal1(fpaths[station])
        timestamp = datetime.fromtimestamp(TBB_data.get_timestamp())

        if get_all_timings or TBB_data.needs_metadata():
            print("downloading for station:", station)
            download_phase_callibrations(station, history_folder, timestamp,
                                         utils.raw_data_dir(timeID))

        print(station)
        print(TBB_data.get_timing_callibration_delays())
Exemplo n.º 6
0
 ### now loop over available calibrations
     
 prev = None
 min_delta = 1.0E-10 ## if difference in calibration is smaller, then skip
 best_revision = None
 best_RMS = np.inf
 best_combined_RMSs = None
 even_antenna_RMSs = None
 odd_antenna_RMSs = None
 even_antenna_SecDer = None
 odd_antenna_SecDer = None
 for rev_i, revision in enumerate(revisions):
     ## load new calibrations
     if actually_find_callibration:
         print(sname, revision, '(', rev_i+1, '/', len(revisions), ')')
         get_phase_callibration( sname, revision,  raw_data_dir(timeID), mode, force=True )
     
     new = TBB_data.get_timing_callibration_delays()
     if prev is not None: ## check is really necisary to find planewaves
         new -= prev
         np.abs(new,out=new)
         if not np.any( new>min_delta ):
             print('skipping!')
             print()
             print()
             continue
     
     prev = new
     
     ## fit planewaves with new callibrations
     even_RMSs, throw, throw, even_ant_fits = fitter_even.go_fit( max_RMS = RMS_cut)