Commit 7737986b authored by Sigurd M. Albrektsen's avatar Sigurd M. Albrektsen
Browse files

Added ENU to mats by rtklib2matlab.py

parent 6c379ec9
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -52,6 +52,7 @@ if __name__ == '__main__':
     'sdz', 'sdxy', 'sdyz', 'sdzx', 'age', 'ratio']

    n_lines = 0
    ref_pos = None
    with open(infile, 'rU') as f:
        for line in f:
            if line.startswith('%'):
@@ -69,6 +70,9 @@ if __name__ == '__main__':
                    names = [handle_name(name) for name in split_line(line.strip('% '))]
                    if names[0] == 'gpst':
                        names.insert(0, 'week')
                if 'ref pos' in line:
                    data_start = line.index(':', 1)
                    ref_pos = [float(p) for p in split_line(line[data_start+1:].strip())]
                continue
            data_line = parseline(line, names)
            for key, val in data_line.items():
@@ -79,6 +83,17 @@ if __name__ == '__main__':
                    data[key][c_line] = val
            c_line += 1

    if 'latitude' in names:
        try:
            from pymap3d import geodetic2enu
            print('Adding enu')
            east, north, up = geodetic2enu(data['latitude'], data['longitude'], data['height'], *ref_pos)
            data['e_baseline'] = east
            data['n_baseline'] = north
            data['u_baseline'] = up
        except ImportError:
            print('Install pymap3d to automatically add enu solution')

    print('Saving .mat')
    savemat(outfile, {'rtklib': data})
    print('Done.')