bin.MarsPull
The MarsPull executable is for querying data from the Mars Climate Modeling Center (MCMC) Mars Global Climate Model (MGCM) repository on the NASA NAS Data Portal at data.nas.nasa.gov/mcmc.
The executable requires 2 arguments:
The directory from which to pull data from, AND
[-ls --ls]The desired solar longitude(s), OR
[-f --filename]The name(s) of the desired file(s)
Third-party Requirements:
sys
argparse
os
re
numpy
functools
traceback
requests
Module Contents
Functions
|
A decorator that wraps a function with error handling |
|
Downloads a file from the NAS Data Portal (data.nas.nasa.gov). |
|
The main function that handles the command-line arguments |
|
Prints a list of files. |
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.
AttributeError – If the function does not have the specified attribute.
IndexError – If the function does not have the specified index.
- download(url, file_name)
Downloads a file from the NAS Data Portal (data.nas.nasa.gov). The function takes a URL and a file name as input, and downloads the file from the URL, saving it to the specified file name. It also provides a progress bar to show the download progress if the file size is known. If the file size is unknown, it simply downloads the file without showing a progress bar. The function handles errors during the download process and prints appropriate messages to the console.
- Parameters:
url (str) – The url to download from, e.g., ‘https://data.nas.nasa.gov/legacygcm/fv3betaout1data/03340.fixed.nc’
file_name (str) – The local file_name e.g., ‘/lou/la4/akling/Data/LegacyGCM_Ls000_Ls004.nc’
- Returns:
The requested file(s), downloaded and saved to the current directory.
- Return type:
None
- Raises:
FileNotFoundError – A file-not-found error.
PermissionError – A permission error.
OSError – An operating system error.
ValueError – A value error.
TypeError – A type error.
requests.exceptions.RequestException – A request error.
requests.exceptions.HTTPError – An HTTP error.
requests.exceptions.ConnectionError – A connection error.
requests.exceptions.Timeout – A timeout error.
requests.exceptions.TooManyRedirects – A too many redirects error.
requests.exceptions.URLRequired – A URL required error.
requests.exceptions.InvalidURL – An invalid URL error.
requests.exceptions.InvalidSchema – An invalid schema error.
requests.exceptions.MissingSchema – A missing schema error.
requests.exceptions.InvalidHeader – An invalid header error.
requests.exceptions.InvalidProxyURL – An invalid proxy URL error.
requests.exceptions.InvalidRequest – An invalid request error.
requests.exceptions.InvalidResponse – An invalid response error.
- main()
The main function that handles the command-line arguments
Handles the command-line arguments and coordinates the download process. It checks for the presence of the required arguments, validates the input, and calls the appropriate functions to download the requested files. It also handles the logic for listing available directories and files, as well as downloading files based on specified solar longitudes (Ls) or file names.
- Returns:
0 if successful, 1 if an error occurred.
- Return type:
int
- Raises:
SystemExit – If an error occurs during the execution of the program, the program will exit with a non-zero status code.
- print_file_list(list_of_files)
Prints a list of files.
- Parameters:
list_of_files (list) – The list of files to print.
- Returns:
None
- Return type:
None
- Raises:
TypeError – If list_of_files is not a list.
ValueError – If list_of_files is empty.
IndexError – If list_of_files is out of range.
KeyError – If list_of_files is not found.
OSError – If list_of_files is not accessible.
IOError – If list_of_files is not open.
- Ls_end
- Ls_ini
- args
- debug
- exit_code
- parser
- save_dir