Exemplo n.º 1
0
    def setup_parser(self):
        # Ignore the header, first two lines
        header_parser = ParserDef(
            end_marker=lambda _l, line_num, _n: line_num == 2,
            label=None,
            parser_def=None)

        # Each line defines a station (site)
        station_parser = ParserDef(
            end_marker=lambda line, _ln, _n: line == "$END",
            label=lambda line, _ln: line != "$END" and "station",
            parser_def={
                "station": {
                    "parser": self.parse_station,
                    "fields": {
                        "name": (0, 8),
                        "pos_x": (10, 25),
                        "pos_y": (25, 40),
                        "pos_z": (40, 55)
                    },
                }
            },
        )

        return itertools.chain([header_parser, station_parser])
Exemplo n.º 2
0
    def setup_parser(self):
        # Ignore the header, first two lines
        header_parser = ParserDef(
            end_marker=lambda _l, line_num, _n: line_num == 2,
            label=None,
            parser_def=None)

        # Skip stations
        station_parser = ParserDef(
            end_marker=lambda line, _ln, _n: line == "$END",
            label=None,
            parser_def=None)

        # Each line defines a radio source
        source_parser = ParserDef(
            end_marker=lambda line, _ln, _n: line == "$END",
            label=lambda line, _ln: line != "$END",
            parser_def={
                True: {
                    "parser": self.parse_radio_source,
                    "fields": {
                        "name": (0, 8),
                        "ra_hrs": (10, 12),
                        "ra_mins": (13, 15),
                        "ra_secs": (16, 28),
                        "dec_degs": (29, 32),
                        "dec_mins": (33, 35),
                        "dec_secs": (36, 48),
                    },
                }
            },
        )

        return itertools.chain([header_parser, station_parser, source_parser])
