<EOL>if isinstance(precvar_results, str) and os.path.exists(precvar_results):<EOL><INDENT>with open(precvar_results,'<STR_LIT:rb>') as infd:<EOL><INDENT>precvar = pickle.load(infd)<EOL><DEDENT><DEDENT>elif isinstance(precvar_results, dict):<EOL><INDENT>precvar = precvar_results<EOL><DEDENT>else:<EOL><INDENT>LOGERROR('<STR_LIT>'<EOL>'<STR_LIT>')<EOL>return None<EOL><DEDENT>simbasedir = precvar['<STR_LIT>']<EOL>lcinfof = os.path.join(simbasedir,'<STR_LIT>')<EOL>if not os.path.exists(lcinfof):<EOL><INDENT>LOGERROR('<STR_LIT>' %<EOL>simbasedir)<EOL>return None<EOL><DEDENT>with open(lcinfof,'<STR_LIT:rb>') as infd:<EOL><INDENT>lcinfo = pickle.load(infd)<EOL><DEDENT>magcols = lcinfo['<STR_LIT>']<EOL>objectid = lcinfo['<STR_LIT>']<EOL>ndet = lcinfo['<STR_LIT>']<EOL>sdssr = lcinfo['<STR_LIT>']<EOL>actual_periodicvars = precvar['<STR_LIT>']<EOL>LOGINFO('<STR_LIT>')<EOL>periodicvar_sdssr = []<EOL>periodicvar_ndet = []<EOL>periodicvar_objectids = []<EOL>for pobj in actual_periodicvars:<EOL><INDENT>pobjind = objectid == pobj<EOL>periodicvar_objectids.append(pobj)<EOL>periodicvar_sdssr.append(sdssr[pobjind])<EOL>periodicvar_ndet.append(ndet[pobjind])<EOL><DEDENT>periodicvar_sdssr = np.array(periodicvar_sdssr)<EOL>periodicvar_objectids = np.array(periodicvar_objectids)<EOL>periodicvar_ndet = np.array(periodicvar_ndet)<EOL>LOGINFO('<STR_LIT>'<EOL>'<STR_LIT>')<EOL>periodicvar_periods = [<EOL>np.asscalar(precvar['<STR_LIT>'][x]['<STR_LIT>'])<EOL>for x in periodicvar_objectids<EOL>]<EOL>periodicvar_amplitudes = [<EOL>np.asscalar(precvar['<STR_LIT>'][x]['<STR_LIT>'])<EOL>for x in periodicvar_objectids<EOL>]<EOL>periodicvar_vartypes = [<EOL>precvar['<STR_LIT>'][x]['<STR_LIT>'] for x in periodicvar_objectids<EOL>]<EOL>LOGINFO('<STR_LIT>')<EOL>magbinned_sdssr = []<EOL>magbinned_periodicvars = []<EOL>if not magbins:<EOL><INDENT>magbins = PERIODREC_DEFAULT_MAGBINS<EOL><DEDENT>magbininds = np.digitize(np.ravel(periodicvar_sdssr), magbins)<EOL>for mbinind, magi in zip(np.unique(magbininds),<EOL>range(len(magbins)-<NUM_LIT:1>)):<EOL><INDENT>thisbin_periodicvars = periodicvar_objectids[magbininds == mbinind]<EOL>if (thisbin_periodicvars.size > (minbinsize-<NUM_LIT:1>)):<EOL><INDENT>magbinned_sdssr.append((magbins[magi] + magbins[magi+<NUM_LIT:1>])/<NUM_LIT>)<EOL>magbinned_periodicvars.append(thisbin_periodicvars)<EOL><DEDENT><DEDENT>LOGINFO('<STR_LIT>')<EOL>periodbinned_periods = []<EOL>periodbinned_periodicvars = []<EOL>if not periodbins:<EOL><INDENT>periodbins = PERIODREC_DEFAULT_PERIODBINS<EOL><DEDENT>periodbininds = np.digitize(np.ravel(periodicvar_periods), periodbins)<EOL>for pbinind, peri in zip(np.unique(periodbininds),<EOL>range(len(periodbins)-<NUM_LIT:1>)):<EOL><INDENT>thisbin_periodicvars = periodicvar_objectids[periodbininds == pbinind]<EOL>if (thisbin_periodicvars.size > (minbinsize-<NUM_LIT:1>)):<EOL><INDENT>periodbinned_periods.append((periodbins[peri] +<EOL>periodbins[peri+<NUM_LIT:1>])/<NUM_LIT>)<EOL>periodbinned_periodicvars.append(thisbin_periodicvars)<EOL><DEDENT><DEDENT>LOGINFO('<STR_LIT>')<EOL>amplitudebinned_amplitudes = []<EOL>amplitudebinned_periodicvars = []<EOL>if not amplitudebins:<EOL><INDENT>amplitudebins = PERIODREC_DEFAULT_AMPBINS<EOL><DEDENT>amplitudebininds = np.digitize(np.ravel(np.abs(periodicvar_amplitudes)),<EOL>amplitudebins)<EOL>for abinind, ampi in zip(np.unique(amplitudebininds),<EOL>range(len(amplitudebins)-<NUM_LIT:1>)):<EOL><INDENT>thisbin_periodicvars = periodicvar_objectids[<EOL>amplitudebininds == abinind<EOL>]<EOL>if (thisbin_periodicvars.size > (minbinsize-<NUM_LIT:1>)):<EOL><INDENT>amplitudebinned_amplitudes.append(<EOL>(amplitudebins[ampi] +<EOL>amplitudebins[ampi+<NUM_LIT:1>])/<NUM_LIT><EOL>)<EOL>amplitudebinned_periodicvars.append(thisbin_periodicvars)<EOL><DEDENT><DEDENT>LOGINFO('<STR_LIT>')<EOL>ndetbinned_ndets = []<EOL>ndetbinned_periodicvars = []<EOL>if not ndetbins:<EOL><INDENT>ndetbins = PERIODREC_DEFAULT_NDETBINS<EOL><DEDENT>ndetbininds = np.digitize(np.ravel(periodicvar_ndet), ndetbins)<EOL>for nbinind, ndeti in zip(np.unique(ndetbininds),<EOL>range(len(ndetbins)-<NUM_LIT:1>)):<EOL><INDENT>thisbin_periodicvars = periodicvar_objectids[ndetbininds == nbinind]<EOL>if (thisbin_periodicvars.size > (minbinsize-<NUM_LIT:1>)):<EOL><INDENT>ndetbinned_ndets.append(<EOL>(ndetbins[ndeti] +<EOL>ndetbins[ndeti+<NUM_LIT:1>])/<NUM_LIT><EOL>)<EOL>ndetbinned_periodicvars.append(thisbin_periodicvars)<EOL><DEDENT><DEDENT>recovered_status = ['<STR_LIT>']<EOL>if isinstance(aliases_count_as_recovered, list):<EOL><INDENT>for atype in aliases_count_as_recovered:<EOL><INDENT>if atype in ALIAS_TYPES:<EOL><INDENT>recovered_status.append(atype)<EOL><DEDENT>else:<EOL><INDENT>LOGWARNING('<STR_LIT>' % atype)<EOL><DEDENT><DEDENT><DEDENT>elif aliases_count_as_recovered and aliases_count_as_recovered == '<STR_LIT:all>':<EOL><INDENT>for atype in ALIAS_TYPES[<NUM_LIT:1>:]:<EOL><INDENT>recovered_status.append(atype)<EOL><DEDENT><DEDENT>recovered_periodicvars = np.array(<EOL>[precvar['<STR_LIT>'][x]['<STR_LIT>'] for x in precvar['<STR_LIT>']<EOL>if (precvar['<STR_LIT>'][x] is not None and<EOL>precvar['<STR_LIT>'][x]['<STR_LIT>']<EOL>in recovered_status)],<EOL>dtype=np.unicode_<EOL>)<EOL>LOGINFO('<STR_LIT>'<EOL>'<STR_LIT>' %<EOL>(recovered_periodicvars.size,<EOL>actual_periodicvars.size,<EOL>float(recovered_periodicvars.size/actual_periodicvars.size),<EOL>'<STR_LIT:U+002CU+0020>'.join(recovered_status)))<EOL>magbinned_recovered_objects = [<EOL>np.intersect1d(x,recovered_periodicvars)<EOL>for x in magbinned_periodicvars<EOL>]<EOL>magbinned_recfrac = np.array([float(x.size/y.size) for x,y<EOL>in zip(magbinned_recovered_objects,<EOL>magbinned_periodicvars)])<EOL>periodbinned_recovered_objects = [<EOL>np.intersect1d(x,recovered_periodicvars)<EOL>for x in periodbinned_periodicvars<EOL>]<EOL>periodbinned_recfrac = np.array([float(x.size/y.size) for x,y<EOL>in zip(periodbinned_recovered_objects,<EOL>periodbinned_periodicvars)])<EOL>amplitudebinned_recovered_objects = [<EOL>np.intersect1d(x,recovered_periodicvars)<EOL>for x in amplitudebinned_periodicvars<EOL>]<EOL>amplitudebinned_recfrac = np.array(<EOL>[float(x.size/y.size) for x,y<EOL>in zip(amplitudebinned_recovered_objects,<EOL>amplitudebinned_periodicvars)]<EOL>)<EOL>ndetbinned_recovered_objects = [<EOL>np.intersect1d(x,recovered_periodicvars)<EOL>for x in ndetbinned_periodicvars<EOL>]<EOL>ndetbinned_recfrac = np.array([float(x.size/y.size) for x,y<EOL>in zip(ndetbinned_recovered_objects,<EOL>ndetbinned_periodicvars)])<EOL>magbinned_sdssr = np.array(magbinned_sdssr)<EOL>periodbinned_periods = np.array(periodbinned_periods)<EOL>amplitudebinned_amplitudes = np.array(amplitudebinned_amplitudes)<EOL>ndetbinned_ndets = np.array(ndetbinned_ndets)<EOL>outdict = {<EOL>'<STR_LIT>':simbasedir,<EOL>'<STR_LIT>':precvar,<EOL>'<STR_LIT>':magcols,<EOL>'<STR_LIT>':objectid,<EOL>'<STR_LIT>':ndet,<EOL>'<STR_LIT>':sdssr,<EOL>'<STR_LIT>':actual_periodicvars,<EOL>'<STR_LIT>':recovered_periodicvars,<EOL>'<STR_LIT>':recovered_status,<EOL>'<STR_LIT>':magbins,<EOL>'<STR_LIT>':magbinned_sdssr,<EOL>'<STR_LIT>':magbinned_periodicvars,<EOL>'<STR_LIT>':magbinned_recovered_objects,<EOL>'<STR_LIT>':magbinned_recfrac,<EOL>'<STR_LIT>':periodbins,<EOL>'<STR_LIT>':periodbinned_periods,<EOL>'<STR_LIT>':periodbinned_periodicvars,<EOL>'<STR_LIT>':periodbinned_recovered_objects,<EOL>'<STR_LIT>':periodbinned_recfrac,<EOL>'<STR_LIT>':amplitudebins,<EOL>'<STR_LIT>':amplitudebinned_amplitudes,<EOL>'<STR_LIT>':amplitudebinned_periodicvars,<EOL>'<STR_LIT>':amplitudebinned_recovered_objects,<EOL>'<STR_LIT>':amplitudebinned_recfrac,<EOL>'<STR_LIT>':ndetbins,<EOL>'<STR_LIT>':ndetbinned_ndets,<EOL>'<STR_LIT>':ndetbinned_periodicvars,<EOL>'<STR_LIT>':ndetbinned_recovered_objects,<EOL>'<STR_LIT>':ndetbinned_recfrac,<EOL>}<EOL>all_pfmethods = np.unique(<EOL>np.concatenate(<EOL>[np.unique(precvar['<STR_LIT>'][x]['<STR_LIT>'])<EOL>for x in precvar['<STR_LIT>']]<EOL>)<EOL>)<EOL>all_vartypes = np.unique(<EOL>[(precvar['<STR_LIT>'][x]['<STR_LIT>'])<EOL>for x in precvar['<STR_LIT>'] if<EOL>(precvar['<STR_LIT>'][x]['<STR_LIT>'] is not None)]<EOL>)<EOL>all_aliastypes = recovered_status<EOL>outdict['<STR_LIT>'] = all_aliastypes<EOL>outdict['<STR_LIT>'] = all_pfmethods<EOL>outdict['<STR_LIT>'] = all_vartypes<EOL>magbinned_per_magcol_recfracs = []<EOL>magbinned_per_vartype_recfracs = []<EOL>magbinned_per_pfmethod_recfracs = []<EOL>magbinned_per_aliastype_recfracs = []<EOL>periodbinned_per_magcol_recfracs = []<EOL>periodbinned_per_vartype_recfracs = []<EOL>periodbinned_per_pfmethod_recfracs = []<EOL>periodbinned_per_aliastype_recfracs = []<EOL>amplitudebinned_per_magcol_recfracs = []<EOL>amplitudebinned_per_vartype_recfracs = []<EOL>amplitudebinned_per_pfmethod_recfracs = []<EOL>amplitudebinned_per_aliastype_recfracs = []<EOL>ndetbinned_per_magcol_recfracs = []<EOL>ndetbinned_per_vartype_recfracs = []<EOL>ndetbinned_per_pfmethod_recfracs = []<EOL>ndetbinned_per_aliastype_recfracs = []<EOL>recplotdir = os.path.join(simbasedir, '<STR_LIT>')<EOL>if not os.path.exists(recplotdir):<EOL><INDENT>os.mkdir(recplotdir)<EOL><DEDENT>fig = plt.figure(figsize=(<NUM_LIT>*<NUM_LIT>,<NUM_LIT>*<NUM_LIT>))<EOL>plt.plot(magbinned_sdssr, magbinned_recfrac,marker='<STR_LIT:.>',ms=<NUM_LIT:0.0>)<EOL>plt.xlabel(r'<STR_LIT>')<EOL>plt.ylabel('<STR_LIT>')<EOL>plt.title('<STR_LIT>')<EOL>plt.ylim((<NUM_LIT:0>,<NUM_LIT:1>))<EOL>plt.savefig(<EOL>os.path.join(recplotdir,<EOL>'<STR_LIT>' % plotfile_ext),<EOL>dpi=<NUM_LIT:100>,<EOL>bbox_inches='<STR_LIT>'<EOL>)<EOL>plt.close('<STR_LIT:all>')<EOL>fig = plt.figure(figsize=(<NUM_LIT>*<NUM_LIT>,<NUM_LIT>*<NUM_LIT>))<EOL>for magcol in magcols:<EOL><INDENT>thismagcol_recfracs = []<EOL>for magbin_pv, magbin_rv in zip(magbinned_periodicvars,<EOL>magbinned_recovered_objects):<EOL><INDENT>thisbin_thismagcol_recvars = [<EOL>x for x in magbin_rv<EOL>if (precvar['<STR_LIT>'][x]['<STR_LIT>'] == magcol)<EOL>]<EOL>thisbin_thismagcol_recfrac = (<EOL>np.array(thisbin_thismagcol_recvars).size /<EOL>magbin_pv.size<EOL>)<EOL>thismagcol_recfracs.append(thisbin_thismagcol_recfrac)<EOL><DEDENT>plt.plot(magbinned_sdssr,<EOL>np.array(thismagcol_recfracs),<EOL>marker='<STR_LIT:.>',<EOL>label='<STR_LIT>' % magcol,<EOL>ms=<NUM_LIT:0.0>)<EOL>magbinned_per_magcol_recfracs.append(np.array(thismagcol_recfracs))<EOL><DEDENT>plt.plot(magbinned_sdssr, magbinned_recfrac,<EOL>marker='<STR_LIT:.>',ms=<NUM_LIT:0.0>, label='<STR_LIT>', color='<STR_LIT:k>')<EOL>plt.xlabel(r'<STR_LIT>')<EOL>plt.ylabel('<STR_LIT>')<EOL>plt.title('<STR_LIT>')<EOL>plt.ylim((<NUM_LIT:0>,<NUM_LIT:1>))<EOL>plt.legend(markerscale=<NUM_LIT>)<EOL>plt.savefig(<EOL>os.path.join(recplotdir,<EOL>'<STR_LIT>' % plotfile_ext),<EOL>dpi=<NUM_LIT:100>,<EOL>bbox_inches='<STR_LIT>'<EOL>)<EOL>plt.close('<STR_LIT:all>')<EOL>fig = plt.figure(figsize=(<NUM_LIT>*<NUM_LIT>,<NUM_LIT>*<NUM_LIT>))<EOL>all_pfmethods = np.unique(<EOL>np.concatenate(<EOL>[np.unique(precvar['<STR_LIT>'][x]['<STR_LIT>'])<EOL>for x in precvar['<STR_LIT>']]<EOL>)<EOL>)<EOL>for pfm in all_pfmethods:<EOL><INDENT>thispf_recfracs = []<EOL>for magbin_pv, magbin_rv in zip(magbinned_periodicvars,<EOL>magbinned_recovered_objects):<EOL><INDENT>thisbin_thispf_recvars = [<EOL>x for x in magbin_rv<EOL>if (precvar['<STR_LIT>'][x]['<STR_LIT>'] == pfm)<EOL>]<EOL>thisbin_thismagcol_recfrac = (<EOL>np.array(thisbin_thispf_recvars).size /<EOL>magbin_pv.size<EOL>)<EOL>thispf_recfracs.append(thisbin_thismagcol_recfrac)<EOL><DEDENT>plt.plot(magbinned_sdssr,<EOL>np.array(thispf_recfracs),<EOL>marker='<STR_LIT:.>',<EOL>label='<STR_LIT:%s>' % pfm.upper(),<EOL>ms=<NUM_LIT:0.0>)<EOL>magbinned_per_pfmethod_recfracs.append(np.array(thispf_recfracs))<EOL><DEDENT>plt.plot(magbinned_sdssr, magbinned_recfrac,<EOL>marker='<STR_LIT:.>',ms=<NUM_LIT:0.0>, label='<STR_LIT>', color='<STR_LIT:k>')<EOL>plt.xlabel(r'<STR_LIT>')<EOL>plt.ylabel('<STR_LIT>')<EOL>plt.title('<STR_LIT>')<EOL>plt.ylim((<NUM_LIT:0>,<NUM_LIT:1>))<EOL>plt.legend(markerscale=<NUM_LIT>)<EOL>plt.savefig(<EOL>os.path.join(recplotdir,<EOL>'<STR_LIT>' % plotfile_ext),<EOL>dpi=<NUM_LIT:100>,<EOL>bbox_inches='<STR_LIT>'<EOL>)<EOL>plt.close('<STR_LIT:all>')<EOL>fig = plt.figure(figsize=(<NUM_LIT>*<NUM_LIT>,<NUM_LIT>*<NUM_LIT>))<EOL>all_vartypes = np.unique(<EOL>[(precvar['<STR_LIT>'][x]['<STR_LIT>'])<EOL>for x in precvar['<STR_LIT>'] if<EOL>(precvar['<STR_LIT>'][x]['<STR_LIT>'] is not None)]<EOL>)<EOL>for vt in all_vartypes:<EOL><INDENT>thisvt_recfracs = []<EOL>for magbin_pv, magbin_rv in zip(magbinned_periodicvars,<EOL>magbinned_recovered_objects):<EOL><INDENT>thisbin_thisvt_recvars = [<EOL>x for x in magbin_rv<EOL>if (precvar['<STR_LIT>'][x]['<STR_LIT>'] == vt)<EOL>]<EOL>thisbin_thismagcol_recfrac = (<EOL>np.array(thisbin_thisvt_recvars).size /<EOL>magbin_pv.size<EOL>)<EOL>thisvt_recfracs.append(thisbin_thismagcol_recfrac)<EOL><DEDENT>plt.plot(magbinned_sdssr,<EOL>np.array(thisvt_recfracs),<EOL>marker='<STR_LIT:.>',<EOL>label='<STR_LIT:%s>' % vt,<EOL>ms=<NUM_LIT:0.0>)<EOL>magbinned_per_vartype_recfracs.append(np.array(thisvt_recfracs))<EOL><DEDENT>plt.plot(magbinned_sdssr, magbinned_recfrac,<EOL>marker='<STR_LIT:.>',ms=<NUM_LIT:0.0>, label='<STR_LIT>', color='<STR_LIT:k>')<EOL>plt.xlabel(r'<STR_LIT>')<EOL>plt.ylabel('<STR_LIT>')<EOL>plt.title('<STR_LIT>')<EOL>plt.ylim((<NUM_LIT:0>,<NUM_LIT:1>))<EOL>plt.legend(markerscale=<NUM_LIT>)<EOL>plt.savefig(<EOL>os.path.join(recplotdir,<EOL>'<STR_LIT>' % plotfile_ext),<EOL>dpi=<NUM_LIT:100>,<EOL>bbox_inches='<STR_LIT>'<EOL>)<EOL>plt.close('<STR_LIT:all>')<EOL>fig = plt.figure(figsize=(<NUM_LIT>*<NUM_LIT>,<NUM_LIT>*<NUM_LIT>))<EOL>all_aliastypes = recovered_status<EOL>for at in all_aliastypes:<EOL><INDENT>thisat_recfracs = []<EOL>for magbin_pv, magbin_rv in zip(magbinned_periodicvars,<EOL>magbinned_recovered_objects):<EOL><INDENT>thisbin_thisat_recvars = [<EOL>x for x in magbin_rv<EOL>if (precvar['<STR_LIT>'][x]['<STR_LIT>'][<NUM_LIT:0>] == at)<EOL>]<EOL>thisbin_thismagcol_recfrac = (<EOL>np.array(thisbin_thisat_recvars).size /<EOL>magbin_pv.size<EOL>)<EOL>thisat_recfracs.append(thisbin_thismagcol_recfrac)<EOL><DEDENT>plt.plot(magbinned_sdssr,<EOL>np.array(thisat_recfracs),<EOL>marker='<STR_LIT:.>',<EOL>label='<STR_LIT:%s>' % at,<EOL>ms=<NUM_LIT:0.0>)<EOL>magbinned_per_aliastype_recfracs.append(np.array(thisat_recfracs))<EOL><DEDENT>plt.plot(magbinned_sdssr, magbinned_recfrac,<EOL>marker='<STR_LIT:.>',ms=<NUM_LIT:0.0>, label='<STR_LIT>', color='<STR_LIT:k>')<EOL>plt.xlabel(r'<STR_LIT>')<EOL>plt.ylabel('<STR_LIT>')<EOL>plt.title('<STR_LIT>')<EOL>plt.ylim((<NUM_LIT:0>,<NUM_LIT:1>))<EOL>plt.legend(markerscale=<NUM_LIT>)<EOL>plt.savefig(<EOL>os.path.join(recplotdir,<EOL>'<STR_LIT>' % plotfile_ext),<EOL>dpi=<NUM_LIT:100>,<EOL>bbox_inches='<STR_LIT>'<EOL>)<EOL>plt.close('<STR_LIT:all>')<EOL>fig = plt.figure(figsize=(<NUM_LIT>*<NUM_LIT>,<NUM_LIT>*<NUM_LIT>))<EOL>plt.plot(periodbinned_periods, periodbinned_recfrac,<EOL>marker='<STR_LIT:.>',ms=<NUM_LIT:0.0>)<EOL>plt.xlabel('<STR_LIT>')<EOL>plt.ylabel('<STR_LIT>')<EOL>plt.title('<STR_LIT>')<EOL>plt.ylim((<NUM_LIT:0>,<NUM_LIT:1>))<EOL>plt.savefig(<EOL>os.path.join(recplotdir,<EOL>'<STR_LIT>' % plotfile_ext),<EOL>dpi=<NUM_LIT:100>,<EOL>bbox_inches='<STR_LIT>'<EOL>)<EOL>plt.close('<STR_LIT:all>')<EOL>fig = plt.figure(figsize=(<NUM_LIT>*<NUM_LIT>,<NUM_LIT>*<NUM_LIT>))<EOL>for magcol in magcols:<EOL><INDENT>thismagcol_recfracs = []<EOL>for periodbin_pv, periodbin_rv in zip(periodbinned_periodicvars,<EOL>periodbinned_recovered_objects):<EOL><INDENT>thisbin_thismagcol_recvars = [<EOL>x for x in periodbin_rv<EOL>if (precvar['<STR_LIT>'][x]['<STR_LIT>'] == magcol)<EOL>]<EOL>thisbin_thismagcol_recfrac = (<EOL>np.array(thisbin_thismagcol_recvars).size /<EOL>periodbin_pv.size<EOL>)<EOL>thismagcol_recfracs.append(thisbin_thismagcol_recfrac)<EOL><DEDENT>plt.plot(periodbinned_periods,<EOL>np.array(thismagcol_recfracs),<EOL>marker='<STR_LIT:.>',<EOL>label='<STR_LIT>' % magcol,<EOL>ms=<NUM_LIT:0.0>)<EOL>periodbinned_per_magcol_recfracs.append(np.array(thismagcol_recfracs))<EOL><DEDENT>plt.plot(periodbinned_periods, periodbinned_recfrac,<EOL>marker='<STR_LIT:.>',ms=<NUM_LIT:0.0>, label='<STR_LIT>', color='<STR_LIT:k>')<EOL>plt.xlabel(r'<STR_LIT>')<EOL>plt.ylabel('<STR_LIT>')<EOL>plt.title('<STR_LIT>')<EOL>plt.ylim((<NUM_LIT:0>,<NUM_LIT:1>))<EOL>plt.legend(markerscale=<NUM_LIT>)<EOL>plt.savefig(<EOL>os.path.join(recplotdir,<EOL>'<STR_LIT>' % plotfile_ext),<EOL>dpi=<NUM_LIT:100>,<EOL>bbox_inches='<STR_LIT>'<EOL>)<EOL>plt.close('<STR_LIT:all>')<EOL>fig = plt.figure(figsize=(<NUM_LIT>*<NUM_LIT>,<NUM_LIT>*<NUM_LIT>))<EOL>all_pfmethods = np.unique(<EOL>np.concatenate(<EOL>[np.unique(precvar['<STR_LIT>'][x]['<STR_LIT>'])<EOL>for x in precvar['<STR_LIT>']]<EOL>)<EOL>)<EOL>for pfm in all_pfmethods:<EOL><INDENT>thispf_recfracs = []<EOL>for periodbin_pv, periodbin_rv in zip(periodbinned_periodicvars,<EOL>periodbinned_recovered_objects):<EOL><INDENT>thisbin_thispf_recvars = [<EOL>x for x in periodbin_rv<EOL>if (precvar['<STR_LIT>'][x]['<STR_LIT>'] == pfm)<EOL>]<EOL>thisbin_thismagcol_recfrac = (<EOL>np.array(thisbin_thispf_recvars).size /<EOL>periodbin_pv.size<EOL>)<EOL>thispf_recfracs.append(thisbin_thismagcol_recfrac)<EOL><DEDENT>plt.plot(periodbinned_periods,<EOL>np.array(thispf_recfracs),<EOL>marker='<STR_LIT:.>',<EOL>label='<STR_LIT:%s>' % pfm.upper(),<EOL>ms=<NUM_LIT:0.0>)<EOL>periodbinned_per_pfmethod_recfracs.append(np.array(thispf_recfracs))<EOL><DEDENT>plt.plot(periodbinned_periods, periodbinned_recfrac,<EOL>marker='<STR_LIT:.>',ms=<NUM_LIT:0.0>, label='<STR_LIT>', color='<STR_LIT:k>')<EOL>plt.xlabel(r'<STR_LIT>')<EOL>plt.ylabel('<STR_LIT>')<EOL>plt.title('<STR_LIT>')<EOL>plt.ylim((<NUM_LIT:0>,<NUM_LIT:1>))<EOL>plt.legend(markerscale=<NUM_LIT>)<EOL>plt.savefig(<EOL>os.path.join(recplotdir,<EOL>'<STR_LIT>' % plotfile_ext),<EOL>dpi=<NUM_LIT:100>,<EOL>bbox_inches='<STR_LIT>'<EOL>)<EOL>plt.close('<STR_LIT:all>')<EOL>fig = plt.figure(figsize=(<NUM_LIT>*<NUM_LIT>,<NUM_LIT>*<NUM_LIT>))<EOL>all_vartypes = np.unique(<EOL>[(precvar['<STR_LIT>'][x]['<STR_LIT>'])<EOL>for x in precvar['<STR_LIT>'] if<EOL>(precvar['<STR_LIT>'][x]['<STR_LIT>'] is not None)]<EOL>)<EOL>for vt in all_vartypes:<EOL><INDENT>thisvt_recfracs = []<EOL>for periodbin_pv, periodbin_rv in zip(periodbinned_periodicvars,<EOL>periodbinned_recovered_objects):<EOL><INDENT>thisbin_thisvt_recvars = [<EOL>x for x in periodbin_rv<EOL>if (precvar['<STR_LIT>'][x]['<STR_LIT>'] == vt)<EOL>]<EOL>thisbin_thismagcol_recfrac = (<EOL>np.array(thisbin_thisvt_recvars).size /<EOL>periodbin_pv.size<EOL>)<EOL>thisvt_recfracs.append(thisbin_thismagcol_recfrac)<EOL><DEDENT>plt.plot(periodbinned_periods,<EOL>np.array(thisvt_recfracs),<EOL>marker='<STR_LIT:.>',<EOL>label='<STR_LIT:%s>' % vt,<EOL>ms=<NUM_LIT:0.0>)<EOL>periodbinned_per_vartype_recfracs.append(np.array(thisvt_recfracs))<EOL><DEDENT>plt.plot(periodbinned_periods, periodbinned_recfrac,<EOL>marker='<STR_LIT:.>',ms=<NUM_LIT:0.0>, label='<STR_LIT>', color='<STR_LIT:k>')<EOL>plt.xlabel(r'<STR_LIT>')<EOL>plt.ylabel('<STR_LIT>')<EOL>plt.title('<STR_LIT>')<EOL>plt.ylim((<NUM_LIT:0>,<NUM_LIT:1>))<EOL>plt.legend(markerscale=<NUM_LIT>)<EOL>plt.savefig(<EOL>os.path.join(recplotdir,<EOL>'<STR_LIT>' % plotfile_ext),<EOL>dpi=<NUM_LIT:100>,<EOL>bbox_inches='<STR_LIT>'<EOL>)<EOL>plt.close('<STR_LIT:all>')<EOL>fig = plt.figure(figsize=(<NUM_LIT>*<NUM_LIT>,<NUM_LIT>*<NUM_LIT>))<EOL>all_aliastypes = recovered_status<EOL>for at in all_aliastypes:<EOL><INDENT>thisat_recfracs = []<EOL>for periodbin_pv, periodbin_rv in zip(<EOL>periodbinned_periodicvars,<EOL>periodbinned_recovered_objects<EOL>):<EOL><INDENT>thisbin_thisat_recvars = [<EOL>x for x in periodbin_rv<EOL>if (precvar['<STR_LIT>'][x]['<STR_LIT>'][<NUM_LIT:0>] == at)<EOL>]<EOL>thisbin_thismagcol_recfrac = (<EOL>np.array(thisbin_thisat_recvars).size /<EOL>periodbin_pv.size<EOL>)<EOL>thisat_recfracs.append(thisbin_thismagcol_recfrac)<EOL><DEDENT>plt.plot(periodbinned_periods,<EOL>np.array(thisat_recfracs),<EOL>marker='<STR_LIT:.>',<EOL>label='<STR_LIT:%s>' % at,<EOL>ms=<NUM_LIT:0.0>)<EOL>periodbinned_per_aliastype_recfracs.append(np.array(thisat_recfracs))<EOL><DEDENT>plt.plot(periodbinned_periods, periodbinned_recfrac,<EOL>marker='<STR_LIT:.>',ms=<NUM_LIT:0.0>, label='<STR_LIT>', color='<STR_LIT:k>')<EOL>plt.xlabel(r'<STR_LIT>')<EOL>plt.ylabel('<STR_LIT>')<EOL>plt.title('<STR_LIT>')<EOL>plt.ylim((<NUM_LIT:0>,<NUM_LIT:1>))<EOL>plt.legend(markerscale=<NUM_LIT>)<EOL>plt.savefig(<EOL>os.path.join(recplotdir,<EOL>'<STR_LIT>' % plotfile_ext),<EOL>dpi=<NUM_LIT:100>,<EOL>bbox_inches='<STR_LIT>'<EOL>)<EOL>plt.close('<STR_LIT:all>')<EOL>fig = plt.figure(figsize=(<NUM_LIT>*<NUM_LIT>,<NUM_LIT>*<NUM_LIT>))<EOL>plt.plot(amplitudebinned_amplitudes, amplitudebinned_recfrac,<EOL>marker='<STR_LIT:.>',ms=<NUM_LIT:0.0>)<EOL>plt.xlabel('<STR_LIT>')<EOL>plt.ylabel('<STR_LIT>')<EOL>plt.title('<STR_LIT>')<EOL>plt.ylim((<NUM_LIT:0>,<NUM_LIT:1>))<EOL>plt.savefig(<EOL>os.path.join(recplotdir,<EOL>'<STR_LIT>' % plotfile_ext),<EOL>dpi=<NUM_LIT:100>,<EOL>bbox_inches='<STR_LIT>'<EOL>)<EOL>plt.close('<STR_LIT:all>')<EOL>fig = plt.figure(figsize=(<NUM_LIT>*<NUM_LIT>,<NUM_LIT>*<NUM_LIT>))<EOL>for magcol in magcols:<EOL><INDENT>thismagcol_recfracs = []<EOL>for amplitudebin_pv, amplitudebin_rv in zip(<EOL>amplitudebinned_periodicvars,<EOL>amplitudebinned_recovered_objects<EOL>):<EOL><INDENT>thisbin_thismagcol_recvars = [<EOL>x for x in amplitudebin_rv<EOL>if (precvar['<STR_LIT>'][x]['<STR_LIT>'] == magcol)<EOL>]<EOL>thisbin_thismagcol_recfrac = (<EOL>np.array(thisbin_thismagcol_recvars).size /<EOL>amplitudebin_pv.size<EOL>)<EOL>thismagcol_recfracs.append(thisbin_thismagcol_recfrac)<EOL><DEDENT>plt.plot(amplitudebinned_amplitudes,<EOL>np.array(thismagcol_recfracs),<EOL>marker='<STR_LIT:.>',<EOL>label='<STR_LIT>' % magcol,<EOL>ms=<NUM_LIT:0.0>)<EOL>amplitudebinned_per_magcol_recfracs.append(<EOL>np.array(thismagcol_recfracs)<EOL>)<EOL><DEDENT>plt.plot(amplitudebinned_amplitudes, amplitudebinned_recfrac,<EOL>marker='<STR_LIT:.>',ms=<NUM_LIT:0.0>, label='<STR_LIT>', color='<STR_LIT:k>')<EOL>plt.xlabel(r'<STR_LIT>')<EOL>plt.ylabel('<STR_LIT>')<EOL>plt.title('<STR_LIT>')<EOL>plt.ylim((<NUM_LIT:0>,<NUM_LIT:1>))<EOL>plt.legend(markerscale=<NUM_LIT>)<EOL>plt.savefig(<EOL>os.path.join(recplotdir,<EOL>'<STR_LIT>' % plotfile_ext),<EOL>dpi=<NUM_LIT:100>,<EOL>bbox_inches='<STR_LIT>'<EOL>)<EOL>plt.close('<STR_LIT:all>')<EOL>fig = plt.figure(figsize=(<NUM_LIT>*<NUM_LIT>,<NUM_LIT>*<NUM_LIT>))<EOL>all_pfmethods = np.unique(<EOL>np.concatenate(<EOL>[np.unique(precvar['<STR_LIT>'][x]['<STR_LIT>'])<EOL>for x in precvar['<STR_LIT>']]<EOL>)<EOL>)<EOL>for pfm in all_pfmethods:<EOL><INDENT>thispf_recfracs = []<EOL>for amplitudebin_pv, amplitudebin_rv in zip(<EOL>amplitudebinned_periodicvars,<EOL>amplitudebinned_recovered_objects<EOL>):<EOL><INDENT>thisbin_thispf_recvars = [<EOL>x for x in amplitudebin_rv<EOL>if (precvar['<STR_LIT>'][x]['<STR_LIT>'] == pfm)<EOL>]<EOL>thisbin_thismagcol_recfrac = (<EOL>np.array(thisbin_thispf_recvars).size /<EOL>amplitudebin_pv.size<EOL>)<EOL>thispf_recfracs.append(thisbin_thismagcol_recfrac)<EOL><DEDENT>plt.plot(amplitudebinned_amplitudes,<EOL>np.array(thispf_recfracs),<EOL>marker='<STR_LIT:.>',<EOL>label='<STR_LIT:%s>' % pfm.upper(),<EOL>ms=<NUM_LIT:0.0>)<EOL>amplitudebinned_per_pfmethod_recfracs.append(<EOL>np.array(thispf_recfracs)<EOL>)<EOL><DEDENT>plt.plot(amplitudebinned_amplitudes, amplitudebinned_recfrac,<EOL>marker='<STR_LIT:.>',ms=<NUM_LIT:0.0>, label='<STR_LIT>', color='<STR_LIT:k>')<EOL>plt.xlabel(r'<STR_LIT>')<EOL>plt.ylabel('<STR_LIT>')<EOL>plt.title('<STR_LIT>')<EOL>plt.ylim((<NUM_LIT:0>,<NUM_LIT:1>))<EOL>plt.legend(markerscale=<NUM_LIT>)<EOL>plt.savefig(<EOL>os.path.join(recplotdir,<EOL>'<STR_LIT>' % plotfile_ext),<EOL>dpi=<NUM_LIT:100>,<EOL>bbox_inches='<STR_LIT>'<EOL>)<EOL>plt.close('<STR_LIT:all>')<EOL>fig = plt.figure(figsize=(<NUM_LIT>*<NUM_LIT>,<NUM_LIT>*<NUM_LIT>))<EOL>all_vartypes = np.unique(<EOL>[(precvar['<STR_LIT>'][x]['<STR_LIT>'])<EOL>for x in precvar['<STR_LIT>'] if<EOL>(precvar['<STR_LIT>'][x]['<STR_LIT>'] is not None)]<EOL>)<EOL>for vt in all_vartypes:<EOL><INDENT>thisvt_recfracs = []<EOL>for amplitudebin_pv, amplitudebin_rv in zip(<EOL>amplitudebinned_periodicvars,<EOL>amplitudebinned_recovered_objects<EOL>):<EOL><INDENT>thisbin_thisvt_recvars = [<EOL>x for x in amplitudebin_rv<EOL>if (precvar['<STR_LIT>'][x]['<STR_LIT>'] == vt)<EOL>]<EOL>thisbin_thismagcol_recfrac = (<EOL>np.array(thisbin_thisvt_recvars).size /<EOL>amplitudebin_pv.size<EOL>)<EOL>thisvt_recfracs.append(thisbin_thismagcol_recfrac)<EOL><DEDENT>plt.plot(amplitudebinned_amplitudes,<EOL>np.array(thisvt_recfracs),<EOL>marker='<STR_LIT:.>',<EOL>label='<STR_LIT:%s>' % vt,<EOL>ms=<NUM_LIT:0.0>)<EOL>amplitudebinned_per_vartype_recfracs.append(<EOL>np.array(thisvt_recfracs)<EOL>)<EOL><DEDENT>plt.plot(amplitudebinned_amplitudes, amplitudebinned_recfrac,<EOL>marker='<STR_LIT:.>',ms=<NUM_LIT:0.0>, label='<STR_LIT>', color='<STR_LIT:k>')<EOL>plt.xlabel(r'<STR_LIT>')<EOL>plt.ylabel('<STR_LIT>')<EOL>plt.title('<STR_LIT>')<EOL>plt.ylim((<NUM_LIT:0>,<NUM_LIT:1>))<EOL>plt.legend(markerscale=<NUM_LIT>)<EOL>plt.savefig(<EOL>os.path.join(recplotdir,<EOL>'<STR_LIT>' % plotfile_ext),<EOL>dpi=<NUM_LIT:100>,<EOL>bbox_inches='<STR_LIT>'<EOL>)<EOL>plt.close('<STR_LIT:all>')<EOL>fig = plt.figure(figsize=(<NUM_LIT>*<NUM_LIT>,<NUM_LIT>*<NUM_LIT>))<EOL>all_aliastypes = recovered_status<EOL>for at in all_aliastypes:<EOL><INDENT>thisat_recfracs = []<EOL>for amplitudebin_pv, amplitudebin_rv in zip(<EOL>amplitudebinned_periodicvars,<EOL>amplitudebinned_recovered_objects<EOL>):<EOL><INDENT>thisbin_thisat_recvars = [<EOL>x for x in amplitudebin_rv<EOL>if (precvar['<STR_LIT>'][x]['<STR_LIT>'][<NUM_LIT:0>] == at)<EOL>]<EOL>thisbin_thismagcol_recfrac = (<EOL>np.array(thisbin_thisat_recvars).size /<EOL>amplitudebin_pv.size<EOL>)<EOL>thisat_recfracs.append(thisbin_thismagcol_recfrac)<EOL><DEDENT>plt.plot(amplitudebinned_amplitudes,<EOL>np.array(thisat_recfracs),<EOL>marker='<STR_LIT:.>',<EOL>label='<STR_LIT:%s>' % at,<EOL>ms=<NUM_LIT:0.0>)<EOL>amplitudebinned_per_aliastype_recfracs.append(<EOL>np.array(thisat_recfracs)<EOL>)<EOL><DEDENT>plt.plot(amplitudebinned_amplitudes, amplitudebinned_recfrac,<EOL>marker='<STR_LIT:.>',ms=<NUM_LIT:0.0>, label='<STR_LIT>', color='<STR_LIT:k>')<EOL>plt.xlabel(r'<STR_LIT>')<EOL>plt.ylabel('<STR_LIT>')<EOL>plt.title('<STR_LIT>')<EOL>plt.ylim((<NUM_LIT:0>,<NUM_LIT:1>))<EOL>plt.legend(markerscale=<NUM_LIT>)<EOL>plt.savefig(<EOL>os.path.join(recplotdir,<EOL>'<STR_LIT>' % plotfile_ext),<EOL>dpi=<NUM_LIT:100>,<EOL>bbox_inches='<STR_LIT>'<EOL>)<EOL>plt.close('<STR_LIT:all>')<EOL>fig = plt.figure(figsize=(<NUM_LIT>*<NUM_LIT>,<NUM_LIT>*<NUM_LIT>))<EOL>plt.plot(ndetbinned_ndets, ndetbinned_recfrac,<EOL>marker='<STR_LIT:.>',ms=<NUM_LIT:0.0>)<EOL>plt.xlabel('<STR_LIT>')<EOL>plt.ylabel('<STR_LIT>')<EOL>plt.title('<STR_LIT>')<EOL>plt.ylim((<NUM_LIT:0>,<NUM_LIT:1>))<EOL>plt.savefig(<EOL>os.path.join(recplotdir,<EOL>'<STR_LIT>' % plotfile_ext),<EOL>dpi=<NUM_LIT:100>,<EOL>bbox_inches='<STR_LIT>'<EOL>)<EOL>plt.close('<STR_LIT:all>')<EOL>fig = plt.figure(figsize=(<NUM_LIT>*<NUM_LIT>,<NUM_LIT>*<NUM_LIT>))<EOL>for magcol in magcols:<EOL><INDENT>thismagcol_recfracs = []<EOL>for ndetbin_pv, ndetbin_rv in zip(ndetbinned_periodicvars,<EOL>ndetbinned_recovered_objects):<EOL><INDENT>thisbin_thismagcol_recvars = [<EOL>x for x in ndetbin_rv<EOL>if (precvar['<STR_LIT>'][x]['<STR_LIT>'] == magcol)<EOL>]<EOL>thisbin_thismagcol_recfrac = (<EOL>np.array(thisbin_thismagcol_recvars).size /<EOL>ndetbin_pv.size<EOL>)<EOL>thismagcol_recfracs.append(thisbin_thismagcol_recfrac)<EOL><DEDENT>plt.plot(ndetbinned_ndets,<EOL>np.array(thismagcol_recfracs),<EOL>marker='<STR_LIT:.>',<EOL>label='<STR_LIT>' % magcol,<EOL>ms=<NUM_LIT:0.0>)<EOL>ndetbinned_per_magcol_recfracs.append(<EOL>np.array(thismagcol_recfracs)<EOL>)<EOL><DEDENT>plt.plot(ndetbinned_ndets, ndetbinned_recfrac,<EOL>marker='<STR_LIT:.>',ms=<NUM_LIT:0.0>, label='<STR_LIT>', color='<STR_LIT:k>')<EOL>plt.xlabel(r'<STR_LIT>')<EOL>plt.ylabel('<STR_LIT>')<EOL>plt.title('<STR_LIT>')<EOL>plt.ylim((<NUM_LIT:0>,<NUM_LIT:1>))<EOL>plt.legend(markerscale=<NUM_LIT>)<EOL>plt.savefig(<EOL>os.path.join(recplotdir,<EOL>'<STR_LIT>' % plotfile_ext),<EOL>dpi=<NUM_LIT:100>,<EOL>bbox_inches='<STR_LIT>'<EOL>)<EOL>plt.close('<STR_LIT:all>')<EOL>fig = plt.figure(figsize=(<NUM_LIT>*<NUM_LIT>,<NUM_LIT>*<NUM_LIT>))<EOL>all_pfmethods = np.unique(<EOL>np.concatenate(<EOL>[np.unique(precvar['<STR_LIT>'][x]['<STR_LIT>'])<EOL>for x in precvar['<STR_LIT>']]<EOL>)<EOL>)<EOL>for pfm in all_pfmethods:<EOL><INDENT>thispf_recfracs = []<EOL>for ndetbin_pv, ndetbin_rv in zip(ndetbinned_periodicvars,<EOL>ndetbinned_recovered_objects):<EOL><INDENT>thisbin_thispf_recvars = [<EOL>x for x in ndetbin_rv<EOL>if (precvar['<STR_LIT>'][x]['<STR_LIT>'] == pfm)<EOL>]<EOL>thisbin_thismagcol_recfrac = (<EOL>np.array(thisbin_thispf_recvars).size /<EOL>ndetbin_pv.size<EOL>)<EOL>thispf_recfracs.append(thisbin_thismagcol_recfrac)<EOL><DEDENT>plt.plot(ndetbinned_ndets,<EOL>np.array(thispf_recfracs),<EOL>marker='<STR_LIT:.>',<EOL>label='<STR_LIT:%s>' % pfm.upper(),<EOL>ms=<NUM_LIT:0.0>)<EOL>ndetbinned_per_pfmethod_recfracs.append(<EOL>np.array(thispf_recfracs)<EOL>)<EOL><DEDENT>plt.plot(ndetbinned_ndets, ndetbinned_recfrac,<EOL>marker='<STR_LIT:.>',ms=<NUM_LIT:0.0>, label='<STR_LIT>', color='<STR_LIT:k>')<EOL>plt.xlabel(r'<STR_LIT>')<EOL>plt.ylabel('<STR_LIT>')<EOL>plt.title('<STR_LIT>')<EOL>plt.ylim((<NUM_LIT:0>,<NUM_LIT:1>))<EOL>plt.legend(markerscale=<NUM_LIT>)<EOL>plt.savefig(<EOL>os.path.join(recplotdir,<EOL>'<STR_LIT>' % plotfile_ext),<EOL>dpi=<NUM_LIT:100>,<EOL>bbox_inches='<STR_LIT>'<EOL>)<EOL>plt.close('<STR_LIT:all>')<EOL>fig = plt.figure(figsize=(<NUM_LIT>*<NUM_LIT>,<NUM_LIT>*<NUM_LIT>))<EOL>all_vartypes = np.unique(<EOL>[(precvar['<STR_LIT>'][x]['<STR_LIT>'])<EOL>for x in precvar['<STR_LIT>'] if<EOL>(precvar['<STR_LIT>'][x]['<STR_LIT>'] in PERIODIC_VARTYPES)]<EOL>)<EOL>for vt in all_vartypes:<EOL><INDENT>thisvt_recfracs = []<EOL>for ndetbin_pv, ndetbin_rv in zip(ndetbinned_periodicvars,<EOL>ndetbinned_recovered_objects):<EOL><INDENT>thisbin_thisvt_recvars = [<EOL>x for x in ndetbin_rv<EOL>if (precvar['<STR_LIT>'][x]['<STR_LIT>'] == vt)<EOL>]<EOL>thisbin_thismagcol_recfrac = (<EOL>np.array(thisbin_thisvt_recvars).size /<EOL>ndetbin_pv.size<EOL>)<EOL>thisvt_recfracs.append(thisbin_thismagcol_recfrac)<EOL><DEDENT>plt.plot(ndetbinned_ndets,<EOL>np.array(thisvt_recfracs),<EOL>marker='<STR_LIT:.>',<EOL>label='<STR_LIT:%s>' % vt,<EOL>ms=<NUM_LIT:0.0>)<EOL>ndetbinned_per_vartype_recfracs.append(<EOL>np.array(thisvt_recfracs)<EOL>)<EOL><DEDENT>plt.plot(ndetbinned_ndets, ndetbinned_recfrac,<EOL>marker='<STR_LIT:.>',ms=<NUM_LIT:0.0>, label='<STR_LIT>', color='<STR_LIT:k>')<EOL>plt.xlabel(r'<STR_LIT>')<EOL>plt.ylabel('<STR_LIT>')<EOL>plt.title('<STR_LIT>')<EOL>plt.ylim((<NUM_LIT:0>,<NUM_LIT:1>))<EOL>plt.legend(markerscale=<NUM_LIT>)<EOL>plt.savefig(<EOL>os.path.join(recplotdir,<EOL>'<STR_LIT>' % plotfile_ext),<EOL>dpi=<NUM_LIT:100>,<EOL>bbox_inches='<STR_LIT>'<EOL>)<EOL>plt.close('<STR_LIT:all>')<EOL>fig = plt.figure(figsize=(<NUM_LIT>*<NUM_LIT>,<NUM_LIT>*<NUM_LIT>))<EOL>all_aliastypes = recovered_status<EOL>for at in all_aliastypes:<EOL><INDENT>thisat_recfracs = []<EOL>for ndetbin_pv, ndetbin_rv in zip(ndetbinned_periodicvars,<EOL>ndetbinned_recovered_objects):<EOL><INDENT>thisbin_thisat_recvars = [<EOL>x for x in ndetbin_rv<EOL>if (precvar['<STR_LIT>'][x]['<STR_LIT>'][<NUM_LIT:0>] == at)<EOL>]<EOL>thisbin_thismagcol_recfrac = (<EOL>np.array(thisbin_thisat_recvars).size /<EOL>ndetbin_pv.size<EOL>)<EOL>thisat_recfracs.append(thisbin_thismagcol_recfrac)<EOL><DEDENT>plt.plot(ndetbinned_ndets,<EOL>np.array(thisat_recfracs),<EOL>marker='<STR_LIT:.>',<EOL>label='<STR_LIT:%s>' % at,<EOL>ms=<NUM_LIT:0.0>)<EOL>ndetbinned_per_aliastype_recfracs.append(<EOL>np.array(thisat_recfracs)<EOL>)<EOL><DEDENT>plt.plot(ndetbinned_ndets, ndetbinned_recfrac,<EOL>marker='<STR_LIT:.>',ms=<NUM_LIT:0.0>, label='<STR_LIT>', color='<STR_LIT:k>')<EOL>plt.xlabel(r'<STR_LIT>')<EOL>plt.ylabel('<STR_LIT>')<EOL>plt.title('<STR_LIT>')<EOL>plt.ylim((<NUM_LIT:0>,<NUM_LIT:1>))<EOL>plt.legend(markerscale=<NUM_LIT>)<EOL>plt.savefig(<EOL>os.path.join(recplotdir,<EOL>'<STR_LIT>' % plotfile_ext),<EOL>dpi=<NUM_LIT:100>,<EOL>bbox_inches='<STR_LIT>'<EOL>)<EOL>plt.close('<STR_LIT:all>')<EOL>outdict['<STR_LIT>'] = (<EOL>magbinned_per_magcol_recfracs<EOL>)<EOL>outdict['<STR_LIT>'] = (<EOL>magbinned_per_pfmethod_recfracs<EOL>)<EOL>outdict['<STR_LIT>'] = (<EOL>magbinned_per_vartype_recfracs<EOL>)<EOL>outdict['<STR_LIT>'] = (<EOL>magbinned_per_aliastype_recfracs<EOL>)<EOL>outdict['<STR_LIT>'] = (<EOL>periodbinned_per_magcol_recfracs<EOL>)<EOL>outdict['<STR_LIT>'] = (<EOL>periodbinned_per_pfmethod_recfracs<EOL>)<EOL>outdict['<STR_LIT>'] = (<EOL>periodbinned_per_vartype_recfracs<EOL>)<EOL>outdict['<STR_LIT>'] = (<EOL>periodbinned_per_aliastype_recfracs<EOL>)<EOL>outdict['<STR_LIT>'] = (<EOL>amplitudebinned_per_magcol_recfracs<EOL>)<EOL>outdict['<STR_LIT>'] = (<EOL>amplitudebinned_per_pfmethod_recfracs<EOL>)<EOL>outdict['<STR_LIT>'] = (<EOL>amplitudebinned_per_vartype_recfracs<EOL>)<EOL>outdict['<STR_LIT>'] = (<EOL>amplitudebinned_per_aliastype_recfracs<EOL>)<EOL>outdict['<STR_LIT>'] = (<EOL>ndetbinned_per_magcol_recfracs<EOL>)<EOL>outdict['<STR_LIT>'] = (<EOL>ndetbinned_per_pfmethod_recfracs<EOL>)<EOL>outdict['<STR_LIT>'] = (<EOL>ndetbinned_per_vartype_recfracs<EOL>)<EOL>outdict['<STR_LIT>'] = (<EOL>ndetbinned_per_aliastype_recfracs<EOL>)<EOL>overall_recvars_per_pfmethod = []<EOL>for pfm in all_pfmethods:<EOL><INDENT>thispfm_recvars = np.array([<EOL>x for x in precvar['<STR_LIT>'] if<EOL>((x in recovered_periodicvars) and<EOL>(precvar['<STR_LIT>'][x]['<STR_LIT>'] == pfm))<EOL>])<EOL>overall_recvars_per_pfmethod.append(thispfm_recvars)<EOL><DEDENT>overall_recvars_per_vartype = []<EOL>for vt in all_vartypes:<EOL><INDENT>thisvt_recvars = np.array([<EOL>x for x in precvar['<STR_LIT>'] if<EOL>((x in recovered_periodicvars) and<EOL>(precvar['<STR_LIT>'][x]['<STR_LIT>'] == vt))<EOL>])<EOL>overall_recvars_per_vartype.append(thisvt_recvars)<EOL><DEDENT>overall_recvars_per_magcol = []<EOL>for mc in magcols:<EOL><INDENT>thismc_recvars = np.array([<EOL>x for x in precvar['<STR_LIT>'] if<EOL>((x in recovered_periodicvars) and<EOL>(precvar['<STR_LIT>'][x]['<STR_LIT>'] == mc))<EOL>])<EOL>overall_recvars_per_magcol.append(thismc_recvars)<EOL><DEDENT>overall_recvars_per_aliastype = []<EOL>for at in all_aliastypes:<EOL><INDENT>thisat_recvars = np.array([<EOL>x for x in precvar['<STR_LIT>'] if<EOL>((x in recovered_periodicvars) and<EOL>(precvar['<STR_LIT>'][x]['<STR_LIT>'] == at))<EOL>])<EOL>overall_recvars_per_aliastype.append(thisat_recvars)<EOL><DEDENT>outdict['<STR_LIT>'] = np.array([<EOL>x.size/actual_periodicvars.size for x in overall_recvars_per_pfmethod<EOL>])<EOL>outdict['<STR_LIT>'] = np.array([<EOL>x.size/actual_periodicvars.size for x in overall_recvars_per_vartype<EOL>])<EOL>outdict['<STR_LIT>'] = np.array([<EOL>x.size/actual_periodicvars.size for x in overall_recvars_per_magcol<EOL>])<EOL>outdict['<STR_LIT>'] = np.array([<EOL>x.size/actual_periodicvars.size for x in overall_recvars_per_aliastype<EOL>])<EOL>fig = plt.figure(figsize=(<NUM_LIT>*<NUM_LIT>,<NUM_LIT>*<NUM_LIT>))<EOL>xt = np.arange(len(all_pfmethods))<EOL>xl = all_pfmethods<EOL>plt.barh(xt, outdict['<STR_LIT>'], <NUM_LIT>)<EOL>plt.yticks(xt, xl)<EOL>plt.xlabel('<STR_LIT>')<EOL>plt.ylabel('<STR_LIT>')<EOL>plt.title('<STR_LIT>')<EOL>plt.savefig(<EOL>os.path.join(recplotdir,<EOL>'<STR_LIT>' % plotfile_ext),<EOL>dpi=<NUM_LIT:100>,<EOL>bbox_inches='<STR_LIT>'<EOL>)<EOL>plt.close('<STR_LIT:all>')<EOL>fig = plt.figure(figsize=(<NUM_LIT>*<NUM_LIT>,<NUM_LIT>*<NUM_LIT>))<EOL>xt = np.arange(len(magcols))<EOL>xl = magcols<EOL>plt.barh(xt, outdict['<STR_LIT>'], <NUM_LIT>)<EOL>plt.yticks(xt, xl)<EOL>plt.xlabel('<STR_LIT>')<EOL>plt.ylabel('<STR_LIT>')<EOL>plt.title('<STR_LIT>')<EOL>plt.savefig(<EOL>os.path.join(recplotdir,<EOL>'<STR_LIT>' % plotfile_ext),<EOL>dpi=<NUM_LIT:100>,<EOL>bbox_inches='<STR_LIT>'<EOL>)<EOL>plt.close('<STR_LIT:all>')<EOL>fig = plt.figure(figsize=(<NUM_LIT>*<NUM_LIT>,<NUM_LIT>*<NUM_LIT>))<EOL>xt = np.arange(len(all_aliastypes))<EOL>xl = all_aliastypes<EOL>plt.barh(xt, outdict['<STR_LIT>'], <NUM_LIT>)<EOL>plt.yticks(xt, xl)<EOL>plt.xlabel('<STR_LIT>')<EOL>plt.ylabel('<STR_LIT>')<EOL>plt.title('<STR_LIT>')<EOL>plt.savefig(<EOL>os.path.join(recplotdir,<EOL>'<STR_LIT>' % plotfile_ext),<EOL>dpi=<NUM_LIT:100>,<EOL>bbox_inches='<STR_LIT>'<EOL>)<EOL>plt.close('<STR_LIT:all>')<EOL>fig = plt.figure(figsize=(<NUM_LIT>*<NUM_LIT>,<NUM_LIT>*<NUM_LIT>))<EOL>xt = np.arange(len(all_vartypes))<EOL>xl = all_vartypes<EOL>plt.barh(xt, outdict['<STR_LIT>'], <NUM_LIT>)<EOL>plt.yticks(xt, xl)<EOL>plt.xlabel('<STR_LIT>')<EOL>plt.ylabel('<STR_LIT>')<EOL>plt.title('<STR_LIT>')<EOL>plt.savefig(<EOL>os.path.join(recplotdir,<EOL>'<STR_LIT>' % plotfile_ext),<EOL>dpi=<NUM_LIT:100>,<EOL>bbox_inches='<STR_LIT>'<EOL>)<EOL>plt.close('<STR_LIT:all>')<EOL>notvariable_recovered_periods = np.concatenate([<EOL>precvar['<STR_LIT>'][x]['<STR_LIT>']<EOL>for x in precvar['<STR_LIT>'] if<EOL>(precvar['<STR_LIT>'][x]['<STR_LIT>'] is None)<EOL>])<EOL>notvariable_recovered_lspvals = np.concatenate([<EOL>precvar['<STR_LIT>'][x]['<STR_LIT>']<EOL>for x in precvar['<STR_LIT>'] if<EOL>(precvar['<STR_LIT>'][x]['<STR_LIT>'] is None)<EOL>])<EOL>sortind = np.argsort(notvariable_recovered_periods)<EOL>notvariable_recovered_periods = notvariable_recovered_periods[sortind]<EOL>notvariable_recovered_lspvals = notvariable_recovered_lspvals[sortind]<EOL>outdict['<STR_LIT>'] = notvariable_recovered_periods<EOL>outdict['<STR_LIT>'] = notvariable_recovered_lspvals<EOL>fig = plt.figure(figsize=(<NUM_LIT>*<NUM_LIT>,<NUM_LIT>*<NUM_LIT>))<EOL>plt.plot(notvariable_recovered_periods,<EOL>notvariable_recovered_lspvals,<EOL>ms=<NUM_LIT:1.0>,linestyle='<STR_LIT:none>',marker='<STR_LIT:.>')<EOL>plt.xscale('<STR_LIT>')<EOL>plt.xlabel('<STR_LIT>')<EOL>plt.ylabel('<STR_LIT>')<EOL>plt.title('<STR_LIT>')<EOL>plt.savefig(<EOL>os.path.join(recplotdir,<EOL>'<STR_LIT>' % plotfile_ext),<EOL>dpi=<NUM_LIT:100>,<EOL>bbox_inches='<STR_LIT>'<EOL>)<EOL>plt.close('<STR_LIT:all>')<EOL>fig = plt.figure(figsize=(<NUM_LIT>*<NUM_LIT>,<NUM_LIT>*<NUM_LIT>))<EOL>plt.hist(notvariable_recovered_periods,bins=np.arange(<NUM_LIT>,<NUM_LIT>,<NUM_LIT>),<EOL>histtype='<STR_LIT>')<EOL>plt.xscale('<STR_LIT>')<EOL>plt.xlabel('<STR_LIT>')<EOL>plt.ylabel('<STR_LIT>')<EOL>plt.title('<STR_LIT>')<EOL>plt.savefig(<EOL>os.path.join(recplotdir,<EOL>'<STR_LIT>' % plotfile_ext),<EOL>dpi=<NUM_LIT:100>,<EOL>bbox_inches='<STR_LIT>'<EOL>)<EOL>plt.close('<STR_LIT:all>')<EOL>outfile = os.path.join(simbasedir, '<STR_LIT>')<EOL>with open(outfile,'<STR_LIT:wb>') as outfd:<EOL><INDENT>pickle.dump(outdict, outfd, pickle.HIGHEST_PROTOCOL)<EOL><DEDENT>return outdict<EOL>

