id
int32
0
252k
repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
51
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
243,700
sryza/spark-timeseries
python/sparkts/timeseriesrdd.py
TimeSeriesRDD.to_pandas_dataframe
def to_pandas_dataframe(self): """ Pulls the contents of the RDD to the driver and places them in a Pandas DataFrame. Each record in the RDD becomes and column, and the DataFrame is indexed with a DatetimeIndex generated from this RDD's index. """ pd_index = self...
python
def to_pandas_dataframe(self): pd_index = self.index().to_pandas_index() return pd.DataFrame.from_items(self.collect()).set_index(pd_index)
[ "def", "to_pandas_dataframe", "(", "self", ")", ":", "pd_index", "=", "self", ".", "index", "(", ")", ".", "to_pandas_index", "(", ")", "return", "pd", ".", "DataFrame", ".", "from_items", "(", "self", ".", "collect", "(", ")", ")", ".", "set_index", "...
Pulls the contents of the RDD to the driver and places them in a Pandas DataFrame. Each record in the RDD becomes and column, and the DataFrame is indexed with a DatetimeIndex generated from this RDD's index.
[ "Pulls", "the", "contents", "of", "the", "RDD", "to", "the", "driver", "and", "places", "them", "in", "a", "Pandas", "DataFrame", ".", "Each", "record", "in", "the", "RDD", "becomes", "and", "column", "and", "the", "DataFrame", "is", "indexed", "with", "...
280aa887dc08ab114411245268f230fdabb76eec
https://github.com/sryza/spark-timeseries/blob/280aa887dc08ab114411245268f230fdabb76eec/python/sparkts/timeseriesrdd.py#L148-L156
243,701
google/textfsm
textfsm/texttable.py
Row._SetHeader
def _SetHeader(self, values): """Set the row's header from a list.""" if self._values and len(values) != len(self._values): raise ValueError('Header values not equal to existing data width.') if not self._values: for _ in range(len(values)): self._values.append(None) self._keys = lis...
python
def _SetHeader(self, values): if self._values and len(values) != len(self._values): raise ValueError('Header values not equal to existing data width.') if not self._values: for _ in range(len(values)): self._values.append(None) self._keys = list(values) self._BuildIndex()
[ "def", "_SetHeader", "(", "self", ",", "values", ")", ":", "if", "self", ".", "_values", "and", "len", "(", "values", ")", "!=", "len", "(", "self", ".", "_values", ")", ":", "raise", "ValueError", "(", "'Header values not equal to existing data width.'", ")...
Set the row's header from a list.
[ "Set", "the", "row", "s", "header", "from", "a", "list", "." ]
63a2aaece33e07947aa80963dca99b893964633b
https://github.com/google/textfsm/blob/63a2aaece33e07947aa80963dca99b893964633b/textfsm/texttable.py#L190-L198
243,702
google/textfsm
textfsm/texttable.py
Row._SetValues
def _SetValues(self, values): """Set values from supplied dictionary or list. Args: values: A Row, dict indexed by column name, or list. Raises: TypeError: Argument is not a list or dict, or list is not equal row length or dictionary keys don't match. """ def _ToStr(value): ...
python
def _SetValues(self, values): def _ToStr(value): """Convert individul list entries to string.""" if isinstance(value, (list, tuple)): result = [] for val in value: result.append(str(val)) return result else: return str(value) # Row with identical head...
[ "def", "_SetValues", "(", "self", ",", "values", ")", ":", "def", "_ToStr", "(", "value", ")", ":", "\"\"\"Convert individul list entries to string.\"\"\"", "if", "isinstance", "(", "value", ",", "(", "list", ",", "tuple", ")", ")", ":", "result", "=", "[", ...
Set values from supplied dictionary or list. Args: values: A Row, dict indexed by column name, or list. Raises: TypeError: Argument is not a list or dict, or list is not equal row length or dictionary keys don't match.
[ "Set", "values", "from", "supplied", "dictionary", "or", "list", "." ]
63a2aaece33e07947aa80963dca99b893964633b
https://github.com/google/textfsm/blob/63a2aaece33e07947aa80963dca99b893964633b/textfsm/texttable.py#L222-L264
243,703
google/textfsm
textfsm/texttable.py
TextTable.Filter
def Filter(self, function=None): """Construct Textable from the rows of which the function returns true. Args: function: A function applied to each row which returns a bool. If function is None, all rows with empty column values are removed. Returns: A new TextT...
python
def Filter(self, function=None): flat = lambda x: x if isinstance(x, str) else ''.join([flat(y) for y in x]) if function is None: function = lambda row: bool(flat(row.values)) new_table = self.__class__() # pylint: disable=protected-access new_table._table = [self.header] for row in self:...
[ "def", "Filter", "(", "self", ",", "function", "=", "None", ")", ":", "flat", "=", "lambda", "x", ":", "x", "if", "isinstance", "(", "x", ",", "str", ")", "else", "''", ".", "join", "(", "[", "flat", "(", "y", ")", "for", "y", "in", "x", "]",...
Construct Textable from the rows of which the function returns true. Args: function: A function applied to each row which returns a bool. If function is None, all rows with empty column values are removed. Returns: A new TextTable() Raises: TableError: Wh...
[ "Construct", "Textable", "from", "the", "rows", "of", "which", "the", "function", "returns", "true", "." ]
63a2aaece33e07947aa80963dca99b893964633b
https://github.com/google/textfsm/blob/63a2aaece33e07947aa80963dca99b893964633b/textfsm/texttable.py#L378-L402
243,704
google/textfsm
textfsm/texttable.py
TextTable._GetTable
def _GetTable(self): """Returns table, with column headers and separators. Returns: The whole table including headers as a string. Each row is joined by a newline and each entry by self.separator. """ result = [] # Avoid the global lookup cost on each iteration. lstr = str for r...
python
def _GetTable(self): result = [] # Avoid the global lookup cost on each iteration. lstr = str for row in self._table: result.append( '%s\n' % self.separator.join(lstr(v) for v in row)) return ''.join(result)
[ "def", "_GetTable", "(", "self", ")", ":", "result", "=", "[", "]", "# Avoid the global lookup cost on each iteration.", "lstr", "=", "str", "for", "row", "in", "self", ".", "_table", ":", "result", ".", "append", "(", "'%s\\n'", "%", "self", ".", "separator...
Returns table, with column headers and separators. Returns: The whole table including headers as a string. Each row is joined by a newline and each entry by self.separator.
[ "Returns", "table", "with", "column", "headers", "and", "separators", "." ]
63a2aaece33e07947aa80963dca99b893964633b
https://github.com/google/textfsm/blob/63a2aaece33e07947aa80963dca99b893964633b/textfsm/texttable.py#L595-L610
243,705
google/textfsm
textfsm/texttable.py
TextTable._SetTable
def _SetTable(self, table): """Sets table, with column headers and separators.""" if not isinstance(table, TextTable): raise TypeError('Not an instance of TextTable.') self.Reset() self._table = copy.deepcopy(table._table) # pylint: disable=W0212 # Point parent table of each row back ourselv...
python
def _SetTable(self, table): if not isinstance(table, TextTable): raise TypeError('Not an instance of TextTable.') self.Reset() self._table = copy.deepcopy(table._table) # pylint: disable=W0212 # Point parent table of each row back ourselves. for row in self: row.table = self
[ "def", "_SetTable", "(", "self", ",", "table", ")", ":", "if", "not", "isinstance", "(", "table", ",", "TextTable", ")", ":", "raise", "TypeError", "(", "'Not an instance of TextTable.'", ")", "self", ".", "Reset", "(", ")", "self", ".", "_table", "=", "...
Sets table, with column headers and separators.
[ "Sets", "table", "with", "column", "headers", "and", "separators", "." ]
63a2aaece33e07947aa80963dca99b893964633b
https://github.com/google/textfsm/blob/63a2aaece33e07947aa80963dca99b893964633b/textfsm/texttable.py#L612-L620
243,706
google/textfsm
textfsm/texttable.py
TextTable._TextJustify
def _TextJustify(self, text, col_size): """Formats text within column with white space padding. A single space is prefixed, and a number of spaces are added as a suffix such that the length of the resultant string equals the col_size. If the length of the text exceeds the column width available then i...
python
def _TextJustify(self, text, col_size): result = [] if '\n' in text: for paragraph in text.split('\n'): result.extend(self._TextJustify(paragraph, col_size)) return result wrapper = textwrap.TextWrapper(width=col_size-2, break_long_words=False, expand_...
[ "def", "_TextJustify", "(", "self", ",", "text", ",", "col_size", ")", ":", "result", "=", "[", "]", "if", "'\\n'", "in", "text", ":", "for", "paragraph", "in", "text", ".", "split", "(", "'\\n'", ")", ":", "result", ".", "extend", "(", "self", "."...
Formats text within column with white space padding. A single space is prefixed, and a number of spaces are added as a suffix such that the length of the resultant string equals the col_size. If the length of the text exceeds the column width available then it is split into words and returned as a lis...
[ "Formats", "text", "within", "column", "with", "white", "space", "padding", "." ]
63a2aaece33e07947aa80963dca99b893964633b
https://github.com/google/textfsm/blob/63a2aaece33e07947aa80963dca99b893964633b/textfsm/texttable.py#L639-L684
243,707
google/textfsm
textfsm/texttable.py
TextTable.index
def index(self, name=None): # pylint: disable=C6409 """Returns index number of supplied column name. Args: name: string of column name. Raises: TableError: If name not found. Returns: Index of the specified header entry. """ try: return self.header.index(name) exc...
python
def index(self, name=None): # pylint: disable=C6409 try: return self.header.index(name) except ValueError: raise TableError('Unknown index name %s.' % name)
[ "def", "index", "(", "self", ",", "name", "=", "None", ")", ":", "# pylint: disable=C6409", "try", ":", "return", "self", ".", "header", ".", "index", "(", "name", ")", "except", "ValueError", ":", "raise", "TableError", "(", "'Unknown index name %s.'", "%",...
Returns index number of supplied column name. Args: name: string of column name. Raises: TableError: If name not found. Returns: Index of the specified header entry.
[ "Returns", "index", "number", "of", "supplied", "column", "name", "." ]
63a2aaece33e07947aa80963dca99b893964633b
https://github.com/google/textfsm/blob/63a2aaece33e07947aa80963dca99b893964633b/textfsm/texttable.py#L1074-L1089
243,708
google/textfsm
textfsm/clitable.py
CliTable._ParseCmdItem
def _ParseCmdItem(self, cmd_input, template_file=None): """Creates Texttable with output of command. Args: cmd_input: String, Device response. template_file: File object, template to parse with. Returns: TextTable containing command output. Raises: CliTableError: A template wa...
python
def _ParseCmdItem(self, cmd_input, template_file=None): # Build FSM machine from the template. fsm = textfsm.TextFSM(template_file) if not self._keys: self._keys = set(fsm.GetValuesByAttrib('Key')) # Pass raw data through FSM. table = texttable.TextTable() table.header = fsm.header #...
[ "def", "_ParseCmdItem", "(", "self", ",", "cmd_input", ",", "template_file", "=", "None", ")", ":", "# Build FSM machine from the template.", "fsm", "=", "textfsm", ".", "TextFSM", "(", "template_file", ")", "if", "not", "self", ".", "_keys", ":", "self", ".",...
Creates Texttable with output of command. Args: cmd_input: String, Device response. template_file: File object, template to parse with. Returns: TextTable containing command output. Raises: CliTableError: A template was not found for the given command.
[ "Creates", "Texttable", "with", "output", "of", "command", "." ]
63a2aaece33e07947aa80963dca99b893964633b
https://github.com/google/textfsm/blob/63a2aaece33e07947aa80963dca99b893964633b/textfsm/clitable.py#L288-L313
243,709
google/textfsm
textfsm/clitable.py
CliTable._Completion
def _Completion(self, match): # pylint: disable=C6114 r"""Replaces double square brackets with variable length completion. Completion cannot be mixed with regexp matching or '\' characters i.e. '[[(\n)]] would become (\(n)?)?.' Args: match: A regex Match() object. Returns: String ...
python
def _Completion(self, match): # pylint: disable=C6114 r"""Replaces double square brackets with variable length completion. Completion cannot be mixed with regexp matching or '\' characters i.e. '[[(\n)]] would become (\(n)?)?.' Args: match: A regex Match() object. Returns: String ...
[ "def", "_Completion", "(", "self", ",", "match", ")", ":", "# pylint: disable=C6114", "# Strip the outer '[[' & ']]' and replace with ()? regexp pattern.", "word", "=", "str", "(", "match", ".", "group", "(", ")", ")", "[", "2", ":", "-", "2", "]", "return", "'(...
r"""Replaces double square brackets with variable length completion. Completion cannot be mixed with regexp matching or '\' characters i.e. '[[(\n)]] would become (\(n)?)?.' Args: match: A regex Match() object. Returns: String of the format '(a(b(c(d)?)?)?)?'.
[ "r", "Replaces", "double", "square", "brackets", "with", "variable", "length", "completion", "." ]
63a2aaece33e07947aa80963dca99b893964633b
https://github.com/google/textfsm/blob/63a2aaece33e07947aa80963dca99b893964633b/textfsm/clitable.py#L329-L344
243,710
google/textfsm
textfsm/parser.py
main
def main(argv=None): """Validate text parsed with FSM or validate an FSM via command line.""" if argv is None: argv = sys.argv try: opts, args = getopt.getopt(argv[1:], 'h', ['help']) except getopt.error as msg: raise Usage(msg) for opt, _ in opts: if opt in ('-h', '--help'): print(__...
python
def main(argv=None): if argv is None: argv = sys.argv try: opts, args = getopt.getopt(argv[1:], 'h', ['help']) except getopt.error as msg: raise Usage(msg) for opt, _ in opts: if opt in ('-h', '--help'): print(__doc__) print(help_msg) return 0 if not args or len(args) > 4:...
[ "def", "main", "(", "argv", "=", "None", ")", ":", "if", "argv", "is", "None", ":", "argv", "=", "sys", ".", "argv", "try", ":", "opts", ",", "args", "=", "getopt", ".", "getopt", "(", "argv", "[", "1", ":", "]", ",", "'h'", ",", "[", "'help'...
Validate text parsed with FSM or validate an FSM via command line.
[ "Validate", "text", "parsed", "with", "FSM", "or", "validate", "an", "FSM", "via", "command", "line", "." ]
63a2aaece33e07947aa80963dca99b893964633b
https://github.com/google/textfsm/blob/63a2aaece33e07947aa80963dca99b893964633b/textfsm/parser.py#L1044-L1093
243,711
google/textfsm
textfsm/parser.py
TextFSMOptions.ValidOptions
def ValidOptions(cls): """Returns a list of valid option names.""" valid_options = [] for obj_name in dir(cls): obj = getattr(cls, obj_name) if inspect.isclass(obj) and issubclass(obj, cls.OptionBase): valid_options.append(obj_name) return valid_options
python
def ValidOptions(cls): valid_options = [] for obj_name in dir(cls): obj = getattr(cls, obj_name) if inspect.isclass(obj) and issubclass(obj, cls.OptionBase): valid_options.append(obj_name) return valid_options
[ "def", "ValidOptions", "(", "cls", ")", ":", "valid_options", "=", "[", "]", "for", "obj_name", "in", "dir", "(", "cls", ")", ":", "obj", "=", "getattr", "(", "cls", ",", "obj_name", ")", "if", "inspect", ".", "isclass", "(", "obj", ")", "and", "is...
Returns a list of valid option names.
[ "Returns", "a", "list", "of", "valid", "option", "names", "." ]
63a2aaece33e07947aa80963dca99b893964633b
https://github.com/google/textfsm/blob/63a2aaece33e07947aa80963dca99b893964633b/textfsm/parser.py#L114-L121
243,712
google/textfsm
textfsm/parser.py
TextFSMValue.Header
def Header(self): """Fetch the header name of this Value.""" # Call OnGetValue on options. _ = [option.OnGetValue() for option in self.options] return self.name
python
def Header(self): # Call OnGetValue on options. _ = [option.OnGetValue() for option in self.options] return self.name
[ "def", "Header", "(", "self", ")", ":", "# Call OnGetValue on options.", "_", "=", "[", "option", ".", "OnGetValue", "(", ")", "for", "option", "in", "self", ".", "options", "]", "return", "self", ".", "name" ]
Fetch the header name of this Value.
[ "Fetch", "the", "header", "name", "of", "this", "Value", "." ]
63a2aaece33e07947aa80963dca99b893964633b
https://github.com/google/textfsm/blob/63a2aaece33e07947aa80963dca99b893964633b/textfsm/parser.py#L262-L266
243,713
google/textfsm
textfsm/parser.py
TextFSMValue._AddOption
def _AddOption(self, name): """Add an option to this Value. Args: name: (str), the name of the Option to add. Raises: TextFSMTemplateError: If option is already present or the option does not exist. """ # Check for duplicate option declaration if name in [option.name for o...
python
def _AddOption(self, name): # Check for duplicate option declaration if name in [option.name for option in self.options]: raise TextFSMTemplateError('Duplicate option "%s"' % name) # Create the option object try: option = self._options_cls.GetOption(name)(self) except AttributeError: ...
[ "def", "_AddOption", "(", "self", ",", "name", ")", ":", "# Check for duplicate option declaration", "if", "name", "in", "[", "option", ".", "name", "for", "option", "in", "self", ".", "options", "]", ":", "raise", "TextFSMTemplateError", "(", "'Duplicate option...
Add an option to this Value. Args: name: (str), the name of the Option to add. Raises: TextFSMTemplateError: If option is already present or the option does not exist.
[ "Add", "an", "option", "to", "this", "Value", "." ]
63a2aaece33e07947aa80963dca99b893964633b
https://github.com/google/textfsm/blob/63a2aaece33e07947aa80963dca99b893964633b/textfsm/parser.py#L321-L342
243,714
google/textfsm
textfsm/parser.py
TextFSM.Reset
def Reset(self): """Preserves FSM but resets starting state and current record.""" # Current state is Start state. self._cur_state = self.states['Start'] self._cur_state_name = 'Start' # Clear table of results and current record. self._result = [] self._ClearAllRecord()
python
def Reset(self): # Current state is Start state. self._cur_state = self.states['Start'] self._cur_state_name = 'Start' # Clear table of results and current record. self._result = [] self._ClearAllRecord()
[ "def", "Reset", "(", "self", ")", ":", "# Current state is Start state.", "self", ".", "_cur_state", "=", "self", ".", "states", "[", "'Start'", "]", "self", ".", "_cur_state_name", "=", "'Start'", "# Clear table of results and current record.", "self", ".", "_resul...
Preserves FSM but resets starting state and current record.
[ "Preserves", "FSM", "but", "resets", "starting", "state", "and", "current", "record", "." ]
63a2aaece33e07947aa80963dca99b893964633b
https://github.com/google/textfsm/blob/63a2aaece33e07947aa80963dca99b893964633b/textfsm/parser.py#L596-L605
243,715
google/textfsm
textfsm/parser.py
TextFSM._GetHeader
def _GetHeader(self): """Returns header.""" header = [] for value in self.values: try: header.append(value.Header()) except SkipValue: continue return header
python
def _GetHeader(self): header = [] for value in self.values: try: header.append(value.Header()) except SkipValue: continue return header
[ "def", "_GetHeader", "(", "self", ")", ":", "header", "=", "[", "]", "for", "value", "in", "self", ".", "values", ":", "try", ":", "header", ".", "append", "(", "value", ".", "Header", "(", ")", ")", "except", "SkipValue", ":", "continue", "return", ...
Returns header.
[ "Returns", "header", "." ]
63a2aaece33e07947aa80963dca99b893964633b
https://github.com/google/textfsm/blob/63a2aaece33e07947aa80963dca99b893964633b/textfsm/parser.py#L612-L620
243,716
google/textfsm
textfsm/parser.py
TextFSM._GetValue
def _GetValue(self, name): """Returns the TextFSMValue object natching the requested name.""" for value in self.values: if value.name == name: return value
python
def _GetValue(self, name): for value in self.values: if value.name == name: return value
[ "def", "_GetValue", "(", "self", ",", "name", ")", ":", "for", "value", "in", "self", ".", "values", ":", "if", "value", ".", "name", "==", "name", ":", "return", "value" ]
Returns the TextFSMValue object natching the requested name.
[ "Returns", "the", "TextFSMValue", "object", "natching", "the", "requested", "name", "." ]
63a2aaece33e07947aa80963dca99b893964633b
https://github.com/google/textfsm/blob/63a2aaece33e07947aa80963dca99b893964633b/textfsm/parser.py#L622-L626
243,717
google/textfsm
textfsm/parser.py
TextFSM._AppendRecord
def _AppendRecord(self): """Adds current record to result if well formed.""" # If no Values then don't output. if not self.values: return cur_record = [] for value in self.values: try: value.OnSaveRecord() except SkipRecord: self._ClearRecord() return ...
python
def _AppendRecord(self): # If no Values then don't output. if not self.values: return cur_record = [] for value in self.values: try: value.OnSaveRecord() except SkipRecord: self._ClearRecord() return except SkipValue: continue # Build curre...
[ "def", "_AppendRecord", "(", "self", ")", ":", "# If no Values then don't output.", "if", "not", "self", ".", "values", ":", "return", "cur_record", "=", "[", "]", "for", "value", "in", "self", ".", "values", ":", "try", ":", "value", ".", "OnSaveRecord", ...
Adds current record to result if well formed.
[ "Adds", "current", "record", "to", "result", "if", "well", "formed", "." ]
63a2aaece33e07947aa80963dca99b893964633b
https://github.com/google/textfsm/blob/63a2aaece33e07947aa80963dca99b893964633b/textfsm/parser.py#L628-L657
243,718
google/textfsm
textfsm/parser.py
TextFSM._Parse
def _Parse(self, template): """Parses template file for FSM structure. Args: template: Valid template file. Raises: TextFSMTemplateError: If template file syntax is invalid. """ if not template: raise TextFSMTemplateError('Null template.') # Parse header with Variables. ...
python
def _Parse(self, template): if not template: raise TextFSMTemplateError('Null template.') # Parse header with Variables. self._ParseFSMVariables(template) # Parse States. while self._ParseFSMState(template): pass # Validate destination states. self._ValidateFSM()
[ "def", "_Parse", "(", "self", ",", "template", ")", ":", "if", "not", "template", ":", "raise", "TextFSMTemplateError", "(", "'Null template.'", ")", "# Parse header with Variables.", "self", ".", "_ParseFSMVariables", "(", "template", ")", "# Parse States.", "while...
Parses template file for FSM structure. Args: template: Valid template file. Raises: TextFSMTemplateError: If template file syntax is invalid.
[ "Parses", "template", "file", "for", "FSM", "structure", "." ]
63a2aaece33e07947aa80963dca99b893964633b
https://github.com/google/textfsm/blob/63a2aaece33e07947aa80963dca99b893964633b/textfsm/parser.py#L659-L680
243,719
google/textfsm
textfsm/parser.py
TextFSM._ParseFSMVariables
def _ParseFSMVariables(self, template): """Extracts Variables from start of template file. Values are expected as a contiguous block at the head of the file. These will be line separated from the State definitions that follow. Args: template: Valid template file, with Value definitions at the to...
python
def _ParseFSMVariables(self, template): self.values = [] for line in template: self._line_num += 1 line = line.rstrip() # Blank line signifies end of Value definitions. if not line: return # Skip commented lines. if self.comment_regex.match(line): continue ...
[ "def", "_ParseFSMVariables", "(", "self", ",", "template", ")", ":", "self", ".", "values", "=", "[", "]", "for", "line", "in", "template", ":", "self", ".", "_line_num", "+=", "1", "line", "=", "line", ".", "rstrip", "(", ")", "# Blank line signifies en...
Extracts Variables from start of template file. Values are expected as a contiguous block at the head of the file. These will be line separated from the State definitions that follow. Args: template: Valid template file, with Value definitions at the top. Raises: TextFSMTemplateError: If ...
[ "Extracts", "Variables", "from", "start", "of", "template", "file", "." ]
63a2aaece33e07947aa80963dca99b893964633b
https://github.com/google/textfsm/blob/63a2aaece33e07947aa80963dca99b893964633b/textfsm/parser.py#L682-L736
243,720
google/textfsm
textfsm/parser.py
TextFSM._ParseFSMState
def _ParseFSMState(self, template): """Extracts State and associated Rules from body of template file. After the Value definitions the remainder of the template is state definitions. The routine is expected to be called iteratively until no more states remain - indicated by returning None. The rou...
python
def _ParseFSMState(self, template): if not template: return state_name = '' # Strip off extra white space lines (including comments). for line in template: self._line_num += 1 line = line.rstrip() # First line is state definition if line and not self.comment_regex.match(l...
[ "def", "_ParseFSMState", "(", "self", ",", "template", ")", ":", "if", "not", "template", ":", "return", "state_name", "=", "''", "# Strip off extra white space lines (including comments).", "for", "line", "in", "template", ":", "self", ".", "_line_num", "+=", "1"...
Extracts State and associated Rules from body of template file. After the Value definitions the remainder of the template is state definitions. The routine is expected to be called iteratively until no more states remain - indicated by returning None. The routine checks that the state names are a well...
[ "Extracts", "State", "and", "associated", "Rules", "from", "body", "of", "template", "file", "." ]
63a2aaece33e07947aa80963dca99b893964633b
https://github.com/google/textfsm/blob/63a2aaece33e07947aa80963dca99b893964633b/textfsm/parser.py#L743-L812
243,721
google/textfsm
textfsm/parser.py
TextFSM._ValidateFSM
def _ValidateFSM(self): """Checks state names and destinations for validity. Each destination state must exist, be a valid name and not be a reserved name. There must be a 'Start' state and if 'EOF' or 'End' states are specified, they must be empty. Returns: True if FSM is valid. Ra...
python
def _ValidateFSM(self): # Must have 'Start' state. if 'Start' not in self.states: raise TextFSMTemplateError("Missing state 'Start'.") # 'End/EOF' state (if specified) must be empty. if self.states.get('End'): raise TextFSMTemplateError("Non-Empty 'End' state.") if self.states.get('EOF...
[ "def", "_ValidateFSM", "(", "self", ")", ":", "# Must have 'Start' state.", "if", "'Start'", "not", "in", "self", ".", "states", ":", "raise", "TextFSMTemplateError", "(", "\"Missing state 'Start'.\"", ")", "# 'End/EOF' state (if specified) must be empty.", "if", "self", ...
Checks state names and destinations for validity. Each destination state must exist, be a valid name and not be a reserved name. There must be a 'Start' state and if 'EOF' or 'End' states are specified, they must be empty. Returns: True if FSM is valid. Raises: TextFSMTemplateErro...
[ "Checks", "state", "names", "and", "destinations", "for", "validity", "." ]
63a2aaece33e07947aa80963dca99b893964633b
https://github.com/google/textfsm/blob/63a2aaece33e07947aa80963dca99b893964633b/textfsm/parser.py#L814-L859
243,722
google/textfsm
textfsm/parser.py
TextFSM.ParseText
def ParseText(self, text, eof=True): """Passes CLI output through FSM and returns list of tuples. First tuple is the header, every subsequent tuple is a row. Args: text: (str), Text to parse with embedded newlines. eof: (boolean), Set to False if we are parsing only part of the file. ...
python
def ParseText(self, text, eof=True): lines = [] if text: lines = text.splitlines() for line in lines: self._CheckLine(line) if self._cur_state_name in ('End', 'EOF'): break if self._cur_state_name != 'End' and 'EOF' not in self.states and eof: # Implicit EOF performs Ne...
[ "def", "ParseText", "(", "self", ",", "text", ",", "eof", "=", "True", ")", ":", "lines", "=", "[", "]", "if", "text", ":", "lines", "=", "text", ".", "splitlines", "(", ")", "for", "line", "in", "lines", ":", "self", ".", "_CheckLine", "(", "lin...
Passes CLI output through FSM and returns list of tuples. First tuple is the header, every subsequent tuple is a row. Args: text: (str), Text to parse with embedded newlines. eof: (boolean), Set to False if we are parsing only part of the file. Suppresses triggering EOF state. Rai...
[ "Passes", "CLI", "output", "through", "FSM", "and", "returns", "list", "of", "tuples", "." ]
63a2aaece33e07947aa80963dca99b893964633b
https://github.com/google/textfsm/blob/63a2aaece33e07947aa80963dca99b893964633b/textfsm/parser.py#L861-L892
243,723
google/textfsm
textfsm/parser.py
TextFSM.ParseTextToDicts
def ParseTextToDicts(self, *args, **kwargs): """Calls ParseText and turns the result into list of dicts. List items are dicts of rows, dict key is column header and value is column value. Args: text: (str), Text to parse with embedded newlines. eof: (boolean), Set to False if we are parsin...
python
def ParseTextToDicts(self, *args, **kwargs): result_lists = self.ParseText(*args, **kwargs) result_dicts = [] for row in result_lists: result_dicts.append(dict(zip(self.header, row))) return result_dicts
[ "def", "ParseTextToDicts", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "result_lists", "=", "self", ".", "ParseText", "(", "*", "args", ",", "*", "*", "kwargs", ")", "result_dicts", "=", "[", "]", "for", "row", "in", "result_lis...
Calls ParseText and turns the result into list of dicts. List items are dicts of rows, dict key is column header and value is column value. Args: text: (str), Text to parse with embedded newlines. eof: (boolean), Set to False if we are parsing only part of the file. Suppresses trig...
[ "Calls", "ParseText", "and", "turns", "the", "result", "into", "list", "of", "dicts", "." ]
63a2aaece33e07947aa80963dca99b893964633b
https://github.com/google/textfsm/blob/63a2aaece33e07947aa80963dca99b893964633b/textfsm/parser.py#L894-L918
243,724
google/textfsm
textfsm/parser.py
TextFSM._AssignVar
def _AssignVar(self, matched, value): """Assigns variable into current record from a matched rule. If a record entry is a list then append, otherwise values are replaced. Args: matched: (regexp.match) Named group for each matched value. value: (str) The matched value. """ _value = self...
python
def _AssignVar(self, matched, value): _value = self._GetValue(value) if _value is not None: _value.AssignVar(matched.group(value))
[ "def", "_AssignVar", "(", "self", ",", "matched", ",", "value", ")", ":", "_value", "=", "self", ".", "_GetValue", "(", "value", ")", "if", "_value", "is", "not", "None", ":", "_value", ".", "AssignVar", "(", "matched", ".", "group", "(", "value", ")...
Assigns variable into current record from a matched rule. If a record entry is a list then append, otherwise values are replaced. Args: matched: (regexp.match) Named group for each matched value. value: (str) The matched value.
[ "Assigns", "variable", "into", "current", "record", "from", "a", "matched", "rule", "." ]
63a2aaece33e07947aa80963dca99b893964633b
https://github.com/google/textfsm/blob/63a2aaece33e07947aa80963dca99b893964633b/textfsm/parser.py#L955-L966
243,725
google/textfsm
textfsm/parser.py
TextFSM._Operations
def _Operations(self, rule, line): """Operators on the data record. Operators come in two parts and are a '.' separated pair: Operators that effect the input line or the current state (line_op). 'Next' Get next input line and restart parsing (default). 'Continue' Keep current input...
python
def _Operations(self, rule, line): # First process the Record operators. if rule.record_op == 'Record': self._AppendRecord() elif rule.record_op == 'Clear': # Clear record. self._ClearRecord() elif rule.record_op == 'Clearall': # Clear all record entries. self._ClearAllRe...
[ "def", "_Operations", "(", "self", ",", "rule", ",", "line", ")", ":", "# First process the Record operators.", "if", "rule", ".", "record_op", "==", "'Record'", ":", "self", ".", "_AppendRecord", "(", ")", "elif", "rule", ".", "record_op", "==", "'Clear'", ...
Operators on the data record. Operators come in two parts and are a '.' separated pair: Operators that effect the input line or the current state (line_op). 'Next' Get next input line and restart parsing (default). 'Continue' Keep current input line and continue resume parsing. ...
[ "Operators", "on", "the", "data", "record", "." ]
63a2aaece33e07947aa80963dca99b893964633b
https://github.com/google/textfsm/blob/63a2aaece33e07947aa80963dca99b893964633b/textfsm/parser.py#L968-L1020
243,726
google/textfsm
textfsm/parser.py
TextFSM.GetValuesByAttrib
def GetValuesByAttrib(self, attribute): """Returns the list of values that have a particular attribute.""" if attribute not in self._options_cls.ValidOptions(): raise ValueError("'%s': Not a valid attribute." % attribute) result = [] for value in self.values: if attribute in value.OptionNa...
python
def GetValuesByAttrib(self, attribute): if attribute not in self._options_cls.ValidOptions(): raise ValueError("'%s': Not a valid attribute." % attribute) result = [] for value in self.values: if attribute in value.OptionNames(): result.append(value.name) return result
[ "def", "GetValuesByAttrib", "(", "self", ",", "attribute", ")", ":", "if", "attribute", "not", "in", "self", ".", "_options_cls", ".", "ValidOptions", "(", ")", ":", "raise", "ValueError", "(", "\"'%s': Not a valid attribute.\"", "%", "attribute", ")", "result",...
Returns the list of values that have a particular attribute.
[ "Returns", "the", "list", "of", "values", "that", "have", "a", "particular", "attribute", "." ]
63a2aaece33e07947aa80963dca99b893964633b
https://github.com/google/textfsm/blob/63a2aaece33e07947aa80963dca99b893964633b/textfsm/parser.py#L1030-L1041
243,727
google/textfsm
textfsm/terminal.py
_AnsiCmd
def _AnsiCmd(command_list): """Takes a list of SGR values and formats them as an ANSI escape sequence. Args: command_list: List of strings, each string represents an SGR value. e.g. 'fg_blue', 'bg_yellow' Returns: The ANSI escape sequence. Raises: ValueError: if a member of command_list d...
python
def _AnsiCmd(command_list): if not isinstance(command_list, list): raise ValueError('Invalid list: %s' % command_list) # Checks that entries are valid SGR names. # No checking is done for sequences that are correct but 'nonsensical'. for sgr in command_list: if sgr.lower() not in SGR: raise ValueE...
[ "def", "_AnsiCmd", "(", "command_list", ")", ":", "if", "not", "isinstance", "(", "command_list", ",", "list", ")", ":", "raise", "ValueError", "(", "'Invalid list: %s'", "%", "command_list", ")", "# Checks that entries are valid SGR names.", "# No checking is done for ...
Takes a list of SGR values and formats them as an ANSI escape sequence. Args: command_list: List of strings, each string represents an SGR value. e.g. 'fg_blue', 'bg_yellow' Returns: The ANSI escape sequence. Raises: ValueError: if a member of command_list does not map to a valid SGR value.
[ "Takes", "a", "list", "of", "SGR", "values", "and", "formats", "them", "as", "an", "ANSI", "escape", "sequence", "." ]
63a2aaece33e07947aa80963dca99b893964633b
https://github.com/google/textfsm/blob/63a2aaece33e07947aa80963dca99b893964633b/textfsm/terminal.py#L115-L138
243,728
google/textfsm
textfsm/terminal.py
TerminalSize
def TerminalSize(): """Returns terminal length and width as a tuple.""" try: with open(os.ctermid(), 'r') as tty_instance: length_width = struct.unpack( 'hh', fcntl.ioctl(tty_instance.fileno(), termios.TIOCGWINSZ, '1234')) except (IOError, OSError): try: length_width = (int(os.enviro...
python
def TerminalSize(): try: with open(os.ctermid(), 'r') as tty_instance: length_width = struct.unpack( 'hh', fcntl.ioctl(tty_instance.fileno(), termios.TIOCGWINSZ, '1234')) except (IOError, OSError): try: length_width = (int(os.environ['LINES']), int(os.environ['COL...
[ "def", "TerminalSize", "(", ")", ":", "try", ":", "with", "open", "(", "os", ".", "ctermid", "(", ")", ",", "'r'", ")", "as", "tty_instance", ":", "length_width", "=", "struct", ".", "unpack", "(", "'hh'", ",", "fcntl", ".", "ioctl", "(", "tty_instan...
Returns terminal length and width as a tuple.
[ "Returns", "terminal", "length", "and", "width", "as", "a", "tuple", "." ]
63a2aaece33e07947aa80963dca99b893964633b
https://github.com/google/textfsm/blob/63a2aaece33e07947aa80963dca99b893964633b/textfsm/terminal.py#L170-L182
243,729
google/textfsm
textfsm/terminal.py
main
def main(argv=None): """Routine to page text or determine window size via command line.""" if argv is None: argv = sys.argv try: opts, args = getopt.getopt(argv[1:], 'dhs', ['nodelay', 'help', 'size']) except getopt.error as msg: raise Usage(msg) # Print usage and return, regardless of presence...
python
def main(argv=None): if argv is None: argv = sys.argv try: opts, args = getopt.getopt(argv[1:], 'dhs', ['nodelay', 'help', 'size']) except getopt.error as msg: raise Usage(msg) # Print usage and return, regardless of presence of other args. for opt, _ in opts: if opt in ('-h', '--help'): ...
[ "def", "main", "(", "argv", "=", "None", ")", ":", "if", "argv", "is", "None", ":", "argv", "=", "sys", ".", "argv", "try", ":", "opts", ",", "args", "=", "getopt", ".", "getopt", "(", "argv", "[", "1", ":", "]", ",", "'dhs'", ",", "[", "'nod...
Routine to page text or determine window size via command line.
[ "Routine", "to", "page", "text", "or", "determine", "window", "size", "via", "command", "line", "." ]
63a2aaece33e07947aa80963dca99b893964633b
https://github.com/google/textfsm/blob/63a2aaece33e07947aa80963dca99b893964633b/textfsm/terminal.py#L447-L484
243,730
google/textfsm
textfsm/terminal.py
Pager.Reset
def Reset(self): """Reset the pager to the top of the text.""" self._displayed = 0 self._currentpagelines = 0 self._lastscroll = 1 self._lines_to_show = self._cli_lines
python
def Reset(self): self._displayed = 0 self._currentpagelines = 0 self._lastscroll = 1 self._lines_to_show = self._cli_lines
[ "def", "Reset", "(", "self", ")", ":", "self", ".", "_displayed", "=", "0", "self", ".", "_currentpagelines", "=", "0", "self", ".", "_lastscroll", "=", "1", "self", ".", "_lines_to_show", "=", "self", ".", "_cli_lines" ]
Reset the pager to the top of the text.
[ "Reset", "the", "pager", "to", "the", "top", "of", "the", "text", "." ]
63a2aaece33e07947aa80963dca99b893964633b
https://github.com/google/textfsm/blob/63a2aaece33e07947aa80963dca99b893964633b/textfsm/terminal.py#L302-L307
243,731
google/textfsm
textfsm/terminal.py
Pager.SetLines
def SetLines(self, lines): """Set number of screen lines. Args: lines: An int, number of lines. If None, use terminal dimensions. Raises: ValueError, TypeError: Not a valid integer representation. """ (self._cli_lines, self._cli_cols) = TerminalSize() if lines: self._cli_li...
python
def SetLines(self, lines): (self._cli_lines, self._cli_cols) = TerminalSize() if lines: self._cli_lines = int(lines)
[ "def", "SetLines", "(", "self", ",", "lines", ")", ":", "(", "self", ".", "_cli_lines", ",", "self", ".", "_cli_cols", ")", "=", "TerminalSize", "(", ")", "if", "lines", ":", "self", ".", "_cli_lines", "=", "int", "(", "lines", ")" ]
Set number of screen lines. Args: lines: An int, number of lines. If None, use terminal dimensions. Raises: ValueError, TypeError: Not a valid integer representation.
[ "Set", "number", "of", "screen", "lines", "." ]
63a2aaece33e07947aa80963dca99b893964633b
https://github.com/google/textfsm/blob/63a2aaece33e07947aa80963dca99b893964633b/textfsm/terminal.py#L309-L322
243,732
google/textfsm
textfsm/terminal.py
Pager.Page
def Page(self, text=None, show_percent=None): """Page text. Continues to page through any text supplied in the constructor. Also, any text supplied to this method will be appended to the total text to be displayed. The method returns when all available text has been displayed to the user, or the us...
python
def Page(self, text=None, show_percent=None): if text is not None: self._text += text if show_percent is None: show_percent = text is None self._show_percent = show_percent text = LineWrap(self._text).splitlines() while True: # Get a list of new lines to display. self._newl...
[ "def", "Page", "(", "self", ",", "text", "=", "None", ",", "show_percent", "=", "None", ")", ":", "if", "text", "is", "not", "None", ":", "self", ".", "_text", "+=", "text", "if", "show_percent", "is", "None", ":", "show_percent", "=", "text", "is", ...
Page text. Continues to page through any text supplied in the constructor. Also, any text supplied to this method will be appended to the total text to be displayed. The method returns when all available text has been displayed to the user, or the user quits the pager. Args: text: A string, ...
[ "Page", "text", "." ]
63a2aaece33e07947aa80963dca99b893964633b
https://github.com/google/textfsm/blob/63a2aaece33e07947aa80963dca99b893964633b/textfsm/terminal.py#L329-L383
243,733
google/textfsm
textfsm/terminal.py
Pager._Scroll
def _Scroll(self, lines=None): """Set attributes to scroll the buffer correctly. Args: lines: An int, number of lines to scroll. If None, scrolls by the terminal length. """ if lines is None: lines = self._cli_lines if lines < 0: self._displayed -= self._cli_lines s...
python
def _Scroll(self, lines=None): if lines is None: lines = self._cli_lines if lines < 0: self._displayed -= self._cli_lines self._displayed += lines if self._displayed < 0: self._displayed = 0 self._lines_to_show = self._cli_lines else: self._lines_to_show = lines ...
[ "def", "_Scroll", "(", "self", ",", "lines", "=", "None", ")", ":", "if", "lines", "is", "None", ":", "lines", "=", "self", ".", "_cli_lines", "if", "lines", "<", "0", ":", "self", ".", "_displayed", "-=", "self", ".", "_cli_lines", "self", ".", "_...
Set attributes to scroll the buffer correctly. Args: lines: An int, number of lines to scroll. If None, scrolls by the terminal length.
[ "Set", "attributes", "to", "scroll", "the", "buffer", "correctly", "." ]
63a2aaece33e07947aa80963dca99b893964633b
https://github.com/google/textfsm/blob/63a2aaece33e07947aa80963dca99b893964633b/textfsm/terminal.py#L385-L404
243,734
google/textfsm
textfsm/terminal.py
Pager._AskUser
def _AskUser(self): """Prompt the user for the next action. Returns: A string, the character entered by the user. """ if self._show_percent: progress = int(self._displayed*100 / (len(self._text.splitlines()))) progress_text = ' (%d%%)' % progress else: progress_text = '' ...
python
def _AskUser(self): if self._show_percent: progress = int(self._displayed*100 / (len(self._text.splitlines()))) progress_text = ' (%d%%)' % progress else: progress_text = '' question = AnsiText( 'Enter: next line, Space: next page, ' 'b: prev page, q: quit.%s' % pro...
[ "def", "_AskUser", "(", "self", ")", ":", "if", "self", ".", "_show_percent", ":", "progress", "=", "int", "(", "self", ".", "_displayed", "*", "100", "/", "(", "len", "(", "self", ".", "_text", ".", "splitlines", "(", ")", ")", ")", ")", "progress...
Prompt the user for the next action. Returns: A string, the character entered by the user.
[ "Prompt", "the", "user", "for", "the", "next", "action", "." ]
63a2aaece33e07947aa80963dca99b893964633b
https://github.com/google/textfsm/blob/63a2aaece33e07947aa80963dca99b893964633b/textfsm/terminal.py#L406-L426
243,735
google/textfsm
textfsm/terminal.py
Pager._GetCh
def _GetCh(self): """Read a single character from the user. Returns: A string, the character read. """ fd = self._tty.fileno() old = termios.tcgetattr(fd) try: tty.setraw(fd) ch = self._tty.read(1) # Also support arrow key shortcuts (escape + 2 chars) if ord(ch) ==...
python
def _GetCh(self): fd = self._tty.fileno() old = termios.tcgetattr(fd) try: tty.setraw(fd) ch = self._tty.read(1) # Also support arrow key shortcuts (escape + 2 chars) if ord(ch) == 27: ch += self._tty.read(2) finally: termios.tcsetattr(fd, termios.TCSADRAIN, old) ...
[ "def", "_GetCh", "(", "self", ")", ":", "fd", "=", "self", ".", "_tty", ".", "fileno", "(", ")", "old", "=", "termios", ".", "tcgetattr", "(", "fd", ")", "try", ":", "tty", ".", "setraw", "(", "fd", ")", "ch", "=", "self", ".", "_tty", ".", "...
Read a single character from the user. Returns: A string, the character read.
[ "Read", "a", "single", "character", "from", "the", "user", "." ]
63a2aaece33e07947aa80963dca99b893964633b
https://github.com/google/textfsm/blob/63a2aaece33e07947aa80963dca99b893964633b/textfsm/terminal.py#L428-L444
243,736
skyfielders/python-skyfield
skyfield/relativity.py
add_deflection
def add_deflection(position, observer, ephemeris, t, include_earth_deflection, count=3): """Update `position` for how solar system masses will deflect its light. Given the ICRS `position` [x,y,z] of an object (au) that is being viewed from the `observer` also expressed as [x,y,z], and gi...
python
def add_deflection(position, observer, ephemeris, t, include_earth_deflection, count=3): # Compute light-time to observed object. tlt = length_of(position) / C_AUDAY # Cycle through gravitating bodies. jd_tdb = t.tdb ts = t.ts for name in deflectors[:count]: try: ...
[ "def", "add_deflection", "(", "position", ",", "observer", ",", "ephemeris", ",", "t", ",", "include_earth_deflection", ",", "count", "=", "3", ")", ":", "# Compute light-time to observed object.", "tlt", "=", "length_of", "(", "position", ")", "/", "C_AUDAY", "...
Update `position` for how solar system masses will deflect its light. Given the ICRS `position` [x,y,z] of an object (au) that is being viewed from the `observer` also expressed as [x,y,z], and given an ephemeris that can be used to determine solar system body positions, and given the time `t` and Bool...
[ "Update", "position", "for", "how", "solar", "system", "masses", "will", "deflect", "its", "light", "." ]
51d9e042e06457f6b1f2415296d50a38cb3a300f
https://github.com/skyfielders/python-skyfield/blob/51d9e042e06457f6b1f2415296d50a38cb3a300f/skyfield/relativity.py#L23-L97
243,737
skyfielders/python-skyfield
skyfield/relativity.py
_add_deflection
def _add_deflection(position, observer, deflector, rmass): """Correct a position vector for how one particular mass deflects light. Given the ICRS `position` [x,y,z] of an object (AU) together with the positions of an `observer` and a `deflector` of reciprocal mass `rmass`, this function updates `posit...
python
def _add_deflection(position, observer, deflector, rmass): # Construct vector 'pq' from gravitating body to observed object and # construct vector 'pe' from gravitating body to observer. pq = observer + position - deflector pe = observer - deflector # Compute vector magnitudes and unit vectors. ...
[ "def", "_add_deflection", "(", "position", ",", "observer", ",", "deflector", ",", "rmass", ")", ":", "# Construct vector 'pq' from gravitating body to observed object and", "# construct vector 'pe' from gravitating body to observer.", "pq", "=", "observer", "+", "position", "-...
Correct a position vector for how one particular mass deflects light. Given the ICRS `position` [x,y,z] of an object (AU) together with the positions of an `observer` and a `deflector` of reciprocal mass `rmass`, this function updates `position` in-place to show how much the presence of the deflector w...
[ "Correct", "a", "position", "vector", "for", "how", "one", "particular", "mass", "deflects", "light", "." ]
51d9e042e06457f6b1f2415296d50a38cb3a300f
https://github.com/skyfielders/python-skyfield/blob/51d9e042e06457f6b1f2415296d50a38cb3a300f/skyfield/relativity.py#L121-L166
243,738
skyfielders/python-skyfield
skyfield/relativity.py
add_aberration
def add_aberration(position, velocity, light_time): """Correct a relative position vector for aberration of light. Given the relative `position` [x,y,z] of an object (AU) from a particular observer, the `velocity` [dx,dy,dz] at which the observer is traveling (AU/day), and the light propagation delay `...
python
def add_aberration(position, velocity, light_time): p1mag = light_time * C_AUDAY vemag = length_of(velocity) beta = vemag / C_AUDAY dot = dots(position, velocity) cosd = dot / (p1mag * vemag) gammai = sqrt(1.0 - beta * beta) p = beta * cosd q = (1.0 + p / (1.0 + gammai)) * light_time ...
[ "def", "add_aberration", "(", "position", ",", "velocity", ",", "light_time", ")", ":", "p1mag", "=", "light_time", "*", "C_AUDAY", "vemag", "=", "length_of", "(", "velocity", ")", "beta", "=", "vemag", "/", "C_AUDAY", "dot", "=", "dots", "(", "position", ...
Correct a relative position vector for aberration of light. Given the relative `position` [x,y,z] of an object (AU) from a particular observer, the `velocity` [dx,dy,dz] at which the observer is traveling (AU/day), and the light propagation delay `light_time` to the object (days), this function updates...
[ "Correct", "a", "relative", "position", "vector", "for", "aberration", "of", "light", "." ]
51d9e042e06457f6b1f2415296d50a38cb3a300f
https://github.com/skyfielders/python-skyfield/blob/51d9e042e06457f6b1f2415296d50a38cb3a300f/skyfield/relativity.py#L170-L193
243,739
skyfielders/python-skyfield
skyfield/jpllib.py
_center
def _center(code, segment_dict): """Starting with `code`, follow segments from target to center.""" while code in segment_dict: segment = segment_dict[code] yield segment code = segment.center
python
def _center(code, segment_dict): while code in segment_dict: segment = segment_dict[code] yield segment code = segment.center
[ "def", "_center", "(", "code", ",", "segment_dict", ")", ":", "while", "code", "in", "segment_dict", ":", "segment", "=", "segment_dict", "[", "code", "]", "yield", "segment", "code", "=", "segment", ".", "center" ]
Starting with `code`, follow segments from target to center.
[ "Starting", "with", "code", "follow", "segments", "from", "target", "to", "center", "." ]
51d9e042e06457f6b1f2415296d50a38cb3a300f
https://github.com/skyfielders/python-skyfield/blob/51d9e042e06457f6b1f2415296d50a38cb3a300f/skyfield/jpllib.py#L217-L222
243,740
skyfielders/python-skyfield
skyfield/jpllib.py
SpiceKernel.names
def names(self): """Return all target names that are valid with this kernel. >>> pprint(planets.names()) {0: ['SOLAR_SYSTEM_BARYCENTER', 'SSB', 'SOLAR SYSTEM BARYCENTER'], 1: ['MERCURY_BARYCENTER', 'MERCURY BARYCENTER'], 2: ['VENUS_BARYCENTER', 'VENUS BARYCENTER'], 3:...
python
def names(self): d = defaultdict(list) for code, name in target_name_pairs: if code in self.codes: d[code].append(name) return dict(d)
[ "def", "names", "(", "self", ")", ":", "d", "=", "defaultdict", "(", "list", ")", "for", "code", ",", "name", "in", "target_name_pairs", ":", "if", "code", "in", "self", ".", "codes", ":", "d", "[", "code", "]", ".", "append", "(", "name", ")", "...
Return all target names that are valid with this kernel. >>> pprint(planets.names()) {0: ['SOLAR_SYSTEM_BARYCENTER', 'SSB', 'SOLAR SYSTEM BARYCENTER'], 1: ['MERCURY_BARYCENTER', 'MERCURY BARYCENTER'], 2: ['VENUS_BARYCENTER', 'VENUS BARYCENTER'], 3: ['EARTH_BARYCENTER', ...
[ "Return", "all", "target", "names", "that", "are", "valid", "with", "this", "kernel", "." ]
51d9e042e06457f6b1f2415296d50a38cb3a300f
https://github.com/skyfielders/python-skyfield/blob/51d9e042e06457f6b1f2415296d50a38cb3a300f/skyfield/jpllib.py#L106-L126
243,741
skyfielders/python-skyfield
skyfield/jpllib.py
SpiceKernel.decode
def decode(self, name): """Translate a target name into its integer code. >>> planets.decode('Venus') 299 Raises ``ValueError`` if you supply an unknown name, or ``KeyError`` if the target is missing from this kernel. You can supply an integer code if you already have ...
python
def decode(self, name): if isinstance(name, int): code = name else: name = name.upper() code = _targets.get(name) if code is None: raise ValueError('unknown SPICE target {0!r}'.format(name)) if code not in self.codes: ta...
[ "def", "decode", "(", "self", ",", "name", ")", ":", "if", "isinstance", "(", "name", ",", "int", ")", ":", "code", "=", "name", "else", ":", "name", "=", "name", ".", "upper", "(", ")", "code", "=", "_targets", ".", "get", "(", "name", ")", "i...
Translate a target name into its integer code. >>> planets.decode('Venus') 299 Raises ``ValueError`` if you supply an unknown name, or ``KeyError`` if the target is missing from this kernel. You can supply an integer code if you already have one and just want to check ...
[ "Translate", "a", "target", "name", "into", "its", "integer", "code", "." ]
51d9e042e06457f6b1f2415296d50a38cb3a300f
https://github.com/skyfielders/python-skyfield/blob/51d9e042e06457f6b1f2415296d50a38cb3a300f/skyfield/jpllib.py#L128-L152
243,742
skyfielders/python-skyfield
skyfield/iokit.py
_search
def _search(mapping, filename): """Search a Loader data structure for a filename.""" result = mapping.get(filename) if result is not None: return result name, ext = os.path.splitext(filename) result = mapping.get(ext) if result is not None: for pattern, result2 in result: ...
python
def _search(mapping, filename): result = mapping.get(filename) if result is not None: return result name, ext = os.path.splitext(filename) result = mapping.get(ext) if result is not None: for pattern, result2 in result: if fnmatch(filename, pattern): retur...
[ "def", "_search", "(", "mapping", ",", "filename", ")", ":", "result", "=", "mapping", ".", "get", "(", "filename", ")", "if", "result", "is", "not", "None", ":", "return", "result", "name", ",", "ext", "=", "os", ".", "path", ".", "splitext", "(", ...
Search a Loader data structure for a filename.
[ "Search", "a", "Loader", "data", "structure", "for", "a", "filename", "." ]
51d9e042e06457f6b1f2415296d50a38cb3a300f
https://github.com/skyfielders/python-skyfield/blob/51d9e042e06457f6b1f2415296d50a38cb3a300f/skyfield/iokit.py#L288-L299
243,743
skyfielders/python-skyfield
skyfield/iokit.py
load_file
def load_file(path): """Open a file on your local drive, using its extension to guess its type. This routine only works on ``.bsp`` ephemeris files right now, but will gain support for additional file types in the future. :: from skyfield.api import load_file planets = load_file('~/Downloa...
python
def load_file(path): path = os.path.expanduser(path) base, ext = os.path.splitext(path) if ext == '.bsp': return SpiceKernel(path) raise ValueError('unrecognized file extension: {}'.format(path))
[ "def", "load_file", "(", "path", ")", ":", "path", "=", "os", ".", "path", ".", "expanduser", "(", "path", ")", "base", ",", "ext", "=", "os", ".", "path", ".", "splitext", "(", "path", ")", "if", "ext", "==", "'.bsp'", ":", "return", "SpiceKernel"...
Open a file on your local drive, using its extension to guess its type. This routine only works on ``.bsp`` ephemeris files right now, but will gain support for additional file types in the future. :: from skyfield.api import load_file planets = load_file('~/Downloads/de421.bsp')
[ "Open", "a", "file", "on", "your", "local", "drive", "using", "its", "extension", "to", "guess", "its", "type", "." ]
51d9e042e06457f6b1f2415296d50a38cb3a300f
https://github.com/skyfielders/python-skyfield/blob/51d9e042e06457f6b1f2415296d50a38cb3a300f/skyfield/iokit.py#L302-L316
243,744
skyfielders/python-skyfield
skyfield/iokit.py
parse_deltat_data
def parse_deltat_data(fileobj): """Parse the United States Naval Observatory ``deltat.data`` file. Each line file gives the date and the value of Delta T:: 2016 2 1 68.1577 This function returns a 2xN array of raw Julian dates and matching Delta T values. """ array = np.loadtxt(fileob...
python
def parse_deltat_data(fileobj): array = np.loadtxt(fileobj) year, month, day = array[-1,:3].astype(int) expiration_date = date(year + 1, month, day) year, month, day, delta_t = array.T data = np.array((julian_date(year, month, day), delta_t)) return expiration_date, data
[ "def", "parse_deltat_data", "(", "fileobj", ")", ":", "array", "=", "np", ".", "loadtxt", "(", "fileobj", ")", "year", ",", "month", ",", "day", "=", "array", "[", "-", "1", ",", ":", "3", "]", ".", "astype", "(", "int", ")", "expiration_date", "="...
Parse the United States Naval Observatory ``deltat.data`` file. Each line file gives the date and the value of Delta T:: 2016 2 1 68.1577 This function returns a 2xN array of raw Julian dates and matching Delta T values.
[ "Parse", "the", "United", "States", "Naval", "Observatory", "deltat", ".", "data", "file", "." ]
51d9e042e06457f6b1f2415296d50a38cb3a300f
https://github.com/skyfielders/python-skyfield/blob/51d9e042e06457f6b1f2415296d50a38cb3a300f/skyfield/iokit.py#L319-L335
243,745
skyfielders/python-skyfield
skyfield/iokit.py
parse_deltat_preds
def parse_deltat_preds(fileobj): """Parse the United States Naval Observatory ``deltat.preds`` file. The old format supplies a floating point year, the value of Delta T, and one or two other fields:: 2015.75 67.97 0.210 0.02 The new format adds a modified Julian day as ...
python
def parse_deltat_preds(fileobj): lines = iter(fileobj) header = next(lines) if header.startswith(b'YEAR'): # Format in use until 2019 February next(lines) # discard blank line year_float, delta_t = np.loadtxt(lines, usecols=[0, 1]).T else: # Format in use sin...
[ "def", "parse_deltat_preds", "(", "fileobj", ")", ":", "lines", "=", "iter", "(", "fileobj", ")", "header", "=", "next", "(", "lines", ")", "if", "header", ".", "startswith", "(", "b'YEAR'", ")", ":", "# Format in use until 2019 February", "next", "(", "line...
Parse the United States Naval Observatory ``deltat.preds`` file. The old format supplies a floating point year, the value of Delta T, and one or two other fields:: 2015.75 67.97 0.210 0.02 The new format adds a modified Julian day as the first field: 58484.000 2019.00...
[ "Parse", "the", "United", "States", "Naval", "Observatory", "deltat", ".", "preds", "file", "." ]
51d9e042e06457f6b1f2415296d50a38cb3a300f
https://github.com/skyfielders/python-skyfield/blob/51d9e042e06457f6b1f2415296d50a38cb3a300f/skyfield/iokit.py#L338-L369
243,746
skyfielders/python-skyfield
skyfield/iokit.py
parse_leap_seconds
def parse_leap_seconds(fileobj): """Parse the IERS file ``Leap_Second.dat``. The leap dates array can be searched with:: index = np.searchsorted(leap_dates, jd, 'right') The resulting index allows (TAI - UTC) to be fetched with:: offset = leap_offsets[index] """ lines = iter(fil...
python
def parse_leap_seconds(fileobj): lines = iter(fileobj) for line in lines: if line.startswith(b'# File expires on'): break else: raise ValueError('Leap_Second.dat is missing its expiration date') line = line.decode('ascii') with _lock: # won't help if anyone user thread...
[ "def", "parse_leap_seconds", "(", "fileobj", ")", ":", "lines", "=", "iter", "(", "fileobj", ")", "for", "line", "in", "lines", ":", "if", "line", ".", "startswith", "(", "b'# File expires on'", ")", ":", "break", "else", ":", "raise", "ValueError", "(", ...
Parse the IERS file ``Leap_Second.dat``. The leap dates array can be searched with:: index = np.searchsorted(leap_dates, jd, 'right') The resulting index allows (TAI - UTC) to be fetched with:: offset = leap_offsets[index]
[ "Parse", "the", "IERS", "file", "Leap_Second", ".", "dat", "." ]
51d9e042e06457f6b1f2415296d50a38cb3a300f
https://github.com/skyfielders/python-skyfield/blob/51d9e042e06457f6b1f2415296d50a38cb3a300f/skyfield/iokit.py#L371-L412
243,747
skyfielders/python-skyfield
skyfield/iokit.py
parse_tle
def parse_tle(fileobj): """Parse a file of TLE satellite element sets. Builds an Earth satellite from each pair of adjacent lines in the file that start with "1 " and "2 " and have 69 or more characters each. If the preceding line is exactly 24 characters long, then it is parsed as the satellite's...
python
def parse_tle(fileobj): b0 = b1 = b'' for b2 in fileobj: if (b1.startswith(b'1 ') and len(b1) >= 69 and b2.startswith(b'2 ') and len(b2) >= 69): b0 = b0.rstrip(b'\n\r') if len(b0) == 24: # Celestrak name = b0.decode('ascii').rstrip() ...
[ "def", "parse_tle", "(", "fileobj", ")", ":", "b0", "=", "b1", "=", "b''", "for", "b2", "in", "fileobj", ":", "if", "(", "b1", ".", "startswith", "(", "b'1 '", ")", "and", "len", "(", "b1", ")", ">=", "69", "and", "b2", ".", "startswith", "(", ...
Parse a file of TLE satellite element sets. Builds an Earth satellite from each pair of adjacent lines in the file that start with "1 " and "2 " and have 69 or more characters each. If the preceding line is exactly 24 characters long, then it is parsed as the satellite's name. For each satellite foun...
[ "Parse", "a", "file", "of", "TLE", "satellite", "element", "sets", "." ]
51d9e042e06457f6b1f2415296d50a38cb3a300f
https://github.com/skyfielders/python-skyfield/blob/51d9e042e06457f6b1f2415296d50a38cb3a300f/skyfield/iokit.py#L415-L461
243,748
skyfielders/python-skyfield
skyfield/iokit.py
download
def download(url, path, verbose=None, blocksize=128*1024): """Download a file from a URL, possibly displaying a progress bar. Saves the output to the file named by `path`. If the URL cannot be downloaded or the file cannot be written, an IOError is raised. Normally, if the standard error output is a ...
python
def download(url, path, verbose=None, blocksize=128*1024): tempname = path + '.download' try: connection = urlopen(url) except Exception as e: raise IOError('cannot get {0} because {1}'.format(url, e)) if verbose is None: verbose = sys.stderr.isatty() bar = None if verbo...
[ "def", "download", "(", "url", ",", "path", ",", "verbose", "=", "None", ",", "blocksize", "=", "128", "*", "1024", ")", ":", "tempname", "=", "path", "+", "'.download'", "try", ":", "connection", "=", "urlopen", "(", "url", ")", "except", "Exception",...
Download a file from a URL, possibly displaying a progress bar. Saves the output to the file named by `path`. If the URL cannot be downloaded or the file cannot be written, an IOError is raised. Normally, if the standard error output is a terminal, then a progress bar is displayed to keep the user en...
[ "Download", "a", "file", "from", "a", "URL", "possibly", "displaying", "a", "progress", "bar", "." ]
51d9e042e06457f6b1f2415296d50a38cb3a300f
https://github.com/skyfielders/python-skyfield/blob/51d9e042e06457f6b1f2415296d50a38cb3a300f/skyfield/iokit.py#L464-L536
243,749
skyfielders/python-skyfield
skyfield/iokit.py
Loader.tle
def tle(self, url, reload=False, filename=None): """Load and parse a satellite TLE file. Given a URL or a local path, this loads a file of three-line records in the common Celestrak file format, or two-line records like those from space-track.org. For a three-line element set, each firs...
python
def tle(self, url, reload=False, filename=None): d = {} with self.open(url, reload=reload, filename=filename) as f: for names, sat in parse_tle(f): d[sat.model.satnum] = sat for name in names: d[name] = sat return d
[ "def", "tle", "(", "self", ",", "url", ",", "reload", "=", "False", ",", "filename", "=", "None", ")", ":", "d", "=", "{", "}", "with", "self", ".", "open", "(", "url", ",", "reload", "=", "reload", ",", "filename", "=", "filename", ")", "as", ...
Load and parse a satellite TLE file. Given a URL or a local path, this loads a file of three-line records in the common Celestrak file format, or two-line records like those from space-track.org. For a three-line element set, each first line gives the name of a satellite and the followi...
[ "Load", "and", "parse", "a", "satellite", "TLE", "file", "." ]
51d9e042e06457f6b1f2415296d50a38cb3a300f
https://github.com/skyfielders/python-skyfield/blob/51d9e042e06457f6b1f2415296d50a38cb3a300f/skyfield/iokit.py#L199-L224
243,750
skyfielders/python-skyfield
skyfield/iokit.py
Loader.open
def open(self, url, mode='rb', reload=False, filename=None): """Open a file, downloading it first if it does not yet exist. Unlike when you call a loader directly like ``my_loader()``, this ``my_loader.open()`` method does not attempt to parse or interpret the file; it simply returns an...
python
def open(self, url, mode='rb', reload=False, filename=None): if '://' not in url: path_that_might_be_relative = url path = os.path.join(self.directory, path_that_might_be_relative) return open(path, mode) if filename is None: filename = urlparse(url).path....
[ "def", "open", "(", "self", ",", "url", ",", "mode", "=", "'rb'", ",", "reload", "=", "False", ",", "filename", "=", "None", ")", ":", "if", "'://'", "not", "in", "url", ":", "path_that_might_be_relative", "=", "url", "path", "=", "os", ".", "path", ...
Open a file, downloading it first if it does not yet exist. Unlike when you call a loader directly like ``my_loader()``, this ``my_loader.open()`` method does not attempt to parse or interpret the file; it simply returns an open file object. The ``url`` can be either an external URL, o...
[ "Open", "a", "file", "downloading", "it", "first", "if", "it", "does", "not", "yet", "exist", "." ]
51d9e042e06457f6b1f2415296d50a38cb3a300f
https://github.com/skyfielders/python-skyfield/blob/51d9e042e06457f6b1f2415296d50a38cb3a300f/skyfield/iokit.py#L226-L256
243,751
skyfielders/python-skyfield
skyfield/iokit.py
Loader.timescale
def timescale(self, delta_t=None): """Open or download three time scale files, returning a `Timescale`. This method is how most Skyfield users build a `Timescale` object, which is necessary for building specific `Time` objects that name specific moments. This will open or downl...
python
def timescale(self, delta_t=None): if delta_t is not None: delta_t_recent = np.array(((-1e99, 1e99), (delta_t, delta_t))) else: data = self('deltat.data') preds = self('deltat.preds') data_end_time = data[0, -1] i = np.searchsorted(preds[0], da...
[ "def", "timescale", "(", "self", ",", "delta_t", "=", "None", ")", ":", "if", "delta_t", "is", "not", "None", ":", "delta_t_recent", "=", "np", ".", "array", "(", "(", "(", "-", "1e99", ",", "1e99", ")", ",", "(", "delta_t", ",", "delta_t", ")", ...
Open or download three time scale files, returning a `Timescale`. This method is how most Skyfield users build a `Timescale` object, which is necessary for building specific `Time` objects that name specific moments. This will open or download the three files that Skyfield needs ...
[ "Open", "or", "download", "three", "time", "scale", "files", "returning", "a", "Timescale", "." ]
51d9e042e06457f6b1f2415296d50a38cb3a300f
https://github.com/skyfielders/python-skyfield/blob/51d9e042e06457f6b1f2415296d50a38cb3a300f/skyfield/iokit.py#L258-L281
243,752
skyfielders/python-skyfield
skyfield/contrib/iosurvey.py
get_summary
def get_summary(url, spk=True): ''' simple function to retrieve the header of a BSP file and return SPK object''' # connect to file at URL bspurl = urllib2.urlopen(url) # retrieve the "tip" of a file at URL bsptip = bspurl.read(10**5) # first 100kB # save data in fake file object (in-memory) ...
python
def get_summary(url, spk=True): ''' simple function to retrieve the header of a BSP file and return SPK object''' # connect to file at URL bspurl = urllib2.urlopen(url) # retrieve the "tip" of a file at URL bsptip = bspurl.read(10**5) # first 100kB # save data in fake file object (in-memory) ...
[ "def", "get_summary", "(", "url", ",", "spk", "=", "True", ")", ":", "# connect to file at URL", "bspurl", "=", "urllib2", ".", "urlopen", "(", "url", ")", "# retrieve the \"tip\" of a file at URL", "bsptip", "=", "bspurl", ".", "read", "(", "10", "**", "5", ...
simple function to retrieve the header of a BSP file and return SPK object
[ "simple", "function", "to", "retrieve", "the", "header", "of", "a", "BSP", "file", "and", "return", "SPK", "object" ]
51d9e042e06457f6b1f2415296d50a38cb3a300f
https://github.com/skyfielders/python-skyfield/blob/51d9e042e06457f6b1f2415296d50a38cb3a300f/skyfield/contrib/iosurvey.py#L11-L29
243,753
skyfielders/python-skyfield
skyfield/vectorlib.py
_correct_for_light_travel_time
def _correct_for_light_travel_time(observer, target): """Return a light-time corrected astrometric position and velocity. Given an `observer` that is a `Barycentric` position somewhere in the solar system, compute where in the sky they will see the body `target`, by computing the light-time between the...
python
def _correct_for_light_travel_time(observer, target): t = observer.t ts = t.ts cposition = observer.position.au cvelocity = observer.velocity.au_per_d tposition, tvelocity, gcrs_position, message = target._at(t) distance = length_of(tposition - cposition) light_time0 = 0.0 t_tdb = t.tdb ...
[ "def", "_correct_for_light_travel_time", "(", "observer", ",", "target", ")", ":", "t", "=", "observer", ".", "t", "ts", "=", "t", ".", "ts", "cposition", "=", "observer", ".", "position", ".", "au", "cvelocity", "=", "observer", ".", "velocity", ".", "a...
Return a light-time corrected astrometric position and velocity. Given an `observer` that is a `Barycentric` position somewhere in the solar system, compute where in the sky they will see the body `target`, by computing the light-time between them and figuring out where `target` was back when the light...
[ "Return", "a", "light", "-", "time", "corrected", "astrometric", "position", "and", "velocity", "." ]
51d9e042e06457f6b1f2415296d50a38cb3a300f
https://github.com/skyfielders/python-skyfield/blob/51d9e042e06457f6b1f2415296d50a38cb3a300f/skyfield/vectorlib.py#L201-L230
243,754
skyfielders/python-skyfield
skyfield/vectorlib.py
VectorFunction.at
def at(self, t): """At time ``t``, compute the target's position relative to the center. If ``t`` is an array of times, then the returned position object will specify as many positions as there were times. The kind of position returned depends on the value of the ``center`` att...
python
def at(self, t): if not isinstance(t, Time): raise ValueError('please provide the at() method with a Time' ' instance as its argument, instead of the' ' value {0!r}'.format(t)) observer_data = ObserverData() observer_data.ephe...
[ "def", "at", "(", "self", ",", "t", ")", ":", "if", "not", "isinstance", "(", "t", ",", "Time", ")", ":", "raise", "ValueError", "(", "'please provide the at() method with a Time'", "' instance as its argument, instead of the'", "' value {0!r}'", ".", "format", "(",...
At time ``t``, compute the target's position relative to the center. If ``t`` is an array of times, then the returned position object will specify as many positions as there were times. The kind of position returned depends on the value of the ``center`` attribute: * Solar Sys...
[ "At", "time", "t", "compute", "the", "target", "s", "position", "relative", "to", "the", "center", "." ]
51d9e042e06457f6b1f2415296d50a38cb3a300f
https://github.com/skyfielders/python-skyfield/blob/51d9e042e06457f6b1f2415296d50a38cb3a300f/skyfield/vectorlib.py#L54-L82
243,755
skyfielders/python-skyfield
skyfield/timelib.py
_to_array
def _to_array(value): """When `value` is a plain Python sequence, return it as a NumPy array.""" if hasattr(value, 'shape'): return value elif hasattr(value, '__len__'): return array(value) else: return float_(value)
python
def _to_array(value): if hasattr(value, 'shape'): return value elif hasattr(value, '__len__'): return array(value) else: return float_(value)
[ "def", "_to_array", "(", "value", ")", ":", "if", "hasattr", "(", "value", ",", "'shape'", ")", ":", "return", "value", "elif", "hasattr", "(", "value", ",", "'__len__'", ")", ":", "return", "array", "(", "value", ")", "else", ":", "return", "float_", ...
When `value` is a plain Python sequence, return it as a NumPy array.
[ "When", "value", "is", "a", "plain", "Python", "sequence", "return", "it", "as", "a", "NumPy", "array", "." ]
51d9e042e06457f6b1f2415296d50a38cb3a300f
https://github.com/skyfielders/python-skyfield/blob/51d9e042e06457f6b1f2415296d50a38cb3a300f/skyfield/timelib.py#L40-L47
243,756
skyfielders/python-skyfield
skyfield/timelib.py
julian_day
def julian_day(year, month=1, day=1): """Given a proleptic Gregorian calendar date, return a Julian day int.""" janfeb = month < 3 return (day + 1461 * (year + 4800 - janfeb) // 4 + 367 * (month - 2 + janfeb * 12) // 12 - 3 * ((year + 4900 - janfeb) // 100) // 4 ...
python
def julian_day(year, month=1, day=1): janfeb = month < 3 return (day + 1461 * (year + 4800 - janfeb) // 4 + 367 * (month - 2 + janfeb * 12) // 12 - 3 * ((year + 4900 - janfeb) // 100) // 4 - 32075)
[ "def", "julian_day", "(", "year", ",", "month", "=", "1", ",", "day", "=", "1", ")", ":", "janfeb", "=", "month", "<", "3", "return", "(", "day", "+", "1461", "*", "(", "year", "+", "4800", "-", "janfeb", ")", "//", "4", "+", "367", "*", "(",...
Given a proleptic Gregorian calendar date, return a Julian day int.
[ "Given", "a", "proleptic", "Gregorian", "calendar", "date", "return", "a", "Julian", "day", "int", "." ]
51d9e042e06457f6b1f2415296d50a38cb3a300f
https://github.com/skyfielders/python-skyfield/blob/51d9e042e06457f6b1f2415296d50a38cb3a300f/skyfield/timelib.py#L700-L707
243,757
skyfielders/python-skyfield
skyfield/timelib.py
julian_date
def julian_date(year, month=1, day=1, hour=0, minute=0, second=0.0): """Given a proleptic Gregorian calendar date, return a Julian date float.""" return julian_day(year, month, day) - 0.5 + ( second + minute * 60.0 + hour * 3600.0) / DAY_S
python
def julian_date(year, month=1, day=1, hour=0, minute=0, second=0.0): return julian_day(year, month, day) - 0.5 + ( second + minute * 60.0 + hour * 3600.0) / DAY_S
[ "def", "julian_date", "(", "year", ",", "month", "=", "1", ",", "day", "=", "1", ",", "hour", "=", "0", ",", "minute", "=", "0", ",", "second", "=", "0.0", ")", ":", "return", "julian_day", "(", "year", ",", "month", ",", "day", ")", "-", "0.5"...
Given a proleptic Gregorian calendar date, return a Julian date float.
[ "Given", "a", "proleptic", "Gregorian", "calendar", "date", "return", "a", "Julian", "date", "float", "." ]
51d9e042e06457f6b1f2415296d50a38cb3a300f
https://github.com/skyfielders/python-skyfield/blob/51d9e042e06457f6b1f2415296d50a38cb3a300f/skyfield/timelib.py#L709-L712
243,758
skyfielders/python-skyfield
skyfield/timelib.py
tdb_minus_tt
def tdb_minus_tt(jd_tdb): """Computes how far TDB is in advance of TT, given TDB. Given that the two time scales never diverge by more than 2ms, TT can also be given as the argument to perform the conversion in the other direction. """ t = (jd_tdb - T0) / 36525.0 # USNO Circular 179, eq. ...
python
def tdb_minus_tt(jd_tdb): t = (jd_tdb - T0) / 36525.0 # USNO Circular 179, eq. 2.6. return (0.001657 * sin ( 628.3076 * t + 6.2401) + 0.000022 * sin ( 575.3385 * t + 4.2970) + 0.000014 * sin (1256.6152 * t + 6.1969) + 0.000005 * sin ( 606.9777 * t + 4.0212) + 0.00000...
[ "def", "tdb_minus_tt", "(", "jd_tdb", ")", ":", "t", "=", "(", "jd_tdb", "-", "T0", ")", "/", "36525.0", "# USNO Circular 179, eq. 2.6.", "return", "(", "0.001657", "*", "sin", "(", "628.3076", "*", "t", "+", "6.2401", ")", "+", "0.000022", "*", "sin", ...
Computes how far TDB is in advance of TT, given TDB. Given that the two time scales never diverge by more than 2ms, TT can also be given as the argument to perform the conversion in the other direction.
[ "Computes", "how", "far", "TDB", "is", "in", "advance", "of", "TT", "given", "TDB", "." ]
51d9e042e06457f6b1f2415296d50a38cb3a300f
https://github.com/skyfielders/python-skyfield/blob/51d9e042e06457f6b1f2415296d50a38cb3a300f/skyfield/timelib.py#L752-L769
243,759
skyfielders/python-skyfield
skyfield/timelib.py
interpolate_delta_t
def interpolate_delta_t(delta_t_table, tt): """Return interpolated Delta T values for the times in `tt`. The 2xN table should provide TT values as element 0 and corresponding Delta T values for element 1. For times outside the range of the table, a long-term formula is used instead. """ tt_ar...
python
def interpolate_delta_t(delta_t_table, tt): tt_array, delta_t_array = delta_t_table delta_t = _to_array(interp(tt, tt_array, delta_t_array, nan, nan)) missing = isnan(delta_t) if missing.any(): # Test if we are dealing with an array and proceed appropriately if missing.shape: ...
[ "def", "interpolate_delta_t", "(", "delta_t_table", ",", "tt", ")", ":", "tt_array", ",", "delta_t_array", "=", "delta_t_table", "delta_t", "=", "_to_array", "(", "interp", "(", "tt", ",", "tt_array", ",", "delta_t_array", ",", "nan", ",", "nan", ")", ")", ...
Return interpolated Delta T values for the times in `tt`. The 2xN table should provide TT values as element 0 and corresponding Delta T values for element 1. For times outside the range of the table, a long-term formula is used instead.
[ "Return", "interpolated", "Delta", "T", "values", "for", "the", "times", "in", "tt", "." ]
51d9e042e06457f6b1f2415296d50a38cb3a300f
https://github.com/skyfielders/python-skyfield/blob/51d9e042e06457f6b1f2415296d50a38cb3a300f/skyfield/timelib.py#L771-L790
243,760
skyfielders/python-skyfield
skyfield/timelib.py
build_delta_t_table
def build_delta_t_table(delta_t_recent): """Build a table for interpolating Delta T. Given a 2xN array of recent Delta T values, whose element 0 is a sorted array of TT Julian dates and element 1 is Delta T values, this routine returns a more complete table by prepending two built-in data sources t...
python
def build_delta_t_table(delta_t_recent): ancient = load_bundled_npy('morrison_stephenson_deltat.npy') historic = load_bundled_npy('historic_deltat.npy') # Prefer USNO over Morrison and Stephenson where they overlap. historic_start_time = historic[0,0] i = searchsorted(ancient[0], historic_start_tim...
[ "def", "build_delta_t_table", "(", "delta_t_recent", ")", ":", "ancient", "=", "load_bundled_npy", "(", "'morrison_stephenson_deltat.npy'", ")", "historic", "=", "load_bundled_npy", "(", "'historic_deltat.npy'", ")", "# Prefer USNO over Morrison and Stephenson where they overlap....
Build a table for interpolating Delta T. Given a 2xN array of recent Delta T values, whose element 0 is a sorted array of TT Julian dates and element 1 is Delta T values, this routine returns a more complete table by prepending two built-in data sources that ship with Skyfield as pre-built arrays: ...
[ "Build", "a", "table", "for", "interpolating", "Delta", "T", "." ]
51d9e042e06457f6b1f2415296d50a38cb3a300f
https://github.com/skyfielders/python-skyfield/blob/51d9e042e06457f6b1f2415296d50a38cb3a300f/skyfield/timelib.py#L803-L839
243,761
skyfielders/python-skyfield
skyfield/timelib.py
Timescale.utc
def utc(self, year, month=1, day=1, hour=0, minute=0, second=0.0): """Build a `Time` from a UTC calendar date. You can either specify the date as separate components, or provide a time zone aware Python datetime. The following two calls are equivalent (the ``utc`` time zone object can ...
python
def utc(self, year, month=1, day=1, hour=0, minute=0, second=0.0): if isinstance(year, datetime): dt = year tai = _utc_datetime_to_tai(self.leap_dates, self.leap_offsets, dt) elif isinstance(year, date): d = year tai = _utc_date_to_tai(self.leap_dates, sel...
[ "def", "utc", "(", "self", ",", "year", ",", "month", "=", "1", ",", "day", "=", "1", ",", "hour", "=", "0", ",", "minute", "=", "0", ",", "second", "=", "0.0", ")", ":", "if", "isinstance", "(", "year", ",", "datetime", ")", ":", "dt", "=", ...
Build a `Time` from a UTC calendar date. You can either specify the date as separate components, or provide a time zone aware Python datetime. The following two calls are equivalent (the ``utc`` time zone object can be imported from the ``skyfield.api`` module, or from ``pytz`` if ...
[ "Build", "a", "Time", "from", "a", "UTC", "calendar", "date", "." ]
51d9e042e06457f6b1f2415296d50a38cb3a300f
https://github.com/skyfielders/python-skyfield/blob/51d9e042e06457f6b1f2415296d50a38cb3a300f/skyfield/timelib.py#L91-L127
243,762
skyfielders/python-skyfield
skyfield/timelib.py
Timescale.tai
def tai(self, year=None, month=1, day=1, hour=0, minute=0, second=0.0, jd=None): """Build a `Time` from a TAI calendar date. Supply the International Atomic Time (TAI) as a proleptic Gregorian calendar date: >>> t = ts.tai(2014, 1, 18, 1, 35, 37.5) >>> t.tai ...
python
def tai(self, year=None, month=1, day=1, hour=0, minute=0, second=0.0, jd=None): if jd is not None: tai = jd else: tai = julian_date( _to_array(year), _to_array(month), _to_array(day), _to_array(hour), _to_array(minute), _to_array(secon...
[ "def", "tai", "(", "self", ",", "year", "=", "None", ",", "month", "=", "1", ",", "day", "=", "1", ",", "hour", "=", "0", ",", "minute", "=", "0", ",", "second", "=", "0.0", ",", "jd", "=", "None", ")", ":", "if", "jd", "is", "not", "None",...
Build a `Time` from a TAI calendar date. Supply the International Atomic Time (TAI) as a proleptic Gregorian calendar date: >>> t = ts.tai(2014, 1, 18, 1, 35, 37.5) >>> t.tai 2456675.56640625 >>> t.tai_calendar() (2014, 1, 18, 1, 35, 37.5)
[ "Build", "a", "Time", "from", "a", "TAI", "calendar", "date", "." ]
51d9e042e06457f6b1f2415296d50a38cb3a300f
https://github.com/skyfielders/python-skyfield/blob/51d9e042e06457f6b1f2415296d50a38cb3a300f/skyfield/timelib.py#L129-L150
243,763
skyfielders/python-skyfield
skyfield/timelib.py
Timescale.tai_jd
def tai_jd(self, jd): """Build a `Time` from a TAI Julian date. Supply the International Atomic Time (TAI) as a Julian date: >>> t = ts.tai_jd(2456675.56640625) >>> t.tai 2456675.56640625 >>> t.tai_calendar() (2014, 1, 18, 1, 35, 37.5) """ tai =...
python
def tai_jd(self, jd): tai = _to_array(jd) t = Time(self, tai + tt_minus_tai) t.tai = tai return t
[ "def", "tai_jd", "(", "self", ",", "jd", ")", ":", "tai", "=", "_to_array", "(", "jd", ")", "t", "=", "Time", "(", "self", ",", "tai", "+", "tt_minus_tai", ")", "t", ".", "tai", "=", "tai", "return", "t" ]
Build a `Time` from a TAI Julian date. Supply the International Atomic Time (TAI) as a Julian date: >>> t = ts.tai_jd(2456675.56640625) >>> t.tai 2456675.56640625 >>> t.tai_calendar() (2014, 1, 18, 1, 35, 37.5)
[ "Build", "a", "Time", "from", "a", "TAI", "Julian", "date", "." ]
51d9e042e06457f6b1f2415296d50a38cb3a300f
https://github.com/skyfielders/python-skyfield/blob/51d9e042e06457f6b1f2415296d50a38cb3a300f/skyfield/timelib.py#L152-L167
243,764
skyfielders/python-skyfield
skyfield/timelib.py
Timescale.tt
def tt(self, year=None, month=1, day=1, hour=0, minute=0, second=0.0, jd=None): """Build a `Time` from a TT calendar date. Supply the Terrestrial Time (TT) as a proleptic Gregorian calendar date: >>> t = ts.tt(2014, 1, 18, 1, 35, 37.5) >>> t.tt 2456675.566406...
python
def tt(self, year=None, month=1, day=1, hour=0, minute=0, second=0.0, jd=None): if jd is not None: tt = jd else: tt = julian_date( _to_array(year), _to_array(month), _to_array(day), _to_array(hour), _to_array(minute), _to_array(second), ...
[ "def", "tt", "(", "self", ",", "year", "=", "None", ",", "month", "=", "1", ",", "day", "=", "1", ",", "hour", "=", "0", ",", "minute", "=", "0", ",", "second", "=", "0.0", ",", "jd", "=", "None", ")", ":", "if", "jd", "is", "not", "None", ...
Build a `Time` from a TT calendar date. Supply the Terrestrial Time (TT) as a proleptic Gregorian calendar date: >>> t = ts.tt(2014, 1, 18, 1, 35, 37.5) >>> t.tt 2456675.56640625 >>> t.tt_calendar() (2014, 1, 18, 1, 35, 37.5)
[ "Build", "a", "Time", "from", "a", "TT", "calendar", "date", "." ]
51d9e042e06457f6b1f2415296d50a38cb3a300f
https://github.com/skyfielders/python-skyfield/blob/51d9e042e06457f6b1f2415296d50a38cb3a300f/skyfield/timelib.py#L169-L191
243,765
skyfielders/python-skyfield
skyfield/timelib.py
Timescale.tdb
def tdb(self, year=None, month=1, day=1, hour=0, minute=0, second=0.0, jd=None): """Build a `Time` from a TDB calendar date. Supply the Barycentric Dynamical Time (TDB) as a proleptic Gregorian calendar date: >>> t = ts.tdb(2014, 1, 18, 1, 35, 37.5) >>> t.tdb ...
python
def tdb(self, year=None, month=1, day=1, hour=0, minute=0, second=0.0, jd=None): if jd is not None: tdb = jd else: tdb = julian_date( _to_array(year), _to_array(month), _to_array(day), _to_array(hour), _to_array(minute), _to_array(secon...
[ "def", "tdb", "(", "self", ",", "year", "=", "None", ",", "month", "=", "1", ",", "day", "=", "1", ",", "hour", "=", "0", ",", "minute", "=", "0", ",", "second", "=", "0.0", ",", "jd", "=", "None", ")", ":", "if", "jd", "is", "not", "None",...
Build a `Time` from a TDB calendar date. Supply the Barycentric Dynamical Time (TDB) as a proleptic Gregorian calendar date: >>> t = ts.tdb(2014, 1, 18, 1, 35, 37.5) >>> t.tdb 2456675.56640625
[ "Build", "a", "Time", "from", "a", "TDB", "calendar", "date", "." ]
51d9e042e06457f6b1f2415296d50a38cb3a300f
https://github.com/skyfielders/python-skyfield/blob/51d9e042e06457f6b1f2415296d50a38cb3a300f/skyfield/timelib.py#L208-L231
243,766
skyfielders/python-skyfield
skyfield/timelib.py
Timescale.tdb_jd
def tdb_jd(self, jd): """Build a `Time` from a TDB Julian date. Supply the Barycentric Dynamical Time (TDB) as a Julian date: >>> t = ts.tdb_jd(2456675.56640625) >>> t.tdb 2456675.56640625 """ tdb = _to_array(jd) tt = tdb - tdb_minus_tt(tdb) / DAY_S ...
python
def tdb_jd(self, jd): tdb = _to_array(jd) tt = tdb - tdb_minus_tt(tdb) / DAY_S t = Time(self, tt) t.tdb = tdb return t
[ "def", "tdb_jd", "(", "self", ",", "jd", ")", ":", "tdb", "=", "_to_array", "(", "jd", ")", "tt", "=", "tdb", "-", "tdb_minus_tt", "(", "tdb", ")", "/", "DAY_S", "t", "=", "Time", "(", "self", ",", "tt", ")", "t", ".", "tdb", "=", "tdb", "ret...
Build a `Time` from a TDB Julian date. Supply the Barycentric Dynamical Time (TDB) as a Julian date: >>> t = ts.tdb_jd(2456675.56640625) >>> t.tdb 2456675.56640625
[ "Build", "a", "Time", "from", "a", "TDB", "Julian", "date", "." ]
51d9e042e06457f6b1f2415296d50a38cb3a300f
https://github.com/skyfielders/python-skyfield/blob/51d9e042e06457f6b1f2415296d50a38cb3a300f/skyfield/timelib.py#L233-L247
243,767
skyfielders/python-skyfield
skyfield/timelib.py
Timescale.ut1
def ut1(self, year=None, month=1, day=1, hour=0, minute=0, second=0.0, jd=None): """Build a `Time` from a UT1 calendar date. Supply the Universal Time (UT1) as a proleptic Gregorian calendar date: >>> t = ts.ut1(2014, 1, 18, 1, 35, 37.5) >>> t.ut1 2456675.56...
python
def ut1(self, year=None, month=1, day=1, hour=0, minute=0, second=0.0, jd=None): if jd is not None: ut1 = jd else: ut1 = julian_date( _to_array(year), _to_array(month), _to_array(day), _to_array(hour), _to_array(minute), _to_array(secon...
[ "def", "ut1", "(", "self", ",", "year", "=", "None", ",", "month", "=", "1", ",", "day", "=", "1", ",", "hour", "=", "0", ",", "minute", "=", "0", ",", "second", "=", "0.0", ",", "jd", "=", "None", ")", ":", "if", "jd", "is", "not", "None",...
Build a `Time` from a UT1 calendar date. Supply the Universal Time (UT1) as a proleptic Gregorian calendar date: >>> t = ts.ut1(2014, 1, 18, 1, 35, 37.5) >>> t.ut1 2456675.56640625
[ "Build", "a", "Time", "from", "a", "UT1", "calendar", "date", "." ]
51d9e042e06457f6b1f2415296d50a38cb3a300f
https://github.com/skyfielders/python-skyfield/blob/51d9e042e06457f6b1f2415296d50a38cb3a300f/skyfield/timelib.py#L249-L268
243,768
skyfielders/python-skyfield
skyfield/timelib.py
Timescale.ut1_jd
def ut1_jd(self, jd): """Build a `Time` from UT1 a Julian date. Supply the Universal Time (UT1) as a Julian date: >>> t = ts.ut1_jd(2456675.56640625) >>> t.ut1 2456675.56640625 """ ut1 = _to_array(jd) # Estimate TT = UT1, to get a rough Delta T estimat...
python
def ut1_jd(self, jd): ut1 = _to_array(jd) # Estimate TT = UT1, to get a rough Delta T estimate. tt_approx = ut1 delta_t_approx = interpolate_delta_t(self.delta_t_table, tt_approx) # Use the rough Delta T to make a much better estimate of TT, # then generate an even bett...
[ "def", "ut1_jd", "(", "self", ",", "jd", ")", ":", "ut1", "=", "_to_array", "(", "jd", ")", "# Estimate TT = UT1, to get a rough Delta T estimate.", "tt_approx", "=", "ut1", "delta_t_approx", "=", "interpolate_delta_t", "(", "self", ".", "delta_t_table", ",", "tt_...
Build a `Time` from UT1 a Julian date. Supply the Universal Time (UT1) as a Julian date: >>> t = ts.ut1_jd(2456675.56640625) >>> t.ut1 2456675.56640625
[ "Build", "a", "Time", "from", "UT1", "a", "Julian", "date", "." ]
51d9e042e06457f6b1f2415296d50a38cb3a300f
https://github.com/skyfielders/python-skyfield/blob/51d9e042e06457f6b1f2415296d50a38cb3a300f/skyfield/timelib.py#L270-L298
243,769
skyfielders/python-skyfield
skyfield/timelib.py
Time.astimezone_and_leap_second
def astimezone_and_leap_second(self, tz): """Convert to a Python ``datetime`` and leap second in a timezone. Convert this time to a Python ``datetime`` and a leap second:: dt, leap_second = t.astimezone_and_leap_second(tz) The argument ``tz`` should be a timezone from the third-pa...
python
def astimezone_and_leap_second(self, tz): dt, leap_second = self.utc_datetime_and_leap_second() normalize = getattr(tz, 'normalize', None) if self.shape and normalize is not None: dt = array([normalize(d.astimezone(tz)) for d in dt]) elif self.shape: dt = array([d...
[ "def", "astimezone_and_leap_second", "(", "self", ",", "tz", ")", ":", "dt", ",", "leap_second", "=", "self", ".", "utc_datetime_and_leap_second", "(", ")", "normalize", "=", "getattr", "(", "tz", ",", "'normalize'", ",", "None", ")", "if", "self", ".", "s...
Convert to a Python ``datetime`` and leap second in a timezone. Convert this time to a Python ``datetime`` and a leap second:: dt, leap_second = t.astimezone_and_leap_second(tz) The argument ``tz`` should be a timezone from the third-party ``pytz`` package, which must be installed...
[ "Convert", "to", "a", "Python", "datetime", "and", "leap", "second", "in", "a", "timezone", "." ]
51d9e042e06457f6b1f2415296d50a38cb3a300f
https://github.com/skyfielders/python-skyfield/blob/51d9e042e06457f6b1f2415296d50a38cb3a300f/skyfield/timelib.py#L365-L399
243,770
skyfielders/python-skyfield
skyfield/timelib.py
Time.utc_datetime_and_leap_second
def utc_datetime_and_leap_second(self): """Convert to a Python ``datetime`` in UTC, plus a leap second value. Convert this time to a `datetime`_ object and a leap second:: dt, leap_second = t.utc_datetime_and_leap_second() If the third-party `pytz`_ package is available, then its ...
python
def utc_datetime_and_leap_second(self): year, month, day, hour, minute, second = self._utc_tuple( _half_millisecond) second, fraction = divmod(second, 1.0) second = second.astype(int) leap_second = second // 60 second -= leap_second milli = (fraction * 1000).a...
[ "def", "utc_datetime_and_leap_second", "(", "self", ")", ":", "year", ",", "month", ",", "day", ",", "hour", ",", "minute", ",", "second", "=", "self", ".", "_utc_tuple", "(", "_half_millisecond", ")", "second", ",", "fraction", "=", "divmod", "(", "second...
Convert to a Python ``datetime`` in UTC, plus a leap second value. Convert this time to a `datetime`_ object and a leap second:: dt, leap_second = t.utc_datetime_and_leap_second() If the third-party `pytz`_ package is available, then its ``utc`` timezone will be used as the timezo...
[ "Convert", "to", "a", "Python", "datetime", "in", "UTC", "plus", "a", "leap", "second", "value", "." ]
51d9e042e06457f6b1f2415296d50a38cb3a300f
https://github.com/skyfielders/python-skyfield/blob/51d9e042e06457f6b1f2415296d50a38cb3a300f/skyfield/timelib.py#L425-L462
243,771
skyfielders/python-skyfield
skyfield/timelib.py
Time.utc_strftime
def utc_strftime(self, format): """Format the UTC time using a Python date formatting string. This internally calls the Python ``strftime()`` routine from the Standard Library ``time()`` module, for which you can find a quick reference at ``http://strftime.org/``. If this object is ...
python
def utc_strftime(self, format): tup = self._utc_tuple(_half_second) year, month, day, hour, minute, second = tup second = second.astype(int) zero = zeros_like(year) tup = (year, month, day, hour, minute, second, zero, zero, zero) if self.shape: return [strftim...
[ "def", "utc_strftime", "(", "self", ",", "format", ")", ":", "tup", "=", "self", ".", "_utc_tuple", "(", "_half_second", ")", "year", ",", "month", ",", "day", ",", "hour", ",", "minute", ",", "second", "=", "tup", "second", "=", "second", ".", "asty...
Format the UTC time using a Python date formatting string. This internally calls the Python ``strftime()`` routine from the Standard Library ``time()`` module, for which you can find a quick reference at ``http://strftime.org/``. If this object is an array of times, then a sequence of ...
[ "Format", "the", "UTC", "time", "using", "a", "Python", "date", "formatting", "string", "." ]
51d9e042e06457f6b1f2415296d50a38cb3a300f
https://github.com/skyfielders/python-skyfield/blob/51d9e042e06457f6b1f2415296d50a38cb3a300f/skyfield/timelib.py#L520-L538
243,772
skyfielders/python-skyfield
skyfield/timelib.py
Time._utc_year
def _utc_year(self): """Return a fractional UTC year, for convenience when plotting. An experiment, probably superseded by the ``J`` attribute below. """ d = self._utc_float() - 1721059.5 #d += offset C = 365 * 100 + 24 d -= 365 d += d // C - d // (4 * C...
python
def _utc_year(self): d = self._utc_float() - 1721059.5 #d += offset C = 365 * 100 + 24 d -= 365 d += d // C - d // (4 * C) d += 365 # Y = d / C * 100 # print(Y) K = 365 * 3 + 366 d -= (d + K*7//8) // K # d -= d // 1461.0 ret...
[ "def", "_utc_year", "(", "self", ")", ":", "d", "=", "self", ".", "_utc_float", "(", ")", "-", "1721059.5", "#d += offset", "C", "=", "365", "*", "100", "+", "24", "d", "-=", "365", "d", "+=", "d", "//", "C", "-", "d", "//", "(", "4", "*", "C...
Return a fractional UTC year, for convenience when plotting. An experiment, probably superseded by the ``J`` attribute below.
[ "Return", "a", "fractional", "UTC", "year", "for", "convenience", "when", "plotting", "." ]
51d9e042e06457f6b1f2415296d50a38cb3a300f
https://github.com/skyfielders/python-skyfield/blob/51d9e042e06457f6b1f2415296d50a38cb3a300f/skyfield/timelib.py#L540-L557
243,773
skyfielders/python-skyfield
skyfield/timelib.py
Time._utc_float
def _utc_float(self): """Return UTC as a floating point Julian date.""" tai = self.tai leap_dates = self.ts.leap_dates leap_offsets = self.ts.leap_offsets leap_reverse_dates = leap_dates + leap_offsets / DAY_S i = searchsorted(leap_reverse_dates, tai, 'right') ret...
python
def _utc_float(self): tai = self.tai leap_dates = self.ts.leap_dates leap_offsets = self.ts.leap_offsets leap_reverse_dates = leap_dates + leap_offsets / DAY_S i = searchsorted(leap_reverse_dates, tai, 'right') return tai - leap_offsets[i] / DAY_S
[ "def", "_utc_float", "(", "self", ")", ":", "tai", "=", "self", ".", "tai", "leap_dates", "=", "self", ".", "ts", ".", "leap_dates", "leap_offsets", "=", "self", ".", "ts", ".", "leap_offsets", "leap_reverse_dates", "=", "leap_dates", "+", "leap_offsets", ...
Return UTC as a floating point Julian date.
[ "Return", "UTC", "as", "a", "floating", "point", "Julian", "date", "." ]
51d9e042e06457f6b1f2415296d50a38cb3a300f
https://github.com/skyfielders/python-skyfield/blob/51d9e042e06457f6b1f2415296d50a38cb3a300f/skyfield/timelib.py#L586-L593
243,774
skyfielders/python-skyfield
skyfield/earthlib.py
terra
def terra(latitude, longitude, elevation, gast): """Compute the position and velocity of a terrestrial observer. `latitude` - Latitude in radians. `longitude` - Longitude in radians. `elevation` - Elevation above sea level in au. `gast` - Hours of Greenwich Apparent Sidereal Time (can be an array)....
python
def terra(latitude, longitude, elevation, gast): zero = zeros_like(gast) sinphi = sin(latitude) cosphi = cos(latitude) c = 1.0 / sqrt(cosphi * cosphi + sinphi * sinphi * one_minus_flattening_squared) s = one_minus_flattening_squared * c ach = earth_radius_au * c + elevation ...
[ "def", "terra", "(", "latitude", ",", "longitude", ",", "elevation", ",", "gast", ")", ":", "zero", "=", "zeros_like", "(", "gast", ")", "sinphi", "=", "sin", "(", "latitude", ")", "cosphi", "=", "cos", "(", "latitude", ")", "c", "=", "1.0", "/", "...
Compute the position and velocity of a terrestrial observer. `latitude` - Latitude in radians. `longitude` - Longitude in radians. `elevation` - Elevation above sea level in au. `gast` - Hours of Greenwich Apparent Sidereal Time (can be an array). The return value is a tuple of two 3-vectors `(pos...
[ "Compute", "the", "position", "and", "velocity", "of", "a", "terrestrial", "observer", "." ]
51d9e042e06457f6b1f2415296d50a38cb3a300f
https://github.com/skyfielders/python-skyfield/blob/51d9e042e06457f6b1f2415296d50a38cb3a300f/skyfield/earthlib.py#L15-L55
243,775
skyfielders/python-skyfield
skyfield/earthlib.py
compute_limb_angle
def compute_limb_angle(position_au, observer_au): """Determine the angle of an object above or below the Earth's limb. Given an object's GCRS `position_au` [x,y,z] vector and the position of an `observer_au` as a vector in the same coordinate system, return a tuple that provides `(limb_ang, nadir_ang)`...
python
def compute_limb_angle(position_au, observer_au): # Compute the distance to the object and the distance to the observer. disobj = sqrt(dots(position_au, position_au)) disobs = sqrt(dots(observer_au, observer_au)) # Compute apparent angular radius of Earth's limb. aprad = arcsin(minimum(earth_radi...
[ "def", "compute_limb_angle", "(", "position_au", ",", "observer_au", ")", ":", "# Compute the distance to the object and the distance to the observer.", "disobj", "=", "sqrt", "(", "dots", "(", "position_au", ",", "position_au", ")", ")", "disobs", "=", "sqrt", "(", "...
Determine the angle of an object above or below the Earth's limb. Given an object's GCRS `position_au` [x,y,z] vector and the position of an `observer_au` as a vector in the same coordinate system, return a tuple that provides `(limb_ang, nadir_ang)`: limb_angle Angle of observed object above ...
[ "Determine", "the", "angle", "of", "an", "object", "above", "or", "below", "the", "Earth", "s", "limb", "." ]
51d9e042e06457f6b1f2415296d50a38cb3a300f
https://github.com/skyfielders/python-skyfield/blob/51d9e042e06457f6b1f2415296d50a38cb3a300f/skyfield/earthlib.py#L85-L127
243,776
skyfielders/python-skyfield
skyfield/earthlib.py
sidereal_time
def sidereal_time(t): """Compute Greenwich sidereal time at the given ``Time``.""" # Compute the Earth Rotation Angle. Time argument is UT1. theta = earth_rotation_angle(t.ut1) # The equinox method. See Circular 179, Section 2.6.2. # Precession-in-RA terms in mean sidereal time taken from third...
python
def sidereal_time(t): # Compute the Earth Rotation Angle. Time argument is UT1. theta = earth_rotation_angle(t.ut1) # The equinox method. See Circular 179, Section 2.6.2. # Precession-in-RA terms in mean sidereal time taken from third # reference, eq. (42), with coefficients in arcseconds. ...
[ "def", "sidereal_time", "(", "t", ")", ":", "# Compute the Earth Rotation Angle. Time argument is UT1.", "theta", "=", "earth_rotation_angle", "(", "t", ".", "ut1", ")", "# The equinox method. See Circular 179, Section 2.6.2.", "# Precession-in-RA terms in mean sidereal time taken ...
Compute Greenwich sidereal time at the given ``Time``.
[ "Compute", "Greenwich", "sidereal", "time", "at", "the", "given", "Time", "." ]
51d9e042e06457f6b1f2415296d50a38cb3a300f
https://github.com/skyfielders/python-skyfield/blob/51d9e042e06457f6b1f2415296d50a38cb3a300f/skyfield/earthlib.py#L130-L151
243,777
skyfielders/python-skyfield
skyfield/earthlib.py
refraction
def refraction(alt_degrees, temperature_C, pressure_mbar): """Given an observed altitude, return how much the image is refracted. Zero refraction is returned both for objects very near the zenith, as well as for objects more than one degree below the horizon. """ r = 0.016667 / tan((alt_degrees + ...
python
def refraction(alt_degrees, temperature_C, pressure_mbar): r = 0.016667 / tan((alt_degrees + 7.31 / (alt_degrees + 4.4)) * DEG2RAD) d = r * (0.28 * pressure_mbar / (temperature_C + 273.0)) return where((-1.0 <= alt_degrees) & (alt_degrees <= 89.9), d, 0.0)
[ "def", "refraction", "(", "alt_degrees", ",", "temperature_C", ",", "pressure_mbar", ")", ":", "r", "=", "0.016667", "/", "tan", "(", "(", "alt_degrees", "+", "7.31", "/", "(", "alt_degrees", "+", "4.4", ")", ")", "*", "DEG2RAD", ")", "d", "=", "r", ...
Given an observed altitude, return how much the image is refracted. Zero refraction is returned both for objects very near the zenith, as well as for objects more than one degree below the horizon.
[ "Given", "an", "observed", "altitude", "return", "how", "much", "the", "image", "is", "refracted", "." ]
51d9e042e06457f6b1f2415296d50a38cb3a300f
https://github.com/skyfielders/python-skyfield/blob/51d9e042e06457f6b1f2415296d50a38cb3a300f/skyfield/earthlib.py#L166-L175
243,778
skyfielders/python-skyfield
skyfield/earthlib.py
refract
def refract(alt_degrees, temperature_C, pressure_mbar): """Given an unrefracted `alt` determine where it will appear in the sky.""" alt = alt_degrees while True: alt1 = alt alt = alt_degrees + refraction(alt, temperature_C, pressure_mbar) converged = abs(alt - alt1) <= 3.0e-5 ...
python
def refract(alt_degrees, temperature_C, pressure_mbar): alt = alt_degrees while True: alt1 = alt alt = alt_degrees + refraction(alt, temperature_C, pressure_mbar) converged = abs(alt - alt1) <= 3.0e-5 if converged.all(): break return alt
[ "def", "refract", "(", "alt_degrees", ",", "temperature_C", ",", "pressure_mbar", ")", ":", "alt", "=", "alt_degrees", "while", "True", ":", "alt1", "=", "alt", "alt", "=", "alt_degrees", "+", "refraction", "(", "alt", ",", "temperature_C", ",", "pressure_mb...
Given an unrefracted `alt` determine where it will appear in the sky.
[ "Given", "an", "unrefracted", "alt", "determine", "where", "it", "will", "appear", "in", "the", "sky", "." ]
51d9e042e06457f6b1f2415296d50a38cb3a300f
https://github.com/skyfielders/python-skyfield/blob/51d9e042e06457f6b1f2415296d50a38cb3a300f/skyfield/earthlib.py#L178-L187
243,779
skyfielders/python-skyfield
skyfield/precessionlib.py
compute_precession
def compute_precession(jd_tdb): """Return the rotation matrices for precessing to an array of epochs. `jd_tdb` - array of TDB Julian dates The array returned has the shape `(3, 3, n)` where `n` is the number of dates that have been provided as input. """ eps0 = 84381.406 # 't' is time in...
python
def compute_precession(jd_tdb): eps0 = 84381.406 # 't' is time in TDB centuries. t = (jd_tdb - T0) / 36525.0 # Numerical coefficients of psi_a, omega_a, and chi_a, along with # epsilon_0, the obliquity at J2000.0, are 4-angle formulation from # Capitaine et al. (2003), eqs. (4), (37), & (39)....
[ "def", "compute_precession", "(", "jd_tdb", ")", ":", "eps0", "=", "84381.406", "# 't' is time in TDB centuries.", "t", "=", "(", "jd_tdb", "-", "T0", ")", "/", "36525.0", "# Numerical coefficients of psi_a, omega_a, and chi_a, along with", "# epsilon_0, the obliquity at J200...
Return the rotation matrices for precessing to an array of epochs. `jd_tdb` - array of TDB Julian dates The array returned has the shape `(3, 3, n)` where `n` is the number of dates that have been provided as input.
[ "Return", "the", "rotation", "matrices", "for", "precessing", "to", "an", "array", "of", "epochs", "." ]
51d9e042e06457f6b1f2415296d50a38cb3a300f
https://github.com/skyfielders/python-skyfield/blob/51d9e042e06457f6b1f2415296d50a38cb3a300f/skyfield/precessionlib.py#L5-L69
243,780
skyfielders/python-skyfield
skyfield/nutationlib.py
compute_nutation
def compute_nutation(t): """Generate the nutation rotations for Time `t`. If the Julian date is scalar, a simple ``(3, 3)`` matrix is returned; if the date is an array of length ``n``, then an array of matrices is returned with dimensions ``(3, 3, n)``. """ oblm, oblt, eqeq, psi, eps = t._eart...
python
def compute_nutation(t): oblm, oblt, eqeq, psi, eps = t._earth_tilt cobm = cos(oblm * DEG2RAD) sobm = sin(oblm * DEG2RAD) cobt = cos(oblt * DEG2RAD) sobt = sin(oblt * DEG2RAD) cpsi = cos(psi * ASEC2RAD) spsi = sin(psi * ASEC2RAD) return array(((cpsi, -spsi * cobm, ...
[ "def", "compute_nutation", "(", "t", ")", ":", "oblm", ",", "oblt", ",", "eqeq", ",", "psi", ",", "eps", "=", "t", ".", "_earth_tilt", "cobm", "=", "cos", "(", "oblm", "*", "DEG2RAD", ")", "sobm", "=", "sin", "(", "oblm", "*", "DEG2RAD", ")", "co...
Generate the nutation rotations for Time `t`. If the Julian date is scalar, a simple ``(3, 3)`` matrix is returned; if the date is an array of length ``n``, then an array of matrices is returned with dimensions ``(3, 3, n)``.
[ "Generate", "the", "nutation", "rotations", "for", "Time", "t", "." ]
51d9e042e06457f6b1f2415296d50a38cb3a300f
https://github.com/skyfielders/python-skyfield/blob/51d9e042e06457f6b1f2415296d50a38cb3a300f/skyfield/nutationlib.py#L19-L44
243,781
skyfielders/python-skyfield
skyfield/nutationlib.py
earth_tilt
def earth_tilt(t): """Return a tuple of information about the earth's axis and position. `t` - A Time object. The returned tuple contains five items: ``mean_ob`` - Mean obliquity of the ecliptic in degrees. ``true_ob`` - True obliquity of the ecliptic in degrees. ``eq_eq`` - Equation of the e...
python
def earth_tilt(t): dp, de = t._nutation_angles c_terms = equation_of_the_equinoxes_complimentary_terms(t.tt) / ASEC2RAD d_psi = dp * 1e-7 + t.psi_correction d_eps = de * 1e-7 + t.eps_correction mean_ob = mean_obliquity(t.tdb) true_ob = mean_ob + d_eps mean_ob /= 3600.0 true_ob /= 3600...
[ "def", "earth_tilt", "(", "t", ")", ":", "dp", ",", "de", "=", "t", ".", "_nutation_angles", "c_terms", "=", "equation_of_the_equinoxes_complimentary_terms", "(", "t", ".", "tt", ")", "/", "ASEC2RAD", "d_psi", "=", "dp", "*", "1e-7", "+", "t", ".", "psi_...
Return a tuple of information about the earth's axis and position. `t` - A Time object. The returned tuple contains five items: ``mean_ob`` - Mean obliquity of the ecliptic in degrees. ``true_ob`` - True obliquity of the ecliptic in degrees. ``eq_eq`` - Equation of the equinoxes in seconds of tim...
[ "Return", "a", "tuple", "of", "information", "about", "the", "earth", "s", "axis", "and", "position", "." ]
51d9e042e06457f6b1f2415296d50a38cb3a300f
https://github.com/skyfielders/python-skyfield/blob/51d9e042e06457f6b1f2415296d50a38cb3a300f/skyfield/nutationlib.py#L46-L75
243,782
skyfielders/python-skyfield
skyfield/nutationlib.py
mean_obliquity
def mean_obliquity(jd_tdb): """Return the mean obliquity of the ecliptic in arcseconds. `jd_tt` - TDB time as a Julian date float, or NumPy array of floats """ # Compute time in Julian centuries from epoch J2000.0. t = (jd_tdb - T0) / 36525.0 # Compute the mean obliquity in arcseconds. Use ...
python
def mean_obliquity(jd_tdb): # Compute time in Julian centuries from epoch J2000.0. t = (jd_tdb - T0) / 36525.0 # Compute the mean obliquity in arcseconds. Use expression from the # reference's eq. (39) with obliquity at J2000.0 taken from eq. (37) # or Table 8. epsilon = (((( - 0.0000000434...
[ "def", "mean_obliquity", "(", "jd_tdb", ")", ":", "# Compute time in Julian centuries from epoch J2000.0.", "t", "=", "(", "jd_tdb", "-", "T0", ")", "/", "36525.0", "# Compute the mean obliquity in arcseconds. Use expression from the", "# reference's eq. (39) with obliquity at J20...
Return the mean obliquity of the ecliptic in arcseconds. `jd_tt` - TDB time as a Julian date float, or NumPy array of floats
[ "Return", "the", "mean", "obliquity", "of", "the", "ecliptic", "in", "arcseconds", "." ]
51d9e042e06457f6b1f2415296d50a38cb3a300f
https://github.com/skyfielders/python-skyfield/blob/51d9e042e06457f6b1f2415296d50a38cb3a300f/skyfield/nutationlib.py#L79-L99
243,783
skyfielders/python-skyfield
skyfield/nutationlib.py
equation_of_the_equinoxes_complimentary_terms
def equation_of_the_equinoxes_complimentary_terms(jd_tt): """Compute the complementary terms of the equation of the equinoxes. `jd_tt` - Terrestrial Time: Julian date float, or NumPy array of floats """ # Interval between fundamental epoch J2000.0 and current date. t = (jd_tt - T0) / 36525.0 ...
python
def equation_of_the_equinoxes_complimentary_terms(jd_tt): # Interval between fundamental epoch J2000.0 and current date. t = (jd_tt - T0) / 36525.0 # Build array for intermediate results. shape = getattr(jd_tt, 'shape', ()) fa = zeros((14,) if shape == () else (14, shape[0])) # Mean Anomaly ...
[ "def", "equation_of_the_equinoxes_complimentary_terms", "(", "jd_tt", ")", ":", "# Interval between fundamental epoch J2000.0 and current date.", "t", "=", "(", "jd_tt", "-", "T0", ")", "/", "36525.0", "# Build array for intermediate results.", "shape", "=", "getattr", "(", ...
Compute the complementary terms of the equation of the equinoxes. `jd_tt` - Terrestrial Time: Julian date float, or NumPy array of floats
[ "Compute", "the", "complementary", "terms", "of", "the", "equation", "of", "the", "equinoxes", "." ]
51d9e042e06457f6b1f2415296d50a38cb3a300f
https://github.com/skyfielders/python-skyfield/blob/51d9e042e06457f6b1f2415296d50a38cb3a300f/skyfield/nutationlib.py#L101-L189
243,784
skyfielders/python-skyfield
skyfield/nutationlib.py
iau2000a
def iau2000a(jd_tt): """Compute Earth nutation based on the IAU 2000A nutation model. `jd_tt` - Terrestrial Time: Julian date float, or NumPy array of floats Returns a tuple ``(delta_psi, delta_epsilon)`` measured in tenths of a micro-arcsecond. Each value is either a float, or a NumPy array with...
python
def iau2000a(jd_tt): # Interval between fundamental epoch J2000.0 and given date. t = (jd_tt - T0) / 36525.0 # Compute fundamental arguments from Simon et al. (1994), in radians. a = fundamental_arguments(t) # ** Luni-solar nutation ** # Summation of luni-solar nutation series (in reverse or...
[ "def", "iau2000a", "(", "jd_tt", ")", ":", "# Interval between fundamental epoch J2000.0 and given date.", "t", "=", "(", "jd_tt", "-", "T0", ")", "/", "36525.0", "# Compute fundamental arguments from Simon et al. (1994), in radians.", "a", "=", "fundamental_arguments", "(", ...
Compute Earth nutation based on the IAU 2000A nutation model. `jd_tt` - Terrestrial Time: Julian date float, or NumPy array of floats Returns a tuple ``(delta_psi, delta_epsilon)`` measured in tenths of a micro-arcsecond. Each value is either a float, or a NumPy array with the same dimensions as the ...
[ "Compute", "Earth", "nutation", "based", "on", "the", "IAU", "2000A", "nutation", "model", "." ]
51d9e042e06457f6b1f2415296d50a38cb3a300f
https://github.com/skyfielders/python-skyfield/blob/51d9e042e06457f6b1f2415296d50a38cb3a300f/skyfield/nutationlib.py#L222-L271
243,785
skyfielders/python-skyfield
skyfield/nutationlib.py
iau2000b
def iau2000b(jd_tt): """Compute Earth nutation based on the faster IAU 2000B nutation model. `jd_tt` - Terrestrial Time: Julian date float, or NumPy array of floats Returns a tuple ``(delta_psi, delta_epsilon)`` measured in tenths of a micro-arcsecond. Each is either a float, or a NumPy array with ...
python
def iau2000b(jd_tt): dpplan = -0.000135 * 1e7 deplan = 0.000388 * 1e7 t = (jd_tt - T0) / 36525.0 # TODO: can these be replaced with fa0 and f1? el = fmod (485868.249036 + t * 1717915923.2178, ASEC360) * ASEC2RAD; elp = fmod (1287104.79305 + t * 129596581.0481, ASEC36...
[ "def", "iau2000b", "(", "jd_tt", ")", ":", "dpplan", "=", "-", "0.000135", "*", "1e7", "deplan", "=", "0.000388", "*", "1e7", "t", "=", "(", "jd_tt", "-", "T0", ")", "/", "36525.0", "# TODO: can these be replaced with fa0 and f1?", "el", "=", "fmod", "(", ...
Compute Earth nutation based on the faster IAU 2000B nutation model. `jd_tt` - Terrestrial Time: Julian date float, or NumPy array of floats Returns a tuple ``(delta_psi, delta_epsilon)`` measured in tenths of a micro-arcsecond. Each is either a float, or a NumPy array with the same dimensions as the...
[ "Compute", "Earth", "nutation", "based", "on", "the", "faster", "IAU", "2000B", "nutation", "model", "." ]
51d9e042e06457f6b1f2415296d50a38cb3a300f
https://github.com/skyfielders/python-skyfield/blob/51d9e042e06457f6b1f2415296d50a38cb3a300f/skyfield/nutationlib.py#L273-L325
243,786
skyfielders/python-skyfield
skyfield/data/hipparcos.py
load_dataframe
def load_dataframe(fobj, compression='gzip'): """Given an open file for `hip_main.dat.gz`, return a parsed dataframe. If your copy of ``hip_main.dat`` has already been unzipped, pass the optional argument ``compression=None``. """ try: from pandas import read_fwf except ImportError: ...
python
def load_dataframe(fobj, compression='gzip'): try: from pandas import read_fwf except ImportError: raise ImportError(PANDAS_MESSAGE) names, colspecs = zip( ('hip', (2, 14)), ('magnitude', (41, 46)), ('ra_degrees', (51, 63)), ('dec_degrees', (64, 76)), ...
[ "def", "load_dataframe", "(", "fobj", ",", "compression", "=", "'gzip'", ")", ":", "try", ":", "from", "pandas", "import", "read_fwf", "except", "ImportError", ":", "raise", "ImportError", "(", "PANDAS_MESSAGE", ")", "names", ",", "colspecs", "=", "zip", "("...
Given an open file for `hip_main.dat.gz`, return a parsed dataframe. If your copy of ``hip_main.dat`` has already been unzipped, pass the optional argument ``compression=None``.
[ "Given", "an", "open", "file", "for", "hip_main", ".", "dat", ".", "gz", "return", "a", "parsed", "dataframe", "." ]
51d9e042e06457f6b1f2415296d50a38cb3a300f
https://github.com/skyfielders/python-skyfield/blob/51d9e042e06457f6b1f2415296d50a38cb3a300f/skyfield/data/hipparcos.py#L44-L71
243,787
skyfielders/python-skyfield
skyfield/toposlib.py
Topos._altaz_rotation
def _altaz_rotation(self, t): """Compute the rotation from the ICRF into the alt-az system.""" R_lon = rot_z(- self.longitude.radians - t.gast * tau / 24.0) return einsum('ij...,jk...,kl...->il...', self.R_lat, R_lon, t.M)
python
def _altaz_rotation(self, t): R_lon = rot_z(- self.longitude.radians - t.gast * tau / 24.0) return einsum('ij...,jk...,kl...->il...', self.R_lat, R_lon, t.M)
[ "def", "_altaz_rotation", "(", "self", ",", "t", ")", ":", "R_lon", "=", "rot_z", "(", "-", "self", ".", "longitude", ".", "radians", "-", "t", ".", "gast", "*", "tau", "/", "24.0", ")", "return", "einsum", "(", "'ij...,jk...,kl...->il...'", ",", "self...
Compute the rotation from the ICRF into the alt-az system.
[ "Compute", "the", "rotation", "from", "the", "ICRF", "into", "the", "alt", "-", "az", "system", "." ]
51d9e042e06457f6b1f2415296d50a38cb3a300f
https://github.com/skyfielders/python-skyfield/blob/51d9e042e06457f6b1f2415296d50a38cb3a300f/skyfield/toposlib.py#L70-L73
243,788
skyfielders/python-skyfield
skyfield/toposlib.py
Topos._at
def _at(self, t): """Compute the GCRS position and velocity of this Topos at time `t`.""" pos, vel = terra(self.latitude.radians, self.longitude.radians, self.elevation.au, t.gast) pos = einsum('ij...,j...->i...', t.MT, pos) vel = einsum('ij...,j...->i...', t.MT,...
python
def _at(self, t): pos, vel = terra(self.latitude.radians, self.longitude.radians, self.elevation.au, t.gast) pos = einsum('ij...,j...->i...', t.MT, pos) vel = einsum('ij...,j...->i...', t.MT, vel) if self.x: R = rot_y(self.x * ASEC2RAD) po...
[ "def", "_at", "(", "self", ",", "t", ")", ":", "pos", ",", "vel", "=", "terra", "(", "self", ".", "latitude", ".", "radians", ",", "self", ".", "longitude", ".", "radians", ",", "self", ".", "elevation", ".", "au", ",", "t", ".", "gast", ")", "...
Compute the GCRS position and velocity of this Topos at time `t`.
[ "Compute", "the", "GCRS", "position", "and", "velocity", "of", "this", "Topos", "at", "time", "t", "." ]
51d9e042e06457f6b1f2415296d50a38cb3a300f
https://github.com/skyfielders/python-skyfield/blob/51d9e042e06457f6b1f2415296d50a38cb3a300f/skyfield/toposlib.py#L75-L89
243,789
skyfielders/python-skyfield
skyfield/elementslib.py
osculating_elements_of
def osculating_elements_of(position, reference_frame=None): """Produce the osculating orbital elements for a position. The ``position`` should be an :class:`~skyfield.positionlib.ICRF` instance like that returned by the ``at()`` method of any Solar System body, specifying a position, a velocity, and a ...
python
def osculating_elements_of(position, reference_frame=None): mu = GM_dict.get(position.center, 0) + GM_dict.get(position.target, 0) if reference_frame is not None: position_vec = Distance(reference_frame.dot(position.position.au)) velocity_vec = Velocity(reference_frame.dot(position.velocity...
[ "def", "osculating_elements_of", "(", "position", ",", "reference_frame", "=", "None", ")", ":", "mu", "=", "GM_dict", ".", "get", "(", "position", ".", "center", ",", "0", ")", "+", "GM_dict", ".", "get", "(", "position", ".", "target", ",", "0", ")",...
Produce the osculating orbital elements for a position. The ``position`` should be an :class:`~skyfield.positionlib.ICRF` instance like that returned by the ``at()`` method of any Solar System body, specifying a position, a velocity, and a time. An instance of :class:`~skyfield.elementslib.OsculatingE...
[ "Produce", "the", "osculating", "orbital", "elements", "for", "a", "position", "." ]
51d9e042e06457f6b1f2415296d50a38cb3a300f
https://github.com/skyfielders/python-skyfield/blob/51d9e042e06457f6b1f2415296d50a38cb3a300f/skyfield/elementslib.py#L12-L34
243,790
skyfielders/python-skyfield
skyfield/sgp4lib.py
theta_GMST1982
def theta_GMST1982(jd_ut1): """Return the angle of Greenwich Mean Standard Time 1982 given the JD. This angle defines the difference between the idiosyncratic True Equator Mean Equinox (TEME) frame of reference used by SGP4 and the more standard Pseudo Earth Fixed (PEF) frame of reference. From AI...
python
def theta_GMST1982(jd_ut1): t = (jd_ut1 - T0) / 36525.0 g = 67310.54841 + (8640184.812866 + (0.093104 + (-6.2e-6) * t) * t) * t dg = 8640184.812866 + (0.093104 * 2.0 + (-6.2e-6 * 3.0) * t) * t theta = (jd_ut1 % 1.0 + g * _second % 1.0) * tau theta_dot = (1.0 + dg * _second / 36525.0) * tau retur...
[ "def", "theta_GMST1982", "(", "jd_ut1", ")", ":", "t", "=", "(", "jd_ut1", "-", "T0", ")", "/", "36525.0", "g", "=", "67310.54841", "+", "(", "8640184.812866", "+", "(", "0.093104", "+", "(", "-", "6.2e-6", ")", "*", "t", ")", "*", "t", ")", "*",...
Return the angle of Greenwich Mean Standard Time 1982 given the JD. This angle defines the difference between the idiosyncratic True Equator Mean Equinox (TEME) frame of reference used by SGP4 and the more standard Pseudo Earth Fixed (PEF) frame of reference. From AIAA 2006-6753 Appendix C.
[ "Return", "the", "angle", "of", "Greenwich", "Mean", "Standard", "Time", "1982", "given", "the", "JD", "." ]
51d9e042e06457f6b1f2415296d50a38cb3a300f
https://github.com/skyfielders/python-skyfield/blob/51d9e042e06457f6b1f2415296d50a38cb3a300f/skyfield/sgp4lib.py#L160-L175
243,791
skyfielders/python-skyfield
skyfield/sgp4lib.py
TEME_to_ITRF
def TEME_to_ITRF(jd_ut1, rTEME, vTEME, xp=0.0, yp=0.0): """Convert TEME position and velocity into standard ITRS coordinates. This converts a position and velocity vector in the idiosyncratic True Equator Mean Equinox (TEME) frame of reference used by the SGP4 theory into vectors into the more standard...
python
def TEME_to_ITRF(jd_ut1, rTEME, vTEME, xp=0.0, yp=0.0): theta, theta_dot = theta_GMST1982(jd_ut1) zero = theta_dot * 0.0 angular_velocity = array([zero, zero, -theta_dot]) R = rot_z(-theta) if len(rTEME.shape) == 1: rPEF = (R).dot(rTEME) vPEF = (R).dot(vTEME) + cross(angular_velocit...
[ "def", "TEME_to_ITRF", "(", "jd_ut1", ",", "rTEME", ",", "vTEME", ",", "xp", "=", "0.0", ",", "yp", "=", "0.0", ")", ":", "theta", ",", "theta_dot", "=", "theta_GMST1982", "(", "jd_ut1", ")", "zero", "=", "theta_dot", "*", "0.0", "angular_velocity", "=...
Convert TEME position and velocity into standard ITRS coordinates. This converts a position and velocity vector in the idiosyncratic True Equator Mean Equinox (TEME) frame of reference used by the SGP4 theory into vectors into the more standard ITRS frame of reference. The velocity should be provided i...
[ "Convert", "TEME", "position", "and", "velocity", "into", "standard", "ITRS", "coordinates", "." ]
51d9e042e06457f6b1f2415296d50a38cb3a300f
https://github.com/skyfielders/python-skyfield/blob/51d9e042e06457f6b1f2415296d50a38cb3a300f/skyfield/sgp4lib.py#L177-L208
243,792
skyfielders/python-skyfield
skyfield/sgp4lib.py
EarthSatellite.ITRF_position_velocity_error
def ITRF_position_velocity_error(self, t): """Return the ITRF position, velocity, and error at time `t`. The position is an x,y,z vector measured in au, the velocity is an x,y,z vector measured in au/day, and the error is a vector of possible error messages for the time or vector of tim...
python
def ITRF_position_velocity_error(self, t): rTEME, vTEME, error = self._position_and_velocity_TEME_km(t) rTEME /= AU_KM vTEME /= AU_KM vTEME *= DAY_S rITRF, vITRF = TEME_to_ITRF(t.ut1, rTEME, vTEME) return rITRF, vITRF, error
[ "def", "ITRF_position_velocity_error", "(", "self", ",", "t", ")", ":", "rTEME", ",", "vTEME", ",", "error", "=", "self", ".", "_position_and_velocity_TEME_km", "(", "t", ")", "rTEME", "/=", "AU_KM", "vTEME", "/=", "AU_KM", "vTEME", "*=", "DAY_S", "rITRF", ...
Return the ITRF position, velocity, and error at time `t`. The position is an x,y,z vector measured in au, the velocity is an x,y,z vector measured in au/day, and the error is a vector of possible error messages for the time or vector of times `t`.
[ "Return", "the", "ITRF", "position", "velocity", "and", "error", "at", "time", "t", "." ]
51d9e042e06457f6b1f2415296d50a38cb3a300f
https://github.com/skyfielders/python-skyfield/blob/51d9e042e06457f6b1f2415296d50a38cb3a300f/skyfield/sgp4lib.py#L136-L149
243,793
skyfielders/python-skyfield
skyfield/sgp4lib.py
EarthSatellite._at
def _at(self, t): """Compute this satellite's GCRS position and velocity at time `t`.""" rITRF, vITRF, error = self.ITRF_position_velocity_error(t) rGCRS, vGCRS = ITRF_to_GCRS2(t, rITRF, vITRF) return rGCRS, vGCRS, rGCRS, error
python
def _at(self, t): rITRF, vITRF, error = self.ITRF_position_velocity_error(t) rGCRS, vGCRS = ITRF_to_GCRS2(t, rITRF, vITRF) return rGCRS, vGCRS, rGCRS, error
[ "def", "_at", "(", "self", ",", "t", ")", ":", "rITRF", ",", "vITRF", ",", "error", "=", "self", ".", "ITRF_position_velocity_error", "(", "t", ")", "rGCRS", ",", "vGCRS", "=", "ITRF_to_GCRS2", "(", "t", ",", "rITRF", ",", "vITRF", ")", "return", "rG...
Compute this satellite's GCRS position and velocity at time `t`.
[ "Compute", "this", "satellite", "s", "GCRS", "position", "and", "velocity", "at", "time", "t", "." ]
51d9e042e06457f6b1f2415296d50a38cb3a300f
https://github.com/skyfielders/python-skyfield/blob/51d9e042e06457f6b1f2415296d50a38cb3a300f/skyfield/sgp4lib.py#L151-L155
243,794
skyfielders/python-skyfield
skyfield/data/earth_orientation.py
morrison_and_stephenson_2004_table
def morrison_and_stephenson_2004_table(): """Table of smoothed Delta T values from Morrison and Stephenson, 2004.""" import pandas as pd f = load.open('http://eclipse.gsfc.nasa.gov/SEcat5/deltat.html') tables = pd.read_html(f.read()) df = tables[0] return pd.DataFrame({'year': df[0], 'delta_t': ...
python
def morrison_and_stephenson_2004_table(): import pandas as pd f = load.open('http://eclipse.gsfc.nasa.gov/SEcat5/deltat.html') tables = pd.read_html(f.read()) df = tables[0] return pd.DataFrame({'year': df[0], 'delta_t': df[1]})
[ "def", "morrison_and_stephenson_2004_table", "(", ")", ":", "import", "pandas", "as", "pd", "f", "=", "load", ".", "open", "(", "'http://eclipse.gsfc.nasa.gov/SEcat5/deltat.html'", ")", "tables", "=", "pd", ".", "read_html", "(", "f", ".", "read", "(", ")", ")...
Table of smoothed Delta T values from Morrison and Stephenson, 2004.
[ "Table", "of", "smoothed", "Delta", "T", "values", "from", "Morrison", "and", "Stephenson", "2004", "." ]
51d9e042e06457f6b1f2415296d50a38cb3a300f
https://github.com/skyfielders/python-skyfield/blob/51d9e042e06457f6b1f2415296d50a38cb3a300f/skyfield/data/earth_orientation.py#L8-L14
243,795
skyfielders/python-skyfield
skyfield/functions.py
angle_between
def angle_between(u_vec, v_vec): """Given 2 vectors in `v` and `u`, return the angle separating them. This works whether `v` and `u` each have the shape ``(3,)``, or whether they are each whole arrays of corresponding x, y, and z coordinates and have shape ``(3, N)``. The returned angle will be bet...
python
def angle_between(u_vec, v_vec): u = length_of(u_vec) v = length_of(v_vec) num = v*u_vec - u*v_vec denom = v*u_vec + u*v_vec return 2*arctan2(length_of(num), length_of(denom))
[ "def", "angle_between", "(", "u_vec", ",", "v_vec", ")", ":", "u", "=", "length_of", "(", "u_vec", ")", "v", "=", "length_of", "(", "v_vec", ")", "num", "=", "v", "*", "u_vec", "-", "u", "*", "v_vec", "denom", "=", "v", "*", "u_vec", "+", "u", ...
Given 2 vectors in `v` and `u`, return the angle separating them. This works whether `v` and `u` each have the shape ``(3,)``, or whether they are each whole arrays of corresponding x, y, and z coordinates and have shape ``(3, N)``. The returned angle will be between 0 and 180 degrees. This formul...
[ "Given", "2", "vectors", "in", "v", "and", "u", "return", "the", "angle", "separating", "them", "." ]
51d9e042e06457f6b1f2415296d50a38cb3a300f
https://github.com/skyfielders/python-skyfield/blob/51d9e042e06457f6b1f2415296d50a38cb3a300f/skyfield/functions.py#L26-L42
243,796
skyfielders/python-skyfield
skyfield/starlib.py
Star._compute_vectors
def _compute_vectors(self): """Compute the star's position as an ICRF position and velocity.""" # Use 1 gigaparsec for stars whose parallax is zero. parallax = self.parallax_mas if parallax <= 0.0: parallax = 1.0e-6 # Convert right ascension, declination, and paral...
python
def _compute_vectors(self): # Use 1 gigaparsec for stars whose parallax is zero. parallax = self.parallax_mas if parallax <= 0.0: parallax = 1.0e-6 # Convert right ascension, declination, and parallax to position # vector in equatorial system with units of au. ...
[ "def", "_compute_vectors", "(", "self", ")", ":", "# Use 1 gigaparsec for stars whose parallax is zero.", "parallax", "=", "self", ".", "parallax_mas", "if", "parallax", "<=", "0.0", ":", "parallax", "=", "1.0e-6", "# Convert right ascension, declination, and parallax to posi...
Compute the star's position as an ICRF position and velocity.
[ "Compute", "the", "star", "s", "position", "as", "an", "ICRF", "position", "and", "velocity", "." ]
51d9e042e06457f6b1f2415296d50a38cb3a300f
https://github.com/skyfielders/python-skyfield/blob/51d9e042e06457f6b1f2415296d50a38cb3a300f/skyfield/starlib.py#L126-L170
243,797
skyfielders/python-skyfield
skyfield/units.py
_to_array
def _to_array(value): """As a convenience, turn Python lists and tuples into NumPy arrays.""" if isinstance(value, (tuple, list)): return array(value) elif isinstance(value, (float, int)): return np.float64(value) else: return value
python
def _to_array(value): if isinstance(value, (tuple, list)): return array(value) elif isinstance(value, (float, int)): return np.float64(value) else: return value
[ "def", "_to_array", "(", "value", ")", ":", "if", "isinstance", "(", "value", ",", "(", "tuple", ",", "list", ")", ")", ":", "return", "array", "(", "value", ")", "elif", "isinstance", "(", "value", ",", "(", "float", ",", "int", ")", ")", ":", "...
As a convenience, turn Python lists and tuples into NumPy arrays.
[ "As", "a", "convenience", "turn", "Python", "lists", "and", "tuples", "into", "NumPy", "arrays", "." ]
51d9e042e06457f6b1f2415296d50a38cb3a300f
https://github.com/skyfielders/python-skyfield/blob/51d9e042e06457f6b1f2415296d50a38cb3a300f/skyfield/units.py#L12-L19
243,798
skyfielders/python-skyfield
skyfield/units.py
_sexagesimalize_to_float
def _sexagesimalize_to_float(value): """Decompose `value` into units, minutes, and seconds. Note that this routine is not appropriate for displaying a value, because rounding to the smallest digit of display is necessary before showing a value to the user. Use `_sexagesimalize_to_int()` for data b...
python
def _sexagesimalize_to_float(value): sign = np.sign(value) n = abs(value) minutes, seconds = divmod(n * 3600.0, 60.0) units, minutes = divmod(minutes, 60.0) return sign, units, minutes, seconds
[ "def", "_sexagesimalize_to_float", "(", "value", ")", ":", "sign", "=", "np", ".", "sign", "(", "value", ")", "n", "=", "abs", "(", "value", ")", "minutes", ",", "seconds", "=", "divmod", "(", "n", "*", "3600.0", ",", "60.0", ")", "units", ",", "mi...
Decompose `value` into units, minutes, and seconds. Note that this routine is not appropriate for displaying a value, because rounding to the smallest digit of display is necessary before showing a value to the user. Use `_sexagesimalize_to_int()` for data being displayed to the user. This routin...
[ "Decompose", "value", "into", "units", "minutes", "and", "seconds", "." ]
51d9e042e06457f6b1f2415296d50a38cb3a300f
https://github.com/skyfielders/python-skyfield/blob/51d9e042e06457f6b1f2415296d50a38cb3a300f/skyfield/units.py#L310-L332
243,799
skyfielders/python-skyfield
skyfield/units.py
_sexagesimalize_to_int
def _sexagesimalize_to_int(value, places=0): """Decompose `value` into units, minutes, seconds, and second fractions. This routine prepares a value for sexagesimal display, with its seconds fraction expressed as an integer with `places` digits. The result is a tuple of five integers: ``(sign [eit...
python
def _sexagesimalize_to_int(value, places=0): sign = int(np.sign(value)) value = abs(value) power = 10 ** places n = int(7200 * power * value + 1) // 2 n, fraction = divmod(n, power) n, seconds = divmod(n, 60) n, minutes = divmod(n, 60) return sign, n, minutes, seconds, fraction
[ "def", "_sexagesimalize_to_int", "(", "value", ",", "places", "=", "0", ")", ":", "sign", "=", "int", "(", "np", ".", "sign", "(", "value", ")", ")", "value", "=", "abs", "(", "value", ")", "power", "=", "10", "**", "places", "n", "=", "int", "("...
Decompose `value` into units, minutes, seconds, and second fractions. This routine prepares a value for sexagesimal display, with its seconds fraction expressed as an integer with `places` digits. The result is a tuple of five integers: ``(sign [either +1 or -1], units, minutes, seconds, second_fract...
[ "Decompose", "value", "into", "units", "minutes", "seconds", "and", "second", "fractions", "." ]
51d9e042e06457f6b1f2415296d50a38cb3a300f
https://github.com/skyfielders/python-skyfield/blob/51d9e042e06457f6b1f2415296d50a38cb3a300f/skyfield/units.py#L334-L356