def get_lcformat(formatkey, use_lcformat_dir=None):
if isinstance(use_lcformat_dir, str):<EOL><INDENT>lcformat_jsonpath = os.path.join(<EOL>use_lcformat_dir,<EOL>'<STR_LIT>' % formatkey<EOL>)<EOL>if not os.path.exists(lcformat_jsonpath):<EOL><INDENT>lcformat_jsonpath = os.path.join(<EOL>os.path.expanduser('<STR_LIT>'),<EOL>'<STR_LIT>' % formatkey<EOL>)<EOL>if not os.path.exists(lcformat_jsonpath):<EOL><INDENT>install_path = os.path.dirname(__file__)<EOL>install_path = os.path.abspath(<EOL>os.path.join(install_path, '<STR_LIT:..>', '<STR_LIT:data>','<STR_LIT>')<EOL>)<EOL>lcformat_jsonpath = os.path.join(<EOL>install_path,<EOL>'<STR_LIT>' % formatkey<EOL>)<EOL>if not os.path.exists(lcformat_jsonpath):<EOL><INDENT>LOGERROR('<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>'<EOL>% formatkey)<EOL>return None<EOL><DEDENT><DEDENT><DEDENT><DEDENT>else:<EOL><INDENT>lcformat_jsonpath = os.path.join(<EOL>os.path.expanduser('<STR_LIT>'),<EOL>'<STR_LIT>' % formatkey<EOL>)<EOL>if not os.path.exists(lcformat_jsonpath):<EOL><INDENT>install_path = os.path.dirname(__file__)<EOL>install_path = os.path.abspath(<EOL>os.path.join(install_path, '<STR_LIT:..>', '<STR_LIT:data>','<STR_LIT>')<EOL>)<EOL>lcformat_jsonpath = os.path.join(<EOL>install_path,<EOL>'<STR_LIT>' % formatkey<EOL>)<EOL>if not os.path.exists(lcformat_jsonpath):<EOL><INDENT>LOGERROR('<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>'<EOL>% formatkey)<EOL>return None<EOL><DEDENT><DEDENT><DEDENT>with open(lcformat_jsonpath) as infd:<EOL><INDENT>lcformatdict = json.load(infd)<EOL><DEDENT>readerfunc_module = lcformatdict['<STR_LIT>']<EOL>readerfunc = lcformatdict['<STR_LIT>']<EOL>readerfunc_kwargs = lcformatdict['<STR_LIT>']<EOL>normfunc_module = lcformatdict['<STR_LIT>']<EOL>normfunc = lcformatdict['<STR_LIT>']<EOL>normfunc_kwargs = lcformatdict['<STR_LIT>']<EOL>fileglob = lcformatdict['<STR_LIT>']<EOL>timecols = lcformatdict['<STR_LIT>']<EOL>magcols = lcformatdict['<STR_LIT>']<EOL>errcols = lcformatdict['<STR_LIT>']<EOL>magsarefluxes = lcformatdict['<STR_LIT>']<EOL>readermodule = _check_extmodule(readerfunc_module, formatkey)<EOL>if not readermodule:<EOL><INDENT>LOGERROR("<STR_LIT>"<EOL>"<STR_LIT>" %<EOL>(readerfunc_module, formatkey))<EOL>return None<EOL><DEDENT>try:<EOL><INDENT>readerfunc_in = getattr(readermodule, readerfunc)<EOL><DEDENT>except AttributeError:<EOL><INDENT>LOGEXCEPTION('<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>'<EOL>% (formatkey, readerfunc_module, readerfunc))<EOL>raise<EOL><DEDENT>if normfunc_module:<EOL><INDENT>normmodule = _check_extmodule(normfunc_module, formatkey)<EOL>if not normmodule:<EOL><INDENT>LOGERROR("<STR_LIT>"<EOL>"<STR_LIT>" %<EOL>(normfunc_module, formatkey))<EOL>return None<EOL><DEDENT><DEDENT>else:<EOL><INDENT>normmodule = None<EOL><DEDENT>if normfunc_module and normfunc:<EOL><INDENT>try:<EOL><INDENT>normfunc_in = getattr(normmodule, normfunc)<EOL><DEDENT>except AttributeError:<EOL><INDENT>LOGEXCEPTION('<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>'<EOL>% (formatkey, normfunc_module, normfunc))<EOL>raise<EOL><DEDENT><DEDENT>else:<EOL><INDENT>normfunc_in = None<EOL><DEDENT>if isinstance(readerfunc_kwargs, dict):<EOL><INDENT>readerfunc_in = partial(readerfunc_in, **readerfunc_kwargs)<EOL><DEDENT>if normfunc_in is not None:<EOL><INDENT>if isinstance(normfunc_kwargs, dict):<EOL><INDENT>normfunc_in = partial(normfunc_in, **normfunc_kwargs)<EOL><DEDENT><DEDENT>returntuple = (<EOL>fileglob,<EOL>readerfunc_in,<EOL>timecols,<EOL>magcols,<EOL>errcols,<EOL>magsarefluxes,<EOL>normfunc_in,<EOL>)<EOL>return returntuple<EOL>
This loads an LC format description from a previously-saved JSON file.

    Parameters
    ----------

    formatkey : str
        The key used to refer to the LC format. This is part of the JSON file's
        name, e.g. the format key 'hat-csv' maps to the format JSON file:
        '<astrobase install path>/data/lcformats/hat-csv.json'.

    use_lcformat_dir : str or None
        If provided, must be the path to a directory that contains the
        corresponding lcformat JSON file for `formatkey`. If this is None, this
        function will look for lcformat JSON files corresponding to the given
        `formatkey`:

        - first, in the directory specified in this kwarg,
        - if not found there, in the home directory: ~/.astrobase/lcformat-jsons
        - if not found there, in: <astrobase install path>/data/lcformats

    Returns
    -------

    tuple
        A tuple of the following form is returned::

            (fileglob       : the file glob of the associated LC files,
             readerfunc_in  : the imported Python function for reading LCs,
             timecols       : list of time col keys to get from the lcdict,
             magcols        : list of mag col keys to get from the lcdict ,
             errcols        : list of err col keys to get from the lcdict,
             magsarefluxes  : True if the measurements are fluxes not mags,
             normfunc_in    : the imported Python function for normalizing LCs)

        All `astrobase.lcproc` functions can then use this tuple to dynamically
        import your LC reader and normalization functions to work with your LC
        format transparently.