This plots the results of periodic var recovery.

    This function makes plots for periodicvar recovered fraction as a function
    of:

    - magbin
    - periodbin
    - amplitude of variability
    - ndet

    with plot lines broken down by:

    - magcol
    - periodfinder
    - vartype
    - recovery status

    The kwargs `magbins`, `periodbins`, `amplitudebins`, and `ndetbins` can be
    used to set the bin lists as needed. The kwarg `minbinsize` controls how
    many elements per bin are required to accept a bin in processing its
    recovery characteristics for mags, periods, amplitudes, and ndets.

    Parameters
    ----------

    precvar_results : dict or str
        This is either a dict returned by parallel_periodicvar_recovery or the
        pickle created by that function.

    aliases_count_as_recovered : list of str or 'all'
        This is used to set which kinds of aliases this function considers as
        'recovered' objects. Normally, we require that recovered objects have a
        recovery status of 'actual' to indicate the actual period was
        recovered. To change this default behavior, aliases_count_as_recovered
        can be set to a list of alias status strings that should be considered
        as 'recovered' objects as well. Choose from the following alias types::

          'twice'                    recovered_p = 2.0*actual_p
          'half'                     recovered_p = 0.5*actual_p
          'ratio_over_1plus'         recovered_p = actual_p/(1.0+actual_p)
          'ratio_over_1minus'        recovered_p = actual_p/(1.0-actual_p)
          'ratio_over_1plus_twice'   recovered_p = actual_p/(1.0+2.0*actual_p)
          'ratio_over_1minus_twice'  recovered_p = actual_p/(1.0-2.0*actual_p)
          'ratio_over_1plus_thrice'  recovered_p = actual_p/(1.0+3.0*actual_p)
          'ratio_over_1minus_thrice' recovered_p = actual_p/(1.0-3.0*actual_p)
          'ratio_over_minus1'        recovered_p = actual_p/(actual_p - 1.0)
          'ratio_over_twice_minus1'  recovered_p = actual_p/(2.0*actual_p - 1.0)

        or set `aliases_count_as_recovered='all'` to include all of the above in
        the 'recovered' periodic var list.

    magbins : np.array
        The magnitude bins to plot the recovery rate results over. If None, the
        default mag bins will be used: `np.arange(8.0,16.25,0.25)`.

    periodbins : np.array
        The period bins to plot the recovery rate results over. If None, the
        default period bins will be used: `np.arange(0.0,500.0,0.5)`.

    amplitudebins : np.array
        The variability amplitude bins to plot the recovery rate results
        over. If None, the default amplitude bins will be used:
        `np.arange(0.0,2.0,0.05)`.

    ndetbins : np.array
        The ndet bins to plot the recovery rate results over. If None, the
        default ndet bins will be used: `np.arange(0.0,60000.0,1000.0)`.

    minbinsize : int
        The minimum number of objects per bin required to plot a bin and its
        recovery fraction on the plot.

    plotfile_ext : {'png','pdf'}
        Sets the plot output files' extension.

    Returns
    -------

    dict
        A dict containing recovery fraction statistics and the paths to each of
        the plots made.


