:py:mod:`exo_k.settings` ======================== .. py:module:: exo_k.settings .. autoapi-nested-parse:: @author: jeremy leconte A class based on a singleton to store global options only once for every instance. Module Contents --------------- .. py:class:: Settings Bases: :py:obj:`exo_k.util.singleton.Singleton` A class based on a singleton to store global options only once for every instance. So all the following methods can be called using the following syntax: >>> exo_k.Settings().method_name(agrs) In gerneal, they will change internal global attributes that change the global behavior of some routines in the library. .. py:property:: search_path Returns the current value of the global search path (_search_path) .. py:method:: init(*args, **kwds) Override to act as an init .. py:method:: reset_search_path(path_type='all', no_path=False) Set default search path. :param path_type: What type of path to reset. Possibilities are 'all' (default), 'kdata', 'cia', and 'aerosol' :type path_type: :class:`str` :param no_path: If False (default), the search path is reset to '.'. If True, empties the search path. :type no_path: :class:`bool (optional)` .. py:method:: add_search_path(*search_paths, path_type='kdata') Add path(s) to the list of paths that will be searched for various files. :param search_path: Search path(s) to look for opacities. :type search_path: :class:`string` or :class:`list` of :class:`strings` :param path_type: What type of path to change. Possibilities are: * 'kdata' (default): global xsec and corr-k search path * 'ktable' : only corr-k files * 'xtable' : only cross section files * 'cia': search path for CIA files * 'aerosol': search path for Aerosol optical property files :type path_type: :class:`str` .. rubric:: Examples >>> exo_k.Settings().add_search_path('data/xsec','data/corrk') >>> exo_k.Settings().search_path() ['/your/path/to/exo_k', '/your/path/to/exo_k/data/xsec', '/your/path/to/exo_k/data/corrk'] .. py:method:: add_cia_search_path(*search_paths) Add path(s) to the list of paths that will be searched for cia files. :param search_path: Search path(s) to look for opacities. :type search_path: :class:`string` or :class:`list` of :class:`strings` .. py:method:: add_aerosol_search_path(*search_paths) Add path(s) to the list of paths that will be searched for aerosol files. :param search_path: Search path(s) to look for opacities. :type search_path: :class:`string` or :class:`list` of :class:`strings` .. py:method:: set_search_path(*search_paths, path_type='kdata') Like :func:~`exo_k.settings.Settings.add_search_path` except for the fact that the path is reset first. .. py:method:: set_cia_search_path(*search_paths) Like :func:~`exo_k.settings.Settings.add_cia_search_path` except for the fact that the path is reset first. .. py:method:: set_aerosol_search_path(*search_paths) Like :func:~`exo_k.settings.Settings.add_aerosol_search_path` except for the fact that the path is reset first. .. py:method:: cia_search_path() Returns the current value of the cia search path (_cia_search_path) .. py:method:: aerosol_search_path() Returns the current value of the aerosol search path (_aerosol_search_path) .. py:method:: set_delimiter(newdelimiter) Sets the delimiter string used to separate molecule names in filenames. :param newdelimiter: New delimiter to use. Default is '_'. :type newdelimiter: :class:`string` .. rubric:: Example If I have a file named 'H2O.R10000_xsec.hdf5' that I want to load in a `Kdatabase`, the default settings will result in an error: >>> database=xk.Kdatabase(['H2O'],'R10000') No file was found with these filters: ('H2O_', 'R1000') in the following directories: ['/home/falco/xsec/xsec_sampled_R10000_0.3-15'] Using >>> xk.Settings().set_delimiter('.') >>> database=xk.Kdatabase(['H2O'],'R10000') finds the file. .. py:method:: set_delimiters(newdelimiters) Sets the delimiter string used to separate molecule names in filenames. If you want to include the '-' character, you must put a '\' before to avoid it being interpreted as a special character by the `re` module. :param newdelimiters: New delimiters to use. Default is '_.\-'. :type newdelimiters: :class:`string` .. py:method:: set_log_interp(log_interp) Sets the default interpolation mode for kdata. Default is Log. :param log_interp: If True, log interpolation. Linear if False. :type log_interp: :class:`boolean` .. py:method:: set_log_interp_aerosol(log_interp) Sets the default interpolation mode for aerosols. Default is Linear. :param log_interp: If True, log interpolation. Linear if False. :type log_interp: :class:`boolean` .. py:method:: set_case_sensitive(case_sensitive) Set whether name matching is case sensitive. Default is False. :param case_sensitive: If True, name matching is case sensitive. :type case_sensitive: :class:`boolean` .. py:method:: set_mks(set_mks) Forces conversion to mks system. :param set_mks: If True, all datasets are converted to mks upon loading. :type set_mks: :class:`boolean` .. py:method:: list_files(*str_filters, molecule=None, only_one=False, search_path=None, path_type='kdata') A routine that provides a list of all filenames containing a set of string filters in one of the global _search_path or a local one. Whether the search is case sensitive is specified through the Settings.set_case_sensitive() method. .. warning:: The pattern matching with the `str_filters` is done using regular expressions. If you want to match special characters (like a dot in a filename), do not forget to put a backslash in front of it. :param \*str_filters: A set of strings that need to be contained in the name of the file :type \*str_filters: :class:`str` :param molecule: The name of a molecule to be looked for in the filename. It must be followed by one of the characters in self._delimiters and either at the begining of the name or just after one of the characters in self._delimiters. :type molecule: :class:`str` :param only_one: If true, only one filename is returned (the first one). If false, a list is returned. Default is False. :type only_one: :class:`boolean`, *optional* :param search_path: If search_path is provided, it locally overrides the global _search_path settings and only files in search_path are returned. :type search_path: :class:`str`, *optional* :returns: list of strings List of filenames corresponding to all the str_filters .. py:method:: list_cia_files(*str_filters, molecule_pair=None, only_one=False, search_path=None) A routine that provides a list of all filenames containing a set of string filters in the global _search_path or a local one. Whether the search is case sensitive is specified through the Settings.set_case_sensitive() method. .. warning:: The pattern matching with the `str_filters` is done using regular expressions. If you want to match special characters (like a dot in a filename), do not forget to put a backslash in front of it. :param \*str_filters: A set of strings that need to be contained in the name of the file :type \*str_filters: :class:`str` :param molecule_pair: The name of the 2 molecules in the cia pair. :type molecule_pair: :class:`list` of :class:`2 str` :param only_one: If true, only one filename is returned (the first one). If false, a list is returned. Default is False. :type only_one: :class:`boolean`, *optional* :param search_path: If search_path is provided, it locally overrides the global _search_path settings and only files in search_path are returned. :type search_path: :class:`str`, *optional* :returns: list of strings List of filenames corresponding to all the str_filters .. py:exception:: NoFileFoundError Bases: :py:obj:`Exception` Error when no file is found Initialize self. See help(type(self)) for accurate signature.