def normalize_lcdict(lcdict,<EOL>timecol='<STR_LIT>',<EOL>magcols='<STR_LIT:all>',<EOL>mingap=<NUM_LIT>,<EOL>normto='<STR_LIT>',<EOL>debugmode=False,<EOL>quiet=False):
<EOL>if '<STR_LIT>' in lcdict and len(lcdict['<STR_LIT>']) > <NUM_LIT:0>:<EOL><INDENT>if not quiet:<EOL><INDENT>LOGWARNING('<STR_LIT>')<EOL><DEDENT>return lcdict<EOL><DEDENT>if timecol in lcdict:<EOL><INDENT>times = lcdict[timecol]<EOL><DEDENT>elif '<STR_LIT>' in lcdict:<EOL><INDENT>times = lcdict['<STR_LIT>']<EOL><DEDENT>else:<EOL><INDENT>LOGERROR("<STR_LIT>" %<EOL>lcdict['<STR_LIT>'])<EOL>return lcdict<EOL><DEDENT>ngroups, timegroups = find_lc_timegroups(np.array(times),<EOL>mingap=mingap)<EOL>if '<STR_LIT>' in lcdict:<EOL><INDENT>apertures = sorted(lcdict['<STR_LIT>'].keys())<EOL><DEDENT>elif '<STR_LIT>' in lcdict and '<STR_LIT>' in lcdict['<STR_LIT>']:<EOL><INDENT>apertures = sorted(lcdict['<STR_LIT>']['<STR_LIT>'].keys())<EOL><DEDENT>aimcols = [('<STR_LIT>' % x) for x in apertures if ('<STR_LIT>' % x) in lcdict]<EOL>armcols = [('<STR_LIT>' % x) for x in apertures if ('<STR_LIT>' % x) in lcdict]<EOL>aepcols = [('<STR_LIT>' % x)for x in apertures if ('<STR_LIT>' % x) in lcdict]<EOL>atfcols = [('<STR_LIT>' % x) for x in apertures if ('<STR_LIT>' % x) in lcdict]<EOL>psimcols = [x for x in ['<STR_LIT>','<STR_LIT>','<STR_LIT>','<STR_LIT>'] if x in lcdict]<EOL>irmcols = [('<STR_LIT>' % x) for x in apertures if ('<STR_LIT>' % x) in lcdict]<EOL>iepcols = [('<STR_LIT>' % x) for x in apertures if ('<STR_LIT>' % x) in lcdict]<EOL>itfcols = [('<STR_LIT>' % x) for x in apertures if ('<STR_LIT>' % x) in lcdict]<EOL>if magcols == '<STR_LIT:all>':<EOL><INDENT>cols_to_normalize = (aimcols + armcols + aepcols + atfcols +<EOL>psimcols + irmcols + iepcols + itfcols)<EOL><DEDENT>elif magcols == '<STR_LIT>':<EOL><INDENT>cols_to_normalize = (irmcols + (['<STR_LIT>'] if '<STR_LIT>' in lcdict else []) +<EOL>irmcols)<EOL><DEDENT>elif magcols == '<STR_LIT>':<EOL><INDENT>cols_to_normalize = (aepcols + (['<STR_LIT>'] if '<STR_LIT>' in lcdict else []) +<EOL>iepcols)<EOL><DEDENT>elif magcols == '<STR_LIT>':<EOL><INDENT>cols_to_normalize = (atfcols + (['<STR_LIT>'] if '<STR_LIT>' in lcdict else []) +<EOL>itfcols)<EOL><DEDENT>elif magcols == '<STR_LIT>':<EOL><INDENT>cols_to_normalize = (aepcols + (['<STR_LIT>'] if '<STR_LIT>' in lcdict else []) +<EOL>iepcols + atfcols +<EOL>(['<STR_LIT>'] if '<STR_LIT>' in lcdict else []) +<EOL>itfcols)<EOL><DEDENT>else:<EOL><INDENT>cols_to_normalize = magcols.split('<STR_LIT:U+002C>')<EOL>cols_to_normalize = [x.strip() for x in cols_to_normalize]<EOL><DEDENT>colsnormalized = []<EOL>for col in cols_to_normalize:<EOL><INDENT>if col in lcdict:<EOL><INDENT>mags = lcdict[col]<EOL>mags = [(nan if x is None else x) for x in mags]<EOL>mags = np.array(mags)<EOL>colsnormalized.append(col)<EOL>finite_ind = np.isfinite(mags)<EOL>if any(finite_ind):<EOL><INDENT>global_mag_median = np.median(mags[finite_ind])<EOL>for tgind, tg in enumerate(timegroups):<EOL><INDENT>finite_ind = np.isfinite(mags[tg])<EOL>group_median = np.median((mags[tg])[finite_ind])<EOL>mags[tg] = mags[tg] - group_median<EOL>if debugmode:<EOL><INDENT>LOGDEBUG('<STR_LIT>'<EOL>'<STR_LIT>' %<EOL>(col, tgind,<EOL>len(mags[tg]),<EOL>len(finite_ind),<EOL>group_median))<EOL><DEDENT><DEDENT><DEDENT>else:<EOL><INDENT>LOGWARNING('<STR_LIT>' % col)<EOL>continue<EOL><DEDENT>if normto == '<STR_LIT>':<EOL><INDENT>mags = mags + global_mag_median<EOL><DEDENT>elif normto in ('<STR_LIT>', '<STR_LIT>', '<STR_LIT>',<EOL>'<STR_LIT>', '<STR_LIT>',<EOL>'<STR_LIT>', '<STR_LIT>', '<STR_LIT>'):<EOL><INDENT>if (normto in lcdict['<STR_LIT>'] and<EOL>lcdict['<STR_LIT>'][normto] is not None):<EOL><INDENT>mags = mags + lcdict['<STR_LIT>'][normto]<EOL><DEDENT>else:<EOL><INDENT>if not quiet:<EOL><INDENT>LOGWARNING('<STR_LIT>'<EOL>'<STR_LIT>' % normto)<EOL><DEDENT>normto = '<STR_LIT>'<EOL>mags = mags + global_mag_median<EOL><DEDENT><DEDENT>lcdict[col] = mags<EOL><DEDENT>else:<EOL><INDENT>if not quiet:<EOL><INDENT>LOGWARNING('<STR_LIT>' % col)<EOL><DEDENT>continue<EOL><DEDENT><DEDENT>lcnormcols = ('<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>') % (<EOL>repr(colsnormalized),<EOL>mingap,<EOL>normto<EOL>)<EOL>lcdict['<STR_LIT>'] = lcnormcols<EOL>return lcdict<EOL>
This normalizes magcols in `lcdict` using `timecol` to find timegroups.

    Parameters
    ----------

    lcdict : dict
        The input lcdict to process.

    timecol : str
        The key in the lcdict that is to be used to extract the time column.

    magcols : 'all' or list of str
        If this is 'all', all of the columns in the lcdict that are indicated to
        be magnitude measurement columns are normalized. If this is a list of
        str, must contain the keys of the lcdict specifying which magnitude
        columns will be normalized.

    mingap : float
        This defines how much the difference between consecutive measurements is
        allowed to be to consider them as parts of different timegroups. By
        default it is set to 4.0 days.

    normto : {'globalmedian', 'zero', 'jmag', 'hmag', 'kmag', 'bmag', 'vmag', 'sdssg', 'sdssr', 'sdssi'}
        This indicates which column will be the normalization target. If this is
        'globalmedian', the normalization will be to the global median of each
        LC column. If this is 'zero', will normalize to 0.0 for each LC
        column. Otherwise, will normalize to the value of one of the other keys
        in the lcdict['objectinfo'][magkey], meaning the normalization will be
        to some form of catalog magnitude.

    debugmode : bool
        If True, will indicate progress as time-groups are found and processed.

    quiet : bool
        If True, will not emit any messages when processing.

    Returns
    -------

    dict
        Returns the lcdict with the magnitude measurements normalized as
        specified. The normalization happens IN PLACE.