popsynth.utils package
Submodules
popsynth.utils.array_to_cmap module
- popsynth.utils.array_to_cmap.array_to_cmap(values, cmap, use_log: bool = False)[source]
Generates a color map and color list that is normalized to the values in an array. Allows for adding a 3rd dimension onto a plot.
- Parameters
values – A list a values to map into a cmap
cmap – The mpl colormap to use
use_log (bool) – True if the mapping should be done in log space False by default.
- Returns
A color map and a normalized color list
popsynth.utils.configuration module
- class popsynth.utils.configuration.LogConsole(on: bool = True, level: str = 'WARNING')[source]
Bases:
object
- on: bool = True
- level: str = 'WARNING'
- __init__(on: bool = True, level: str = 'WARNING') None
- class popsynth.utils.configuration.LogFile(on: bool = True, level: str = 'WARNING')[source]
Bases:
object
- on: bool = True
- level: str = 'WARNING'
- __init__(on: bool = True, level: str = 'WARNING') None
- class popsynth.utils.configuration.Logging(debug: bool = False, console: popsynth.utils.configuration.LogConsole = LogConsole(on=True, level='WARNING'), file: popsynth.utils.configuration.LogFile = LogFile(on=True, level='WARNING'))[source]
Bases:
object
- debug: bool = False
- console: LogConsole = LogConsole(on=True, level='WARNING')
- __init__(debug: bool = False, console: LogConsole = LogConsole(on=True, level='WARNING'), file: LogFile = LogFile(on=True, level='WARNING')) None
- class popsynth.utils.configuration.Cosmology(Om: float = 0.307, h0: float = 67.7)[source]
Bases:
object
- Om: float = 0.307
- h0: float = 67.7
- __init__(Om: float = 0.307, h0: float = 67.7) None
- class popsynth.utils.configuration.PopSynthConfig(logging: popsynth.utils.configuration.Logging = Logging(debug=False, console=LogConsole(on=True, level='WARNING'), file=LogFile(on=True, level='WARNING')), cosmology: popsynth.utils.configuration.Cosmology = Cosmology(Om=0.307, h0=67.7), show_progress: bool = True)[source]
Bases:
object
- logging: Logging = Logging(debug=False, console=LogConsole(on=True, level='WARNING'), file=LogFile(on=True, level='WARNING'))
- show_progress: bool = True
popsynth.utils.cosmology module
popsynth.utils.hdf5_utils module
- popsynth.utils.hdf5_utils.recursively_save_dict_contents_to_group(h5file, path, dic: Dict[Any, Any])[source]
Save dict to HDF5.
- Parameters
h5file – HDF5 file
path – Path inside file
dic (Dict[Any, Any]) – Dictionary to save
- popsynth.utils.hdf5_utils.recursively_load_dict_contents_from_group(h5file, path)[source]
Load files from hdf5.
- Parameters
h5file – HDF5 file
path – Path in file
- Returns
A dictionary
- Return type
Dict[Any, Any]
popsynth.utils.logging module
- class popsynth.utils.logging.ColoredFormatter(*args, colors: Optional[Dict[str, str]] = None, **kwargs)[source]
Bases:
Formatter
Colored log formatter.
- class popsynth.utils.logging.LoggingState(popsynth_usr_log_handler, popsynth_console_log_handler)[source]
Bases:
object
- popsynth.utils.logging.silence_warnings()[source]
Supress warning messages in console and file usr logs.
popsynth.utils.meta module
- class popsynth.utils.meta.Parameter(default: Optional[float] = None, vmin: Optional[float] = None, vmax: Optional[float] = None, free: bool = True, is_normalization: bool = False)[source]
Bases:
object
- __init__(default: Optional[float] = None, vmin: Optional[float] = None, vmax: Optional[float] = None, free: bool = True, is_normalization: bool = False)[source]
Parameter base class.
- Parameters
default (Optional[float]) – Default parameter value
vmin (Optional[float]) – Minimum parameter value
vmax (Optional[float]) – Maximum parameter value
free – If True, parameter is free
- property default: Optional[float]
- property is_normalization: bool
- property free
‘p.free = True’ or ‘p.free = False’.
- Type
Gets or sets whether the parameter is free or not. Use booleans, like
- property fix
‘p.fix = True’ or ‘p.fix = False’.
- Type
Gets or sets whether the parameter is fixed or not. Use booleans, like