astrocats.catalog.utils package¶
Submodules¶
astrocats.catalog.utils.dates module¶
Utility functions related to dates.
-
astrocats.catalog.utils.dates.jd_to_mjd(jd)¶
-
astrocats.catalog.utils.dates.make_date_string(year, month='', day='')¶
-
astrocats.catalog.utils.dates.get_source_year(source)¶
astrocats.catalog.utils.digits module¶
-
astrocats.catalog.utils.digits.get_sig_digits(x, strip_zeroes=True)¶
-
astrocats.catalog.utils.digits.is_integer(s)¶
-
astrocats.catalog.utils.digits.is_number(s)¶
-
astrocats.catalog.utils.digits.pretty_num(x, sig=4)¶
-
astrocats.catalog.utils.digits.round_sig(x, sig=4)¶
-
astrocats.catalog.utils.digits.zpad(val, n=2)¶
astrocats.catalog.utils.imports module¶
Utility functions related to importing data.
-
astrocats.catalog.utils.imports.compress_gz(fname)¶ Compress the file with the given name and delete the uncompressed file.
The compressed filename is simply the input filename with ‘.gz’ appended.
- fname : str
- Name of the file to compress and delete.
- comp_fname : str
- Name of the compressed file produced. Equal to fname + ‘.gz’.
-
astrocats.catalog.utils.imports.convert_aq_output(row)¶
-
astrocats.catalog.utils.imports.read_json_dict(filename)¶
-
astrocats.catalog.utils.imports.read_json_arr(filename)¶
-
astrocats.catalog.utils.imports.uncompress_gz(fname)¶
astrocats.catalog.utils.logger module¶
Logging submodule and related functions.
-
astrocats.catalog.utils.logger.get_logger(name=None, stream_fmt=None, file_fmt=None, date_fmt=None, stream_level=None, file_level=None, tofile=None, tostr=True)¶ Create a standard logger object which logs to file and or stdout stream.
If a logger has already been created in this session, it is returned (unless name is given).
- name : str,
- Handle for this logger, must be distinct for a distinct logger.
- stream_fmt : str or None,
- Format of log messages to stream (stdout). If None, default settings are used.
- file_fmt : str or None,
- Format of log messages to file. If None, default settings are used.
- date_fmt : str or None
- Format of time stamps to stream and/or file. If None, default settings are used.
- stream_level : int,
- Logging level for stream.
- file_level : int,
- Logging level for file.
- tofile : str or None,
- Filename to log to (turned off if None).
- tostr : bool,
- Log to stdout stream.
- logger :
logging.Loggerobject, - Logger object to use for logging.
-
astrocats.catalog.utils.logger.log_raise(log, err_str, err_type=<type 'exceptions.RuntimeError'>)¶ Log an error message and raise an error.
log : logging.Logger object err_str : str
Error message to be logged and raised.- err_type : Exception object
- Type of error to raise.
-
astrocats.catalog.utils.logger.log_memory(log, pref=None, lvl=10, raise_flag=True)¶ Log the current memory usage.
astrocats.catalog.utils.sorting module¶
Key sorting functions
-
astrocats.catalog.utils.sorting.alias_priority(name, attr)¶
-
astrocats.catalog.utils.sorting.bib_priority(attr)¶
-
astrocats.catalog.utils.sorting.repo_priority(attr)¶
-
astrocats.catalog.utils.sorting.sortOD(od)¶
astrocats.catalog.utils.strings module¶
-
astrocats.catalog.utils.strings.dict_to_pretty_string(odict)¶
-
astrocats.catalog.utils.strings.rep_chars(string, chars, rep='')¶
-
astrocats.catalog.utils.strings.get_entry_filename(name)¶
-
astrocats.catalog.utils.strings.single_spaces(string)¶
-
astrocats.catalog.utils.strings.trim_str_arr(arr, length=10, max_rows=10)¶
-
astrocats.catalog.utils.strings.uniq_cdl(values)¶
-
astrocats.catalog.utils.strings.utf8(x)¶
astrocats.catalog.utils.tq_funcs module¶
-
astrocats.catalog.utils.tq_funcs.tq(li, currenttask='', leave=True)¶
-
astrocats.catalog.utils.tq_funcs.tprint(string)¶ Print string via tqdm so that it doesnt interfere with a progressbar.
-
astrocats.catalog.utils.tq_funcs.pbar(iter, desc='', **kwargs)¶ Wrapper for tqdm progress bar.
-
astrocats.catalog.utils.tq_funcs.pbar_strings(files, desc='', **kwargs)¶ Wrapper for tqdm progress bar which also sorts list of strings
Module contents¶
General utility functions used by multiple OSC scripts.
-
astrocats.catalog.utils.jd_to_mjd(jd)¶
-
astrocats.catalog.utils.make_date_string(year, month='', day='')¶
-
astrocats.catalog.utils.get_source_year(source)¶
-
astrocats.catalog.utils.get_sig_digits(x, strip_zeroes=True)¶
-
astrocats.catalog.utils.is_integer(s)¶
-
astrocats.catalog.utils.is_number(s)¶
-
astrocats.catalog.utils.pretty_num(x, sig=4)¶
-
astrocats.catalog.utils.round_sig(x, sig=4)¶
-
astrocats.catalog.utils.zpad(val, n=2)¶
-
astrocats.catalog.utils.compress_gz(fname)¶ Compress the file with the given name and delete the uncompressed file.
The compressed filename is simply the input filename with ‘.gz’ appended.
- fname : str
- Name of the file to compress and delete.
- comp_fname : str
- Name of the compressed file produced. Equal to fname + ‘.gz’.
-
astrocats.catalog.utils.convert_aq_output(row)¶
-
astrocats.catalog.utils.read_json_dict(filename)¶
-
astrocats.catalog.utils.read_json_arr(filename)¶
-
astrocats.catalog.utils.uncompress_gz(fname)¶
-
astrocats.catalog.utils.listify(x)¶
-
astrocats.catalog.utils.get_logger(name=None, stream_fmt=None, file_fmt=None, date_fmt=None, stream_level=None, file_level=None, tofile=None, tostr=True)¶ Create a standard logger object which logs to file and or stdout stream.
If a logger has already been created in this session, it is returned (unless name is given).
- name : str,
- Handle for this logger, must be distinct for a distinct logger.
- stream_fmt : str or None,
- Format of log messages to stream (stdout). If None, default settings are used.
- file_fmt : str or None,
- Format of log messages to file. If None, default settings are used.
- date_fmt : str or None
- Format of time stamps to stream and/or file. If None, default settings are used.
- stream_level : int,
- Logging level for stream.
- file_level : int,
- Logging level for file.
- tofile : str or None,
- Filename to log to (turned off if None).
- tostr : bool,
- Log to stdout stream.
- logger :
logging.Loggerobject, - Logger object to use for logging.
-
astrocats.catalog.utils.log_raise(log, err_str, err_type=<type 'exceptions.RuntimeError'>)¶ Log an error message and raise an error.
log : logging.Logger object err_str : str
Error message to be logged and raised.- err_type : Exception object
- Type of error to raise.
-
astrocats.catalog.utils.log_memory(log, pref=None, lvl=10, raise_flag=True)¶ Log the current memory usage.
-
astrocats.catalog.utils.bandrepf(code)¶
-
astrocats.catalog.utils.bandcolorf(code)¶
-
astrocats.catalog.utils.radiocolorf(freq)¶
-
astrocats.catalog.utils.xraycolorf(code)¶
-
astrocats.catalog.utils.bandaliasf(code)¶
-
astrocats.catalog.utils.bandshortaliasf(code)¶
-
astrocats.catalog.utils.bandwavef(code)¶
-
astrocats.catalog.utils.bandmetaf(band, field)¶
-
astrocats.catalog.utils.bandgroupf(code)¶
-
astrocats.catalog.utils.alias_priority(name, attr)¶
-
astrocats.catalog.utils.bib_priority(attr)¶
-
astrocats.catalog.utils.repo_priority(attr)¶
-
astrocats.catalog.utils.sortOD(od)¶
-
astrocats.catalog.utils.dict_to_pretty_string(odict)¶
-
astrocats.catalog.utils.rep_chars(string, chars, rep='')¶
-
astrocats.catalog.utils.get_entry_filename(name)¶
-
astrocats.catalog.utils.single_spaces(string)¶
-
astrocats.catalog.utils.trim_str_arr(arr, length=10, max_rows=10)¶
-
astrocats.catalog.utils.uniq_cdl(values)¶
-
astrocats.catalog.utils.utf8(x)¶
-
astrocats.catalog.utils.tq(li, currenttask='', leave=True)¶
-
astrocats.catalog.utils.tprint(string)¶ Print string via tqdm so that it doesnt interfere with a progressbar.
-
astrocats.catalog.utils.pbar(iter, desc='', **kwargs)¶ Wrapper for tqdm progress bar.
-
astrocats.catalog.utils.pbar_strings(files, desc='', **kwargs)¶ Wrapper for tqdm progress bar which also sorts list of strings