Exemplo n.º 1
0
    def setup_parsers(self):
        # Data are organized in tables of positions (and sometimes velocities)
        header_parser = parser.define_parser(
            end_marker=lambda _l, _ln, nextline: nextline[0:2].isnumeric(),
            label=lambda line, _ln: line[0:2].upper(),
            parser_def={
                "H1": {
                    "parser": self.parse_default,
                    "fields": {
                        "cpf": (3, 6),
                        "format_version": (7, 9),
                        "ephemeris_source": (11, 14),
                        "year_of_ephemeris_production": (15, 19),
                        "month_of_ephemeris_production": (20, 22),
                    },
                },
                "H2": {
                    "parser": self.parse_default,
                    "fields": {
                        "satellite_id": (3, 11)
                    }
                },
            },
        )
        # Each line contains information about the satellite at a given time.
        orbit_parser = parser.define_parser(
            end_marker=lambda _l, _ln, nextline: nextline[0:2] == "99",
            label=lambda line, _ln: line[0:2],
            parser_def={
                "10": {
                    "parser":
                    self.parse_position,
                    "fields": [
                        "record_type",
                        "direction_flag",
                        "mjd",
                        "seconds_of_day",
                        "leap_second_flag",
                        "pos_x",
                        "pos_y",
                        "pos_z",
                    ],
                },
                "20": {
                    "parser":
                    self.parse_velocity,
                    "fields": [
                        "record_type", "direction_flag", "vel_x", "vel_y",
                        "vel_z"
                    ],
                },
            },
        )

        return itertools.chain([header_parser], itertools.repeat(orbit_parser))
Exemplo n.º 2
0
 def setup_parsers(self):
     # Each line contains data for a given station and period of time.
     com_parser = parser.define_parser(
         end_marker=lambda _l, _ln, _n: True,
         label=lambda line, _ln: line[0:4].isnumeric(),
         parser_def={
             True: {
                 "parser": self.parse_com_line,
                 "fields": {
                     "station": (0, 4),
                     "start_day": (5, 7),
                     "start_month": (8, 10),
                     "start_year": (11, 15),
                     "end_day": (16, 18),
                     "end_month": (19, 21),
                     "end_year": (22, 26),
                     "pulse_width": (27, 30),
                     "detector_type": (30, 35),
                     "op_mod": (35, 39),
                     "e_lev": (40, 44),
                     "dummy1": (44, 48),
                     "dummy2": (49, 52),
                     "lcmh": (53, 56),
                     "lcml": (57, 60),
                     "lcm": (61, 64),
                     "iflg": (65, 67),
                 },
             }
         },
     )
     return itertools.repeat(com_parser)
Exemplo n.º 3
0
    def setup_parsers(self):
        """Define parsers for reading RINEX clock file
        """
        data_parser = parser.define_parser(
            end_marker=lambda _l, _ln, n: n.startswith("*"),
            label=lambda line, _ln: line[0:3],
            parser_def={
                "AS ": {
                    "parser":
                    self.parse_sat_clk,
                    "fields": [
                        None,
                        "satellite",
                        "year",
                        "month",
                        "day",
                        "hour",
                        "minute",
                        "seconds",
                        "num_val",
                        "sat_clock_bias",
                        "sat_clock_bias_sigma",
                    ],
                }
            },
        )

        return itertools.repeat(data_parser)
Exemplo n.º 4
0
    def setup_parsers(self):
        flux_parser = parser.define_parser(
            end_marker=lambda _l, _ln, nextline: nextline[0:1].isdigit(),
            label=lambda line, _ln: line[0:1].isdigit(),
            parser_def={
                True: {"parser": self.parse_header, "fields": {"year": (0, 4)}},
                False: {
                    "parser": self.parse_flux,
                    "fields": {
                        "day": (3, 5),
                        "01": (6, 11),
                        "02": (12, 17),
                        "03": (18, 23),
                        "04": (24, 29),
                        "05": (30, 35),
                        "06": (36, 41),
                        "07": (42, 47),
                        "08": (48, 53),
                        "09": (54, 59),
                        "10": (60, 65),
                        "11": (66, 71),
                        "12": (72, 77),
                    },
                },
            },
        )

        return itertools.repeat(flux_parser)