c = paramiko.client.SSHClient()<EOL>c.load_system_host_keys()<EOL>c.set_missing_host_key_policy(paramiko.client.AutoAddPolicy)<EOL>privatekey = paramiko.RSAKey.from_private_key_file(keypem_file)<EOL>try:<EOL><INDENT>c.connect(ip_address,<EOL>pkey=privatekey,<EOL>username='<STR_LIT>')<EOL>return c<EOL><DEDENT>except Exception as e:<EOL><INDENT>LOGEXCEPTION('<STR_LIT>'<EOL>'<STR_LIT>' %<EOL>(ip_address, keypem_file, username))<EOL>if raiseonfail:<EOL><INDENT>raise<EOL><DEDENT>return None<EOL><DEDENT>

This opens an SSH connection to the EC2 instance at `ip_address`.

    Parameters
    ----------

    ip_address : str
        IP address of the AWS EC2 instance to connect to.

    keypem_file : str
        The path to the keypair PEM file generated by AWS to allow SSH
        connections.

    username : str
        The username to use to login to the EC2 instance.

    raiseonfail : bool
        If True, will re-raise whatever Exception caused the operation to fail
        and break out immediately.

    Returns
    -------

    paramiko.SSHClient
        This has all the usual `paramiko` functionality:

        - Use `SSHClient.exec_command(command, environment=None)` to exec a
          shell command.

        - Use `SSHClient.open_sftp()` to get a `SFTPClient` for the server. Then
          call SFTPClient.get() and .put() to copy files from and to the server.


if not client:<EOL><INDENT>client = boto3.client('<STR_LIT>')<EOL><DEDENT>try:<EOL><INDENT>client.download_file(bucket, filename, local_file)<EOL>return local_file<EOL><DEDENT>except Exception as e:<EOL><INDENT>if altexts is not None:<EOL><INDENT>for alt_extension in altexts:<EOL><INDENT>split_ext = os.path.splitext(filename)<EOL>check_file = split_ext[<NUM_LIT:0>] + alt_extension<EOL>try:<EOL><INDENT>client.download_file(<EOL>bucket,<EOL>check_file,<EOL>local_file.replace(split_ext[-<NUM_LIT:1>],<EOL>alt_extension)<EOL>)<EOL>return local_file.replace(split_ext[-<NUM_LIT:1>],<EOL>alt_extension)<EOL><DEDENT>except Exception as e:<EOL><INDENT>pass<EOL><DEDENT><DEDENT><DEDENT>else:<EOL><INDENT>LOGEXCEPTION('<STR_LIT>' % (bucket, filename))<EOL>if raiseonfail:<EOL><INDENT>raise<EOL><DEDENT>return None<EOL><DEDENT><DEDENT>

This gets a file from an S3 bucket.

    Parameters
    ----------

    bucket : str
        The AWS S3 bucket name.

    filename : str
        The full filename of the file to get from the bucket

    local_file : str
        Path to where the downloaded file will be stored.

    altexts : None or list of str
        If not None, this is a list of alternate extensions to try for the file
        other than the one provided in `filename`. For example, to get anything
        that's an .sqlite where .sqlite.gz is expected, use altexts=[''] to
        strip the .gz.

    client : boto3.Client or None
        If None, this function will instantiate a new `boto3.Client` object to
        use in its operations. Alternatively, pass in an existing `boto3.Client`
        instance to re-use it here.

    raiseonfail : bool
        If True, will re-raise whatever Exception caused the operation to fail
        and break out immediately.

    Returns
    -------

    str
        Path to the downloaded filename or None if the download was
        unsuccessful.


bucket_item = url.replace('<STR_LIT>','<STR_LIT>')<EOL>bucket_item = bucket_item.split('<STR_LIT:/>')<EOL>bucket = bucket_item[<NUM_LIT:0>]<EOL>filekey = '<STR_LIT:/>'.join(bucket_item[<NUM_LIT:1>:])<EOL>return s3_get_file(bucket,<EOL>filekey,<EOL>bucket_item[-<NUM_LIT:1>],<EOL>altexts=altexts,<EOL>client=client,<EOL>raiseonfail=raiseonfail)<EOL>

This gets a file from an S3 bucket based on its s3:// URL.

    Parameters
    ----------

    url : str
        S3 URL to download. This should begin with 's3://'.

    altexts : None or list of str
        If not None, this is a list of alternate extensions to try for the file
        other than the one provided in `filename`. For example, to get anything
        that's an .sqlite where .sqlite.gz is expected, use altexts=[''] to
        strip the .gz.

    client : boto3.Client or None
        If None, this function will instantiate a new `boto3.Client` object to
        use in its operations. Alternatively, pass in an existing `boto3.Client`
        instance to re-use it here.

    raiseonfail : bool
        If True, will re-raise whatever Exception caused the operation to fail
        and break out immediately.

    Returns
    -------

    str
        Path to the downloaded filename or None if the download was
        unsuccessful. The file will be downloaded into the current working
        directory and will have a filename == basename of the file on S3.


def s3_put_file(local_file, bucket, client=None, raiseonfail=False):

if not client:<EOL><INDENT>client = boto3.client('<STR_LIT>')<EOL><DEDENT>try:<EOL><INDENT>client.upload_file(local_file, bucket, os.path.basename(local_file))<EOL>return '<STR_LIT>' % (bucket, os.path.basename(local_file))<EOL><DEDENT>except Exception as e:<EOL><INDENT>LOGEXCEPTION('<STR_LIT>' % (local_file,<EOL>bucket))<EOL>if raiseonfail:<EOL><INDENT>raise<EOL><DEDENT>return None<EOL><DEDENT>

This uploads a file to S3.

    Parameters
    ----------

    local_file : str
        Path to the file to upload to S3.

    bucket : str
        The AWS S3 bucket to upload the file to.

    client : boto3.Client or None
        If None, this function will instantiate a new `boto3.Client` object to
        use in its operations. Alternatively, pass in an existing `boto3.Client`
        instance to re-use it here.

    raiseonfail : bool
        If True, will re-raise whatever Exception caused the operation to fail
        and break out immediately.

    Returns
    -------

    str or None
        If the file upload is successful, returns the s3:// URL of the uploaded
        file. If it failed, will return None.


def s3_delete_file(bucket, filename, client=None, raiseonfail=False):

if not client:<EOL><INDENT>client = boto3.client('<STR_LIT>')<EOL><DEDENT>try:<EOL><INDENT>resp = client.delete_object(Bucket=bucket, Key=filename)<EOL>if not resp:<EOL><INDENT>LOGERROR('<STR_LIT>' % (filename,<EOL>bucket))<EOL><DEDENT>else:<EOL><INDENT>return resp['<STR_LIT>']<EOL><DEDENT><DEDENT>except Exception as e:<EOL><INDENT>LOGEXCEPTION('<STR_LIT>' % (filename,<EOL>bucket))<EOL>if raiseonfail:<EOL><INDENT>raise<EOL><DEDENT>return None<EOL><DEDENT>

