omfit-base 2020.12.2.22.59
omfit_base
Requires Python: >=3.6

**BASE** files used as part of the OMFIT project: https://omfit.io/

Provides:
=========
* OMFITtree
* OMFITlist
* module_selective_deepcopy
* module_noscratch_deepcopy
* OMFITcollection
* OMFITmcTree
* OMFITstorage
* OMFITtreeCompressed
* OMFITmodule
* OMFITtmp
* OMFITproject
* OMFIThelp
* _OMFITnoSave
* OMFITexpressionsReturnNone
* OMFITexpression
* OMFITiterableExpression
* OMFITlazyLoad
* relativeLocations
* absLocation
* isinstance
* type
* hasattr
* shotBookmarks
* OMFITshotBookmarks
* OMFITmainSettings
* OMFITtypes
* OMFITtypesStr
* OMFITdictypes
* OMFITdictypesStr
* omfit_log
* ismodule
* diffTreeGUI
* exportTreeGUI
* diffViewer
* askDescription
* all_pylab_imports
* evalExpr

Requires:
=========
* numpy>=1.12
* omas>=0.67.0
* scipy>=1.0
* uncertainties>=3
* xarray>=0.10.8
* omfit_namelist==2020.12.2.22.59
* omfit_ascii==2020.12.2.22.59
* omfit_path==2020.12.2.22.59
* omfit_weblink==2020.12.2.22.59
* omfit_json==2020.12.2.22.59
* omfit_error==2020.12.2.22.59
* omfit_harvest==2020.12.2.22.59
* omfit_commonclasses==2020.12.2.22.59

Authors:
=========
https://omfit.io/contributors.html

Documentation:
==============
OMFITtree
---------

    A branch in the tree is represented in the filesystem as a directory.
    Note that the OMFIT object itself belongs to the OMFITmainTree class,
    which is a subclass of the OMFITtree class.
    

OMFITlist
---------

    list of which the individual values are saved to disk as it is done for the key:value pairs in an OMFITtree object
    

module_selective_deepcopy
-------------------------

    Function that returns the equivalent of a module copy.deepcopy
    but can selectively include entries based on their class

    :param location: string with OMFIT tree location where the module resides

    :param classes: list of strings with allwed classes

    :return: copy of the module containing a deepcopy of the allowed classes
    

module_noscratch_deepcopy
-------------------------

    deepcopy of a module (and submodules) but neglecting the scratch '__scratch__' directories

    :param module_root: instance of the module to be copied

    :return: module deepcopy
    

OMFITcollection
---------------

    A class for holding sets of similar objects

    :param selector: sets selection of a specific realization (`None` for all realizations, `'random'` for a random realization). This can also be an OMFITexpression.

    :param strategy: sets operation to be performed on all realizations (if `.selector == None`)

    :param raise_errors: sets how to proceed in case of errors (eg. missing objects, attributes)

        * `None`: print warning on errors

        * `True`: raise errors

        * `False`: ignore errors

    :param no_subdir: This keyword affects how the OMFITcollection is deployed.

        * `False` (default) the OMFITcollection is deployed like a normal OMFITtree, such that the files of the
            collection are deployed under a subdirectory, whose name comes from the entry in the tree

        * `True` the files are deployed in the same level directory as the parent

    `.selector`, `.strategy`, `.raise_errors` can be modified after the object is instantiated

    >> tmp=OMFITcollection(raise_errors=True)
    >> for k in range(1,10):
    >>     tmp[k]={}
    >>     tmp[k]['hello']=np.linspace(0,1,100)**k
    >>
    >> #return a single realization
    >> tmp.selector=5
    >> tmp.strategy=None
    >> pyplot.plot(tmp['hello'],'--r',lw=2)
    >>
    >> #return all realizations
    >> tmp.selector=None
    >> tmp.strategy=None
    >> plotc(tmp['hello'])
    >>
    >> #attribute on all realizations
    >> tmp.selector=None
    >> tmp.strategy=None
    >> print(tmp['hello'].mean())
    >>
    >> #perform operation on all realizations
    >> tmp.selector=None
    >> tmp.strategy='np.mean(x,axis=1)'
    >> pyplot.plot(tmp['hello'],'k--',lw=2)
    >>
    >> OMFIT['variable']=3
    >> tmp.selector=OMFITexpression("OMFIT['variable']")
    >> print(tmp)
    >>
    >> print(tmp.GET(3)['hello']-tmp['hello'])
    >>
    >> # to update values, you can use the UPDATE method
    >> tmp.UPDATE(location="['hello'][0]",values=-1e6)
    >> tmp.selector=None
    >> tmp.strategy=None
    >> print(tmp['hello'].mean())
    