Exemplo n.º 5
0
    def setup_parsers(self):
        header_parser = parser.define_parser(
            end_marker=lambda line, _ln, _n: line.startswith("end_of_head"),
            label=lambda line, _ln: (line + " .").split()[0],
            parser_def={
                "earth_gravity_constant": {"parser": self.parse_constant, "fields": [None, "GM"]},
                "radius": {"parser": self.parse_constant, "fields": [None, "a"]},
            },
        )

        coefficient_parser = parser.define_parser(
            end_marker=lambda _l, _ln, _n: np.all(self.coeff_read),
            label=lambda line, _ln: (line + " .").split()[0],
            parser_def={
                "gfc": {"parser": self.parse_coeff, "fields": [None, "degree", "order", "coeff_C", "coeff_S"]}
            },
        )

        return itertools.chain([header_parser, coefficient_parser])
Exemplo n.º 6
0
 def setup_parsers(self):
     # Each line contains data for a given station and period of time.
     handling_parser = parser.define_parser(
         end_marker=lambda _l, _ln, _n: True,
         label=lambda line, _ln: line[1:5].isnumeric() and line[18:19].isnumeric(),
         parser_def={
             True: {
                 "parser": self.parse_handling_line,
                 "fields": {
                     "station": (1, 5),
                     "unit": (10, 12),
                     "start_time": (17, 29),
                     "end_time": (30, 42),
                     "code": (43, 44),
                 },
             }
         },
     )
     return itertools.repeat(handling_parser)
Exemplo n.º 7
0
    def setup_parsers(self):
        # Each line contains identifiers for a station
        station_parser = parser.define_parser(
            end_marker=lambda _l, _ln, _n: True,
            label=lambda line, ln: not (line.startswith("$") or line.startswith("#")),
            parser_def={
                True: {
                    "parser": self.parse_station,
                    "fields": {
                        "name": (2, 10),
                        "site_id": (11, 16),
                        "start": (17, 34),
                        "end": (35, 52),
                        "v1": (53, 64),
                        "v2": (64, 75),
                        "v3": (75, 85),
                        "type": (87, 91),
                    },
                }
            },
        )

        return itertools.chain(itertools.repeat(station_parser))
Exemplo n.º 8
0
    def setup_parsers(self):
        """Parsers defined for reading GNSS receiver type file line by line.
        """
        file_parser = parser.define_parser(
            end_marker=lambda _l, _ln, _n: True,
            label=lambda line, _ln: not re.
            match("^#|^\s*$", line
                  ),  # skip comments starting with '#' and empty lines
            parser_def={
                # ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9
                # ALTUS APS-3          P  Y     # GPS L1/L2+L2C, GLO L1/L2, SBAS integrated rcvr/antenna
                # ALTUS APS-3L         P  Y     # GPS L1/L2+L2C, GLO L1/L2, SBAS, L-Band rcvr/antenna
                True: {
                    "parser": self.parse_string,
                    "fields": {
                        "name": (0, 20),
                        "type": (20, 22),
                        "igs_format": (22, 25)
                    },
                }
            },
        )

        return itertools.repeat(file_parser)
Exemplo n.º 9
0
    def setup_parsers(self):
        # Each line contains identifiers for a station
        station_parser = parser.define_parser(
            end_marker=lambda _l, _ln, _n: True,
            label=lambda line, ln:
            (not (line.startswith("$") or line.startswith("#") or line.
                  startswith("*")) and line[42:45] == "XYZ"),
            parser_def={
                True: {
                    "parser": self.parse_station,
                    "fields": {
                        "site_id": (1, 5),
                        "start": (16, 28),
                        "end": (29, 41),
                        "type": (42, 45),
                        "v1": (45, 54),
                        "v2": (54, 63),
                        "v3": (63, 72),
                    },
                }
            },
        )

        return itertools.chain(itertools.repeat(station_parser))