Exemplo n.º 3
0
    def setup_parser(self):
        flux_parser = ParserDef(
            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.º 4
0
    def setup_parser(self):
        # Each line contains identifiers for a session
        session_parser = ParserDef(
            end_marker=lambda _l, _ln, _n: True,
            label=lambda line, _ln: line.startswith("|"),
            parser_def={
                True: {
                    "parser":
                    self.parse_session,
                    "delimiter":
                    "|",
                    "fields": [
                        None,
                        "session_name",
                        "session_code",
                        None,
                        "doy",
                        "start",
                        "duration",
                        "stations",
                        "scheduler",
                        "correlator",
                        "status",
                        None,
                        "session",
                        None,
                        None,
                        None,
                        None,
                    ],
                }
            },
        )

        return itertools.chain(itertools.repeat(session_parser))
Exemplo n.º 5
0
    def setup_parser(self):
        # Data are organized in tables of positions (and sometimes velocities)
        header_parser = ParserDef(
            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 = ParserDef(
            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.º 6
0
    def setup_parser(self):
        """Parsers defined for reading SINEX bias file line by line
        """
        #
        # +BIAS/SOLUTION
        # ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1
        # *BIAS SVN_ PRN STATION__ OBS1 OBS2 BIAS_START____ BIAS_END______ UNIT __ESTIMATED_VALUE____ _STD_DEV___
        #  DSB  G063 G01           C1C  C1W  2018:032:00000 2018:033:00000 ns                 -0.9800      0.0085
        #  DSB  G061 G02           C1C  C1W  2018:032:00000 2018:033:00000 ns                  1.3100      0.0085
        #  DSB  G069 G03           C1C  C1W  2018:032:00000 2018:033:00000 ns                 -1.4730      0.0090

        # TODO: How to handle different SINEX BIAS format versions?
        file_parser = ParserDef(
            # TODO: start_marker=lambda line, _ln: startswith('+BIAS/SOLUTION') ????
            end_marker=lambda line, _ln, _n: line.startswith("-BIAS/SOLUTION"),
            label=lambda line, _ln: line.startswith(" DSB"),
            parser_def={
                True: {
                    "parser": self.parse_bias_solution,
                    "fields": {
                        "bias": (0, 5),
                        "svn": (5, 10),
                        "prn": (10, 14),
                        "station": (
                            14, 25
                        ),  # TODO: Old format is not consistent with SINEX BIAS format 1.0.
                        "obs1": (25, 29),
                        "obs2": (29, 34),
                        "start_time": (
                            34,
                            49,
                        ),  # TODO: Old format is not consistent with SINEX BIAS format 1.0. -> yy instead of yyyy
                        "end_time": (
                            49,
                            64,
                        ),  # TODO: Old format is not consistent with SINEX BIAS format 1.0. -> yy instead of yyyy
                        "unit": (64, 69),
                        "estimate": (69, 91),
                        "estimate_sigma": (91, 103),
                        "slope_estimate": (103, 125),  # TODO: Not implemented.
                        "slope_estimate_sigma":
                        (125, 137),  # TODO: Not implemented.
                    },
                }
            },
        )

        return itertools.repeat(file_parser)
Exemplo n.º 7
0
    def setup_parser(self):

        # Each line contains identifiers for a station
        station_parser = ParserDef(
            end_marker=lambda _l, _ln, _n: True,
            label=lambda line, _ln: not line.startswith("*"),
            parser_def={
                True: {
                    "parser": self.parse_station,
                    "fields": {
                        "ivscode": (0, 3),
                        "name": (4, 12),
                        "domes": (13, 18),
                        "marker": (18, 22),
                        "cdp": (23, 27),
                        "description": (28, 150),
                    },
                }
            },
        )

        return itertools.chain(itertools.repeat(station_parser))
Exemplo n.º 8
0
    def setup_parser(self):
        # Each line contains identifiers for a station
        station_parser = ParserDef(
            end_marker=lambda _l, _ln, _n: True,
            label=lambda line, _ln: line.startswith("A"),
            parser_def={
                True: {
                    "parser":
                    self.parse_station,
                    "fields": [
                        None,
                        "ivsname",
                        "focus",
                        "mount",
                        "radome",
                        "quality",
                        "reference_temperature",
                        "sin_amplitude",
                        "cos_amplitude",
                        "reference_pressure",
                        "diameter",
                        "height_foundation",
                        "depth_foundation",
                        "coefficient_foundation",
                        "fixed_axis",
                        "coefficient_fixed_axis",
                        "axis_offset",
                        "coefficient_axis_offset",
                        "distance_antenna_vertex",
                        "coefficient_distance",
                        "height_focus",
                        "coefficient_height_focus",
                    ],
                }
            },
        )

        return itertools.chain(itertools.repeat(station_parser))
Exemplo n.º 9
0
 def setup_parser(self):
     # Data are organized in sessions
     session_parser = ParserDef(
         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", "system_number", "occupancy_number",
                     "epoch_time_scale", "station_network"
                 ],
             },
             "H3": {
                 "parser":
                 self.parse_satellite,
                 "fields": [
                     "satellite_name", "satellite_id", "sic", "norad_id",
                     "spacecraft_epoch_time_scale", "target_type",
                     "target_class", "target_location"
                 ],
             },
             "H4": {
                 "parser":
                 self.parse_session,
                 "fields": [
                     "data_type", "starting_year", "starting_month",
                     "starting_day", "starting_hour", "starting_minute",
                     "starting_second", "ending_year", "ending_month",
                     "ending_day", "ending_hour", "ending_minute",
                     "ending_second", "data_release",
                     "trop_refr_corr_applied",
                     "center_of_mass_corr_applied",
                     "receive_ampl_corr_applied", "station_syst_del_appl",
                     "spacecraft_syst_del_appl", "range_type_indicator",
                     "data_quality_alert"
                 ],
             },
             "H5": {
                 "parser":
                 self.parse_prediction,
                 "fields": [
                     "prediction_type", "date_and_time",
                     "prediction_provider", "sequence_number"
                 ],
             },
             "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", "epoch_event",
                     "number_of_raw", "bin_rms"
                 ],
             },
             "20": {
                 "parser":
                 self.parse_meteorology,
                 "fields":
                 [None, "seconds", "pressure", "temperature", "humidity"],
             },
         },
     )
     return itertools.repeat(session_parser)
