示例#1
0
def read_atl09_ancillary_data(atl09filepath):
    # Iterate through keys for ancillary data
    subgroup = '/ancillary_data/'
    keys = getH5Keys(atl09filepath, subgroup)
    key_info = get_H5_keys_info(atl09filepath, subgroup)
    
    byte_encoded = ['control', 'data_start_utc', 'data_end_utc',
                    'granule_start_utc', 'granule_end_utc']
    
    # Read each key, put it in pandas df
    for idx, key in enumerate(keys):
        data = readAtlH5(atl09filepath, subgroup + '/' + key + '/')
        
        if np.isin(key, ['release', 'version']):
            data = int(data)
            
        if np.isin(key, byte_encoded):
            data = data[0]             
            data = data.decode('utf-8')
        
        if key_info[idx][1] != 'Group':
            if len(key.split('/')) == 1:
                if idx == 0:
                    df = pd.Series(data,
                                   index=[key.split('/')[-1]],
                                   dtype=object)
                else:
                    df = pd.concat(
                        [df, pd.Series(data, 
                                       index=[key.split('/')[-1]],
                                       dtype=object)])
            
    return df
示例#2
0
def check_for_matching_segments(atl09file, atl03file_list, atl09basepath,
                                atl03basepath):
    atl03_overlap_with_atl09 = pd.DataFrame(
        columns=['starting_seg', 'ending_seg'])

    if len(atl03file_list) == 0:
        print('WARNING No matching atl03 file found')
    else:
        atl09_segment_ids = readAtlH5(atl09basepath + atl09file,
                                      'profile_1/high_rate/segment_id')
        sc_orient = readAtlH5(atl09basepath + atl09file,
                              'orbit_info/sc_orient')

        if len(sc_orient) == 1 and sc_orient[0] == 0:
            gt = 'gt1l'
        elif len(sc_orient) == 1 and sc_orient[0] == 1:
            gt = 'gt1r'
        else:
            print(
                'WARNING the spacecraft transitions orientation during this granule'
            )

        for atl03file in atl03file_list:
            atl03_segment_ids = readAtlH5(atl03basepath + atl03file,
                                          gt + '/geolocation/segment_id')

            segments_in_both = np.isin(atl09_segment_ids, atl03_segment_ids)
            if np.any(segments_in_both):
                starting_seg = atl09_segment_ids[segments_in_both][0]
                ending_seg = atl09_segment_ids[segments_in_both][-1]
                atl03_overlap_with_atl09.loc[atl03file,
                                             'starting_seg'] = starting_seg
                atl03_overlap_with_atl09.loc[atl03file,
                                             'ending_seg'] = ending_seg

    return atl03_overlap_with_atl09
示例#3
0
def read_atl09_orbit_info(atl09filepath):

    subgroup = '/orbit_info/'
    keys = getH5Keys(atl09filepath, subgroup)
    key_info = get_H5_keys_info(atl09filepath, subgroup)

    # Read each key, put it in pandas df
    for idx, key in enumerate(keys):
        data = readAtlH5(atl09filepath, subgroup + '/' + key + '/')
        if idx == 0:
            df = pd.Series(data, index=[key], dtype=object)
        else:
            df_key = pd.Series(data, index=[key], dtype=object)
            df = pd.concat([df, df_key])

    return df
示例#4
0
def read_atl09_hr_profile(atl09filepath, gt):
    # Iterate through keys for "Land Segments"
    subgroup = 'profile_' + gt[2] + '/high_rate/'
    keys = getH5Keys(atl09filepath, subgroup)
    key_info = get_H5_keys_info(atl09filepath, subgroup)
    # Read each key, put it in pandas df
    for idx, key in enumerate(keys):
        data = readAtlH5(atl09filepath, subgroup + '/' + key + '/')
        if key == 'ds_layers':
            ds_layers = np.array(data)
        elif key == 'ds_va_bin_h':
            ds_va_bin_h = np.array(data)
        elif key == 'cab_prof':
            cab_prof = np.array(data)
        elif key == 'density_pass1':
            density_pass1 = np.array(data)
        elif key == 'density_pass2':
            density_pass2 = np.array(data)
        else:

            if key_info[idx][1] != 'Group':
                if idx == 0:
                    df = pd.DataFrame(data, columns=[key.split('/')[-1]])
                else:
                    if len(data.shape) == 2:
                        cols = data.shape[1]
                        for idx2 in range(0, cols):
                            df = pd.concat(
                                [df,pd.DataFrame(data[:,idx2],columns=\
                                                 [key.split('/')[-1] +'_' +
                                                  str(idx2)])],axis=1)
                    else:
                        df = pd.concat(
                            [df,pd.DataFrame(data,columns=\
                                             [key.split('/')[-1]])],axis=1)

    return df, ds_layers, ds_va_bin_h, cab_prof, density_pass1, density_pass2