Exemplo n.º 10
0
    def setup_parsers(self):
        """Parsers defined for reading RINEX observation file line by line.

           First the RINEX header information are read and afterwards the RINEX observation.
        """
        # Parser for RINEX header
        header_parser = parser.define_parser(
            end_marker=lambda line, _ln, _n: line[60:73] == "END OF HEADER",
            label=lambda line, _ln: line[60:].strip(),
            parser_def={
                # ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
                #      2.11           OBSERVATION DATA    M (MIXED)           RINEX VERSION / TYPE
                "RINEX VERSION / TYPE": {
                    "parser": self.parse_rinex_version_type,
                    "fields": {
                        "version": (0, 20),
                        "file_type": (20, 21),
                        "sat_sys": (40, 41)
                    },
                },
                # ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
                # XXRINEXO V9.9       AIUB                24-MAR-01 14:43     PGM / RUN BY / DATE
                "PGM / RUN BY / DATE": {
                    "parser": self.parse_string,
                    "fields": {
                        "program": (0, 20),
                        "run_by": (20, 40),
                        "file_created": (40, 60)
                    },
                },
                # ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
                # G = GPS R = GLONASS E = GALILEO S = GEO M = MIXED           COMMENT
                "COMMENT": {
                    "parser": self.parse_comment,
                    "fields": {
                        "comment": (0, 60)
                    }
                },
                # ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
                # A 9080                                                      MARKER NAME
                "MARKER NAME": {
                    "parser": self.parse_string,
                    "fields": {
                        "marker_name": (0, 60)
                    }
                },
                # ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
                # 9080.1.34                                                   MARKER NUMBER
                "MARKER NUMBER": {
                    "parser": self.parse_string,
                    "fields": {
                        "marker_number": (0, 20)
                    }
                },
                # ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
                # BILL SMITH          ABC INSTITUTE                           OBSERVER / AGENCY
                "OBSERVER / AGENCY": {
                    "parser": self.parse_string,
                    "fields": {
                        "observer": (0, 20),
                        "agency": (20, 60)
                    },
                },
                # ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
                # X1234A123           XX                  ZZZ                 REC # / TYPE / VERS
                "REC # / TYPE / VERS": {
                    "parser": self.parse_string,
                    "fields": {
                        "receiver_number": (0, 20),
                        "receiver_type": (20, 40),
                        "receiver_version": (40, 60)
                    },
                },
                # ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
                # 234                 YY                                      ANT # / TYPE
                "ANT # / TYPE": {
                    "parser": self.parse_string,
                    "fields": {
                        "antenna_number": (0, 20),
                        "antenna_type": (20, 40)
                    },
                },
                # ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
                #   4375274.       587466.      4589095.                      APPROX POSITION XYZ
                "APPROX POSITION XYZ": {
                    "parser": self.parse_approx_position,
                    "fields": {
                        "pos_x": (0, 14),
                        "pos_y": (14, 28),
                        "pos_z": (28, 42)
                    },
                },
                # ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
                #          .9030         .0000         .0000                  ANTENNA: DELTA H/E/N
                "ANTENNA: DELTA H/E/N": {
                    "parser": self.parse_float,
                    "fields": {
                        "antenna_height": (0, 14),
                        "antenna_east": (14, 28),
                        "antenna_north": (28, 42)
                    },
                },
                # ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
                #      1     1                                                WAVELENGTH FACT L1/2
                #      1     2     6   G14   G15   G16   G17   G18   G19      WAVELENGTH FACT L1/2
                "WAVELENGTH FACT L1/2": {
                    "parser": self.parse_wavelength_fact,
                    "fields": {
                        "l1_wave_fact": (0, 6),
                        "l2_wave_fact": (6, 12),
                        "num_satellite": (12, 18),
                        "prn_1": (21, 24),
                        "prn_2": (27, 30),
                        "prn_3": (33, 36),
                        "prn_4": (39, 42),
                        "prn_5": (45, 48),
                        "prn_6": (51, 54),
                        "prn_7": (57, 60),
                    },
                },
                # ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
                #     14    C1    C2    C5    P1    P2    L1    L2    L5    D1# / TYPES OF OBSERV
                #           D2    D5    S1    S2    S5                        # / TYPES OF OBSERV
                "# / TYPES OF OBSERV": {
                    "parser": self.parse_types_of_observ,
                    "fields": {
                        "num_obstypes": (0, 6),
                        "type_1": (6, 12),
                        "type_2": (12, 18),
                        "type_3": (18, 24),
                        "type_4": (24, 30),
                        "type_5": (30, 36),
                        "type_6": (36, 42),
                        "type_7": (42, 48),
                        "type_8": (48, 54),
                        "type_9": (54, 60),
                    },
                },
                # ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
                #     18.000                                                  INTERVAL
                "INTERVAL": {
                    "parser": self.parse_float,
                    "fields": {
                        "interval": (0, 10)
                    }
                },
                # ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
                #   2005     3    24    13    10   36.0000000                 TIME OF FIRST OBS
                "TIME OF FIRST OBS": {
                    "parser": self.parse_time_of_first_obs,
                    "fields": {
                        "year": (0, 6),
                        "month": (6, 12),
                        "day": (12, 18),
                        "hour": (18, 24),
                        "minute": (24, 30),
                        "second": (30, 43),
                        "time_sys": (48, 51),
                    },
                },
                # ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
                #   2005     3    24    23    59   59.0000000                 TIME OF LAST OBS
                "TIME OF LAST OBS": {
                    "parser": self.parse_time_of_last_obs,
                    "fields": {
                        "year": (0, 6),
                        "month": (6, 12),
                        "day": (12, 18),
                        "hour": (18, 24),
                        "minute": (24, 30),
                        "second": (30, 43),
                        "time_sys": (48, 51),
                    },
                },
                # ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
                #      0                                                      RCV CLOCK OFFS APPL
                "RCV CLOCK OFFS APPL": {
                    "parser": self.parse_string,
                    "fields": {
                        "rcv_clk_offset_flag": (0, 6)
                    }
                },
                # ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
                #     13                                                      LEAP SECONDS
                "LEAP SECONDS": {
                    "parser": self.parse_leap_seconds,
                    "fields": {
                        "leap_seconds": (0, 6)
                    }
                },
                # ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
                #     71                                                      # OF SATELLITES
                "# OF SATELLITES": {
                    "parser": self.parse_integer,
                    "fields": {
                        "num_satellites": (0, 6)
                    }
                },
                # TODO: 'PRN / # OF OBS'
            },
        )

        # Parser for RINEX observation blocks

        # ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
        #  16  3  1  0  0  0.0000000  0 19G07G27G20G21G26G15G10G16G08G18G30R06  .000000000
        #                                 R22R21R04R13R20R11R05
        #      1     2     2   G 9   G12                              WAVELENGTH FACT L1/2
        #   *** WAVELENGTH FACTOR CHANGED FOR 2 SATELLITES ***        COMMENT
        #   23522570.266    23522573.871            .000    23522570.500    23522573.969
        #  123611978.15417  96321063.91253          .000         932.031         726.258
        obs_parser = parser.define_parser(
            end_marker=lambda _l, _ln, next_line:
            (next_line[2:3].isdigit() and next_line[3:4].isspace()),
            label=lambda line, _ln:
            ((line[10:11] == "." or line[0:16].isspace()
              )  # Accepting of value or blank entry
             and not line[32:33].isalpha()  # Continuation of satellite list
             and not (line[34:35].isnumeric() and line[35:36].isspace(
             ))  # Continuation of satellite list with blank satellite system identifier (GPS only)
             and not line[60:61].isalpha()),  # Comment line
            parser_def={
                False: {
                    "parser": self.parse_observation_epoch,
                    "strip":
                    "\n",  # Remove only newline '\n' leading and trailing characters from line.
                    "fields": {
                        "year": (0, 3),
                        "month": (3, 6),
                        "day": (6, 9),
                        "hour": (9, 12),
                        "minute": (12, 15),
                        "second": (15, 26),
                        "epoch_flag": (26, 29),
                        "num_sat": (29, 32),
                        "sat_list": (32, 68),
                        "rcv_clk_offset": (68, 80),
                    },
                },
                True: {
                    "parser": self.parse_observation,
                    "strip":
                    "\n",  # Remove only newline '\n' leading and trailing characters from line.
                    "fields": {
                        "obs_1": (0, 16),
                        "obs_2": (16, 32),
                        "obs_3": (32, 48),
                        "obs_4": (48, 64),
                        "obs_5": (64, 80),
                    },
                },
            },
        )

        return itertools.chain([header_parser], itertools.repeat(obs_parser))
Exemplo n.º 11
0
    def setup_parsers(self):
        """Setup parser definition
        """

        # Parser for SP3 header
        header_parser = parser.define_parser(
            end_marker=lambda _l, _ln, next_line: next_line.startswith("*"),
            # end_marker=lambda _l, line_num, _n: line_num == 22,
            label=lambda _l, line_num: line_num,
            parser_def={
                # ----+----1----+----2----+----3----+----4----+----5----+----6
                # #cP2016  3  1  0  0  0.00000000      96 ORBIT IGb08 HLM  IGS
                1: {
                    "parser": self._parse_string,
                    "fields": {
                        "version": (1, 2),
                        "pv_flag": (2, 3),
                        "year": (3, 7),
                        "month": (8, 10),
                        "day": (11, 13),
                        "hour": (14, 16),
                        "minute": (17, 19),
                        "second": (20, 31),
                        "num_epoch": (32, 39),
                        "data_used": (40, 45),
                        "coord_sys": (46, 51),
                        "orb_type": (52, 55),
                        "agency": (56, 60),
                    },
                },
                # ----+----1----+----2----+----3----+----4----+----5----+----6
                # ## 1886 172800.00000000   900.00000000 57448 0.0000000000000
                2: {
                    "parser": self._parse_string,
                    "fields": {
                        "gpsweek": (3, 7),
                        "gpssec": (8, 23),
                        "epoch_interval": (24, 38),
                        "mjd_int": (39, 44),
                        "mjd_frac": (45, 60),
                    },
                },
                # ----+----1----+----2----+----3----+----4----+----5----+----6
                # %c G  cc GPS ccc cccc cccc cccc cccc ccccc ccccc ccccc ccccc
                13: {
                    "parser": self._parse_string,
                    "fields": {
                        "file_type": (3, 5),
                        "time_sys": (9, 12)
                    }
                },
                # ----+----1----+----2----+----3----+----4----+----5----+----6
                # %f  1.2500000  1.025000000  0.00000000000  0.000000000000000
                15: {
                    "parser": self._parse_float,
                    "fields": {
                        "base_posvel": (3, 13),
                        "base_clkrate": (14, 26)
                    }
                },
            },
        )

        # Parser for SP3 data block

        # *  2016  3  1  0  0  0.00000000
        # PG01  10138.887745 -20456.557725 -13455.830128     13.095853  7  6  4 137
        # PG02 -21691.921884  13338.131173  -6326.904893    599.417359 10  7  8 114
        # PG03   1061.483783 -15622.426751 -21452.532447    -30.693182  7  6 10 125
        # PG04  25398.213954   6966.881030   4188.487313 999999.999999
        # PG05 -20431.536257   5143.439387  16220.688245   -141.634044  9  8  7 101
        # PG06 -19896.425641    760.039334 -17564.616810    153.322562 12 10 13 104
        # PG07  -5499.233721 -14614.719047  21564.675152    467.390140  7 10  7 123
        # PG08   7359.468852 -20268.667422  15550.334189    -25.778533  8  6  8 113
        data_parser = parser.define_parser(
            end_marker=lambda _l, _ln, next_line: next_line.startswith("*"),
            label=lambda line, _ln: line[0],
            parser_def={
                "*": {
                    "parser":
                    self._parse_date,
                    "fields":
                    [None, "year", "month", "day", "hour", "minute", "second"],
                },
                "P": {
                    "parser": self._parse_position,
                    "fields": {
                        "sat": (1, 4),
                        "pos_x": (4, 18),
                        "pos_y": (18, 32),
                        "pos_z": (32, 46),
                        "clk_bias": (46, 60),
                        "sig_pos_x": (61, 63),
                        "sig_pos_y": (64, 66),
                        "sig_pos_z": (67, 69),
                        "sig_clk_bias": (70, 73),
                        "clk_event_flag": (74, 75),
                        "clk_pred_flag": (75, 76),
                        "maneuver_flag": (78, 79),
                        "orb_pred_flag": (79, 80),
                    },
                },
                "V": {
                    "parser": self._parse_velocity,
                    "fields": {
                        "sat": (1, 4),
                        "vel_x": (4, 18),
                        "vel_y": (18, 32),
                        "vel_z": (32, 46),
                        "clk_rate": (46, 60),
                        "sig_vel_x": (61, 63),
                        "sig_vel_y": (64, 66),
                        "sig_vel_z": (67, 69),
                        "sig_clk_rate": (70, 73),
                    },
                },
            },
        )

        return itertools.chain([header_parser], itertools.repeat(data_parser))
Exemplo n.º 12
0
    def setup_parsers(self):
        """Parsers defined for reading GNSS raw data file line by line.
        """
        file_parser = parser.define_parser(
            end_marker=lambda _l, _ln, _n: True,
            label=lambda line, _ln: line[0:3].strip(),
            parser_def={
                # ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
                # Fix,gps,37.422541,-122.081659,-33.000000,0.000000,3.000000,1467321969000
                "Fix": {
                    "parser":
                    self.parse_fix,
                    "fields": [
                        "dummy",
                        "provider",
                        "latitude",
                        "longitude",
                        "altitude",
                        "speed",
                        "accuracy",
                        "time_utc",
                    ],
                },
                # ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0
                # Raw,72065126,72076939000000,,,-1151285108458178048,0.0,26.542398700257763,-0.634638974724185, ...
                "Raw": {
                    "parser":
                    self.parse_raw,
                    "delimiter":
                    ",",
                    "fields": [
                        "dummy",
                        "ElapsedRealtimeMillis",
                        "TimeNanos",
                        "LeapSecond",
                        "TimeUncertaintyNanos",
                        "FullBiasNanos",
                        "BiasNanos",
                        "BiasUncertaintyNanos",
                        "DriftNanosPerSecond",
                        "DriftUncertaintyNanosPerSecond",
                        "HardwareClockDiscontinuityCount",
                        "Svid",
                        "TimeOffsetNanos",
                        "State",
                        "ReceivedSvTimeNanos",
                        "ReceivedSvTimeUncertaintyNanos",
                        "Cn0DbHz",
                        "PseudorangeRateMetersPerSecond",
                        "PseudorangeRateUncertaintyMetersPerSecond",
                        "AccumulatedDeltaRangeState",
                        "AccumulatedDeltaRangeMeters",
                        "AccumulatedDeltaRangeUncertaintyMeters",
                        "CarrierFrequencyHz",
                        "CarrierCycles",
                        "CarrierPhase",
                        "CarrierPhaseUncertainty",
                        "MultipathIndicator",
                        "SnrInDb",
                        "ConstellationType",
                    ],
                },
            },
        )

        return itertools.repeat(file_parser)
