@gen.coroutine<EOL><INDENT>def get(self, cpfile):<DEDENT>
if cpfile:<EOL><INDENT>self.cpfile = (<EOL>xhtml_escape(base64.b64decode(url_unescape(cpfile)))<EOL>)<EOL>if self.cpfile in self.currentproject['<STR_LIT>']:<EOL><INDENT>cpfpath = os.path.join(<EOL>os.path.abspath(os.path.dirname(self.cplistfile)),<EOL>self.cpfile<EOL>)<EOL>if not os.path.exists(cpfpath):<EOL><INDENT>msg = "<STR_LIT>" % cpfpath<EOL>LOGGER.error(msg)<EOL>resultdict = {'<STR_LIT:status>':'<STR_LIT:error>',<EOL>'<STR_LIT:message>':msg,<EOL>'<STR_LIT>':self.readonly,<EOL>'<STR_LIT:result>':None}<EOL>self.write(resultdict)<EOL>raise tornado.web.Finish()<EOL><DEDENT>forcereload = self.get_argument('<STR_LIT>',False)<EOL>if forcereload and xhtml_escape(forcereload):<EOL><INDENT>forcereload = True if forcereload == '<STR_LIT:true>' else False<EOL><DEDENT>cpobjectid = self.get_argument('<STR_LIT>',None)<EOL>lctool = self.get_argument('<STR_LIT>', None)<EOL>resultdict = {'<STR_LIT:status>':None,<EOL>'<STR_LIT:message>':None,<EOL>'<STR_LIT>':self.readonly,<EOL>'<STR_LIT:result>':None}<EOL>if lctool:<EOL><INDENT>lctool = xhtml_escape(lctool)<EOL>lctoolargs = []<EOL>lctoolkwargs = {}<EOL>if lctool in CPTOOLMAP:<EOL><INDENT>try:<EOL><INDENT>for xkwarg, xkwargtype, xkwargdef in zip(<EOL>CPTOOLMAP[lctool]['<STR_LIT>'],<EOL>CPTOOLMAP[lctool]['<STR_LIT>'],<EOL>CPTOOLMAP[lctool]['<STR_LIT>']<EOL>):<EOL><INDENT>if xkwargtype is list:<EOL><INDENT>wbkwarg = self.get_arguments(xkwarg)<EOL>if len(wbkwarg) > <NUM_LIT:0>:<EOL><INDENT>wbkwarg = [url_unescape(xhtml_escape(x))<EOL>for x in wbkwarg]<EOL><DEDENT>else:<EOL><INDENT>wbkwarg = None<EOL><DEDENT><DEDENT>else:<EOL><INDENT>wbkwarg = self.get_argument(xkwarg, None)<EOL>if wbkwarg is not None:<EOL><INDENT>wbkwarg = url_unescape(<EOL>xhtml_escape(wbkwarg)<EOL>)<EOL><DEDENT><DEDENT>LOGGER.info('<STR_LIT>' %<EOL>(xkwarg, repr(wbkwarg)))<EOL>if wbkwarg is None:<EOL><INDENT>wbkwarg = xkwargdef<EOL><DEDENT>else:<EOL><INDENT>if xkwargtype is list:<EOL><INDENT>wbkwarg = [float(x) for x in wbkwarg]<EOL><DEDENT>elif xkwargtype is bool:<EOL><INDENT>if wbkwarg == '<STR_LIT:false>':<EOL><INDENT>wbkwarg = False<EOL><DEDENT>elif wbkwarg == '<STR_LIT:true>':<EOL><INDENT>wbkwarg = True<EOL><DEDENT>else:<EOL><INDENT>wbkwarg = xkwargdef<EOL><DEDENT><DEDENT>else:<EOL><INDENT>wbkwarg = xkwargtype(wbkwarg)<EOL><DEDENT><DEDENT>if xkwarg.endswith('<STR_LIT>'):<EOL><INDENT>xkwarg = xkwarg.rstrip('<STR_LIT>')<EOL><DEDENT>lctoolkwargs.update({xkwarg:wbkwarg})<EOL><DEDENT><DEDENT>except Exception as e:<EOL><INDENT>LOGGER.exception('<STR_LIT>'<EOL>'<STR_LIT>' %<EOL>(lctool, xkwarg))<EOL>resultdict['<STR_LIT:status>'] = '<STR_LIT:error>'<EOL>resultdict['<STR_LIT:message>'] = (<EOL>'<STR_LIT>'<EOL>'<STR_LIT>' %<EOL>(lctool, xkwarg)<EOL>)<EOL>resultdict['<STR_LIT:result>'] = {'<STR_LIT>':cpobjectid}<EOL>self.write(resultdict)<EOL>raise tornado.web.Finish()<EOL><DEDENT><DEDENT>else:<EOL><INDENT>LOGGER.error('<STR_LIT>' % lctool)<EOL>resultdict['<STR_LIT:status>'] = '<STR_LIT:error>'<EOL>resultdict['<STR_LIT:message>'] = (<EOL>'<STR_LIT>' % lctool<EOL>)<EOL>resultdict['<STR_LIT:result>'] = {'<STR_LIT>':cpobjectid}<EOL>self.write(resultdict)<EOL>raise tornado.web.Finish()<EOL><DEDENT><DEDENT>else:<EOL><INDENT>LOGGER.error('<STR_LIT>')<EOL>resultdict['<STR_LIT:status>'] = '<STR_LIT:error>'<EOL>resultdict['<STR_LIT:message>'] = (<EOL>'<STR_LIT>'<EOL>)<EOL>resultdict['<STR_LIT:result>'] = {'<STR_LIT>':cpobjectid}<EOL>self.write(resultdict)<EOL>raise tornado.web.Finish()<EOL><DEDENT>LOGGER.info('<STR_LIT>' % cpfpath)<EOL>cpdict = yield self.executor.submit(<EOL>_read_checkplot_picklefile, cpfpath<EOL>)<EOL>tempfpath = cpfpath + '<STR_LIT>'<EOL>if os.path.exists(tempfpath):<EOL><INDENT>tempcpdict = yield self.executor.submit(<EOL>_read_checkplot_picklefile, tempfpath<EOL>)<EOL><DEDENT>else:<EOL><INDENT>tempcpdict = {<EOL>'<STR_LIT>':cpdict['<STR_LIT>'],<EOL>'<STR_LIT>':{<EOL>'<STR_LIT>':cpdict['<STR_LIT>']['<STR_LIT>'],<EOL>'<STR_LIT>':cpdict['<STR_LIT>']['<STR_LIT>'],<EOL>'<STR_LIT>':cpdict['<STR_LIT>']['<STR_LIT>'],<EOL>}<EOL>}<EOL><DEDENT>if not forcereload:<EOL><INDENT>cptimes, cpmags, cperrs = (<EOL>tempcpdict['<STR_LIT>']['<STR_LIT>'],<EOL>tempcpdict['<STR_LIT>']['<STR_LIT>'],<EOL>tempcpdict['<STR_LIT>']['<STR_LIT>'],<EOL>)<EOL>LOGGER.info('<STR_LIT>')<EOL><DEDENT>else:<EOL><INDENT>cptimes, cpmags, cperrs = (cpdict['<STR_LIT>']['<STR_LIT>'],<EOL>cpdict['<STR_LIT>']['<STR_LIT>'],<EOL>cpdict['<STR_LIT>']['<STR_LIT>'])<EOL>LOGGER.info('<STR_LIT>')<EOL><DEDENT>for xarg, xargtype in zip(CPTOOLMAP[lctool]['<STR_LIT:args>'],<EOL>CPTOOLMAP[lctool]['<STR_LIT>']):<EOL><INDENT>if xarg is None:<EOL><INDENT>lctoolargs.append(None)<EOL><DEDENT>elif xarg == '<STR_LIT>':<EOL><INDENT>lctoolargs.append(cptimes)<EOL><DEDENT>elif xarg == '<STR_LIT>':<EOL><INDENT>lctoolargs.append(cpmags)<EOL><DEDENT>elif xarg == '<STR_LIT>':<EOL><INDENT>lctoolargs.append(cperrs)<EOL><DEDENT>else:<EOL><INDENT>try:<EOL><INDENT>if xargtype is list:<EOL><INDENT>wbarg = self.get_arguments(xarg)<EOL><DEDENT>else:<EOL><INDENT>wbarg = url_unescape(<EOL>xhtml_escape(<EOL>self.get_argument(xarg, None)<EOL>)<EOL>)<EOL><DEDENT>if xargtype is list:<EOL><INDENT>wbarg = [float(x) for x in wbarg]<EOL><DEDENT>elif xargtype is float and xarg == '<STR_LIT>':<EOL><INDENT>try:<EOL><INDENT>wbarg = xargtype(wbarg)<EOL><DEDENT>except Exception as e:<EOL><INDENT>wbarg = None<EOL><DEDENT><DEDENT>else:<EOL><INDENT>wbarg = xargtype(wbarg)<EOL><DEDENT>lctoolargs.append(wbarg)<EOL><DEDENT>except Exception as e:<EOL><INDENT>LOGGER.exception('<STR_LIT>'<EOL>'<STR_LIT>' %<EOL>(lctool, xarg))<EOL>resultdict['<STR_LIT:status>'] = '<STR_LIT:error>'<EOL>resultdict['<STR_LIT:message>'] = (<EOL>'<STR_LIT>'<EOL>'<STR_LIT>' %<EOL>(lctool, xarg)<EOL>)<EOL>resultdict['<STR_LIT:result>'] = {'<STR_LIT>':cpobjectid}<EOL>self.write(resultdict)<EOL>raise tornado.web.Finish()<EOL><DEDENT><DEDENT><DEDENT>LOGGER.info(lctool)<EOL>LOGGER.info(lctoolargs)<EOL>LOGGER.info(lctoolkwargs)<EOL>resloc = CPTOOLMAP[lctool]['<STR_LIT>']<EOL>objectid = cpdict['<STR_LIT>']<EOL>if lctool in ('<STR_LIT>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT>'):<EOL><INDENT>lspmethod = resloc[<NUM_LIT:0>]<EOL>if (lspmethod in tempcpdict and<EOL>isinstance(tempcpdict[lspmethod], dict) and<EOL>(not forcereload)):<EOL><INDENT>bestperiod = (<EOL>tempcpdict[lspmethod]['<STR_LIT>']<EOL>)<EOL>nbestperiods = (<EOL>tempcpdict[lspmethod]['<STR_LIT>']<EOL>)<EOL>nbestlspvals = (<EOL>tempcpdict[lspmethod]['<STR_LIT>']<EOL>)<EOL>periodogram = (<EOL>tempcpdict[lspmethod]['<STR_LIT>']<EOL>)<EOL>phasedlc0plot = (<EOL>tempcpdict[lspmethod][<NUM_LIT:0>]['<STR_LIT>']<EOL>)<EOL>phasedlc0period = float(<EOL>tempcpdict[lspmethod][<NUM_LIT:0>]['<STR_LIT>']<EOL>)<EOL>phasedlc0epoch = float(<EOL>tempcpdict[lspmethod][<NUM_LIT:0>]['<STR_LIT>']<EOL>)<EOL>LOGGER.warning(<EOL>'<STR_LIT>'<EOL>'<STR_LIT>' %<EOL>(lctool, tempfpath)<EOL>)<EOL>resultdict['<STR_LIT:status>'] = '<STR_LIT>'<EOL>resultdict['<STR_LIT:message>'] = (<EOL>'<STR_LIT>'<EOL>'<STR_LIT>' %<EOL>lctool<EOL>)<EOL>resultdict['<STR_LIT:result>'] = {<EOL>'<STR_LIT>':objectid,<EOL>lspmethod:{<EOL>'<STR_LIT>':nbestperiods,<EOL>'<STR_LIT>':periodogram,<EOL>'<STR_LIT>':bestperiod,<EOL>'<STR_LIT>':nbestlspvals,<EOL>'<STR_LIT>':{<EOL>'<STR_LIT>':phasedlc0plot,<EOL>'<STR_LIT>':phasedlc0period,<EOL>'<STR_LIT>':phasedlc0epoch,<EOL>}<EOL>}<EOL>}<EOL>self.write(resultdict)<EOL>self.finish()<EOL><DEDENT>else:<EOL><INDENT>if lctoolkwargs['<STR_LIT>'] is not None:<EOL><INDENT>wtimes, wmags, werrs = lcmath.sigclip_magseries(<EOL>lctoolargs[<NUM_LIT:0>],<EOL>lctoolargs[<NUM_LIT:1>],<EOL>lctoolargs[<NUM_LIT:2>],<EOL>sigclip=lctoolkwargs['<STR_LIT>'],<EOL>magsarefluxes=lctoolkwargs['<STR_LIT>']<EOL>)<EOL>lctoolargs[<NUM_LIT:0>] = wtimes<EOL>lctoolargs[<NUM_LIT:1>] = wmags<EOL>lctoolargs[<NUM_LIT:2>] = werrs<EOL><DEDENT>if lctoolkwargs['<STR_LIT>']:<EOL><INDENT>wtimes, wmags, werrs = (lctoolargs[<NUM_LIT:0>],<EOL>lctoolargs[<NUM_LIT:1>],<EOL>lctoolargs[<NUM_LIT:2>])<EOL>filtermasks = [<EOL>np.full_like(wtimes, False, dtype=np.bool_)<EOL>]<EOL>filterstr = lctoolkwargs['<STR_LIT>']<EOL>filters = filterstr.split('<STR_LIT:U+002C>')<EOL>filters = [<EOL>x.strip().lstrip('<STR_LIT:(>').rstrip('<STR_LIT:)>').strip()<EOL>for x in filters<EOL>]<EOL>for filt in filters:<EOL><INDENT>try:<EOL><INDENT>thisfilt = filt.split('<STR_LIT::>')<EOL>if len(thisfilt) == <NUM_LIT:2>:<EOL><INDENT>filt_lo = float(thisfilt[<NUM_LIT:0>])<EOL>filt_hi = float(thisfilt[<NUM_LIT:1>])<EOL>filtermasks.append(<EOL>((wtimes -<EOL>cptimes.min()) < filt_hi) &<EOL>((wtimes -<EOL>cptimes.min()) > filt_lo)<EOL>)<EOL><DEDENT>elif (len(thisfilt) == <NUM_LIT:3> and<EOL>thisfilt[<NUM_LIT:0>].strip() == '<STR_LIT>'):<EOL><INDENT>filt_lo = float(thisfilt[<NUM_LIT:1>])<EOL>filt_hi = float(thisfilt[<NUM_LIT:2>])<EOL>filtermasks.append(np.logical_not(<EOL>(((wtimes -<EOL>cptimes.min()) < filt_hi) &<EOL>((wtimes -<EOL>cptimes.min()) > filt_lo))<EOL>))<EOL><DEDENT>else:<EOL><INDENT>continue<EOL><DEDENT><DEDENT>except Exception as e:<EOL><INDENT>continue<EOL><DEDENT><DEDENT>if len(filtermasks) > <NUM_LIT:0>:<EOL><INDENT>filterind = np.column_stack(filtermasks)<EOL>filterind = np.any(filterind, axis=<NUM_LIT:1>)<EOL>lctoolargs[<NUM_LIT:0>] = wtimes[filterind]<EOL>lctoolargs[<NUM_LIT:1>] = wmags[filterind]<EOL>lctoolargs[<NUM_LIT:2>] = werrs[filterind]<EOL><DEDENT><DEDENT>if lctoolkwargs['<STR_LIT>']:<EOL><INDENT>wtimes, wmags, werrs = (lctoolargs[<NUM_LIT:0>],<EOL>lctoolargs[<NUM_LIT:1>],<EOL>lctoolargs[<NUM_LIT:2>])<EOL>filtermasks = [<EOL>np.full_like(wtimes, False, dtype=np.bool_)<EOL>]<EOL>filterstr = lctoolkwargs['<STR_LIT>']<EOL>filters = filterstr.split('<STR_LIT:U+002C>')<EOL>filters = [<EOL>x.strip().strip()<EOL>for x in filters<EOL>]<EOL>for filt in filters:<EOL><INDENT>try:<EOL><INDENT>thisfilt = filt.split('<STR_LIT::>')<EOL>if len(thisfilt) == <NUM_LIT:2>:<EOL><INDENT>filt_lo = float(thisfilt[<NUM_LIT:0>])<EOL>filt_hi = float(thisfilt[<NUM_LIT:1>])<EOL>filtermasks.append(<EOL>(wmags < filt_hi) &<EOL>(wmags > filt_lo)<EOL>)<EOL><DEDENT>elif (len(thisfilt) == <NUM_LIT:3> and<EOL>thisfilt[<NUM_LIT:0>].strip() == '<STR_LIT>'):<EOL><INDENT>filt_lo = float(thisfilt[<NUM_LIT:1>])<EOL>filt_hi = float(thisfilt[<NUM_LIT:2>])<EOL>filtermasks.append(np.logical_not(<EOL>((wmags < filt_hi) &<EOL>(wmags > filt_lo))<EOL>))<EOL><DEDENT>else:<EOL><INDENT>continue<EOL><DEDENT><DEDENT>except Exception as e:<EOL><INDENT>continue<EOL><DEDENT><DEDENT>if len(filtermasks) > <NUM_LIT:0>:<EOL><INDENT>filterind = np.column_stack(filtermasks)<EOL>filterind = np.any(filterind, axis=<NUM_LIT:1>)<EOL>lctoolargs[<NUM_LIT:0>] = wtimes[filterind]<EOL>lctoolargs[<NUM_LIT:1>] = wmags[filterind]<EOL>lctoolargs[<NUM_LIT:2>] = werrs[filterind]<EOL><DEDENT><DEDENT>del lctoolkwargs['<STR_LIT>']<EOL>del lctoolkwargs['<STR_LIT>']<EOL>lctoolfunction = CPTOOLMAP[lctool]['<STR_LIT>']<EOL>funcresults = yield self.executor.submit(<EOL>lctoolfunction,<EOL>*lctoolargs,<EOL>**lctoolkwargs<EOL>)<EOL>nbestperiods = funcresults['<STR_LIT>']<EOL>nbestlspvals = funcresults['<STR_LIT>']<EOL>bestperiod = funcresults['<STR_LIT>']<EOL>pgramres = yield self.executor.submit(<EOL>_pkl_periodogram,<EOL>funcresults,<EOL>)<EOL>phasedlcargs0 = (None,<EOL>lspmethod,<EOL>-<NUM_LIT:1>,<EOL>lctoolargs[<NUM_LIT:0>],<EOL>lctoolargs[<NUM_LIT:1>],<EOL>lctoolargs[<NUM_LIT:2>],<EOL>nbestperiods[<NUM_LIT:0>],<EOL>'<STR_LIT>')<EOL>if len(nbestperiods) > <NUM_LIT:1>:<EOL><INDENT>phasedlcargs1 = (None,<EOL>lspmethod,<EOL>-<NUM_LIT:1>,<EOL>lctoolargs[<NUM_LIT:0>],<EOL>lctoolargs[<NUM_LIT:1>],<EOL>lctoolargs[<NUM_LIT:2>],<EOL>nbestperiods[<NUM_LIT:1>],<EOL>'<STR_LIT>')<EOL><DEDENT>else:<EOL><INDENT>phasedlcargs1 = None<EOL><DEDENT>if len(nbestperiods) > <NUM_LIT:2>:<EOL><INDENT>phasedlcargs2 = (None,<EOL>lspmethod,<EOL>-<NUM_LIT:1>,<EOL>lctoolargs[<NUM_LIT:0>],<EOL>lctoolargs[<NUM_LIT:1>],<EOL>lctoolargs[<NUM_LIT:2>],<EOL>nbestperiods[<NUM_LIT:2>],<EOL>'<STR_LIT>')<EOL><DEDENT>else:<EOL><INDENT>phasedlcargs2 = None<EOL><DEDENT>phasedlckwargs = {<EOL>'<STR_LIT>':False,<EOL>'<STR_LIT>':lctoolkwargs['<STR_LIT>'],<EOL>'<STR_LIT>':'<STR_LIT>',<EOL>}<EOL>phasedlc0 = yield self.executor.submit(<EOL>_pkl_phased_magseries_plot,<EOL>*phasedlcargs0,<EOL>**phasedlckwargs<EOL>)<EOL>if phasedlcargs1 is not None:<EOL><INDENT>phasedlc1 = yield self.executor.submit(<EOL>_pkl_phased_magseries_plot,<EOL>*phasedlcargs1,<EOL>**phasedlckwargs<EOL>)<EOL><DEDENT>else:<EOL><INDENT>phasedlc1 = None<EOL><DEDENT>if phasedlcargs2 is not None:<EOL><INDENT>phasedlc2 = yield self.executor.submit(<EOL>_pkl_phased_magseries_plot,<EOL>*phasedlcargs2,<EOL>**phasedlckwargs<EOL>)<EOL><DEDENT>else:<EOL><INDENT>phasedlc2 = None<EOL><DEDENT>if not self.readonly:<EOL><INDENT>tempcpdict[lspmethod] = {<EOL>'<STR_LIT>':funcresults['<STR_LIT>'],<EOL>'<STR_LIT>':funcresults['<STR_LIT>'],<EOL>'<STR_LIT>':funcresults['<STR_LIT>'],<EOL>'<STR_LIT>':funcresults['<STR_LIT>'],<EOL>'<STR_LIT>':funcresults['<STR_LIT>'],<EOL>'<STR_LIT>':(<EOL>pgramres[lspmethod]['<STR_LIT>']<EOL>),<EOL><NUM_LIT:0>:phasedlc0,<EOL>}<EOL>if phasedlc1 is not None:<EOL><INDENT>tempcpdict[lspmethod][<NUM_LIT:1>] = phasedlc1<EOL><DEDENT>if phasedlc2 is not None:<EOL><INDENT>tempcpdict[lspmethod][<NUM_LIT:2>] = phasedlc2<EOL><DEDENT>savekwargs = {<EOL>'<STR_LIT>':tempfpath,<EOL>'<STR_LIT>':pickle.HIGHEST_PROTOCOL<EOL>}<EOL>savedcpf = yield self.executor.submit(<EOL>_write_checkplot_picklefile,<EOL>tempcpdict,<EOL>**savekwargs<EOL>)<EOL>LOGGER.info(<EOL>'<STR_LIT>'<EOL>'<STR_LIT>' %<EOL>(lctool, savedcpf)<EOL>)<EOL><DEDENT>else:<EOL><INDENT>LOGGER.warning(<EOL>'<STR_LIT>'<EOL>'<STR_LIT>'<EOL>)<EOL><DEDENT>periodogram = pgramres[lspmethod]['<STR_LIT>']<EOL>phasedlc0plot = phasedlc0['<STR_LIT>']<EOL>phasedlc0period = float(phasedlc0['<STR_LIT>'])<EOL>phasedlc0epoch = float(phasedlc0['<STR_LIT>'])<EOL>if phasedlc1 is not None:<EOL><INDENT>phasedlc1plot = phasedlc1['<STR_LIT>']<EOL>phasedlc1period = float(phasedlc1['<STR_LIT>'])<EOL>phasedlc1epoch = float(phasedlc1['<STR_LIT>'])<EOL><DEDENT>if phasedlc2 is not None:<EOL><INDENT>phasedlc2plot = phasedlc2['<STR_LIT>']<EOL>phasedlc2period = float(phasedlc2['<STR_LIT>'])<EOL>phasedlc2epoch = float(phasedlc2['<STR_LIT>'])<EOL><DEDENT>resultdict['<STR_LIT:status>'] = '<STR_LIT:success>'<EOL>resultdict['<STR_LIT:message>'] = (<EOL>'<STR_LIT>' %<EOL>lctool<EOL>)<EOL>resultdict['<STR_LIT:result>'] = {<EOL>'<STR_LIT>':objectid,<EOL>lspmethod:{<EOL>'<STR_LIT>':nbestperiods,<EOL>'<STR_LIT>':nbestlspvals,<EOL>'<STR_LIT>':periodogram,<EOL>'<STR_LIT>':bestperiod,<EOL>'<STR_LIT>':{<EOL>'<STR_LIT>':phasedlc0plot,<EOL>'<STR_LIT>':phasedlc0period,<EOL>'<STR_LIT>':phasedlc0epoch,<EOL>},<EOL>}<EOL>}<EOL>if phasedlc1 is not None:<EOL><INDENT>resultdict['<STR_LIT:result>'][lspmethod]['<STR_LIT>'] = {<EOL>'<STR_LIT>':phasedlc1plot,<EOL>'<STR_LIT>':phasedlc1period,<EOL>'<STR_LIT>':phasedlc1epoch,<EOL>}<EOL><DEDENT>if phasedlc2 is not None:<EOL><INDENT>resultdict['<STR_LIT:result>'][lspmethod]['<STR_LIT>'] = {<EOL>'<STR_LIT>':phasedlc2plot,<EOL>'<STR_LIT>':phasedlc2period,<EOL>'<STR_LIT>':phasedlc2epoch,<EOL>}<EOL><DEDENT>self.write(resultdict)<EOL>self.finish()<EOL><DEDENT><DEDENT>elif lctool == '<STR_LIT>':<EOL><INDENT>lspmethod = lctoolargs[<NUM_LIT:1>]<EOL>periodind = lctoolargs[<NUM_LIT:2>]<EOL>if (not forcereload and lspmethod in tempcpdict and<EOL>isinstance(tempcpdict[lspmethod], dict) and<EOL>periodind in tempcpdict[lspmethod] and<EOL>isinstance(tempcpdict[lspmethod][periodind], dict)):<EOL><INDENT>phasedlc = tempcpdict[lspmethod][periodind]<EOL>LOGGER.warning(<EOL>'<STR_LIT>'<EOL>'<STR_LIT>' %<EOL>(lctool, tempfpath)<EOL>)<EOL>resultdict['<STR_LIT:status>'] = '<STR_LIT>'<EOL>resultdict['<STR_LIT:message>'] = (<EOL>'<STR_LIT>'<EOL>'<STR_LIT>' %<EOL>lctool<EOL>)<EOL>retkey = '<STR_LIT>' % periodind<EOL>resultdict['<STR_LIT:result>'] = {<EOL>'<STR_LIT>':objectid,<EOL>lspmethod:{<EOL>retkey:phasedlc<EOL>}<EOL>}<EOL>self.write(resultdict)<EOL>self.finish()<EOL><DEDENT>else:<EOL><INDENT>lctoolkwargs['<STR_LIT>'] = '<STR_LIT>'<EOL>lctoolargs[<NUM_LIT:2>] = -<NUM_LIT:1><EOL>if lctoolkwargs['<STR_LIT>'] is not None:<EOL><INDENT>stimes, smags, serrs = lcmath.sigclip_magseries(<EOL>lctoolargs[<NUM_LIT:3>],<EOL>lctoolargs[<NUM_LIT:4>],<EOL>lctoolargs[<NUM_LIT:5>],<EOL>sigclip=lctoolkwargs['<STR_LIT>'],<EOL>magsarefluxes=lctoolkwargs['<STR_LIT>']<EOL>)<EOL><DEDENT>else:<EOL><INDENT>stimes, smags, serrs = (lctoolargs[<NUM_LIT:3>],<EOL>lctoolargs[<NUM_LIT:4>],<EOL>lctoolargs[<NUM_LIT:5>])<EOL><DEDENT>if lctoolkwargs['<STR_LIT>']:<EOL><INDENT>wtimes, wmags, werrs = stimes, smags, serrs<EOL>filtermasks = [<EOL>np.full_like(wtimes, False, dtype=np.bool_)<EOL>]<EOL>filterstr = lctoolkwargs['<STR_LIT>']<EOL>filters = filterstr.split('<STR_LIT:U+002C>')<EOL>filters = [<EOL>x.strip().lstrip('<STR_LIT:(>').rstrip('<STR_LIT:)>').strip()<EOL>for x in filters<EOL>]<EOL>for filt in filters:<EOL><INDENT>try:<EOL><INDENT>thisfilt = filt.split('<STR_LIT::>')<EOL>if len(thisfilt) == <NUM_LIT:2>:<EOL><INDENT>filt_lo = float(thisfilt[<NUM_LIT:0>])<EOL>filt_hi = float(thisfilt[<NUM_LIT:1>])<EOL>filtermasks.append(<EOL>((wtimes -<EOL>cptimes.min()) < filt_hi) &<EOL>((wtimes -<EOL>cptimes.min()) > filt_lo)<EOL>)<EOL><DEDENT>elif (len(thisfilt) == <NUM_LIT:3> and<EOL>thisfilt[<NUM_LIT:0>].strip() == '<STR_LIT>'):<EOL><INDENT>filt_lo = float(thisfilt[<NUM_LIT:1>])<EOL>filt_hi = float(thisfilt[<NUM_LIT:2>])<EOL>filtermasks.append(np.logical_not(<EOL>(((wtimes -<EOL>cptimes.min()) < filt_hi) &<EOL>((wtimes -<EOL>cptimes.min()) > filt_lo))<EOL>))<EOL><DEDENT>else:<EOL><INDENT>continue<EOL><DEDENT><DEDENT>except Exception as e:<EOL><INDENT>continue<EOL><DEDENT><DEDENT>if len(filtermasks) > <NUM_LIT:0>:<EOL><INDENT>filterind = np.column_stack(filtermasks)<EOL>filterind = np.any(filterind, axis=<NUM_LIT:1>)<EOL>stimes = wtimes[filterind]<EOL>smags = wmags[filterind]<EOL>serrs = werrs[filterind]<EOL><DEDENT><DEDENT>if lctoolkwargs['<STR_LIT>']:<EOL><INDENT>wtimes, wmags, werrs = stimes, smags, serrs<EOL>filtermasks = [<EOL>np.full_like(wtimes, False, dtype=np.bool_)<EOL>]<EOL>filterstr = lctoolkwargs['<STR_LIT>']<EOL>filters = filterstr.split('<STR_LIT:U+002C>')<EOL>filters = [<EOL>x.strip().strip()<EOL>for x in filters<EOL>]<EOL>for filt in filters:<EOL><INDENT>try:<EOL><INDENT>thisfilt = filt.split('<STR_LIT::>')<EOL>if len(thisfilt) == <NUM_LIT:2>:<EOL><INDENT>filt_lo = float(thisfilt[<NUM_LIT:0>])<EOL>filt_hi = float(thisfilt[<NUM_LIT:1>])<EOL>filtermasks.append(<EOL>(wmags < filt_hi) &<EOL>(wmags > filt_lo)<EOL>)<EOL><DEDENT>elif (len(thisfilt) == <NUM_LIT:3> and<EOL>thisfilt[<NUM_LIT:0>].strip() == '<STR_LIT>'):<EOL><INDENT>filt_lo = float(thisfilt[<NUM_LIT:1>])<EOL>filt_hi = float(thisfilt[<NUM_LIT:2>])<EOL>filtermasks.append(np.logical_not(<EOL>((wmags < filt_hi) &<EOL>(wmags > filt_lo))<EOL>))<EOL><DEDENT>else:<EOL><INDENT>continue<EOL><DEDENT><DEDENT>except Exception as e:<EOL><INDENT>continue<EOL><DEDENT><DEDENT>if len(filtermasks) > <NUM_LIT:0>:<EOL><INDENT>filterind = np.column_stack(filtermasks)<EOL>filterind = np.any(filterind, axis=<NUM_LIT:1>)<EOL>stimes = wtimes[filterind]<EOL>smags = wmags[filterind]<EOL>serrs = werrs[filterind]<EOL><DEDENT><DEDENT>del lctoolkwargs['<STR_LIT>']<EOL>del lctoolkwargs['<STR_LIT>']<EOL>if lctoolargs[-<NUM_LIT:1>] is None:<EOL><INDENT>LOGGER.warning(<EOL>'<STR_LIT>'<EOL>'<STR_LIT>'<EOL>)<EOL>try:<EOL><INDENT>spfit = lcfit.spline_fit_magseries(<EOL>stimes,         <EOL>smags,          <EOL>serrs,          <EOL>lctoolargs[<NUM_LIT:6>],  <EOL>magsarefluxes=lctoolkwargs['<STR_LIT>'],<EOL>sigclip=None,<EOL>verbose=True<EOL>)<EOL>lctoolargs[-<NUM_LIT:1>] = spfit['<STR_LIT>']['<STR_LIT>']<EOL>if len(spfit['<STR_LIT>']['<STR_LIT>']) != <NUM_LIT:1>:<EOL><INDENT>lctoolargs[-<NUM_LIT:1>] = (<EOL>spfit['<STR_LIT>']['<STR_LIT>'][<NUM_LIT:0>]<EOL>)<EOL><DEDENT><DEDENT>except Exception as e:<EOL><INDENT>LOGGER.exception(<EOL>'<STR_LIT>'<EOL>'<STR_LIT>'<EOL>)<EOL>lctoolargs[-<NUM_LIT:1>] = np.min(stimes)<EOL><DEDENT><DEDENT>lctoolargs[<NUM_LIT:3>] = stimes<EOL>lctoolargs[<NUM_LIT:4>] = smags<EOL>lctoolargs[<NUM_LIT:5>] = serrs<EOL>del lctoolkwargs['<STR_LIT>']<EOL>lctoolfunction = CPTOOLMAP[lctool]['<STR_LIT>']<EOL>funcresults = yield self.executor.submit(<EOL>lctoolfunction,<EOL>*lctoolargs,<EOL>**lctoolkwargs<EOL>)<EOL>if not self.readonly:<EOL><INDENT>if (lspmethod in tempcpdict and<EOL>isinstance(tempcpdict[lspmethod], dict)):<EOL><INDENT>if periodind in tempcpdict[lspmethod]:<EOL><INDENT>tempcpdict[lspmethod][periodind] = (<EOL>funcresults<EOL>)<EOL><DEDENT>else:<EOL><INDENT>tempcpdict[lspmethod].update(<EOL>{periodind: funcresults}<EOL>)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>tempcpdict[lspmethod] = {periodind: funcresults}<EOL><DEDENT>savekwargs = {<EOL>'<STR_LIT>':tempfpath,<EOL>'<STR_LIT>':pickle.HIGHEST_PROTOCOL<EOL>}<EOL>savedcpf = yield self.executor.submit(<EOL>_write_checkplot_picklefile,<EOL>tempcpdict,<EOL>**savekwargs<EOL>)<EOL>LOGGER.info(<EOL>'<STR_LIT>'<EOL>'<STR_LIT>' %<EOL>(lctool, savedcpf)<EOL>)<EOL><DEDENT>else:<EOL><INDENT>LOGGER.warning(<EOL>'<STR_LIT>'<EOL>'<STR_LIT>'<EOL>)<EOL><DEDENT>resultdict['<STR_LIT:status>'] = '<STR_LIT:success>'<EOL>resultdict['<STR_LIT:message>'] = (<EOL>'<STR_LIT>' %<EOL>lctool<EOL>)<EOL>retkey = '<STR_LIT>' % periodind<EOL>resultdict['<STR_LIT:result>'] = {<EOL>'<STR_LIT>':objectid,<EOL>lspmethod:{<EOL>retkey:funcresults<EOL>}<EOL>}<EOL>self.write(resultdict)<EOL>self.finish()<EOL><DEDENT><DEDENT>elif lctool == '<STR_LIT>':<EOL><INDENT>if (not forcereload and<EOL>'<STR_LIT>' in tempcpdict and<EOL>isinstance(tempcpdict['<STR_LIT>'], dict) and<EOL>'<STR_LIT>' in tempcpdict['<STR_LIT>'] and<EOL>isinstance(tempcpdict['<STR_LIT>']['<STR_LIT>'], dict)):<EOL><INDENT>LOGGER.warning(<EOL>'<STR_LIT>'<EOL>'<STR_LIT>' %<EOL>(lctool, tempfpath)<EOL>)<EOL>resultdict['<STR_LIT:status>'] = '<STR_LIT>'<EOL>resultdict['<STR_LIT:message>'] = (<EOL>'<STR_LIT>'<EOL>'<STR_LIT>' %<EOL>lctool<EOL>)<EOL>resultdict['<STR_LIT:result>'] = {<EOL>'<STR_LIT>':objectid,<EOL>'<STR_LIT>': {<EOL>'<STR_LIT>': (<EOL>tempcpdict['<STR_LIT>']['<STR_LIT>']<EOL>)<EOL>}<EOL>}<EOL>self.write(resultdict)<EOL>self.finish()<EOL><DEDENT>else:<EOL><INDENT>lctoolfunction = CPTOOLMAP[lctool]['<STR_LIT>']<EOL>funcresults = yield self.executor.submit(<EOL>lctoolfunction,<EOL>*lctoolargs,<EOL>**lctoolkwargs<EOL>)<EOL>if not self.readonly:<EOL><INDENT>if ('<STR_LIT>' in tempcpdict and<EOL>isinstance(tempcpdict['<STR_LIT>'], dict)):<EOL><INDENT>if '<STR_LIT>' in tempcpdict['<STR_LIT>']:<EOL><INDENT>tempcpdict['<STR_LIT>']['<STR_LIT>'] = (<EOL>funcresults<EOL>)<EOL><DEDENT>else:<EOL><INDENT>tempcpdict['<STR_LIT>'].update(<EOL>{'<STR_LIT>': funcresults}<EOL>)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>tempcpdict['<STR_LIT>'] = {'<STR_LIT>':<EOL>funcresults}<EOL><DEDENT>savekwargs = {<EOL>'<STR_LIT>':tempfpath,<EOL>'<STR_LIT>':pickle.HIGHEST_PROTOCOL<EOL>}<EOL>savedcpf = yield self.executor.submit(<EOL>_write_checkplot_picklefile,<EOL>tempcpdict,<EOL>**savekwargs<EOL>)<EOL>LOGGER.info(<EOL>'<STR_LIT>'<EOL>'<STR_LIT>' %<EOL>(lctool, savedcpf)<EOL>)<EOL><DEDENT>else:<EOL><INDENT>LOGGER.warning(<EOL>'<STR_LIT>'<EOL>'<STR_LIT>'<EOL>)<EOL><DEDENT>resultdict['<STR_LIT:status>'] = '<STR_LIT:success>'<EOL>resultdict['<STR_LIT:message>'] = (<EOL>'<STR_LIT>' %<EOL>lctool<EOL>)<EOL>resultdict['<STR_LIT:result>'] = {<EOL>'<STR_LIT>':objectid,<EOL>'<STR_LIT>':{<EOL>'<STR_LIT>':funcresults<EOL>}<EOL>}<EOL>self.write(resultdict)<EOL>self.finish()<EOL><DEDENT><DEDENT>elif lctool in ('<STR_LIT>','<STR_LIT>'):<EOL><INDENT>key1, key2 = resloc<EOL>if (not forcereload and<EOL>key1 in tempcpdict and<EOL>isinstance(tempcpdict[key1], dict) and<EOL>key2 in tempcpdict[key1] and<EOL>isinstance(tempcpdict[key1][key2], dict)):<EOL><INDENT>LOGGER.warning(<EOL>'<STR_LIT>'<EOL>'<STR_LIT>' %<EOL>(lctool, tempfpath)<EOL>)<EOL>resultdict['<STR_LIT:status>'] = '<STR_LIT>'<EOL>resultdict['<STR_LIT:message>'] = (<EOL>'<STR_LIT>'<EOL>'<STR_LIT>' %<EOL>lctool<EOL>)<EOL>resultdict['<STR_LIT:result>'] = {<EOL>'<STR_LIT>':objectid,<EOL>key1: {<EOL>key2: (<EOL>tempcpdict[key1][key2]<EOL>)<EOL>}<EOL>}<EOL>self.write(resultdict)<EOL>self.finish()<EOL><DEDENT>else:<EOL><INDENT>lctoolfunction = CPTOOLMAP[lctool]['<STR_LIT>']<EOL>lctoolkwargs['<STR_LIT>'] = StrIO()<EOL>funcresults = yield self.executor.submit(<EOL>lctoolfunction,<EOL>*lctoolargs,<EOL>**lctoolkwargs<EOL>)<EOL>fitfd = funcresults['<STR_LIT>']<EOL>fitfd.seek(<NUM_LIT:0>)<EOL>fitbin = fitfd.read()<EOL>fitb64 = base64.b64encode(fitbin)<EOL>fitfd.close()<EOL>funcresults['<STR_LIT>'] = fitb64<EOL>if not self.readonly:<EOL><INDENT>if (key1 in tempcpdict and<EOL>isinstance(tempcpdict[key1], dict)):<EOL><INDENT>if key2 in tempcpdict[key1]:<EOL><INDENT>tempcpdict[key1][key2] = (<EOL>funcresults<EOL>)<EOL><DEDENT>else:<EOL><INDENT>tempcpdict[key1].update(<EOL>{key2: funcresults}<EOL>)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>tempcpdict[key1] = {key2: funcresults}<EOL><DEDENT>savekwargs = {<EOL>'<STR_LIT>':tempfpath,<EOL>'<STR_LIT>':pickle.HIGHEST_PROTOCOL<EOL>}<EOL>savedcpf = yield self.executor.submit(<EOL>_write_checkplot_picklefile,<EOL>tempcpdict,<EOL>**savekwargs<EOL>)<EOL>LOGGER.info(<EOL>'<STR_LIT>'<EOL>'<STR_LIT>' %<EOL>(lctool, savedcpf)<EOL>)<EOL><DEDENT>else:<EOL><INDENT>LOGGER.warning(<EOL>'<STR_LIT>'<EOL>'<STR_LIT>'<EOL>)<EOL><DEDENT>fitreturndict = {'<STR_LIT>':fitb64}<EOL>resultdict['<STR_LIT:status>'] = '<STR_LIT:success>'<EOL>resultdict['<STR_LIT:message>'] = (<EOL>'<STR_LIT>' %<EOL>lctool<EOL>)<EOL>resultdict['<STR_LIT:result>'] = {<EOL>'<STR_LIT>':objectid,<EOL>key1:{<EOL>key2:fitreturndict<EOL>}<EOL>}<EOL>self.write(resultdict)<EOL>self.finish()<EOL><DEDENT><DEDENT>elif lctool in ('<STR_LIT>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT>'):<EOL><INDENT>key1, key2 = resloc<EOL>if (not forcereload and<EOL>key1 in tempcpdict and<EOL>isinstance(tempcpdict[key1], dict) and<EOL>key2 in tempcpdict[key1] and<EOL>isinstance(tempcpdict[key1][key2], dict)):<EOL><INDENT>LOGGER.warning(<EOL>'<STR_LIT>'<EOL>'<STR_LIT>' %<EOL>(lctool, tempfpath)<EOL>)<EOL>resultdict['<STR_LIT:status>'] = '<STR_LIT>'<EOL>resultdict['<STR_LIT:message>'] = (<EOL>'<STR_LIT>'<EOL>'<STR_LIT>' %<EOL>lctool<EOL>)<EOL>phasedfitlc = tempcpdict[key1][key2]<EOL>fitresults = {<EOL>'<STR_LIT>':phasedfitlc['<STR_LIT>']['<STR_LIT>'],<EOL>'<STR_LIT>':phasedfitlc['<STR_LIT>']['<STR_LIT>'],<EOL>'<STR_LIT>':phasedfitlc['<STR_LIT>']['<STR_LIT>'],<EOL>'<STR_LIT>':phasedfitlc['<STR_LIT>'],<EOL>'<STR_LIT>':phasedfitlc['<STR_LIT>'],<EOL>'<STR_LIT>':phasedfitlc['<STR_LIT>'],<EOL>}<EOL>if ('<STR_LIT>' in phasedfitlc['<STR_LIT>']['<STR_LIT>'] and<EOL>phasedfitlc['<STR_LIT>']['<STR_LIT>']['<STR_LIT>']<EOL>is not None):<EOL><INDENT>fitresults['<STR_LIT>'] = (<EOL>phasedfitlc['<STR_LIT>']['<STR_LIT>']['<STR_LIT>']<EOL>)<EOL><DEDENT>resultdict['<STR_LIT:result>'] = {<EOL>'<STR_LIT>':objectid,<EOL>key1: {<EOL>key2: (<EOL>fitresults<EOL>)<EOL>}<EOL>}<EOL>self.write(resultdict)<EOL>self.finish()<EOL><DEDENT>else:<EOL><INDENT>lctoolfunction = CPTOOLMAP[lctool]['<STR_LIT>']<EOL>funcresults = yield self.executor.submit(<EOL>lctoolfunction,<EOL>*lctoolargs,<EOL>**lctoolkwargs<EOL>)<EOL>phasedlcargs = (None,<EOL>'<STR_LIT>',<EOL>-<NUM_LIT:1>,<EOL>cptimes,<EOL>cpmags,<EOL>cperrs,<EOL>lctoolargs[<NUM_LIT:3>],  <EOL>'<STR_LIT>')<EOL>phasedlckwargs = {<EOL>'<STR_LIT>':False,<EOL>'<STR_LIT>':lctoolkwargs['<STR_LIT>'],<EOL>'<STR_LIT>':'<STR_LIT>',<EOL>'<STR_LIT>':funcresults<EOL>}<EOL>phasedlc = yield self.executor.submit(<EOL>_pkl_phased_magseries_plot,<EOL>*phasedlcargs,<EOL>**phasedlckwargs<EOL>)<EOL>if not self.readonly:<EOL><INDENT>if (key1 in tempcpdict and<EOL>isinstance(tempcpdict[key1], dict)):<EOL><INDENT>if key2 in tempcpdict[key1]:<EOL><INDENT>tempcpdict[key1][key2] = (<EOL>phasedlc<EOL>)<EOL><DEDENT>else:<EOL><INDENT>tempcpdict[key1].update(<EOL>{key2: phasedlc}<EOL>)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>tempcpdict[key1] = {key2: phasedlc}<EOL><DEDENT>savekwargs = {<EOL>'<STR_LIT>':tempfpath,<EOL>'<STR_LIT>':pickle.HIGHEST_PROTOCOL<EOL>}<EOL>savedcpf = yield self.executor.submit(<EOL>_write_checkplot_picklefile,<EOL>tempcpdict,<EOL>**savekwargs<EOL>)<EOL>LOGGER.info(<EOL>'<STR_LIT>'<EOL>'<STR_LIT>' %<EOL>(lctool, savedcpf)<EOL>)<EOL><DEDENT>else:<EOL><INDENT>LOGGER.warning(<EOL>'<STR_LIT>'<EOL>'<STR_LIT>'<EOL>)<EOL><DEDENT>fitresults = {<EOL>'<STR_LIT>':phasedlc['<STR_LIT>']['<STR_LIT>'],<EOL>'<STR_LIT>':phasedlc['<STR_LIT>']['<STR_LIT>'],<EOL>'<STR_LIT>':phasedlc['<STR_LIT>']['<STR_LIT>'],<EOL>'<STR_LIT>':phasedlc['<STR_LIT>'],<EOL>'<STR_LIT>':phasedlc['<STR_LIT>'],<EOL>'<STR_LIT>':phasedlc['<STR_LIT>'],<EOL>}<EOL>if ('<STR_LIT>' in funcresults['<STR_LIT>'] and<EOL>funcresults['<STR_LIT>']['<STR_LIT>'] is not None):<EOL><INDENT>fitresults['<STR_LIT>'] = (<EOL>funcresults['<STR_LIT>']['<STR_LIT>']<EOL>)<EOL><DEDENT>resultdict['<STR_LIT:status>'] = '<STR_LIT:success>'<EOL>resultdict['<STR_LIT:message>'] = (<EOL>'<STR_LIT>' %<EOL>lctool<EOL>)<EOL>resultdict['<STR_LIT:result>'] = {<EOL>'<STR_LIT>':objectid,<EOL>key1:{<EOL>key2:fitresults<EOL>}<EOL>}<EOL>self.write(resultdict)<EOL>self.finish()<EOL><DEDENT><DEDENT>elif lctool == '<STR_LIT>':<EOL><INDENT>fitmethod, periodind = lctoolargs<EOL><DEDENT>elif lctool == '<STR_LIT>':<EOL><INDENT>if os.path.exists(tempfpath):<EOL><INDENT>os.remove(tempfpath)<EOL>LOGGER.warning('<STR_LIT>'<EOL>'<STR_LIT>' %<EOL>(tempfpath, cpfpath))<EOL>resultdict['<STR_LIT:status>'] = '<STR_LIT:success>'<EOL><DEDENT>else:<EOL><INDENT>resultdict['<STR_LIT:status>'] = '<STR_LIT:error>'<EOL>LOGGER.warning('<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>' %<EOL>(tempfpath, cpfpath))<EOL><DEDENT>resultdict['<STR_LIT:message>'] = (<EOL>'<STR_LIT>'<EOL>)<EOL>resultdict['<STR_LIT:result>'] = {'<STR_LIT>':cpobjectid}<EOL>self.write(resultdict)<EOL>self.finish()<EOL><DEDENT>elif lctool == '<STR_LIT>':<EOL><INDENT>target = self.get_argument('<STR_LIT>',None)<EOL>if target is not None:<EOL><INDENT>target = xhtml_escape(target)<EOL>if (target not in CPTOOLMAP or<EOL>target == '<STR_LIT>' or<EOL>target == '<STR_LIT>' or<EOL>target == '<STR_LIT>' or<EOL>target == '<STR_LIT>'):<EOL><INDENT>LOGGER.error("<STR_LIT>" % target)<EOL>resultdict['<STR_LIT:status>'] = '<STR_LIT:error>'<EOL>resultdict['<STR_LIT:message>'] = (<EOL>"<STR_LIT>" % target<EOL>)<EOL>resultdict['<STR_LIT:result>'] = {'<STR_LIT>':cpobjectid}<EOL>self.write(resultdict)<EOL>raise tornado.web.Finish()<EOL><DEDENT>targetloc = CPTOOLMAP[target]['<STR_LIT>']<EOL><DEDENT>else:<EOL><INDENT>pass<EOL><DEDENT><DEDENT>else:<EOL><INDENT>LOGGER.error('<STR_LIT>' % lctool)<EOL>resultdict['<STR_LIT:status>'] = '<STR_LIT:error>'<EOL>resultdict['<STR_LIT:message>'] = (<EOL>'<STR_LIT>' % lctool<EOL>)<EOL>resultdict['<STR_LIT:result>'] = {'<STR_LIT>':cpobjectid}<EOL>self.write(resultdict)<EOL>raise tornado.web.Finish()<EOL><DEDENT><DEDENT>else:<EOL><INDENT>LOGGER.error('<STR_LIT>' % self.cpfile)<EOL>resultdict = {'<STR_LIT:status>':'<STR_LIT:error>',<EOL>'<STR_LIT:message>':"<STR_LIT>",<EOL>'<STR_LIT>':self.readonly,<EOL>'<STR_LIT:result>':None}<EOL>self.write(resultdict)<EOL>raise tornado.web.Finish()<EOL><DEDENT><DEDENT>else:<EOL><INDENT>resultdict = {'<STR_LIT:status>':'<STR_LIT:error>',<EOL>'<STR_LIT:message>':'<STR_LIT>',<EOL>'<STR_LIT>':self.readonly,<EOL>'<STR_LIT:result>':None}<EOL>self.write(resultdict)<EOL>raise tornado.web.Finish()<EOL><DEDENT>
This handles a GET request to run a specified LC tool.

        Parameters
        ----------

        cpfile : str
            This is the checkplot file to run the tool on.

        Returns
        -------

        str
            Returns a JSON response.

        Notes
        -----

        The URI structure is::

            /tools/<cpfile>?[args]

        where args are::

            ?lctool=<lctool>&argkey1=argval1&argkey2=argval2&...

            &forcereload=true <- if this is present, then reload values from
            original checkplot.

            &objectid=<objectid>

        `lctool` is one of the strings below

        Period search functions::

            psearch-gls: run Lomb-Scargle with given params
            psearch-bls: run BLS with given params
            psearch-pdm: run phase dispersion minimization with given params
            psearch-aov: run analysis-of-variance with given params
            psearch-mav: run analysis-of-variance (multi-harm) with given params
            psearch-acf: run ACF period search with given params
            psearch-win: run spectral window function search with given params

        Arguments recognized by all period-search functions are::

            startp=XX
            endp=XX
            magsarefluxes=True|False
            autofreq=True|False
            stepsize=XX

        Variability characterization functions::

            var-varfeatures: gets the variability features from the checkplot or
                             recalculates if they're not present

            var-prewhiten: pre-whitens the light curve with a sinusoidal signal

            var-masksig: masks a given phase location with given width from the
                         light curve

        Light curve manipulation functions ::

            phasedlc-newplot: make phased LC with new provided period/epoch
            lcfit-fourier: fit a Fourier function to the phased LC
            lcfit-spline: fit a spline function to the phased LC
            lcfit-legendre: fit a Legendre polynomial to the phased LC
            lcfit-savgol: fit a Savitsky-Golay polynomial to the phased LC

        FIXME: figure out how to cache the results of these functions
        temporarily and save them back to the checkplot after we click on save
        in the frontend.

        TODO: look for a checkplot-blah-blah.pkl-cps-processing file in the same
        place as the usual pickle file. if this exists and is newer than the pkl
        file, load it instead. Or have a checkplotdict['cpservertemp'] item.