OMFITmcTree
-----------

    A class for holding results from a Monte Carlo set of runs

    Effectively this is a `OMFITcollection` class with default strategy set to: `uarray(np.mean(x,1),np.std(x,1))`

    

OMFITstorage
------------
N/A

OMFITtreeCompressed
-------------------
N/A

OMFITmodule
-----------

    Class for OMFIT modules

    :param filename: None: create new module from skeleton, '': create an empty module
    

OMFITtmp
--------

    Same class of SortedDict, but is not saved when a project is saved
    This class is used to define the __scratch__ space under each module as well as the global OMFIT['scratch']
    

OMFITproject
------------
Similar to OMFITtree class

OMFIThelp
---------

    Class used to parse OMFIT modules help.rst files
    

_OMFITnoSave
------------
N/A

OMFITexpressionsReturnNone
--------------------------
bool(x) -> bool

Returns True when the argument x is true, False otherwise.
The builtins True and False are the only two instances of the class bool.
The class bool is a subclass of the class int, and cannot be subclassed.

OMFITexpression
---------------
This class handles so called OMFIT `dynamic expressions`.

    If you generate dynamic expressions in a Python script, note that the relative location of the expression
    (root,parent,DEPENDENCIES,...) is evaluated with respect to where the expression is in the tree,
    not relative to where the script which generated the expression resides

    If you are using relative locations in your expression, things may not work if you have the same expression into
    two locations in the tree. A classic of this happening is if you do a memory copy of something (e.g. namelist) containing
    an expression to some other location in the tree. If this happens the results are unpredictable.

    :param expression: string containing python code to be dynamically evaluated every time an attribute of this object is accessed
    

OMFITiterableExpression
-----------------------

    Subclass of OMFITexpression used for iterable objects
    The distinction between iterable and not iterable expressions
    is used in case someone tests for iterability of an object
    

OMFITlazyLoad
-------------

    OMFIT class that imports xarray datasets with dynamic loading
    

relativeLocations
-----------------

    This function provides a dictionary references to some useful quantities with respect to the object specified in `location`.
    Note that the variables in the returned dictionary are the same ones that are available within the namespace of OMFIT scripts and expressions.

    :param location: location in the OMFIT tree

    :return: dictionary containing the following variables:

    * OMFITlocation : list of references to the tree items that compose the OMFIT-tree path

    * OMFITlocationName : list of path strings to the tree items that compose the OMFIT-tree path

    * parent : reference to the parent object

    * parentName : path string to the parent object

    * this : reference to the current object

    * thisName : path string to the current object

    * OMFITmodules : list of modules to the current module

    * OMFITmodulesName : list of string paths to the current module

    * MainSettings : reference to OMFIT['MainSettings']

    * MainScratch: reference to OMFIT['scratch']

    * scratch : reference to module scratch

    * scratchName : string path to module scratch

    * root : reference to this module

    * rootName : string path to this module

    * DEPENDENCIES variables defined within the module
    