Exemplo n.º 13
0
    def setup_parsers(self):
        header_parser = parser.define_parser(
            end_marker=lambda line, _ln, _n: line[60:73] == "END OF HEADER",
            label=lambda line, _ln: line[60:].strip(),
            parser_def={
                "REC # / TYPE / VERS": {"parser": self._parse_default, "fields": {"receiver": (20, 40)}},
                "ANT # / TYPE": {"parser": self._parse_default, "fields": {"antenna_type": (20, 40)}},
                "APPROX POSITION XYZ": {
                    "parser": self._parse_xyz,
                    "fields": {"antenna_pos_x": (0, 14), "antenna_pos_y": (14, 28), "antenna_pos_z": (28, 42)},
                },
                "CENTER OF MASS: XYZ": {
                    "parser": self._parse_xyz,
                    "fields": {
                        "center_of_mass_x": (0, 14),
                        "center_of_mass_y": (14, 28),
                        "center_of_mass_z": (28, 42),
                    },
                },
                "SYS / SCALE FACTOR": {
                    "parser": self._parse_default,
                    "fields": {"scale_factor": (2, 6), "fields": (10, 58)},
                },
                "L2 / L1 DATE OFFSET": {"parser": self._parse_float, "fields": {"date_offset": (3, 17)}},
                "STATION REFERENCE": {
                    "parser": self._parse_station,
                    "fields": {
                        "station_key": (0, 3),
                        "site_id": (5, 9),
                        "site_name": (10, 40),
                        "domes": (40, 50),
                        "type": (51, 52),
                        "freq_shift": (53, 56),
                    },
                },
                "TIME REF STATION": {
                    "parser": self._parse_timeref_station,
                    "fields": {"station_key": (0, 3), "bias": (5, 19), "shift": (21, 35)},
                },
                "TIME REF STAT DATE": {
                    "parser": self._parse_float,
                    "fields": {
                        "timeref_year": (0, 6),
                        "timeref_month": (6, 12),
                        "timeref_day": (12, 18),
                        "timeref_hour": (18, 24),
                        "timeref_minute": (24, 30),
                        "timeref_second": (30, 43),
                    },
                },
            },
        )

        """Definition of the observation data of the input file.

        This dictionary defines how to parse the data part of the input file, and is based on the "Rinex Doris
        3.0"-document (Appendix A).
        """
        obs_parser = parser.define_parser(
            end_marker=lambda _l, _ln, next_line: next_line.startswith(">"),
            label=lambda line, _ln: line[0:1],
            parser_def={
                ">": {
                    "parser": self._parse_epoch,
                    "fields": {
                        "year": (2, 6),
                        "month": (7, 9),
                        "day": (10, 12),
                        "hour": (13, 15),
                        "minute": (16, 18),
                        "second": (19, 21),
                        "fracsec": (21, 31),
                        "epoch_flag": (33, 34),
                        "numrecords": (34, 37),
                        "clock_offset": (43, 56),
                        "clock_offset_flag": (57, 58),
                    },
                },
                "D": {
                    "parser": self._parse_observation_line_1,
                    "fields": {
                        "station_key": (0, 3),
                        "l1": (3, 17),
                        "l1_flag": (17, 19),
                        "l2": (19, 33),
                        "l2_flag": (33, 35),
                        "c1": (35, 49),
                        "c1a_flag": (49, 50),
                        "c1b_flag": (50, 51),
                        "c2": (51, 65),
                        "c2a_flag": (65, 66),
                        "c2b_flag": (66, 67),
                        "w1": (67, 81),
                        "w1_flag": (81, 83),
                    },
                },
                " ": {
                    "parser": self._parse_observation_line_2,
                    "fields": {
                        "w2": (3, 17),
                        "w2_flag": (17, 19),
                        "f": (19, 33),
                        "f_flag": (33, 35),
                        "p": (35, 49),
                        "p_flag": (49, 51),
                        "t": (51, 65),
                        "t_flag": (65, 67),
                        "h": (67, 81),
                        "h_flag": (81, 83),
                    },
                },
            },
        )
        return itertools.chain([header_parser], itertools.repeat(obs_parser))
