pool = Pool(WORKERS)
        map_func = pool.map
    else:
        pool = None
        map_func = map

    for su_type in range(SU):
        for file_num in range(NUM_FILES):
            bins_surrogates = np.zeros((SU, NUM_SURR / NUM_FILES,
                                        sg.data.shape[1], sg.data.shape[2], 8))
            bins_surrogates_var = np.zeros_like(bins_surrogates)
            for surr_completed in range(NUM_SURR / NUM_FILES):
                # create surrogates field
                if (SURR_TYPE == 'MF') or (SURR_TYPE == 'ALL'
                                           and su_type == 0):
                    sg.construct_multifractal_surrogates(pool=pool)
                    sg.add_seasonality(0, var, trend)
                elif (SURR_TYPE == 'FT') or (SURR_TYPE == 'ALL'
                                             and su_type == 1):
                    sg.construct_fourier_surrogates_spatial(pool=pool)
                    sg.add_seasonality(0, var, trend)
                elif (SURR_TYPE == 'AR') or (SURR_TYPE == 'ALL'
                                             and su_type == 2):
                    sg.construct_surrogates_with_residuals(pool=pool)
                    sg.add_seasonality(0, var[:-1, ...], trend[:-1, ...])

                # oscillatory modes
                phase_surrs = np.zeros_like(sg.surr_data)
                job_args = [(i, j, s0, sg.surr_data[:, i, j])
                            for i in range(sg.lats.shape[0])
                            for j in range(sg.lons.shape[0])]
 t_last = t_start
 if WORKERS != 0:
     pool = Pool(WORKERS)
     map_func = pool.map
 else:
     pool = None
     map_func = map
 
 for su_type in range(SU):
     for file_num in range(NUM_FILES):
         bins_surrogates = np.zeros((SU, NUM_SURR/NUM_FILES, sg.data.shape[1], sg.data.shape[2], 8))
         bins_surrogates_var = np.zeros_like(bins_surrogates)
         for surr_completed in range(NUM_SURR/NUM_FILES):
             # create surrogates field
             if (SURR_TYPE == 'MF') or (SURR_TYPE == 'ALL' and su_type == 0):
                 sg.construct_multifractal_surrogates(pool = pool)
                 sg.add_seasonality(0, var, trend)
             elif (SURR_TYPE == 'FT') or (SURR_TYPE == 'ALL' and su_type == 1):
                 sg.construct_fourier_surrogates_spatial(pool = pool)
                 sg.add_seasonality(0, var, trend)
             elif (SURR_TYPE == 'AR') or (SURR_TYPE == 'ALL' and su_type == 2):
                 sg.construct_surrogates_with_residuals(pool = pool)
                 sg.add_seasonality(0, var[:-1, ...], trend[:-1, ...])
         
             # oscillatory modes
             phase_surrs = np.zeros_like(sg.surr_data)
             job_args = [ (i, j, s0, sg.surr_data[:, i, j]) for i in range(sg.lats.shape[0]) for j in range(sg.lons.shape[0]) ]
             job_result = map_func(_get_oscillatory_modes, job_args)
             del job_args
             # map results
             for i, j, ph in job_result: