def periodicvar_recovery(fakepfpkl,<EOL>simbasedir,<EOL>period_tolerance=<NUM_LIT>):
if fakepfpkl.endswith('<STR_LIT>'):<EOL><INDENT>infd = gzip.open(fakepfpkl,'<STR_LIT:rb>')<EOL><DEDENT>else:<EOL><INDENT>infd = open(fakepfpkl,'<STR_LIT:rb>')<EOL><DEDENT>fakepf = pickle.load(infd)<EOL>infd.close()<EOL>objectid, lcfbasename = fakepf['<STR_LIT>'], fakepf['<STR_LIT>']<EOL>lcfpath = os.path.join(simbasedir,'<STR_LIT>',lcfbasename)<EOL>if not os.path.exists(lcfpath):<EOL><INDENT>LOGERROR('<STR_LIT>' % (objectid,<EOL>lcfpath))<EOL>return None<EOL><DEDENT>fakelc = lcproc._read_pklc(lcfpath)<EOL>actual_varparams, actual_varperiod, actual_varamplitude, actual_vartype = (<EOL>fakelc['<STR_LIT>'],<EOL>fakelc['<STR_LIT>'],<EOL>fakelc['<STR_LIT>'],<EOL>fakelc['<STR_LIT>']<EOL>)<EOL>actual_moments = fakelc['<STR_LIT>']<EOL>magcols = fakelc['<STR_LIT>']<EOL>pfres = {<EOL>'<STR_LIT>':objectid,<EOL>'<STR_LIT>':simbasedir,<EOL>'<STR_LIT>':magcols,<EOL>'<STR_LIT>':os.path.abspath(lcfpath),<EOL>'<STR_LIT>':os.path.abspath(fakepfpkl),<EOL>'<STR_LIT>':actual_vartype,<EOL>'<STR_LIT>':actual_varperiod,<EOL>'<STR_LIT>':actual_varamplitude,<EOL>'<STR_LIT>':actual_varparams,<EOL>'<STR_LIT>':actual_moments,<EOL>'<STR_LIT>':[],<EOL>'<STR_LIT>':[],<EOL>'<STR_LIT>':[],<EOL>'<STR_LIT>':[],<EOL>'<STR_LIT>':[],<EOL>'<STR_LIT>':[],<EOL>}<EOL>for magcol in magcols:<EOL><INDENT>for pfm in lcproc.PFMETHODS:<EOL><INDENT>if pfm in fakepf[magcol]:<EOL><INDENT>for rpi, rp in enumerate(<EOL>fakepf[magcol][pfm]['<STR_LIT>']<EOL>):<EOL><INDENT>if ((not np.any(np.isclose(<EOL>rp,<EOL>np.array(pfres['<STR_LIT>']),<EOL>rtol=period_tolerance<EOL>))) and np.isfinite(rp)):<EOL><INDENT>pfres['<STR_LIT>'].append(rp)<EOL>pfres['<STR_LIT>'].append(pfm)<EOL>pfres['<STR_LIT>'].append(magcol)<EOL>if pfm == '<STR_LIT>':<EOL><INDENT>this_lspval = (<EOL>np.max(fakepf[magcol][pfm]['<STR_LIT>']) -<EOL>fakepf[magcol][pfm]['<STR_LIT>'][rpi]<EOL>)<EOL><DEDENT>else:<EOL><INDENT>this_lspval = (<EOL>fakepf[magcol][pfm]['<STR_LIT>'][rpi] /<EOL>np.max(fakepf[magcol][pfm]['<STR_LIT>'])<EOL>)<EOL><DEDENT>pfres['<STR_LIT>'].append(this_lspval)<EOL><DEDENT><DEDENT><DEDENT><DEDENT><DEDENT>pfres['<STR_LIT>'] = np.array(pfres['<STR_LIT>'])<EOL>pfres['<STR_LIT>'] = np.array(pfres['<STR_LIT>'])<EOL>pfres['<STR_LIT>'] = np.array(pfres['<STR_LIT>'])<EOL>pfres['<STR_LIT>'] = np.array(pfres['<STR_LIT>'])<EOL>if (actual_vartype and<EOL>actual_vartype in PERIODIC_VARTYPES and<EOL>np.isfinite(actual_varperiod)):<EOL><INDENT>if pfres['<STR_LIT>'].size > <NUM_LIT:0>:<EOL><INDENT>for ri in range(pfres['<STR_LIT>'].size):<EOL><INDENT>pfres['<STR_LIT>'].append(pfres['<STR_LIT>'][ri] -<EOL>np.asscalar(actual_varperiod))<EOL>pfres['<STR_LIT>'].append(<EOL>check_periodrec_alias(actual_varperiod,<EOL>pfres['<STR_LIT>'][ri],<EOL>tolerance=period_tolerance)<EOL>)<EOL><DEDENT>pfres['<STR_LIT>'] = np.array(pfres['<STR_LIT>'])<EOL>pfres['<STR_LIT>'] = np.array(pfres['<STR_LIT>'])<EOL>rec_absdiff = np.abs(pfres['<STR_LIT>'])<EOL>best_recp_ind = rec_absdiff == rec_absdiff.min()<EOL>pfres['<STR_LIT>'] = (<EOL>pfres['<STR_LIT>'][best_recp_ind]<EOL>)<EOL>pfres['<STR_LIT>'] = (<EOL>pfres['<STR_LIT>'][best_recp_ind]<EOL>)<EOL>pfres['<STR_LIT>'] = (<EOL>pfres['<STR_LIT>'][best_recp_ind]<EOL>)<EOL>pfres['<STR_LIT>'] = (<EOL>pfres['<STR_LIT>'][best_recp_ind]<EOL>)<EOL>pfres['<STR_LIT>'] = (<EOL>pfres['<STR_LIT>'][best_recp_ind]<EOL>)<EOL><DEDENT>else:<EOL><INDENT>LOGWARNING(<EOL>'<STR_LIT>' %<EOL>fakepfpkl<EOL>)<EOL>pfres['<STR_LIT>'] = np.array(['<STR_LIT>'])<EOL>pfres['<STR_LIT>'] = np.array([np.nan])<EOL>pfres['<STR_LIT>'] = np.array([np.nan])<EOL>pfres['<STR_LIT>'] = np.array([],dtype=np.unicode_)<EOL>pfres['<STR_LIT>'] = np.array([],dtype=np.unicode_)<EOL>pfres['<STR_LIT>'] = np.array([],dtype=np.unicode_)<EOL>pfres['<STR_LIT>'] = np.array([np.nan])<EOL><DEDENT><DEDENT>else:<EOL><INDENT>pfres['<STR_LIT>'] = np.array(<EOL>['<STR_LIT>']*pfres['<STR_LIT>'].size<EOL>)<EOL>pfres['<STR_LIT>'] = np.zeros(pfres['<STR_LIT>'].size)<EOL>pfres['<STR_LIT>'] = np.array([np.nan])<EOL>pfres['<STR_LIT>'] = np.array([],dtype=np.unicode_)<EOL>pfres['<STR_LIT>'] = np.array([],dtype=np.unicode_)<EOL>pfres['<STR_LIT>'] = np.array(['<STR_LIT>'])<EOL>pfres['<STR_LIT>'] = np.array([np.nan])<EOL><DEDENT>return pfres<EOL>
Recovers the periodic variable status/info for the simulated PF result.

    - Uses simbasedir and the lcfbasename stored in fakepfpkl to figure out
      where the LC for this object is.
    - Gets the actual_varparams, actual_varperiod, actual_vartype,
      actual_varamplitude elements from the LC.
    - Figures out if the current objectid is a periodic variable (using
      actual_vartype).
    - If it is a periodic variable, gets the canonical period assigned to it.
    - Checks if the period was recovered in any of the five best periods
      reported by any of the period-finders, checks if the period recovered was
      a harmonic of the period.
    - Returns the objectid, actual period and vartype, recovered period, and
      recovery status.


    Parameters
    ----------

    fakepfpkl : str
        This is a periodfinding-<objectid>.pkl[.gz] file produced in the
        `simbasedir/periodfinding` subdirectory after `run_periodfinding` above
        is done.

    simbasedir : str
        The base directory where all of the fake LCs and period-finding results
        are.

    period_tolerance : float
        The maximum difference that this function will consider between an
        actual period (or its aliases) and a recovered period to consider it as
        as a 'recovered' period.

    Returns
    -------

    dict
        Returns a dict of period-recovery results.