Exemplo n.º 14
0
 def setup_parsers(self):
     # Data are organized in sessions
     session_parser = parser.define_parser(
         end_marker=lambda line, _ln, _n: line[0:2].upper() == "H8",
         label=lambda line, _ln: line[0:2].upper(),
         parser_def={
             "H2": {
                 "parser": self.parse_station,
                 "fields": {
                     "cdp": (14, 18),
                     "system_number": (19, 21),
                     "occupancy_number": (22, 24),
                     "epoch_time_scale": (25, 27),
                 },
             },
             "H3": {
                 "parser": self.parse_satellite,
                 "fields": {
                     "satellite_id": (14, 22),
                     "sic": (23, 27),
                     "norad_id": (28, 36),
                     "spacecraft_epoch_time_scale": (37, 38),
                     "target_type": (39, 40),
                 },
             },
             "H4": {
                 "parser": self.parse_session,
                 "fields": {
                     "data_type": (3, 5),
                     "starting_year": (6, 10),
                     "starting_month": (11, 13),
                     "starting_day": (14, 16),
                     "starting_hour": (17, 19),
                     "starting_minute": (20, 22),
                     "starting_second": (23, 25),
                     "ending_year": (26, 30),
                     "ending_month": (31, 33),
                     "ending_day": (34, 36),
                     "ending_hour": (37, 39),
                     "ending_minute": (40, 42),
                     "ending_second": (43, 45),
                     "data_release": (46, 48),
                     "trop_refr_corr_applied": (49, 50),
                     "center_of_mass_corr_applied": (51, 52),
                     "receive_ampl_corr_applied": (53, 54),
                     "station_syst_del_appl": (55, 56),
                     "spacecraft_syst_del_appl": (57, 58),
                     "range_type_indicator": (59, 60),
                     "data_quality_alert": (61, 62),
                 },
             },
             "C0": {
                 "parser": self.parse_config,
                 "fields":
                 ["record_type", "detail_type", "wavelength", None]
             },
             "C2": {
                 "parser":
                 self.parse_config2,
                 "fields": [
                     "record_type",
                     "detail_type",
                     "detector_configuration_id",
                     "detector_type",
                     "applicable_wavelength",
                     "quantum_efficiency",
                     "applied_voltage",
                     "dark_count",
                     "output_pulse_type",
                     "output_pulse_width",
                     "spectral_filter",
                     None,
                 ],
             },
             "11": {
                 "parser": self.parse_obs_normal,
                 "fields": [None, "second", "time_of_flight"]
             },
             "20": {
                 "parser":
                 self.parse_meteorology,
                 "fields":
                 [None, "seconds", "pressure", "temperature", "humidity"],
             },
         },
     )
     return itertools.repeat(session_parser)