astromodels.utils package

Submodules

astromodels.utils.angular_distance module

astromodels.utils.angular_distance.angular_distance(ra1, dec1, ra2, dec2)[source]

Returns the angular distance between two points, two sets of points, or a set of points and one point.

Parameters:
  • ra1 – array or float, longitude of first point(s)

  • dec1 – array or float, latitude of first point(s)

  • ra2 – array or float, longitude of second point(s)

  • dec2 – array or float, latitude of second point(s)

Returns:

angular distance(s) in degrees

astromodels.utils.angular_distance.angular_distance_fast(ra1, dec1, ra2, dec2)[source]

Compute angular distance using the Haversine formula. Use this one when you know you will never ask for points at their antipodes. If this is not the case, use the angular_distance function which is slower, but works also for antipodes.

Parameters:
  • lon1

  • lat1

  • lon2

  • lat2

Returns:

astromodels.utils.angular_distance.spherical_angle(ra0, dec0, ra1, dec1, ra2, dec2)[source]

Returns the spherical angle distance between two sets of great circles defined by (ra0, dec0), (ra1, dec1) and (ra0, dec0), (ra2, dec2)

Parameters:
  • ra0 – array or float, longitude of intersection point(s)

  • dec0 – array or float, latitude of intersection point(s)

  • ra1 – array or float, longitude of first point(s)

  • dec1 – array or float, latitude of first point(s)

  • ra2 – array or float, longitude of second point(s)

  • dec2 – array or float, latitude of second point(s)

Returns:

spherical angle in degrees

astromodels.utils.config_structure module

class astromodels.utils.config_structure.AbsTables(value)[source]

Bases: Enum

An enumeration.

AG89 = 'AG89'
ASPL = 'ASPL'
WILM = 'WILM'
class astromodels.utils.config_structure.AbsorptionModels(tbabs_table: astromodels.utils.config_structure.AbsTables = <AbsTables.WILM: 'WILM'>, phabs_table: astromodels.utils.config_structure.AbsTables = <AbsTables.AG89: 'AG89'>, ebl_table: astromodels.utils.config_structure.EBLTable = <EBLTable.dominguez: 'dominguez'>)[source]

Bases: object

ebl_table: EBLTable = 'dominguez'
phabs_table: AbsTables = 'AG89'
tbabs_table: AbsTables = 'WILM'
class astromodels.utils.config_structure.Config(logging: astromodels.utils.config_structure.Logging = <factory>, absorption_models: astromodels.utils.config_structure.AbsorptionModels = <factory>, modeling: astromodels.utils.config_structure.Modeling = <factory>)[source]

Bases: object

absorption_models: AbsorptionModels
logging: Logging
modeling: Modeling
class astromodels.utils.config_structure.EBLTable(value)[source]

Bases: Enum

An enumeration.

dominguez = 'dominguez'
franceschini = 'franceschini'
gilmore = 'gilmore'
inuoe = 'inuoe'
kneiske = 'kneiske'
class astromodels.utils.config_structure.Logging(path: str = '~/.astromodels/log', developer: bool = 'off', usr: bool = 'on', console: bool = 'on', level: astromodels.utils.config_structure.LoggingLevel = <LoggingLevel.INFO: 20>, startup_warnings: bool = 'on', info_style: str = 'medium_spring_green', warn_style: str = 'medium_orchid', error_style: str = 'blink bold bright_red', debug_style: str = 'blue_violet', message_style: str = 'bold grey78')[source]

Bases: object

console: bool = 'on'
debug_style: str = 'blue_violet'
developer: bool = 'off'
error_style: str = 'blink bold bright_red'
info_style: str = 'medium_spring_green'
level: LoggingLevel = 20
message_style: str = 'bold grey78'
path: str = '~/.astromodels/log'
startup_warnings: bool = 'on'
usr: bool = 'on'
warn_style: str = 'medium_orchid'
class astromodels.utils.config_structure.LoggingLevel(value)[source]

Bases: IntEnum

An enumeration.

