def _reform_templatelc_for_tfa(task):
try:<EOL><INDENT>(lcfile, lcformat, lcformatdir,<EOL>tcol, mcol, ecol,<EOL>timebase, interpolate_type, sigclip) = task<EOL>try:<EOL><INDENT>formatinfo = get_lcformat(lcformat,<EOL>use_lcformat_dir=lcformatdir)<EOL>if formatinfo:<EOL><INDENT>(dfileglob, readerfunc,<EOL>dtimecols, dmagcols, derrcols,<EOL>magsarefluxes, normfunc) = formatinfo<EOL><DEDENT>else:<EOL><INDENT>LOGERROR("<STR_LIT>")<EOL>return None<EOL><DEDENT><DEDENT>except Exception as e:<EOL><INDENT>LOGEXCEPTION("<STR_LIT>")<EOL>return None<EOL><DEDENT>lcdict = readerfunc(lcfile)<EOL>if ( (isinstance(lcdict, (list, tuple))) and<EOL>(isinstance(lcdict[<NUM_LIT:0>], dict)) ):<EOL><INDENT>lcdict = lcdict[<NUM_LIT:0>]<EOL><DEDENT>outdict = {}<EOL>if '<STR_LIT:.>' in tcol:<EOL><INDENT>tcolget = tcol.split('<STR_LIT:.>')<EOL><DEDENT>else:<EOL><INDENT>tcolget = [tcol]<EOL><DEDENT>times = _dict_get(lcdict, tcolget)<EOL>if '<STR_LIT:.>' in mcol:<EOL><INDENT>mcolget = mcol.split('<STR_LIT:.>')<EOL><DEDENT>else:<EOL><INDENT>mcolget = [mcol]<EOL><DEDENT>mags = _dict_get(lcdict, mcolget)<EOL>if '<STR_LIT:.>' in ecol:<EOL><INDENT>ecolget = ecol.split('<STR_LIT:.>')<EOL><DEDENT>else:<EOL><INDENT>ecolget = [ecol]<EOL><DEDENT>errs = _dict_get(lcdict, ecolget)<EOL>if normfunc is None:<EOL><INDENT>ntimes, nmags = normalize_magseries(<EOL>times, mags,<EOL>magsarefluxes=magsarefluxes<EOL>)<EOL><DEDENT>times, mags, errs = ntimes, nmags, errs<EOL>stimes, smags, serrs = sigclip_magseries(times,<EOL>mags,<EOL>errs,<EOL>sigclip=sigclip)<EOL>mags_interpolator = spi.interp1d(stimes, smags,<EOL>kind=interpolate_type,<EOL>fill_value='<STR_LIT>')<EOL>errs_interpolator = spi.interp1d(stimes, serrs,<EOL>kind=interpolate_type,<EOL>fill_value='<STR_LIT>')<EOL>interpolated_mags = mags_interpolator(timebase)<EOL>interpolated_errs = errs_interpolator(timebase)<EOL>magmedian = np.median(interpolated_mags)<EOL>renormed_mags = interpolated_mags - magmedian<EOL>outdict = {'<STR_LIT>':renormed_mags,<EOL>'<STR_LIT>':interpolated_errs,<EOL>'<STR_LIT>':interpolated_mags}<EOL>return outdict<EOL><DEDENT>except Exception as e:<EOL><INDENT>LOGEXCEPTION('<STR_LIT>' % repr(task))<EOL>return None<EOL><DEDENT>
This is a parallel worker that reforms light curves for TFA.

task[0] = lcfile
task[1] = lcformat
task[2] = lcformatdir
task[3] = timecol
task[4] = magcol
task[5] = errcol
task[6] = timebase
task[7] = interpolate_type
task[8] = sigclip