absLocation
-----------

    This method translates relative location strings to absolute location strings in the OMFIT tree

    :param location: string (or list of strings) with relative/absolute location in the OMFIT tree

    :param base: tree object with respect to which the query is made

    :param base_is_relativeLocations_output: is the `base` parameter the output of the relativeLocations() function

    :return: absolute location string (or list of strings) in the OMFIT tree
    

isinstance
----------
Return whether an object is an instance of a class or of a subclass thereof.

A tuple, as in ``isinstance(x, (A, B, ...))``, may be given as the target to
check against. This is equivalent to ``isinstance(x, A) or isinstance(x, B)
or ...`` etc.

This function is modified to account for special behavior of some OMFIT classes, such as OMFITexpression.

type
----
N/A

hasattr
-------
N/A

shotBookmarks
-------------
N/A

OMFITshotBookmarks
------------------
N/A

OMFITmainSettings
-----------------
Contains system wide settings

OMFITtypes
----------
Built-in mutable sequence.

If no argument is given, the constructor creates a new empty list.
The argument must be an iterable if specified.

OMFITtypesStr
-------------
Built-in mutable sequence.

If no argument is given, the constructor creates a new empty list.
The argument must be an iterable if specified.

OMFITdictypes
-------------
Built-in mutable sequence.

If no argument is given, the constructor creates a new empty list.
The argument must be an iterable if specified.

OMFITdictypesStr
----------------
Built-in mutable sequence.

If no argument is given, the constructor creates a new empty list.
The argument must be an iterable if specified.

omfit_log
---------
N/A

ismodule
--------

    convenience function to check if an OMFITmodule is one of a given set of IDs

    :param module: module

    :param module_ids: list of module IDs to check for

    :return: True if the module ID matches one of the IDs in the module_ids list
    

diffTreeGUI
-----------

    Function used to compare two dictionary objects and manage their merge

    :param this: reference object (the one where data will be written to in case of merge)

    :param other: secondary object to compare to

    :param thisName: ['Original'] representation of reference object in the GUI

    :param otherName: ['Compared to'] representation of secondary object in the GUI

    :param resultName: ['Final result'] representation of result

    :param title: [None] GUI title

    :param diffSubModules: [True] do diff of sumbmodules or not. If `None` only compare module ID and its DEPENDENCIES.

    :param precision: [0.0] relative precision to which to compare objects

    :param description: [False] commit to be input by the user

    :param tellDescription: [False] show description or not

    :param deepcopyOther: [True] Whether to perform internally `other=copy.deepcopy(other)` to avoid `diffTreeGUI` to modify the original content

    :param skipClasses: () tuple containing classes to skip

    :param noloadClasses: () tuple containing classes to not load

    :param flatten: whether to flatten the data in nested dictionaries

    :param allow_merge: whether to allow merging of data

    :param always_show_GUI: whether to show GUIs even if there are no differences

    :param order: order of the keys matters

    :return: (switch,False/True,keys)

    * switch is a dictionary which lists all of the differences

    * False/True will be used to keep track of what the user wants to switch between dictionaries

    * keys is used to keep the keys of the merged dictionary in order
    

exportTreeGUI
-------------
N/A

diffViewer
----------

    Present a side by side visual comparison of two strings

    :param root: A tk master GUI
    

askDescription
--------------
N/A

all_pylab_imports
-----------------
dict() -> new empty dictionary
dict(mapping) -> new dictionary initialized from a mapping object's
    (key, value) pairs
dict(iterable) -> new dictionary initialized as if via:
    d = {}
    for k, v in iterable:
        d[k] = v
dict(**kwargs) -> new dictionary initialized with the name=value pairs
    in the keyword argument list.  For example:  dict(one=1, two=2)

evalExpr
--------

    Return the object that dynamic expressions return when evaluated
    This allows OMFITexpression('None') is None to work as one would expect.
    Epxressions that are invalid they will raise an OMFITexception when evaluated

    :param inv: input object

    :return:

        * If inv was a dynamic expression, returns the object that dynamic expressions return when evaluated

        * Else returns the input object