This deletes a file from S3.

    Parameters
    ----------

    bucket : str
        The AWS S3 bucket to delete the file from.

    filename : str
        The full file name of the file to delete, including any prefixes.

    client : boto3.Client or None
        If None, this function will instantiate a new `boto3.Client` object to
        use in its operations. Alternatively, pass in an existing `boto3.Client`
        instance to re-use it here.

    raiseonfail : bool
        If True, will re-raise whatever Exception caused the operation to fail
        and break out immediately.

    Returns
    -------

    str or None
        If the file was successfully deleted, will return the delete-marker
        (https://docs.aws.amazon.com/AmazonS3/latest/dev/DeleteMarker.html). If
        it wasn't, returns None


def sqs_create_queue(queue_name, options=None, client=None):

if not client:<EOL><INDENT>client = boto3.client('<STR_LIT>')<EOL><DEDENT>try:<EOL><INDENT>if isinstance(options, dict):<EOL><INDENT>resp = client.create_queue(QueueName=queue_name, Attributes=options)<EOL><DEDENT>else:<EOL><INDENT>resp = client.create_queue(QueueName=queue_name)<EOL><DEDENT>if resp is not None:<EOL><INDENT>return {'<STR_LIT:url>':resp['<STR_LIT>'],<EOL>'<STR_LIT:name>':queue_name}<EOL><DEDENT>else:<EOL><INDENT>LOGERROR('<STR_LIT>'<EOL>% (queue_name, options))<EOL>return None<EOL><DEDENT><DEDENT>except Exception as e:<EOL><INDENT>LOGEXCEPTION('<STR_LIT>'<EOL>% (queue_name, options))<EOL>return None<EOL><DEDENT>

This creates an SQS queue.

Parameters
----------

queue_name : str
    The name of the queue to create.

options : dict or None
    A dict of options indicate extra attributes the queue should have.
    See the SQS docs for details. If None, no custom attributes will be
    attached to the queue.

client : boto3.Client or None
    If None, this function will instantiate a new `boto3.Client` object to
    use in its operations. Alternatively, pass in an existing `boto3.Client`
    instance to re-use it here.

Returns
-------

dict
    This returns a dict of the form::

        {'url': SQS URL of the queue,
         'name': name of the queue}


if not client:<EOL><INDENT>client = boto3.client('<STR_LIT>')<EOL><DEDENT>try:<EOL><INDENT>client.delete_queue(QueueUrl=queue_url)<EOL>return True<EOL><DEDENT>except Exception as e:<EOL><INDENT>LOGEXCEPTION('<STR_LIT>'<EOL>% (queue_url,))<EOL>return False<EOL><DEDENT>

This deletes an SQS queue given its URL

    Parameters
    ----------

    queue_url : str
        The SQS URL of the queue to delete.

    client : boto3.Client or None
        If None, this function will instantiate a new `boto3.Client` object to
        use in its operations. Alternatively, pass in an existing `boto3.Client`
        instance to re-use it here.

    Returns
    -------

    bool
        True if the queue was deleted successfully. False otherwise.


if not client:<EOL><INDENT>client = boto3.client('<STR_LIT>')<EOL><DEDENT>try:<EOL><INDENT>json_msg = json.dumps(item)<EOL>resp = client.send_message(<EOL>QueueUrl=queue_url,<EOL>MessageBody=json_msg,<EOL>DelaySeconds=delay_seconds,<EOL>)<EOL>if not resp:<EOL><INDENT>LOGERROR('<STR_LIT>' % queue_url)<EOL>return None<EOL><DEDENT>else:<EOL><INDENT>return resp<EOL><DEDENT><DEDENT>except Exception as e:<EOL><INDENT>LOGEXCEPTION('<STR_LIT>' % queue_url)<EOL>if raiseonfail:<EOL><INDENT>raise<EOL><DEDENT>return None<EOL><DEDENT>

This pushes a dict serialized to JSON to the specified SQS queue.

    Parameters
    ----------

    queue_url : str
        The SQS URL of the queue to push the object to.

    item : dict
        The dict passed in here will be serialized to JSON.

    delay_seconds : int
        The amount of time in seconds the pushed item will be held before going
        'live' and being visible to all queue consumers.

    client : boto3.Client or None
        If None, this function will instantiate a new `boto3.Client` object to
        use in its operations. Alternatively, pass in an existing `boto3.Client`
        instance to re-use it here.

    raiseonfail : bool
        If True, will re-raise whatever Exception caused the operation to fail
        and break out immediately.

    Returns
    -------

    boto3.Response or None
        If the item was successfully put on the queue, will return the response
        from the service. If it wasn't, will return None.


if not client:<EOL><INDENT>client = boto3.client('<STR_LIT>')<EOL><DEDENT>try:<EOL><INDENT>resp = client.receive_message(<EOL>QueueUrl=queue_url,<EOL>AttributeNames=['<STR_LIT>'],<EOL>MaxNumberOfMessages=max_items,<EOL>WaitTimeSeconds=wait_time_seconds<EOL>)<EOL>if not resp:<EOL><INDENT>LOGERROR('<STR_LIT>' %<EOL>queue_url)<EOL><DEDENT>else:<EOL><INDENT>messages = []<EOL>for msg in resp.get('<STR_LIT>',[]):<EOL><INDENT>try:<EOL><INDENT>messages.append({<EOL>'<STR_LIT:id>':msg['<STR_LIT>'],<EOL>'<STR_LIT>':msg['<STR_LIT>'],<EOL>'<STR_LIT>':msg['<STR_LIT>'],<EOL>'<STR_LIT>':msg['<STR_LIT>'],<EOL>'<STR_LIT>':json.loads(msg['<STR_LIT>']),<EOL>})<EOL><DEDENT>except Exception as e:<EOL><INDENT>LOGEXCEPTION(<EOL>'<STR_LIT>' %<EOL>(msg['<STR_LIT>'], msg['<STR_LIT>'])<EOL>)<EOL>continue<EOL><DEDENT><DEDENT>return messages<EOL><DEDENT><DEDENT>except Exception as e:<EOL><INDENT>LOGEXCEPTION('<STR_LIT>' % queue_url)<EOL>if raiseonfail:<EOL><INDENT>raise<EOL><DEDENT>return None<EOL><DEDENT>

This gets a single item from the SQS queue.

    The `queue_url` is composed of some internal SQS junk plus a
    `queue_name`. For our purposes (`lcproc_aws.py`), the queue name will be
    something like::

        lcproc_queue_<action>

    where action is one of::

        runcp
        runpf

    The item is always a JSON object::

        {'target': S3 bucket address of the file to process,
         'action': the action to perform on the file ('runpf', 'runcp', etc.)
         'args': the action's args as a tuple (not including filename, which is
                 generated randomly as a temporary local file),
         'kwargs': the action's kwargs as a dict,
         'outbucket: S3 bucket to write the result to,
         'outqueue': SQS queue to write the processed item's info to (optional)}

    The action MUST match the <action> in the queue name for this item to be
    processed.

    Parameters
    ----------

    queue_url : str
        The SQS URL of the queue to get messages from.

    max_items : int
        The number of items to pull from the queue in this request.

    wait_time_seconds : int
        This specifies how long the function should block until a message is
        received on the queue. If the timeout expires, an empty list will be
        returned. If the timeout doesn't expire, the function will return a list
        of items received (up to `max_items`).

    client : boto3.Client or None
        If None, this function will instantiate a new `boto3.Client` object to
        use in its operations. Alternatively, pass in an existing `boto3.Client`
        instance to re-use it here.

    raiseonfail : bool
        If True, will re-raise whatever Exception caused the operation to fail
        and break out immediately.

    Returns
    -------

    list of dicts or None
        For each item pulled from the queue in this request (up to `max_items`),
        a dict will be deserialized from the retrieved JSON, containing the
        message items and various metadata. The most important item of the
        metadata is the `receipt_handle`, which can be used to acknowledge
        receipt of all items in this request (see `sqs_delete_item` below).

        If the queue pull fails outright, returns None. If no messages are
        available for this queue pull, returns an empty list.


if not client:<EOL><INDENT>client = boto3.client('<STR_LIT>')<EOL><DEDENT>try:<EOL><INDENT>client.delete_message(<EOL>QueueUrl=queue_url,<EOL>ReceiptHandle=receipt_handle<EOL>)<EOL><DEDENT>except Exception as e:<EOL><INDENT>LOGEXCEPTION(<EOL>'<STR_LIT>'<EOL>'<STR_LIT>' % (receipt_handle, queue_url)<EOL>)<EOL>if raiseonfail:<EOL><INDENT>raise<EOL><DEDENT><DEDENT>

This deletes a message from the queue, effectively acknowledging its
    receipt.

    Call this only when all messages retrieved from the queue have been
    processed, since this will prevent redelivery of these messages to other
    queue workers pulling fromn the same queue channel.

    Parameters
    ----------

    queue_url : str
        The SQS URL of the queue where we got the messages from. This should be
        the same queue used to retrieve the messages in `sqs_get_item`.

    receipt_handle : str
        The receipt handle of the queue message that we're responding to, and
        will acknowledge receipt of. This will be present in each message
        retrieved using `sqs_get_item`.

    client : boto3.Client or None
        If None, this function will instantiate a new `boto3.Client` object to
        use in its operations. Alternatively, pass in an existing `boto3.Client`
        instance to re-use it here.

    raiseonfail : bool
        If True, will re-raise whatever Exception caused the operation to fail
        and break out immediately.

    Returns
    -------

    Nothing.


if not client:<EOL><INDENT>client = boto3.client('<STR_LIT>')<EOL><DEDENT>if isinstance(user_data, str) and os.path.exists(user_data):<EOL><INDENT>with open(user_data,'<STR_LIT:r>') as infd:<EOL><INDENT>udata = infd.read()<EOL><DEDENT><DEDENT>elif isinstance(user_data, str):<EOL><INDENT>udata = user_data<EOL><DEDENT>else:<EOL><INDENT>udata = (<EOL>'<STR_LIT>'<EOL>'<STR_LIT>' % datetime.utcnow().isoformat()<EOL>)<EOL><DEDENT>try:<EOL><INDENT>resp = client.run_instances(<EOL>ImageId=ami,<EOL>InstanceType=instance,<EOL>SecurityGroupIds=[<EOL>security_groupid,<EOL>],<EOL>SubnetId=subnet_id,<EOL>UserData=udata,<EOL>IamInstanceProfile={'<STR_LIT>':iam_instance_profile_arn},<EOL>InstanceInitiatedShutdownBehavior='<STR_LIT>',<EOL>KeyName=keypair_name,<EOL>MaxCount=launch_instances,<EOL>MinCount=launch_instances,<EOL>EbsOptimized=ebs_optimized,<EOL>)<EOL>if not resp:<EOL><INDENT>LOGERROR('<STR_LIT>')<EOL>return None<EOL><DEDENT>else:<EOL><INDENT>instance_dict = {}<EOL>instance_list = resp.get('<STR_LIT>',[])<EOL>if len(instance_list) > <NUM_LIT:0>:<EOL><INDENT>for instance in instance_list:<EOL><INDENT>LOGINFO('<STR_LIT>'<EOL>'<STR_LIT>'<EOL>% (instance['<STR_LIT>'],<EOL>instance['<STR_LIT>'],<EOL>instance['<STR_LIT>'].isoformat(),<EOL>instance['<STR_LIT>']['<STR_LIT:Name>']))<EOL>instance_dict[instance['<STR_LIT>']] = {<EOL>'<STR_LIT:type>':instance['<STR_LIT>'],<EOL>'<STR_LIT>':instance['<STR_LIT>'],<EOL>'<STR_LIT:state>':instance['<STR_LIT>']['<STR_LIT:Name>'],<EOL>'<STR_LIT:info>':instance<EOL>}<EOL><DEDENT><DEDENT>if wait_until_up:<EOL><INDENT>ready_instances = []<EOL>LOGINFO('<STR_LIT>')<EOL>ntries = <NUM_LIT:5><EOL>curr_try = <NUM_LIT:0><EOL>while ( (curr_try < ntries) or<EOL>( len(ready_instances) <<EOL>len(list(instance_dict.keys()))) ):<EOL><INDENT>resp = client.describe_instances(<EOL>InstanceIds=list(instance_dict.keys()),<EOL>)<EOL>if len(resp['<STR_LIT>']) > <NUM_LIT:0>:<EOL><INDENT>for resv in resp['<STR_LIT>']:<EOL><INDENT>if len(resv['<STR_LIT>']) > <NUM_LIT:0>:<EOL><INDENT>for instance in resv['<STR_LIT>']:<EOL><INDENT>if instance['<STR_LIT>']['<STR_LIT:Name>'] == '<STR_LIT>':<EOL><INDENT>ready_instances.append(<EOL>instance['<STR_LIT>']<EOL>)<EOL>instance_dict[<EOL>instance['<STR_LIT>']<EOL>]['<STR_LIT:state>'] = '<STR_LIT>'<EOL>instance_dict[<EOL>instance['<STR_LIT>']<EOL>]['<STR_LIT>'] = instance['<STR_LIT>']<EOL>instance_dict[<EOL>instance['<STR_LIT>']<EOL>]['<STR_LIT:info>'] = instance<EOL><DEDENT><DEDENT><DEDENT><DEDENT><DEDENT>curr_try = curr_try + <NUM_LIT:1><EOL>time.sleep(<NUM_LIT>)<EOL><DEDENT>if len(ready_instances) == len(list(instance_dict.keys())):<EOL><INDENT>LOGINFO('<STR_LIT>')<EOL><DEDENT>else:<EOL><INDENT>LOGWARNING(<EOL>'<STR_LIT>'<EOL>'<STR_LIT>'<EOL>)<EOL><DEDENT><DEDENT>return instance_dict<EOL><DEDENT><DEDENT>except ClientError as e:<EOL><INDENT>LOGEXCEPTION('<STR_LIT>')<EOL>if raiseonfail:<EOL><INDENT>raise<EOL><DEDENT>return None<EOL><DEDENT>except Exception as e:<EOL><INDENT>LOGEXCEPTION('<STR_LIT>')<EOL>if raiseonfail:<EOL><INDENT>raise<EOL><DEDENT>return None<EOL><DEDENT>

This makes new EC2 worker nodes.

    This requires a security group ID attached to a VPC config and subnet, a
    keypair generated beforehand, and an IAM role ARN for the instance. See:

    https://docs.aws.amazon.com/cli/latest/userguide/tutorial-ec2-ubuntu.html

    Use `user_data` to launch tasks on instance launch.

    Parameters
    ----------

    security_groupid : str
        The security group ID of the AWS VPC where the instances will be
        launched.

    subnet_id : str
        The subnet ID of the AWS VPC where the instances will be
        launched.

    keypair_name : str
        The name of the keypair to be used to allow SSH access to all instances
        launched here. This corresponds to an already downloaded AWS keypair PEM
        file.

    iam_instance_profile_arn : str
        The ARN string corresponding to the AWS instance profile that describes
        the permissions the launched instances have to access other AWS
        resources. Set this up in AWS IAM.

    launch_instances : int
        The number of instances to launch in this request.

    ami : str
        The Amazon Machine Image ID that describes the OS the instances will use
        after launch. The default ID is Amazon Linux 2 in the US East region.

    instance : str
        The instance type to launch. See the following URL for a list of IDs:
        https://aws.amazon.com/ec2/pricing/on-demand/

    ebs_optimized : bool
        If True, will enable EBS optimization to speed up IO. This is usually
        True for all instances made available in the last couple of years.

    user_data : str or None
        This is either the path to a file on disk that contains a shell-script
        or a string containing a shell-script that will be executed by root
        right after the instance is launched. Use to automatically set up
        workers and queues. If None, will not execute anything at instance
        start up.

    wait_until_up : bool
        If True, will not return from this function until all launched instances
        are verified as running by AWS.

    client : boto3.Client or None
        If None, this function will instantiate a new `boto3.Client` object to
        use in its operations. Alternatively, pass in an existing `boto3.Client`
        instance to re-use it here.

    raiseonfail : bool
        If True, will re-raise whatever Exception caused the operation to fail
        and break out immediately.

    Returns
    -------

    dict
        Returns launched instance info as a dict, keyed by instance ID.


if not client:<EOL><INDENT>client = boto3.client('<STR_LIT>')<EOL><DEDENT>resp = client.terminate_instances(<EOL>InstanceIds=instance_id_list<EOL>)<EOL>return resp<EOL>

This deletes EC2 nodes and terminates the instances.

    Parameters
    ----------

    instance_id_list : list of str
        A list of EC2 instance IDs to terminate.

    client : boto3.Client or None
        If None, this function will instantiate a new `boto3.Client` object to
        use in its operations. Alternatively, pass in an existing `boto3.Client`
        instance to re-use it here.

    Returns
    -------

    Nothing.


fleetconfig = copy.deepcopy(SPOT_FLEET_CONFIG)<EOL>fleetconfig['<STR_LIT>'] = spot_fleet_iam_role<EOL>fleetconfig['<STR_LIT>'] = allocation_strategy<EOL>fleetconfig['<STR_LIT>'] = target_capacity<EOL>fleetconfig['<STR_LIT>'] = str(spot_price)<EOL>fleetconfig['<STR_LIT>'] = (<EOL>datetime.utcnow() + timedelta(days=expires_days)<EOL>).strftime(<EOL>'<STR_LIT>'<EOL>)<EOL>if (isinstance(instance_user_data, str) and<EOL>os.path.exists(instance_user_data)):<EOL><INDENT>with open(instance_user_data,'<STR_LIT:rb>') as infd:<EOL><INDENT>udata = base64.b64encode(infd.read()).decode()<EOL><DEDENT><DEDENT>elif isinstance(instance_user_data, str):<EOL><INDENT>udata = base64.b64encode(instance_user_data.encode()).decode()<EOL><DEDENT>else:<EOL><INDENT>udata = (<EOL>'<STR_LIT>'<EOL>'<STR_LIT>' % datetime.utcnow().isoformat()<EOL>)<EOL>udata = base64.b64encode(udata.encode()).decode()<EOL><DEDENT>for ind, itype in enumerate(instance_types):<EOL><INDENT>thisinstance = SPOT_PERINSTANCE_CONFIG.copy()<EOL>thisinstance['<STR_LIT>'] = itype<EOL>thisinstance['<STR_LIT>'] = instance_ami<EOL>thisinstance['<STR_LIT>'] = subnet_id<EOL>thisinstance['<STR_LIT>'] = keypair_name<EOL>thisinstance['<STR_LIT>']['<STR_LIT>'] = iam_instance_profile_arn<EOL>thisinstance['<STR_LIT>'][<NUM_LIT:0>] = {'<STR_LIT>':security_groupid}<EOL>thisinstance['<STR_LIT>'] = udata<EOL>thisinstance['<STR_LIT>'] = instance_ebs_optimized<EOL>if isinstance(instance_weights, list):<EOL><INDENT>thisinstance['<STR_LIT>'] = instance_weights[ind]<EOL><DEDENT>fleetconfig['<STR_LIT>'].append(thisinstance)<EOL><DEDENT>if not client:<EOL><INDENT>client = boto3.client('<STR_LIT>')<EOL><DEDENT>try:<EOL><INDENT>resp = client.request_spot_fleet(<EOL>SpotFleetRequestConfig=fleetconfig,<EOL>)<EOL>if not resp:<EOL><INDENT>LOGERROR('<STR_LIT>')<EOL>return None<EOL><DEDENT>else:<EOL><INDENT>spot_fleet_reqid = resp['<STR_LIT>']<EOL>LOGINFO('<STR_LIT>' %<EOL>spot_fleet_reqid)<EOL>if not wait_until_up:<EOL><INDENT>return spot_fleet_reqid<EOL><DEDENT>else:<EOL><INDENT>ntries = <NUM_LIT:10><EOL>curr_try = <NUM_LIT:0><EOL>while curr_try < ntries:<EOL><INDENT>resp = client.describe_spot_fleet_requests(<EOL>SpotFleetRequestIds=[<EOL>spot_fleet_reqid<EOL>]<EOL>)<EOL>curr_state = resp.get('<STR_LIT>',[])<EOL>if len(curr_state) > <NUM_LIT:0>:<EOL><INDENT>curr_state = curr_state[<NUM_LIT:0>]['<STR_LIT>']<EOL>if curr_state == '<STR_LIT>':<EOL><INDENT>LOGINFO('<STR_LIT>' %<EOL>spot_fleet_reqid)<EOL>break<EOL><DEDENT><DEDENT>LOGINFO(<EOL>'<STR_LIT>'<EOL>'<STR_LIT>' % (curr_try, ntries)<EOL>)<EOL>curr_try = curr_try + <NUM_LIT:1><EOL>time.sleep(<NUM_LIT>)<EOL><DEDENT>return spot_fleet_reqid<EOL><DEDENT><DEDENT><DEDENT>except ClientError as e:<EOL><INDENT>LOGEXCEPTION('<STR_LIT>')<EOL>if raiseonfail:<EOL><INDENT>raise<EOL><DEDENT>return None<EOL><DEDENT>except Exception as e:<EOL><INDENT>LOGEXCEPTION('<STR_LIT>')<EOL>if raiseonfail:<EOL><INDENT>raise<EOL><DEDENT>return None<EOL><DEDENT>

This makes an EC2 spot-fleet cluster.

    This requires a security group ID attached to a VPC config and subnet, a
    keypair generated beforehand, and an IAM role ARN for the instance. See:

    https://docs.aws.amazon.com/cli/latest/userguide/tutorial-ec2-ubuntu.html

    Use `user_data` to launch tasks on instance launch.

    Parameters
    ----------

    security_groupid : str
        The security group ID of the AWS VPC where the instances will be
        launched.

    subnet_id : str
        The subnet ID of the AWS VPC where the instances will be
        launched.

    keypair_name : str
        The name of the keypair to be used to allow SSH access to all instances
        launched here. This corresponds to an already downloaded AWS keypair PEM
        file.

    iam_instance_profile_arn : str
        The ARN string corresponding to the AWS instance profile that describes
        the permissions the launched instances have to access other AWS
        resources. Set this up in AWS IAM.

    spot_fleet_iam_role : str
        This is the name of AWS IAM role that allows the Spot Fleet Manager to
        scale up and down instances based on demand and instances failing,
        etc. Set this up in IAM.

    target_capacity : int
        The number of instances to target in the fleet request. The fleet
        manager service will attempt to maintain this number over the lifetime
        of the Spot Fleet Request.

    spot_price : float
        The bid price in USD for the instances. This is per hour. Keep this at
        about half the hourly on-demand price of the desired instances to make
        sure your instances aren't taken away by AWS when it needs capacity.

    expires_days : int
        The number of days this request is active for. All instances launched by
        this request will live at least this long and will be terminated
        automatically after.

    allocation_strategy : {'lowestPrice', 'diversified'}
        The allocation strategy used by the fleet manager.

    instance_types : list of str
        List of the instance type to launch. See the following URL for a list of
        IDs: https://aws.amazon.com/ec2/pricing/on-demand/

    instance_weights : list of float or None
        If `instance_types` is a list of different instance types, this is the
        relative weight applied towards launching each instance type. This can
        be used to launch a mix of instances in a defined ratio among their
        types. Doing this can make the spot fleet more resilient to AWS taking
        back the instances if it runs out of capacity.

    instance_ami : str
        The Amazon Machine Image ID that describes the OS the instances will use
        after launch. The default ID is Amazon Linux 2 in the US East region.

    instance_user_data : str or None
        This is either the path to a file on disk that contains a shell-script
        or a string containing a shell-script that will be executed by root
        right after the instance is launched. Use to automatically set up
        workers and queues. If None, will not execute anything at instance
        start up.

    instance_ebs_optimized : bool
        If True, will enable EBS optimization to speed up IO. This is usually
        True for all instances made available in the last couple of years.

    wait_until_up : bool
        If True, will not return from this function until the spot fleet request
        is acknowledged by AWS.

    client : boto3.Client or None
        If None, this function will instantiate a new `boto3.Client` object to
        use in its operations. Alternatively, pass in an existing `boto3.Client`
        instance to re-use it here.

    raiseonfail : bool
        If True, will re-raise whatever Exception caused the operation to fail
        and break out immediately.

    Returns
    -------

    str or None
        This is the spot fleet request ID if successful. Otherwise, returns
        None.


if not client:<EOL><INDENT>client = boto3.client('<STR_LIT>')<EOL><DEDENT>resp = client.cancel_spot_fleet_requests(<EOL>SpotFleetRequestIds=[spot_fleet_reqid],<EOL>TerminateInstances=True<EOL>)<EOL>return resp<EOL>

This deletes a spot-fleet cluster.

Parameters
----------

spot_fleet_reqid : str
    The fleet request ID returned by `make_spot_fleet_cluster`.

client : boto3.Client or None
    If None, this function will instantiate a new `boto3.Client` object to
    use in its operations. Alternatively, pass in an existing `boto3.Client`
    instance to re-use it here.

Returns
-------

Nothing.


<EOL>stimes, smags, serrs = sigclip_magseries(times,<EOL>mags,<EOL>errs,<EOL>magsarefluxes=magsarefluxes,<EOL>sigclip=sigclip)<EOL>if timebin and errs is not None:<EOL><INDENT>binned = time_bin_magseries_with_errs(stimes, smags, serrs,<EOL>binsize=timebin)<EOL>btimes, bmags, berrs = (binned['<STR_LIT>'],<EOL>binned['<STR_LIT>'],<EOL>binned['<STR_LIT>'])<EOL><DEDENT>elif timebin and errs is None:<EOL><INDENT>binned = time_bin_magseries(stimes, smags,<EOL>binsize=timebin)<EOL>btimes, bmags, berrs = binned['<STR_LIT>'], binned['<STR_LIT>'], None<EOL><DEDENT>else:<EOL><INDENT>btimes, bmags, berrs = stimes, smags, serrs<EOL><DEDENT>if normto is not False:<EOL><INDENT>btimes, bmags = normalize_magseries(btimes, bmags,<EOL>normto=normto,<EOL>magsarefluxes=magsarefluxes,<EOL>mingap=normmingap)<EOL><DEDENT>btimeorigin = btimes.min()<EOL>btimes = btimes - btimeorigin<EOL>if segmentmingap is not None:<EOL><INDENT>ntimegroups, timegroups = find_lc_timegroups(btimes,<EOL>mingap=segmentmingap)<EOL><DEDENT>if yrange and isinstance(yrange,(list,tuple)) and len(yrange) == <NUM_LIT:2>:<EOL><INDENT>ymin, ymax = yrange<EOL><DEDENT>else:<EOL><INDENT>if not magsarefluxes:<EOL><INDENT>ymin, ymax = (bmags.min() - <NUM_LIT>,<EOL>bmags.max() + <NUM_LIT>)<EOL><DEDENT>else:<EOL><INDENT>ycov = bmags.max() - bmags.min()<EOL>ymin = bmags.min() - <NUM_LIT>*ycov<EOL>ymax = bmags.max() + <NUM_LIT>*ycov<EOL><DEDENT><DEDENT>if segmentmingap and ntimegroups > <NUM_LIT:1>:<EOL><INDENT>LOGINFO('<STR_LIT>' % ntimegroups)<EOL>fig, axes = plt.subplots(<NUM_LIT:1>,ntimegroups,sharey=True)<EOL>fig.set_size_inches(<NUM_LIT:10>,<NUM_LIT>)<EOL>axes = np.ravel(axes)<EOL>for timegroup, ax, axind in zip(timegroups, axes, range(len(axes))):<EOL><INDENT>tgtimes = btimes[timegroup]<EOL>tgmags = bmags[timegroup]<EOL>if berrs:<EOL><INDENT>tgerrs = berrs[timegroup]<EOL><DEDENT>else:<EOL><INDENT>tgerrs = None<EOL><DEDENT>LOGINFO('<STR_LIT>' % (<EOL>axind,<EOL>axind+<NUM_LIT:1>,<EOL>btimeorigin + tgtimes.min(),<EOL>btimeorigin + tgtimes.max())<EOL>)<EOL>ax.errorbar(tgtimes, tgmags, fmt='<STR_LIT>', yerr=tgerrs,<EOL>markersize=<NUM_LIT>, markeredgewidth=<NUM_LIT:0.0>, ecolor='<STR_LIT>',<EOL>capsize=<NUM_LIT:0>)<EOL>ax.get_xaxis().get_major_formatter().set_useOffset(False)<EOL>if axind == <NUM_LIT:0>:<EOL><INDENT>ax.get_yaxis().get_major_formatter().set_useOffset(False)<EOL>ax.spines['<STR_LIT:right>'].set_visible(False)<EOL>ax.yaxis.tick_left()<EOL><DEDENT>elif <NUM_LIT:0> < axind < (len(axes)-<NUM_LIT:1>):<EOL><INDENT>ax.spines['<STR_LIT:right>'].set_visible(False)<EOL>ax.spines['<STR_LIT:left>'].set_visible(False)<EOL>ax.tick_params(right='<STR_LIT>', labelright='<STR_LIT>',<EOL>left='<STR_LIT>',labelleft='<STR_LIT>')<EOL><DEDENT>elif axind == (len(axes)-<NUM_LIT:1>):<EOL><INDENT>ax.spines['<STR_LIT:left>'].set_visible(False)<EOL>ax.spines['<STR_LIT:right>'].set_visible(True)<EOL>ax.yaxis.tick_right()<EOL><DEDENT>if not magsarefluxes:<EOL><INDENT>ax.set_ylim(ymax, ymin)<EOL><DEDENT>else:<EOL><INDENT>ax.set_ylim(ymin, ymax)<EOL><DEDENT>tgrange = tgtimes.max() - tgtimes.min()<EOL>if tgrange < <NUM_LIT>:<EOL><INDENT>ticklocations = [tgrange/<NUM_LIT>]<EOL>ax.set_xlim(npmin(tgtimes) - <NUM_LIT:0.5>, npmax(tgtimes) + <NUM_LIT:0.5>)<EOL><DEDENT>elif <NUM_LIT> < tgrange < <NUM_LIT>:<EOL><INDENT>ticklocations = np.linspace(tgtimes.min()+<NUM_LIT>,<EOL>tgtimes.max()-<NUM_LIT>,<EOL>num=<NUM_LIT:2>)<EOL>ax.set_xlim(npmin(tgtimes) - <NUM_LIT>, npmax(tgtimes) + <NUM_LIT>)<EOL><DEDENT>elif <NUM_LIT> < tgrange < <NUM_LIT>:<EOL><INDENT>ticklocations = np.linspace(tgtimes.min()+<NUM_LIT>,<EOL>tgtimes.max()-<NUM_LIT>,<EOL>num=<NUM_LIT:3>)<EOL>ax.set_xlim(npmin(tgtimes) - <NUM_LIT>, npmax(tgtimes) + <NUM_LIT>)<EOL><DEDENT>else:<EOL><INDENT>ticklocations = np.linspace(tgtimes.min()+<NUM_LIT>,<EOL>tgtimes.max()-<NUM_LIT>,<EOL>num=<NUM_LIT:3>)<EOL>ax.set_xlim(npmin(tgtimes) - <NUM_LIT>, npmax(tgtimes) + <NUM_LIT>)<EOL><DEDENT>ax.xaxis.set_ticks([int(x) for x in ticklocations])<EOL><DEDENT>plt.subplots_adjust(wspace=<NUM_LIT>)<EOL>fig.text(<NUM_LIT:0.5>, <NUM_LIT>, '<STR_LIT>' %<EOL>(btimeorigin, segmentmingap), ha='<STR_LIT>')<EOL>if not magsarefluxes:<EOL><INDENT>fig.text(<NUM_LIT>, <NUM_LIT:0.5>, '<STR_LIT>', va='<STR_LIT>', rotation='<STR_LIT>')<EOL><DEDENT>else:<EOL><INDENT>fig.text(<NUM_LIT>, <NUM_LIT:0.5>, '<STR_LIT>', va='<STR_LIT>', rotation='<STR_LIT>')<EOL><DEDENT><DEDENT>else:<EOL><INDENT>fig = plt.figure()<EOL>fig.set_size_inches(<NUM_LIT>,<NUM_LIT>)<EOL>plt.errorbar(btimes, bmags, fmt='<STR_LIT>', yerr=berrs,<EOL>markersize=<NUM_LIT>, markeredgewidth=<NUM_LIT:0.0>, ecolor='<STR_LIT>',<EOL>capsize=<NUM_LIT:0>)<EOL>plt.grid(color='<STR_LIT>',<EOL>alpha=<NUM_LIT>,<EOL>zorder=<NUM_LIT:0>,<EOL>linewidth=<NUM_LIT:1.0>,<EOL>linestyle='<STR_LIT::>')<EOL>plt.gca().get_yaxis().get_major_formatter().set_useOffset(False)<EOL>plt.gca().get_xaxis().get_major_formatter().set_useOffset(False)<EOL>plt.xlabel('<STR_LIT>' % btimeorigin)<EOL>if not magsarefluxes:<EOL><INDENT>plt.ylim(ymax, ymin)<EOL>plt.ylabel('<STR_LIT>')<EOL><DEDENT>else:<EOL><INDENT>plt.ylim(ymin, ymax)<EOL>plt.ylabel('<STR_LIT>')<EOL><DEDENT><DEDENT>if sys.version_info[:<NUM_LIT:2>] < (<NUM_LIT:3>,<NUM_LIT:0>):<EOL><INDENT>is_Strio = isinstance(out, cStringIO.InputType)<EOL><DEDENT>else:<EOL><INDENT>is_Strio = isinstance(out, Strio)<EOL><DEDENT>if out and not is_Strio:<EOL><INDENT>if out.endswith('<STR_LIT>'):<EOL><INDENT>plt.savefig(out,bbox_inches='<STR_LIT>',dpi=plotdpi)<EOL><DEDENT>else:<EOL><INDENT>plt.savefig(out,bbox_inches='<STR_LIT>')<EOL><DEDENT>plt.close()<EOL>return os.path.abspath(out)<EOL><DEDENT>elif out and is_Strio:<EOL><INDENT>plt.savefig(out, bbox_inches='<STR_LIT>', dpi=plotdpi, format='<STR_LIT>')<EOL>return out<EOL><DEDENT>elif not out and dispok:<EOL><INDENT>plt.show()<EOL>plt.close()<EOL>return<EOL><DEDENT>else:<EOL><INDENT>LOGWARNING('<STR_LIT>'<EOL>'<STR_LIT>')<EOL>outfile = '<STR_LIT>'<EOL>plt.savefig(outfile,bbox_inches='<STR_LIT>',dpi=plotdpi)<EOL>plt.close()<EOL>return os.path.abspath(outfile)<EOL><DEDENT>

This plots a magnitude/flux time-series.

    Parameters
    ----------

    times,mags : np.array
        The mag/flux time-series to plot as a function of time.

    magsarefluxes : bool
        Indicates if the input `mags` array is actually an array of flux
        measurements instead of magnitude measurements. If this is set to True,
        then the plot y-axis will be set as appropriate for mag or fluxes. In
        addition:

        - if `normto` is 'zero', then the median flux is divided from each
          observation's flux value to yield normalized fluxes with 1.0 as the
          global median.
        - if `normto` is 'globalmedian', then the global median flux value
          across the entire time series is multiplied with each measurement.
        - if `norm` is set to a `float`, then this number is multiplied with the
          flux value for each measurement.

    errs : np.array or None
        If this is provided, contains the measurement errors associated with
        each measurement of flux/mag in time-series. Providing this kwarg will
        add errbars to the output plot.

    out : str or StringIO/BytesIO object or None
        Sets the output type and target:

        - If `out` is a string, will save the plot to the specified file name.
        - If `out` is a StringIO/BytesIO object, will save the plot to that file
          handle. This can be useful to carry out additional operations on the
          output binary stream, or convert it to base64 text for embedding in
          HTML pages.
        - If `out` is None, will save the plot to a file called
          'magseries-plot.png' in the current working directory.

    sigclip : float or int or sequence of two floats/ints or None
        If a single float or int, a symmetric sigma-clip will be performed using
        the number provided as the sigma-multiplier to cut out from the input
        time-series.

        If a list of two ints/floats is provided, the function will perform an
        'asymmetric' sigma-clip. The first element in this list is the sigma
        value to use for fainter flux/mag values; the second element in this
        list is the sigma value to use for brighter flux/mag values. For
        example, `sigclip=[10., 3.]`, will sigclip out greater than 10-sigma
        dimmings and greater than 3-sigma brightenings. Here the meaning of
        "dimming" and "brightening" is set by *physics* (not the magnitude
        system), which is why the `magsarefluxes` kwarg must be correctly set.

        If `sigclip` is None, no sigma-clipping will be performed, and the
        time-series (with non-finite elems removed) will be passed through to
        the output.

    normto : {'globalmedian', 'zero'} or a float
        Sets the normalization target::

          'globalmedian' -> norms each mag to the global median of the LC column
          'zero'         -> norms each mag to zero
          a float        -> norms each mag to this specified float value.

    normmingap : 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.

    timebin : float or None
        The bin size to use to group together measurements closer than this
        amount in time. This is in seconds. If this is None, no time-binning
        will be performed.

    yrange : list of two floats or None
        This is used to provide a custom y-axis range to the plot. If None, will
        automatically determine y-axis range.

    segmentmingap : float or None
        This controls the minimum length of time (in days) required to consider
        a timegroup in the light curve as a separate segment. This is useful
        when the light curve consists of measurements taken over several
        seasons, so there's lots of dead space in the plot that can be cut out
        to zoom in on the interesting stuff. If `segmentmingap` is not None, the
        magseries plot will be cut in this way and the x-axis will show these
        breaks.

    plotdpi : int
        Sets the resolution in DPI for PNG plots (default = 100).

    Returns
    -------

    str or BytesIO/StringIO object
        Returns based on the input:

        - If `out` is a str or None, the path to the generated plot file is
          returned.
        - If `out` is a StringIO/BytesIO object, will return the
          StringIO/BytesIO object to which the plot was written.


<EOL>stimes, smags, serrs = sigclip_magseries(times,<EOL>mags,<EOL>errs,<EOL>magsarefluxes=magsarefluxes,<EOL>sigclip=sigclip)<EOL>if normto is not False:<EOL><INDENT>stimes, smags = normalize_magseries(stimes, smags,<EOL>normto=normto,<EOL>magsarefluxes=magsarefluxes,<EOL>mingap=normmingap)<EOL>if ( isinstance(modelmags, np.ndarray) and<EOL>isinstance(modeltimes, np.ndarray) ):<EOL><INDENT>stimes, smags = normalize_magseries(modeltimes, modelmags,<EOL>normto=normto,<EOL>magsarefluxes=magsarefluxes,<EOL>mingap=normmingap)<EOL><DEDENT><DEDENT>if epoch is None:<EOL><INDENT>epoch = stimes.min()<EOL><DEDENT>elif isinstance(epoch, str) and epoch == '<STR_LIT>':<EOL><INDENT>try:<EOL><INDENT>spfit = spline_fit_magseries(stimes, smags, serrs, period,<EOL>knotfraction=fitknotfrac)<EOL>epoch = spfit['<STR_LIT>']['<STR_LIT>']<EOL>if len(epoch) != <NUM_LIT:1>:<EOL><INDENT>epoch = epoch[<NUM_LIT:0>]<EOL><DEDENT><DEDENT>except Exception as e:<EOL><INDENT>LOGEXCEPTION('<STR_LIT>')<EOL>epoch = npmin(stimes)<EOL><DEDENT><DEDENT>if errs is not None:<EOL><INDENT>phasedlc = phase_magseries_with_errs(stimes, smags, serrs, period,<EOL>epoch, wrap=phasewrap,<EOL>sort=phasesort)<EOL>plotphase = phasedlc['<STR_LIT>']<EOL>plotmags = phasedlc['<STR_LIT>']<EOL>ploterrs = phasedlc['<STR_LIT>']<EOL>if phasebin:<EOL><INDENT>binphasedlc = phase_bin_magseries_with_errs(plotphase, plotmags,<EOL>ploterrs,<EOL>binsize=phasebin)<EOL>binplotphase = binphasedlc['<STR_LIT>']<EOL>binplotmags = binphasedlc['<STR_LIT>']<EOL>binploterrs = binphasedlc['<STR_LIT>']<EOL><DEDENT><DEDENT>else:<EOL><INDENT>phasedlc = phase_magseries(stimes, smags, period, epoch,<EOL>wrap=phasewrap, sort=phasesort)<EOL>plotphase = phasedlc['<STR_LIT>']<EOL>plotmags = phasedlc['<STR_LIT>']<EOL>ploterrs = None<EOL>if phasebin:<EOL><INDENT>binphasedlc = phase_bin_magseries(plotphase,<EOL>plotmags,<EOL>binsize=phasebin)<EOL>binplotphase = binphasedlc['<STR_LIT>']<EOL>binplotmags = binphasedlc['<STR_LIT>']<EOL>binploterrs = None<EOL><DEDENT><DEDENT>modelplotphase, modelplotmags = None, None<EOL>if ( isinstance(modelerrs,np.ndarray) and<EOL>isinstance(modeltimes,np.ndarray) and<EOL>isinstance(modelmags,np.ndarray) ):<EOL><INDENT>modelphasedlc = phase_magseries_with_errs(modeltimes, modelmags,<EOL>modelerrs, period, epoch,<EOL>wrap=phasewrap,<EOL>sort=phasesort)<EOL>modelplotphase = modelphasedlc['<STR_LIT>']<EOL>modelplotmags = modelphasedlc['<STR_LIT>']<EOL><DEDENT>elif ( not isinstance(modelerrs,np.ndarray) and<EOL>isinstance(modeltimes,np.ndarray) and<EOL>isinstance(modelmags,np.ndarray) ):<EOL><INDENT>modelphasedlc = phase_magseries(modeltimes, modelmags, period, epoch,<EOL>wrap=phasewrap, sort=phasesort)<EOL>modelplotphase = modelphasedlc['<STR_LIT>']<EOL>modelplotmags = modelphasedlc['<STR_LIT>']<EOL><DEDENT>if isinstance(outfile, matplotlib.axes.Axes):<EOL><INDENT>ax = outfile<EOL><DEDENT>else:<EOL><INDENT>fig = plt.figure()<EOL>fig.set_size_inches(<NUM_LIT>,<NUM_LIT>)<EOL>ax = plt.gca()<EOL><DEDENT>if xtimenotphase:<EOL><INDENT>plotphase *= period<EOL><DEDENT>if phasebin:<EOL><INDENT>ax.errorbar(plotphase, plotmags, fmt='<STR_LIT:o>',<EOL>color='<STR_LIT>',<EOL>yerr=ploterrs,<EOL>markersize=<NUM_LIT>,<EOL>markeredgewidth=<NUM_LIT:0.0>,<EOL>ecolor='<STR_LIT>',<EOL>capsize=<NUM_LIT:0>)<EOL>if xtimenotphase:<EOL><INDENT>binplotphase *= period<EOL><DEDENT>ax.errorbar(binplotphase, binplotmags, fmt='<STR_LIT>', yerr=binploterrs,<EOL>markersize=<NUM_LIT>, markeredgewidth=<NUM_LIT:0.0>, ecolor='<STR_LIT>',<EOL>capsize=<NUM_LIT:0>)<EOL><DEDENT>else:<EOL><INDENT>ax.errorbar(plotphase, plotmags, fmt='<STR_LIT>', yerr=ploterrs,<EOL>markersize=<NUM_LIT>, markeredgewidth=<NUM_LIT:0.0>, ecolor='<STR_LIT>',<EOL>capsize=<NUM_LIT:0>)<EOL><DEDENT>if (isinstance(modelplotphase, np.ndarray) and<EOL>isinstance(modelplotmags, np.ndarray)):<EOL><INDENT>if xtimenotphase:<EOL><INDENT>modelplotphase *= period<EOL><DEDENT>ax.plot(modelplotphase, modelplotmags, zorder=<NUM_LIT:5>, linewidth=<NUM_LIT:2>,<EOL>alpha=<NUM_LIT>, color='<STR_LIT>')<EOL><DEDENT>ax.grid(color='<STR_LIT>',<EOL>alpha=<NUM_LIT>,<EOL>zorder=<NUM_LIT:0>,<EOL>linewidth=<NUM_LIT:1.0>,<EOL>linestyle='<STR_LIT::>')<EOL>ax.axvline(<NUM_LIT:0.0>,alpha=<NUM_LIT>,linestyle='<STR_LIT>',color='<STR_LIT:g>')<EOL>if not xtimenotphase:<EOL><INDENT>ax.axvline(-<NUM_LIT:0.5>,alpha=<NUM_LIT>,linestyle='<STR_LIT>',color='<STR_LIT:g>')<EOL>ax.axvline(<NUM_LIT:0.5>,alpha=<NUM_LIT>,linestyle='<STR_LIT>',color='<STR_LIT:g>')<EOL><DEDENT>else:<EOL><INDENT>ax.axvline(-period*<NUM_LIT:0.5>,alpha=<NUM_LIT>,linestyle='<STR_LIT>',color='<STR_LIT:g>')<EOL>ax.axvline(period*<NUM_LIT:0.5>,alpha=<NUM_LIT>,linestyle='<STR_LIT>',color='<STR_LIT:g>')<EOL><DEDENT>ax.get_yaxis().get_major_formatter().set_useOffset(False)<EOL>ax.get_xaxis().get_major_formatter().set_useOffset(False)<EOL>if yrange and isinstance(yrange,(list,tuple)) and len(yrange) == <NUM_LIT:2>:<EOL><INDENT>ymin, ymax = yrange<EOL><DEDENT>else:<EOL><INDENT>ymin, ymax = ax.get_ylim()<EOL><DEDENT>if not yaxlabel:<EOL><INDENT>if not magsarefluxes:<EOL><INDENT>ax.set_ylim(ymax, ymin)<EOL>yaxlabel = '<STR_LIT>'<EOL><DEDENT>else:<EOL><INDENT>ax.set_ylim(ymin, ymax)<EOL>yaxlabel = '<STR_LIT>'<EOL><DEDENT><DEDENT>if not plotphaselim:<EOL><INDENT>ax.set_xlim((npmin(plotphase)-<NUM_LIT:0.1>,<EOL>npmax(plotphase)+<NUM_LIT:0.1>))<EOL><DEDENT>else:<EOL><INDENT>if xtimenotphase:<EOL><INDENT>ax.set_xlim((period*plotphaselim[<NUM_LIT:0>],period*plotphaselim[<NUM_LIT:1>]))<EOL><DEDENT>else:<EOL><INDENT>ax.set_xlim((plotphaselim[<NUM_LIT:0>],plotphaselim[<NUM_LIT:1>]))<EOL><DEDENT><DEDENT>ax.set_xlabel(xaxlabel)<EOL>ax.set_ylabel(yaxlabel)<EOL>ax.set_title('<STR_LIT>' % (period, epoch))<EOL>LOGINFO('<STR_LIT>' % (period, epoch))<EOL>if sys.version_info[:<NUM_LIT:2>] < (<NUM_LIT:3>,<NUM_LIT:0>):<EOL><INDENT>is_Strio = isinstance(outfile, cStringIO.InputType)<EOL><DEDENT>else:<EOL><INDENT>is_Strio = isinstance(outfile, Strio)<EOL><DEDENT>if (outfile and<EOL>not is_Strio and<EOL>not isinstance(outfile, matplotlib.axes.Axes)):<EOL><INDENT>if outfile.endswith('<STR_LIT>'):<EOL><INDENT>fig.savefig(outfile, bbox_inches='<STR_LIT>', dpi=plotdpi)<EOL><DEDENT>else:<EOL><INDENT>fig.savefig(outfile, bbox_inches='<STR_LIT>')<EOL><DEDENT>plt.close()<EOL>return period, epoch, os.path.abspath(outfile)<EOL><DEDENT>elif outfile and is_Strio:<EOL><INDENT>fig.savefig(outfile, bbox_inches='<STR_LIT>', dpi=plotdpi, format='<STR_LIT>')<EOL>return outfile<EOL><DEDENT>elif outfile and isinstance(outfile, matplotlib.axes.Axes):<EOL><INDENT>return outfile<EOL><DEDENT>elif not outfile and dispok:<EOL><INDENT>plt.show()<EOL>plt.close()<EOL>return period, epoch<EOL><DEDENT>else:<EOL><INDENT>LOGWARNING('<STR_LIT>'<EOL>'<STR_LIT>')<EOL>outfile = '<STR_LIT>'<EOL>plt.savefig(outfile, bbox_inches='<STR_LIT>', dpi=plotdpi)<EOL>plt.close()<EOL>return period, epoch, os.path.abspath(outfile)<EOL><DEDENT>

Plots a phased magnitude/flux time-series using the period provided.

    Parameters
    ----------

    times,mags : np.array
        The mag/flux time-series to plot as a function of phase given `period`.

    period : float
        The period to use to phase-fold the time-series. Should be the same unit
        as `times` (usually in days)

    epoch : 'min' or float or None
        This indicates how to get the epoch to use for phasing the light curve:

        - If None, uses the `min(times)` as the epoch for phasing.

        - If epoch is the string 'min', then fits a cubic spline to the phased
          light curve using `min(times)` as the initial epoch, finds the
          magnitude/flux minimum of this phased light curve fit, and finally
          uses the that time value as the epoch. This is useful for plotting
          planetary transits and eclipsing binary phased light curves so that
          phase 0.0 corresponds to the mid-center time of primary eclipse (or
          transit).

        - If epoch is a float, then uses that directly to phase the light
          curve and as the epoch of the phased mag series plot.

    fitknotfrac : float
        If `epoch='min'`, this function will attempt to fit a cubic spline to
        the phased light curve to find a time of light minimum as phase
        0.0. This kwarg sets the number of knots to generate the spline as a
        fraction of the total number of measurements in the input
        time-series. By default, this is set so that 100 knots are used to
        generate a spline for fitting the phased light curve consisting of 10000
        measurements.

    errs : np.array or None
        If this is provided, contains the measurement errors associated with
        each measurement of flux/mag in time-series. Providing this kwarg will
        add errbars to the output plot.

    magsarefluxes : bool
        Indicates if the input `mags` array is actually an array of flux
        measurements instead of magnitude measurements. If this is set to True,
        then the plot y-axis will be set as appropriate for mag or fluxes.

    normto : {'globalmedian', 'zero'} or a float
        Sets the normalization target::

          'globalmedian' -> norms each mag to the global median of the LC column
          'zero'         -> norms each mag to zero
          a float        -> norms each mag to this specified float value.

    normmingap : 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.

    sigclip : float or int or sequence of two floats/ints or None
        If a single float or int, a symmetric sigma-clip will be performed using
        the number provided as the sigma-multiplier to cut out from the input
        time-series.

        If a list of two ints/floats is provided, the function will perform an
        'asymmetric' sigma-clip. The first element in this list is the sigma
        value to use for fainter flux/mag values; the second element in this
        list is the sigma value to use for brighter flux/mag values. For
        example, `sigclip=[10., 3.]`, will sigclip out greater than 10-sigma
        dimmings and greater than 3-sigma brightenings. Here the meaning of
        "dimming" and "brightening" is set by *physics* (not the magnitude
        system), which is why the `magsarefluxes` kwarg must be correctly set.

        If `sigclip` is None, no sigma-clipping will be performed, and the
        time-series (with non-finite elems removed) will be passed through to
        the output.

    phasewrap : bool
        If this is True, the phased time-series will be wrapped around phase
        0.0.

    phasesort : bool
        If this is True, the phased time-series will be sorted in phase.

    phasebin : float or None
        If this is provided, indicates the bin size to use to group together
        measurements closer than this amount in phase. This is in units of
        phase. The binned phased light curve will be overplotted on top of the
        phased light curve. Useful for when one has many measurement points and
        needs to pick out a small trend in an otherwise noisy phased light
        curve.

    plotphaselim : sequence of two floats or None
        The x-axis limits to use when making the phased light curve plot. By
        default, this is (-0.8, 0.8), which places phase 0.0 at the center of
        the plot and covers approximately two cycles in phase to make any trends
        clear.

    yrange : list of two floats or None
        This is used to provide a custom y-axis range to the plot. If None, will
        automatically determine y-axis range.

    xtimenotphase : bool
        If True, the x-axis gets units of time (multiplies phase by period).

    xaxlabel : str
        Sets the label for the x-axis.

    yaxlabel : str or None
        Sets the label for the y-axis. If this is None, the appropriate label
        will be used based on the value of the `magsarefluxes` kwarg.

    modeltimes,modelmags,modelerrs : np.array or None
        If all of these are provided, then this function will overplot the
        values of modeltimes and modelmags on top of the actual phased light
        curve. This is useful for plotting variability models on top of the
        light curve (e.g. plotting a Mandel-Agol transit model over the actual
        phased light curve. These arrays will be phased using the already
        provided period and epoch.

    outfile : str or StringIO/BytesIO or matplotlib.axes.Axes or None
        - a string filename for the file where the plot will be written.
        - a StringIO/BytesIO object to where the plot will be written.
        - a matplotlib.axes.Axes object to where the plot will be written.
        - if None, plots to 'magseries-phased-plot.png' in current dir.

    plotdpi : int
        Sets the resolution in DPI for PNG plots (default = 100).

    Returns
    -------

    str or StringIO/BytesIO or matplotlib.axes.Axes
        This returns based on the input:

        - If `outfile` is a str or None, the path to the generated plot file is
          returned.
        - If `outfile` is a StringIO/BytesIO object, will return the
          StringIO/BytesIO object to which the plot was written.
        - If `outfile` is a matplotlib.axes.Axes object, will return the Axes
          object with the plot elements added to it. One can then directly
          include this Axes object in some other Figure.


stampdict = get_stamp(ra, decl,<EOL>survey=survey,<EOL>scaling=scaling,<EOL>forcefetch=forcefetch,<EOL>cachedir=cachedir,<EOL>timeout=timeout,<EOL>retry_failed=retry_failed,<EOL>verbose=verbose)<EOL>if stampdict:<EOL><INDENT>stampfits = pyfits.open(stampdict['<STR_LIT>'])<EOL>header = stampfits[<NUM_LIT:0>].header<EOL>frame = stampfits[<NUM_LIT:0>].data<EOL>stampfits.close()<EOL>if flip:<EOL><INDENT>frame = np.flipud(frame)<EOL><DEDENT>if verbose:<EOL><INDENT>LOGINFO('<STR_LIT>'<EOL>% (ra, decl))<EOL><DEDENT>if convolvewith:<EOL><INDENT>convolved = aconv.convolve(frame, convolvewith)<EOL>if savewcsheader:<EOL><INDENT>return convolved, header<EOL><DEDENT>else:<EOL><INDENT>return convolved<EOL><DEDENT><DEDENT>else:<EOL><INDENT>if savewcsheader:<EOL><INDENT>return frame, header<EOL><DEDENT>else:<EOL><INDENT>return frame<EOL><DEDENT><DEDENT><DEDENT>else:<EOL><INDENT>LOGERROR('<STR_LIT>'<EOL>'<STR_LIT>'<EOL>% (ra, decl, survey, scaling))<EOL>return None<EOL><DEDENT>

This downloads a DSS FITS stamp centered on the coordinates specified.

    This wraps the function :py:func:`astrobase.services.skyview.get_stamp`,
    which downloads Digitized Sky Survey stamps in FITS format from the NASA
    SkyView service:

    https://skyview.gsfc.nasa.gov/current/cgi/query.pl

    Also adds some useful operations on top of the FITS file returned.

    Parameters
    ----------

    ra,decl : float
        The center coordinates for the stamp in decimal degrees.

    survey : str
        The survey name to get the stamp from. This is one of the
        values in the 'SkyView Surveys' option boxes on the SkyView
        webpage. Currently, we've only tested using 'DSS2 Red' as the value for
        this kwarg, but the other ones should work in principle.

    scaling : str
        This is the pixel value scaling function to use.

    flip : bool
        Will flip the downloaded image top to bottom. This should usually be
        True because matplotlib and FITS have different image coord origin
        conventions. Alternatively, set this to False and use the
        `origin='lower'` in any call to `matplotlib.pyplot.imshow` when plotting
        this image.

    convolvewith : astropy.convolution Kernel object or None
        If `convolvewith` is an astropy.convolution Kernel object from:

        http://docs.astropy.org/en/stable/convolution/kernels.html

        then, this function will return the stamp convolved with that
        kernel. This can be useful to see effects of wide-field telescopes (like
        the HATNet and HATSouth lenses) degrading the nominal 1 arcsec/px of
        DSS, causing blending of targets and any variability.

    forcefetch : bool
        If True, will disregard any existing cached copies of the stamp already
        downloaded corresponding to the requested center coordinates and
        redownload the FITS from the SkyView service.

    cachedir : str
        This is the path to the astrobase cache directory. All downloaded FITS
        stamps are stored here as .fits.gz files so we can immediately respond
        with the cached copy when a request is made for a coordinate center
        that's already been downloaded.

    timeout : float
        Sets the timeout in seconds to wait for a response from the NASA SkyView
        service.

    retry_failed : bool
        If the initial request to SkyView fails, and this is True, will retry
        until it succeeds.

    savewcsheader : bool
        If this is True, also returns the WCS header of the downloaded FITS
        stamp in addition to the FITS image itself. Useful for projecting object
        coordinates onto image xy coordinates for visualization.

    verbose : bool
        If True, indicates progress.

    Returns
    -------

    tuple or array or None
        This returns based on the value of `savewcsheader`:

        - If `savewcsheader=True`, returns a tuple:
          (FITS stamp image as a numpy array, FITS header)
        - If `savewcsheader=False`, returns only the FITS stamp image as numpy
          array.
        - If the stamp retrieval fails, returns None.