def pdw_worker(task):
frequency = task[<NUM_LIT:0>]<EOL>times, modmags = task[<NUM_LIT:1>], task[<NUM_LIT:2>]<EOL>fold_time = task[<NUM_LIT:3>]<EOL>j_range = range(task[<NUM_LIT:4>])<EOL>keep_threshold_1 = task[<NUM_LIT:5>]<EOL>keep_threshold_2 = task[<NUM_LIT:6>]<EOL>phasebinsize = task[<NUM_LIT:7>]<EOL>try:<EOL><INDENT>period = <NUM_LIT:1.0>/frequency<EOL>phased = phase_magseries(times,<EOL>modmags,<EOL>period,<EOL>fold_time,<EOL>wrap=False,<EOL>sort=True)<EOL>if phasebinsize is not None and phasebinsize > <NUM_LIT:0>:<EOL><INDENT>bphased = pwd_phasebin(phased['<STR_LIT>'],<EOL>phased['<STR_LIT>'],<EOL>binsize=phasebinsize)<EOL>phase_sorted = bphased[<NUM_LIT:0>]<EOL>mod_mag_sorted = bphased[<NUM_LIT:1>]<EOL>j_range = range(len(mod_mag_sorted) - <NUM_LIT:1>)<EOL><DEDENT>else:<EOL><INDENT>phase_sorted = phased['<STR_LIT>']<EOL>mod_mag_sorted = phased['<STR_LIT>']<EOL><DEDENT>rolledmags = nproll(mod_mag_sorted,<NUM_LIT:1>)<EOL>rolledphases = nproll(phase_sorted,<NUM_LIT:1>)<EOL>strings = (<EOL>(rolledmags - mod_mag_sorted)*(rolledmags - mod_mag_sorted) +<EOL>(rolledphases - phase_sorted)*(rolledphases - phase_sorted)<EOL>)<EOL>strings[<NUM_LIT:0>] = (<EOL>((mod_mag_sorted[<NUM_LIT:0>] - mod_mag_sorted[-<NUM_LIT:1>]) *<EOL>(mod_mag_sorted[<NUM_LIT:0>] - mod_mag_sorted[-<NUM_LIT:1>])) +<EOL>((phase_sorted[<NUM_LIT:0>] - phase_sorted[-<NUM_LIT:1>] + <NUM_LIT:1>) *<EOL>(phase_sorted[<NUM_LIT:0>] - phase_sorted[-<NUM_LIT:1>] + <NUM_LIT:1>))<EOL>)<EOL>strlen = npsum(npsqrt(strings))<EOL>if (keep_threshold_1 < strlen < keep_threshold_2):<EOL><INDENT>p_goodflag  = True<EOL><DEDENT>else:<EOL><INDENT>p_goodflag = False<EOL><DEDENT>return (period, strlen, p_goodflag)<EOL><DEDENT>except Exception as e:<EOL><INDENT>LOGEXCEPTION('<STR_LIT>')<EOL>return(period, npnan, False)<EOL><DEDENT>
This is the parallel worker for the function below.

task[0] = frequency for this worker
task[1] = times array
task[2] = mags array
task[3] = fold_time
task[4] = j_range
task[5] = keep_threshold_1
task[6] = keep_threshold_2
task[7] = phasebinsize

we don't need errs for the worker.