Exemplo n.º 10
0
    def setup_parser(self):
        """Setup parser definition
        """

        # Parser for SP3 header
        header_parser = ParserDef(
            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 = ParserDef(
            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.º 11
0
 def setup_parser(self):
     # Data are organized in sessions
     session_parser = ParserDef(
         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", "epoch_event",
                     "number_of_raw", "bin_rms"
                 ],
             },
             "20": {
                 "parser":
                 self.parse_meteorology,
                 "fields":
                 [None, "seconds", "pressure", "temperature", "humidity"],
             },
         },
     )
     return itertools.repeat(session_parser)
Exemplo n.º 12
0
    def setup_parser(self):
        # Ignore the header, first two lines
        header_parser = ParserDef(
            end_marker=lambda _l, line_num, _n: line_num == 2,
            label=None,
            parser_def=None)

        station_parser = ParserDef(
            end_marker=lambda line, _ln, _n: line == "$END",
            label=None,
            parser_def=None)
        source_parser = ParserDef(
            end_marker=lambda line, _ln, _n: line == "$END",
            label=None,
            parser_def=None)
        param_parser = ParserDef(
            end_marker=lambda line, _ln, _n: line == "$END",
            label=None,
            parser_def=None)

        # Observations are listed on 9 lines
        obs_parser = ParserDef(
            end_marker=lambda _l, _ln, next_line: next_line[78:80] == "01",
            # end_callback=self.copy_cache_to_obs,
            label=lambda line, _ln: line[78:80],
            parser_def={
                "01": {
                    "parser": self.parse_obs_meta,
                    "fields": {
                        "station_1": (0, 8),
                        "station_2": (10, 18),
                        "source": (20, 28),
                        "year": (29, 33),
                        "month": (34, 36),
                        "day": (37, 39),
                        "hour": (40, 42),
                        "minute": (43, 45),
                        "seconds": (46, 60),
                    },
                },
                "02": {
                    "parser":
                    self.parse_obs(unit_in="nanoseconds",
                                   except_fields=("data_quality", )),
                    "fields": {
                        "observed_delay": (0, 20),
                        "observed_delay_ferr": (20, 30),
                        #                                  'observed_delay_rate':      (30, 50),
                        #                                  'observed_delay_rate_ferr': (50, 60),
                        "data_quality": (60, 62),
                        #                                  'flag_delay_type':          (63, 65),
                        #                                  'flag_delay_rate_type':     (66, 68),
                    },
                },
                #                 "03": {
                #                     "parser": self.parse_obs(),
                #                     "fields": {
                #                         "correlation_coeff": (0, 10),
                #                         "correlation_coeff_ferr": (10, 20),
                #                         "fringe_amplitude": (20, 30),
                #                         "fringe_amplitude_ferr": (30, 40),
                #                         "total_fringe_phase": (40, 60),
                #                         "total_fringe_phase_ferr": (60, 70),
                #                     },
                #                 },
                "05": {
                    "parser": self.parse_obs(unit_in="nanoseconds"),
                    "fields": {
                        "cable_delay_1": (0, 10),
                        "cable_delay_2": (10, 20)
                    },
                },
                "06": {
                    "parser": self.parse_obs_missing,
                    "fields": {
                        "temperature_1": (0, 10),
                        "temperature_2": (10, 20),
                        "pressure_1": (20, 30),
                        "pressure_2": (30, 40),
                    },
                },
                "08": {
                    "parser":
                    self.parse_obs(unit_in="nanoseconds",
                                   except_fields=("iono_quality", )),
                    "fields": {
                        "iono_delay": (0, 20),
                        "iono_delay_ferr": (20, 30),
                        #                                  'iono_delay_rate':           (30, 50),
                        #                                  'iono_delay_rate_ferr':      (50, 60),
                        "iono_quality": (61, 63),
                    },
                },
            },
        )

        return itertools.chain(
            [header_parser, station_parser, source_parser, param_parser],
            itertools.repeat(obs_parser))