CRITICAL = 50
DEBUG = 10
ERROR = 40
INFO = 20
WARNING = 30
class astromodels.utils.config_structure.Modeling(use_memoization: bool = True, use_parameter_transforms: bool = True, ignore_parameter_bounds: bool = False)[source]

Bases: object

ignore_parameter_bounds: bool = False
use_memoization: bool = True
use_parameter_transforms: bool = True

astromodels.utils.configuration module

astromodels.utils.configuration.recurse_dict(d, tree)[source]
astromodels.utils.configuration.show_configuration(sub_menu: Optional[str] = None)[source]

display the current configuration or a sub menu if provided

astromodels.utils.data_files module

astromodels.utils.disk_usage module

astromodels.utils.disk_usage.disk_usage(path)[source]

astromodels.utils.file_utils module

astromodels.utils.file_utils.get_path_of_user_config() Path[source]
astromodels.utils.file_utils.get_user_data_path() Path[source]
astromodels.utils.file_utils.get_user_path() Path[source]

astromodels.utils.io module

astromodels.utils.logging module

class astromodels.utils.logging.LogFilter(level)[source]

Bases: object

filter(logRecord)[source]
astromodels.utils.logging.activate_warnings()[source]

supress warning messages in console and file usr logs

astromodels.utils.logging.debug_node(self, message, *args, **kws)[source]
astromodels.utils.logging.get_path_of_log_dir()[source]
astromodels.utils.logging.get_path_of_log_file(log_file: str) Path[source]

returns the path of the log files

astromodels.utils.logging.setup_logger(name)[source]
astromodels.utils.logging.silence_console_log()[source]

temporarily silence the console and progress bars

astromodels.utils.logging.silence_warnings()[source]

supress warning messages in console and file usr logs

astromodels.utils.logging.update_logging_level(level)[source]

astromodels.utils.long_path_formatter module

astromodels.utils.long_path_formatter.long_path_formatter(line, max_width=50)[source]

If a path is longer than max_width, it substitute it with the first and last element, joined by “…”. For example ‘this.is.a.long.path.which.we.want.to.shorten’ becomes ‘this…shorten’

Parameters:
  • line

  • max_width

Returns:

astromodels.utils.pretty_list module

astromodels.utils.pretty_list.dict_to_list(dictionary, html=False)[source]

Convert a dictionary into a unordered list.

Parameters:
  • dictionary – a dictionary

  • html – whether to output HTML or simple text (True or False)

Returns:

the list

astromodels.utils.table module

class astromodels.utils.table.NumericMatrix(data=None, masked=False, names=None, dtype=None, meta=None, copy=True, rows=None, copy_indices=True, units=None, descriptions=None, **kwargs)[source]

Bases: Table

class astromodels.utils.table.Table(data=None, masked=False, names=None, dtype=None, meta=None, copy=True, rows=None, copy_indices=True, units=None, descriptions=None, **kwargs)[source]

Bases: Table

Wrapper around the astropy table to remove some useless clutter (like the format of each column)

astromodels.utils.table.dict_to_table(dictionary, list_of_keys=None)[source]

Return a table representing the dictionary.

Parameters:
  • dictionary – the dictionary to represent

  • list_of_keys – optionally, only the keys in this list will be inserted in the table

Returns:

a Table instance

astromodels.utils.valid_variable module

astromodels.utils.valid_variable.is_valid_variable_name(string_to_check)[source]

Returns whether the provided name is a valid variable name in Python

Parameters:

string_to_check – the string to be checked

Returns:

True or False

astromodels.utils.vincenty module

astromodels.utils.vincenty.vincenty(lon0, lat0, a1, s)[source]

Returns the coordinates of a new point that is a given angular distance s away from a starting point (lon0, lat0) at bearing (angle from north) a1), to within a given precision

Note that this calculation is a simplified version of the full vincenty problem, which solves for the coordinates on the surface on an arbitrary ellipsoid. Here we only care about the surface of a sphere.

Note: All parameters are assumed to be given in DEGREES :param lon0: float, longitude of starting point :param lat0: float, latitude of starting point :param a1: float, bearing to second point, i.e. angle between due north and line connecting 2 points :param s: float, angular distance between the two points :return: coordinates of second point in degrees

Module contents