bin.MarsCalendar
The MarsCalendar executable accepts an input Ls or day-of-year (sol) and returns the corresponding sol or Ls, respectively.
The executable requires 1 of the following arguments:
[-sol --sol]The sol to convert to Ls, OR
[-ls --ls]The Ls to convert to sol
and optionally accepts:
[-my --marsyear]The Mars Year of the simulation to compute sol or Ls from, AND/OR
[-c --continuous]Returns Ls in continuous form
Third-party Requirements:
numpy
argparse
functools
traceback
sys
amescap
Module Contents
Functions
|
A decorator that wraps a function with error handling |
|
Main function for MarsCalendar command-line tool. |
|
Formats the input array for conversion. |
Attributes
- debug_wrapper(func)
A decorator that wraps a function with error handling based on the –debug flag.
If the –debug flag is set, it prints the full traceback of any exception that occurs. Otherwise, it prints a simplified error message.
- Parameters:
func (function) – The function to wrap.
- Returns:
The wrapped function.
- Return type:
function
- Raises:
Exception – If an error occurs during the function call.
TypeError – If the function is not callable.
ValueError – If the function is not found.
NameError – If the function is not defined.
AttributeError – If the function does not have the specified attribute.
ImportError – If the function cannot be imported.
RuntimeError – If the function cannot be run.
KeyError – If the function does not have the specified key.
IndexError – If the function does not have the specified index.
IOError – If the function cannot be opened.
OSError – If the function cannot be accessed.
EOFError – If the function cannot be read.
MemoryError – If the function cannot be allocated.
OverflowError – If the function cannot be overflowed.
ZeroDivisionError – If the function cannot be divided by zero.
StopIteration – If the function cannot be stopped.
KeyboardInterrupt – If the function cannot be interrupted.
SystemExit – If the function cannot be exited.
AssertionError – If the function cannot be asserted.
- main()
Main function for MarsCalendar command-line tool.
This function processes user-specified arguments to convert between Mars solar longitude (Ls) and sol (Martian day) values for a given Mars year. It supports both continuous and discrete sol calculations, and can handle input in either Ls or sol, returning the corresponding converted values. The results are printed in a formatted table.
Arguments are expected to be provided via the args namespace:
args.marsyear: Mars year (default is 0)
args.continuous: If set, enables continuous sol calculation
args.ls: List of Ls values to convert to sol
args.sol: List of sol values to convert to Ls
- Parameters:
args (argparse.Namespace) – Command-line arguments parsed using argparse.
- Raises:
ValueError – If the input is not a valid number or range.
RuntimeError – If the input is not a valid runtime.
TypeError – If the input is not a valid type.
IndexError – If the input is not a valid index.
KeyError – If the input is not a valid key.
AttributeError – If the input is not a valid attribute.
ImportError – If the input is not a valid import.
- Returns:
0 if the program runs successfully, 1 if an error occurs.
- Return type:
int
- parse_array(len_input)
Formats the input array for conversion.
Confirms that either
[-ls --ls]or[-sol --sol]was passed as an argument. Creates an array that ls2sol or sol2ls can read for the conversion from sol -> Ls or Ls -> sol.- Parameters:
len_input (float or list of floats) – The input Ls or sol to convert. Can either be one number (e.g., 300) or start stop step (e.g., 300 310 2).
- Raises:
Error if neither
[-ls --ls]or[-sol --sol]are provided.- Returns:
input_as_arrAn array formatted for input intols2solorsol2ls. Iflen_input = 300, theninput_as_arr=[300]. Iflen_input = 300 310 2, theninput_as_arr = [300, 302, 304, 306, 308].- Return type:
list of floats
- Raises:
ValueError – If the input is not a valid number or range.
TypeError – If the input is not a valid type.
IndexError – If the input is not a valid index.
KeyError – If the input is not a valid key.
AttributeError – If the input is not a valid attribute.
ImportError – If the input is not a valid import.
RuntimeError – If the input is not a valid runtime.
OverflowError – If the input is not a valid overflow.
MemoryError – If the input is not a valid memory.
- args
- debug
- exclusive_group
- exit_code
- group
- parser