mangadap.util.parser module¶
Provides a set of parsing utility functions.
Todo
- Add function that will parse the default MaNGA fits file name (see
mangadap.config.defaults.default_manga_fits_root()
).
Revision history¶
2015: Original implementation by K. Westfall (KBW)20 May 2015: (KBW) Documentation and Sphinx tests04 Jun 2015: (KBW) Addedparse_drp_file_name()
,parse_dap_file_name()
Copyright © 2019, SDSS-IV/MaNGA Pipeline Group
-
class
mangadap.util.parser.
DefaultConfig
(f=None, interpolate=False)[source]¶ Bases:
object
A wrapper for the ConfigParser class that handles None values and provides some convenience functions.
-
mangadap.util.parser.
arginp_to_list
(inp, evaluate=False, quiet=True)[source]¶ Separate a list of comma-separated values in the input string to a list object.
Parameters: - inp (str or list) – Input string with a list of comma-separated values
- evaluate (bool) – (Optional) Attempt to evaluate the elements in
the list using
eval()
. - quiet (bool) – (Optional) Suppress terminal output
Returns: The list of the comma-separated values
Return type: list
-
mangadap.util.parser.
list_to_csl_string
(flist)[source]¶ Convert a list to a comma-separated string; i.e. perform the inverse of
arginp_to_list()
.Parameters: flist (list) – List to convert to a comma-separated string Returns: String with the values in the input list converted to string, using str()
, separated by commasReturn type: str
-
mangadap.util.parser.
parse_dap_file_name
(name)[source]¶ Parse the name of a DAP file and return the plate, ifudesign, mode, binning type, and iteration number.
Parameters: name (str) – Name of the DAP file.
Returns: The plate, ifudesign, mode (‘RSS’ or ‘CUBE’), bin type, and iteration number of the DAP file, pulled from the name of the file.
Return type: int, int, str, str, int
Raises: TypeError
– Raised if name is not a string.ValueError
– Raised if if the file name does not look like a DRP file because it does not include ‘manga-‘, ‘-BIN’, or ‘.fits’.
-
mangadap.util.parser.
parse_drp_file_name
(name)[source]¶ Parse the name of a DRP file to provide the plate, ifudesign, and mode.
Parameters: name (str) – Name of the DRP file.
Returns: The plate, ifudesign, and mode (‘RSS’ or ‘CUBE’) of the DRP file pulled from the file name.
Return type: int, int, str
Raises: TypeError
– Raised if name is not a string.ValueError
– Raised if if the file name does not look like a DRP file because it does not include ‘manga-‘, ‘-LOG’, or ‘.fits.gz’.