midgard.parsers._parser_sinex
Basic functionality for parsing Sinex datafiles
Description:
This module contains functions and classes for parsing Sinex datafiles.
References:
- SINEX Format: https://www.iers.org/IERS/EN/Organization/AnalysisCoordinator/SinexFormat/sinex.html
SinexBlock
SinexBlock(marker:str, fields:Tuple[midgard.parsers._parser_sinex.SinexField, ...], parser:Callable[[<built-in function array>, Tuple[str, ...]], Dict[str, Any]])
A convenience class for defining a Sinex block
Args:
marker
: Sinex marker denoting the block.fields
: Fields in Sinex block.parser
: Function used to parse the data.
SinexField
SinexField(name:str, start_col:int, dtype:Union[str, NoneType], converter:Union[str, NoneType]=None)
A convenience class for defining the fields in a Sinex block
Args:
name
: Name of field.start_col
: Starting column of field (First column is 0)dtype
: String, using numpy notation, defining type of field, use None to ignore field.converter
: Optional, name of converter to apply to field data.
SinexParser
SinexParser(file_path:Union[str, pathlib.Path], encoding:Union[str, NoneType]=None, logger:Union[Callable[[str], NoneType], NoneType]=None, header:bool=True) -> None
An abstract base class that has basic methods for parsing a Sinex file
This class provides functionality for parsing a sinex file with chained
groups of information. You should inherit from this one, and at least
specify which Sinex blocks you are interested in by implementing
setup_parser
, as well as implement methods that parse each block if
needed.
SinexParser.as_dataframe()
as_dataframe(self, index:Union[str, List[str], NoneType]=None, marker:Union[str, NoneType]=None) -> pandas.core.frame.DataFrame
Return the parsed data as a Pandas DataFrame
This is a basic implementation, assuming the self.data
-dictionary has
a simple structure. More advanced parsers may need to reimplement this
method.
Args:
marker
: Only return data from this marker in the DataFrame.index
: Name of field to use as index. May also be a list of strings.
Returns:
Pandas DataFrame with the parsed data.
SinexParser.parse_bias_epochs()
parse_bias_epochs(self:'SinexParser', data:<built-in function array>, *params:str) -> Dict[str, Any]
Simple parser for Sinex data
Converts the input data to a dictionary of numpy arrays and returns it in order to add it to self.data['{marker}']. Ignores any block title parameters.
Args:
data
: Input data, raw data for the block.params
: Tuple of strings with parameters given after the marker at the start of the block.
Returns:
Dictionary with each column in the Sinex file as a numpy array.
SinexParser.parse_blocks()
parse_blocks(self, fid:Iterable[bytes]) -> None
Parse contents of Sinex blocks
Contents of Sinex blocks are stored as separate numpy-arrays in self._sinex
Args:
fid
: Pointer to file being read.
SinexParser.parse_file_comment()
parse_file_comment(self:'SinexParser', data:<built-in function array>, *params:str) -> Dict[str, Any]
Simple parser for Sinex data
Converts the input data to a dictionary of numpy arrays and returns it in order to add it to self.data['{marker}']. Ignores any block title parameters.
Args:
data
: Input data, raw data for the block.params
: Tuple of strings with parameters given after the marker at the start of the block.
Returns:
Dictionary with each column in the Sinex file as a numpy array.
SinexParser.parse_file_reference()
parse_file_reference(self:'SinexParser', data:<built-in function array>, *params:str) -> Dict[str, Any]
Simple parser for Sinex data
Converts the input data to a dictionary of numpy arrays and returns it in order to add it to self.data['{marker}']. Ignores any block title parameters.
Args:
data
: Input data, raw data for the block.params
: Tuple of strings with parameters given after the marker at the start of the block.
Returns:
Dictionary with each column in the Sinex file as a numpy array.
SinexParser.parse_header_line()
parse_header_line(self, header_line:bytes) -> None
Parse header of Sinex file
Header information is stored in self.meta
.
Args:
header_line
: First line of Sinex file.
SinexParser.parse_input_acknowledgements()
parse_input_acknowledgements(self:'SinexParser', data:<built-in function array>, *params:str) -> Dict[str, Any]
Simple parser for Sinex data
Converts the input data to a dictionary of numpy arrays and returns it in order to add it to self.data['{marker}']. Ignores any block title parameters.
Args:
data
: Input data, raw data for the block.params
: Tuple of strings with parameters given after the marker at the start of the block.
Returns:
Dictionary with each column in the Sinex file as a numpy array.
SinexParser.parse_input_files()
parse_input_files(self:'SinexParser', data:<built-in function array>, *params:str) -> Dict[str, Any]
Simple parser for Sinex data
Converts the input data to a dictionary of numpy arrays and returns it in order to add it to self.data['{marker}']. Ignores any block title parameters.
Args:
data
: Input data, raw data for the block.params
: Tuple of strings with parameters given after the marker at the start of the block.
Returns:
Dictionary with each column in the Sinex file as a numpy array.
SinexParser.parse_input_history()
parse_input_history(self:'SinexParser', data:<built-in function array>, *params:str) -> Dict[str, Any]
Simple parser for Sinex data
Converts the input data to a dictionary of numpy arrays and returns it in order to add it to self.data['{marker}']. Ignores any block title parameters.
Args:
data
: Input data, raw data for the block.params
: Tuple of strings with parameters given after the marker at the start of the block.
Returns:
Dictionary with each column in the Sinex file as a numpy array.
SinexParser.parse_lines()
parse_lines(self, lines:List[bytes], fields:Tuple[midgard.parsers._parser_sinex.SinexField, ...]) -> <built-in function array>
Parse lines in a Sinex file
Args:
lines
: Lines to parse.fields
: Definition of sinex fields in lines.
Returns:
Data contained in lines.
SinexParser.parse_nutation_data()
parse_nutation_data(self:'SinexParser', data:<built-in function array>, *params:str) -> Dict[str, Any]
Simple parser for Sinex data
Converts the input data to a dictionary of numpy arrays and returns it in order to add it to self.data['{marker}']. Ignores any block title parameters.
Args:
data
: Input data, raw data for the block.params
: Tuple of strings with parameters given after the marker at the start of the block.
Returns:
Dictionary with each column in the Sinex file as a numpy array.
SinexParser.parse_precession_data()
parse_precession_data(self:'SinexParser', data:<built-in function array>, *params:str) -> Dict[str, Any]
Simple parser for Sinex data
Converts the input data to a dictionary of numpy arrays and returns it in order to add it to self.data['{marker}']. Ignores any block title parameters.
Args:
data
: Input data, raw data for the block.params
: Tuple of strings with parameters given after the marker at the start of the block.
Returns:
Dictionary with each column in the Sinex file as a numpy array.
SinexParser.parse_satellite_id()
parse_satellite_id(self:'SinexParser', data:<built-in function array>, *params:str) -> Dict[str, Any]
Simple parser for Sinex data
Converts the input data to a dictionary of numpy arrays and returns it in order to add it to self.data['{marker}']. Ignores any block title parameters.
Args:
data
: Input data, raw data for the block.params
: Tuple of strings with parameters given after the marker at the start of the block.
Returns:
Dictionary with each column in the Sinex file as a numpy array.
SinexParser.parse_satellite_phase_center()
parse_satellite_phase_center(self:'SinexParser', data:<built-in function array>, *params:str) -> Dict[str, Any]
Simple parser for Sinex data
Converts the input data to a dictionary of numpy arrays and returns it in order to add it to self.data['{marker}']. Ignores any block title parameters.
Args:
data
: Input data, raw data for the block.params
: Tuple of strings with parameters given after the marker at the start of the block.
Returns:
Dictionary with each column in the Sinex file as a numpy array.
SinexParser.parse_site_antenna()
parse_site_antenna(self:'SinexParser', data:<built-in function array>, *params:str) -> Dict[str, Any]
Simple parser for Sinex data
Converts the input data to a dictionary of numpy arrays and returns it in order to add it to self.data['{marker}']. Ignores any block title parameters.
Args:
data
: Input data, raw data for the block.params
: Tuple of strings with parameters given after the marker at the start of the block.
Returns:
Dictionary with each column in the Sinex file as a numpy array.
SinexParser.parse_site_data()
parse_site_data(self:'SinexParser', data:<built-in function array>, *params:str) -> Dict[str, Any]
Simple parser for Sinex data
Converts the input data to a dictionary of numpy arrays and returns it in order to add it to self.data['{marker}']. Ignores any block title parameters.
Args:
data
: Input data, raw data for the block.params
: Tuple of strings with parameters given after the marker at the start of the block.
Returns:
Dictionary with each column in the Sinex file as a numpy array.
SinexParser.parse_site_eccentricity()
parse_site_eccentricity(self:'SinexParser', data:<built-in function array>, *params:str) -> Dict[str, Any]
Simple parser for Sinex data
Converts the input data to a dictionary of numpy arrays and returns it in order to add it to self.data['{marker}']. Ignores any block title parameters.
Args:
data
: Input data, raw data for the block.params
: Tuple of strings with parameters given after the marker at the start of the block.
Returns:
Dictionary with each column in the Sinex file as a numpy array.
SinexParser.parse_site_gal_phase_center()
parse_site_gal_phase_center(self:'SinexParser', data:<built-in function array>, *params:str) -> Dict[str, Any]
Simple parser for Sinex data
Converts the input data to a dictionary of numpy arrays and returns it in order to add it to self.data['{marker}']. Ignores any block title parameters.
Args:
data
: Input data, raw data for the block.params
: Tuple of strings with parameters given after the marker at the start of the block.
Returns:
Dictionary with each column in the Sinex file as a numpy array.
SinexParser.parse_site_gps_phase_center()
parse_site_gps_phase_center(self:'SinexParser', data:<built-in function array>, *params:str) -> Dict[str, Any]
Simple parser for Sinex data
Converts the input data to a dictionary of numpy arrays and returns it in order to add it to self.data['{marker}']. Ignores any block title parameters.
Args:
data
: Input data, raw data for the block.params
: Tuple of strings with parameters given after the marker at the start of the block.
Returns:
Dictionary with each column in the Sinex file as a numpy array.
SinexParser.parse_site_id()
parse_site_id(self:'SinexParser', data:<built-in function array>, *params:str) -> Dict[str, Any]
Simple parser for Sinex data
Converts the input data to a dictionary of numpy arrays and returns it in order to add it to self.data['{marker}']. Ignores any block title parameters.
Args:
data
: Input data, raw data for the block.params
: Tuple of strings with parameters given after the marker at the start of the block.
Returns:
Dictionary with each column in the Sinex file as a numpy array.
SinexParser.parse_site_receiver()
parse_site_receiver(self:'SinexParser', data:<built-in function array>, *params:str) -> Dict[str, Any]
Simple parser for Sinex data
Converts the input data to a dictionary of numpy arrays and returns it in order to add it to self.data['{marker}']. Ignores any block title parameters.
Args:
data
: Input data, raw data for the block.params
: Tuple of strings with parameters given after the marker at the start of the block.
Returns:
Dictionary with each column in the Sinex file as a numpy array.
SinexParser.parse_solution_apriori()
parse_solution_apriori(self:'SinexParser', data:<built-in function array>, *params:str) -> Dict[str, Any]
Simple parser for Sinex data
Converts the input data to a dictionary of numpy arrays and returns it in order to add it to self.data['{marker}']. Ignores any block title parameters.
Args:
data
: Input data, raw data for the block.params
: Tuple of strings with parameters given after the marker at the start of the block.
Returns:
Dictionary with each column in the Sinex file as a numpy array.
SinexParser.parse_solution_epochs()
parse_solution_epochs(self:'SinexParser', data:<built-in function array>, *params:str) -> Dict[str, Any]
Simple parser for Sinex data
Converts the input data to a dictionary of numpy arrays and returns it in order to add it to self.data['{marker}']. Ignores any block title parameters.
Args:
data
: Input data, raw data for the block.params
: Tuple of strings with parameters given after the marker at the start of the block.
Returns:
Dictionary with each column in the Sinex file as a numpy array.
SinexParser.parse_solution_estimate()
parse_solution_estimate(self:'SinexParser', data:<built-in function array>, *params:str) -> Dict[str, Any]
Simple parser for Sinex data
Converts the input data to a dictionary of numpy arrays and returns it in order to add it to self.data['{marker}']. Ignores any block title parameters.
Args:
data
: Input data, raw data for the block.params
: Tuple of strings with parameters given after the marker at the start of the block.
Returns:
Dictionary with each column in the Sinex file as a numpy array.
SinexParser.parse_solution_matrix_apriori()
parse_solution_matrix_apriori(self:'SinexParser', data:<built-in function array>, lower_upper:str, type:str='') -> Dict[str, Any]
Parser for SOLUTION/MATRIX_APRIORI data
Converts the input data to a symmetric matrix and adds it to self.data['SOLUTION/MATRIX_APRIORI'].
The NEQ-Matrix Row/Column Number correspond to the Estimated Parameters Index in the SOLUTION/ESTIMATE block. Missing elements in the matrix are assumed to be zero (0); consequently, zero elements may be omitted to reduce the size of this block.
Args:
data
: Input data, raw data for SOLUTION/MATRIX_APRIORI block.lower_upper
: Either 'L' or 'U', indicating whether the matrix is given in lower or upper form.type
: Information about the type of matrix, optional.
Returns:
Dictionary with symmetric matrix as a numpy array.
SinexParser.parse_solution_matrix_estimate()
parse_solution_matrix_estimate(self:'SinexParser', data:<built-in function array>, lower_upper:str, type:str='') -> Dict[str, Any]
Parser for SOLUTION/MATRIX_ESTIMATE data
Converts the input data to a symmetric matrix and adds it to self.data['SOLUTION/MATRIX_ESTIMATE'].
The NEQ-Matrix Row/Column Number correspond to the Estimated Parameters Index in the SOLUTION/ESTIMATE block. Missing elements in the matrix are assumed to be zero (0); consequently, zero elements may be omitted to reduce the size of this block.
Args:
data
: Input data, raw data for SOLUTION/MATRIX_ESTIMATE block.lower_upper
: Either 'L' or 'U', indicating whether the matrix is given in lower or upper form.type
: Information about the type of matrix, optional.
Returns:
Dictionary with symmetric matrix as a numpy array.
SinexParser.parse_solution_normal_equation_matrix()
parse_solution_normal_equation_matrix(self:'SinexParser', data:<built-in function array>, lower_upper:str, type:str='') -> Dict[str, Any]
Parser for SOLUTION/NORMAL_EQUATION_MATRIX data
Converts the input data to a symmetric matrix and adds it to self.data['SOLUTION/NORMAL_EQUATION_MATRIX'].
The NEQ-Matrix Row/Column Number correspond to the Estimated Parameters Index in the SOLUTION/ESTIMATE block. Missing elements in the matrix are assumed to be zero (0); consequently, zero elements may be omitted to reduce the size of this block.
Args:
data
: Input data, raw data for SOLUTION/NORMAL_EQUATION_MATRIX block.lower_upper
: Either 'L' or 'U', indicating whether the matrix is given in lower or upper form.type
: Information about the type of matrix, optional.
Returns:
Dictionary with symmetric matrix as a numpy array.
SinexParser.parse_solution_normal_equation_vector()
parse_solution_normal_equation_vector(self:'SinexParser', data:<built-in function array>, *params:str) -> Dict[str, Any]
Simple parser for Sinex data
Converts the input data to a dictionary of numpy arrays and returns it in order to add it to self.data['{marker}']. Ignores any block title parameters.
Args:
data
: Input data, raw data for the block.params
: Tuple of strings with parameters given after the marker at the start of the block.
Returns:
Dictionary with each column in the Sinex file as a numpy array.
SinexParser.parse_solution_statistics()
parse_solution_statistics(self:'SinexParser', data:<built-in function array>, *params:str) -> Dict[str, Any]
Simple parser for Sinex data
Converts the input data to a dictionary of numpy arrays and returns it in order to add it to self.data['{marker}']. Ignores any block title parameters.
Args:
data
: Input data, raw data for the block.params
: Tuple of strings with parameters given after the marker at the start of the block.
Returns:
Dictionary with each column in the Sinex file as a numpy array.
SinexParser.parse_source_id()
parse_source_id(self:'SinexParser', data:<built-in function array>, *params:str) -> Dict[str, Any]
Simple parser for Sinex data
Converts the input data to a dictionary of numpy arrays and returns it in order to add it to self.data['{marker}']. Ignores any block title parameters.
Args:
data
: Input data, raw data for the block.params
: Tuple of strings with parameters given after the marker at the start of the block.
Returns:
Dictionary with each column in the Sinex file as a numpy array.
SinexParser.read_data()
read_data(self) -> None
Read data from a Sinex file and parse the contents
First the whole Sinex file is read and the requested blocks are stored in self._sinex. After the file has been read, a parser is called on each block so that self.data is properly populated.
SinexParser.setup_parser()
setup_parser(self) -> Any
Set up information needed for the parser
Each individual Sinex-parser should at least implement this method.
If the order the blocks are parsed is not important, the information should be returned as a set for optimal performance. If the parsing order is important, a tuple of SinexBlock-objects may be returned instead.
Returns:
Iterable of blocks in the Sinex file that should be parsed.
parsing_factory()
parsing_factory() -> Callable[..., Dict[str, Any]]
Create a default parsing function for a Sinex block
The default parsing function returns a dictionary containing all fields of the block as separated arrays. This will be stored in self.data['{marker}'] with the {marker} of the current block.
Returns:
Simple parsing function for one Sinex block.
parsing_matrix_factory()
parsing_matrix_factory(marker:str, size_marker:str) -> Callable[..., Dict[str, Any]]
Create a parsing function for parsing a matrix within a Sinex block
The default parsing function converts data to a symmetric matrix and stores
it inside self.data[marker]
.
The size of the matrix is set to equal the number of parameters in the
size_marker
-block. If that block is not parsed/found. The size is set to
the last given row index. If some zero elements in the matrix are omitted
this might be wrong.
Args:
marker
: Marker of Sinex block.size_marker
: Marker of a different Sinex block indicating the size of the matrix.
Returns:
Simple parsing function for one Sinex block.