docs: def generate_return_periods(qout_file,
                              return_period_file,
                              num_cpus=multiprocessing.cpu_count(),
                              storm_duration_days=7,
                              method='weibull'):
      """
      Generate return period from RAPID Qout file
      """
      # get ERA Interim Data Analyzed
      with RAPIDDataset(qout_file) as qout_nc_file:
          print("Setting up Return Periods File ...")
          return_period_nc = Dataset(return_period_file, 'w')
  
          return_period_nc.createDimension('rivid', qout_nc_file.size_river_id)
  
          timeSeries_var = \
              return_period_nc.createVariable('rivid', 'i4', ('rivid',))
          timeSeries_var.long_name = (
              'unique identifier for each river reach')
  
          max_flow_var = \
              return_period_nc.createVariable('max_flow', 'f8', ('rivid',))
          max_flow_var.long_name = 'maximum streamflow'
          max_flow_var.units = 'm3/s'
  
          if method == 'weibull':
  
              return_period_20_var = \
                  return_period_nc.createVariable('return_period_20',
                                                  'f8', ('rivid',))
              return_period_20_var.long_name = '20 year return period flow'
              return_period_20_var.units = 'm3/s'
  
          if method == 'gumble':
  
              return_period_100_var = \
                  return_period_nc.createVariable('return_period_100',
                                                  'f8', ('rivid',))
              return_period_100_var.long_name = '100 year return period flow'
              return_period_100_var.units = 'm3/s'
  
              return_period_50_var = \
                  return_period_nc.createVariable('return_period_50',
                                                  'f8', ('rivid',))
              return_period_50_var.long_name = '50 year return period flow'
              return_period_50_var.units = 'm3/s'
  
              return_period_20_var = \
                  return_period_nc.createVariable('return_period_20',
                                                  'f8', ('rivid',))
              return_period_20_var.long_name = '20 year return period flow'
              return_period_20_var.units = 'm3/s'
  
          if method == 'log_pearson':
  
              return_period_100_var = \
                  return_period_nc.createVariable('return_period_100',
                                                  'f8', ('rivid',))
              return_period_100_var.long_name = '100 year return period flow'
              return_period_100_var.units = 'm3/s'
  
              return_period_50_var = \
                  return_period_nc.createVariable('return_period_50',
                                                  'f8', ('rivid',))
              return_period_50_var.long_name = '50 year return period flow'
              return_period_50_var.units = 'm3/s'
  
              return_period_25_var = \
                  return_period_nc.createVariable('return_period_25',
                                                  'f8', ('rivid',))
              return_period_25_var.long_name = '25 year return period flow'
              return_period_25_var.units = 'm3/s'
  
          return_period_10_var = \
              return_period_nc.createVariable('return_period_10',
                                              'f8', ('rivid',))
          return_period_10_var.long_name = '10 year return period flow'
          return_period_10_var.units = 'm3/s'
  
          return_period_2_var = \
              return_period_nc.createVariable('return_period_2',
                                              'f8', ('rivid',))
          return_period_2_var.long_name = '2 year return period flow'
          return_period_2_var.units = 'm3/s'
  
          lat_var = return_period_nc.createVariable('lat', 'f8', ('rivid',),
                                                    fill_value=-9999.0)
  
          lon_var = return_period_nc.createVariable('lon', 'f8', ('rivid',),
                                                    fill_value=-9999.0)
  
          add_latlon_metadata(lat_var, lon_var)
  
          return_period_nc.variables['lat'][:] = \
              qout_nc_file.qout_nc.variables['lat'][:]
          return_period_nc.variables['lon'][:] = \
              qout_nc_file.qout_nc.variables['lon'][:]
  
          river_id_list = qout_nc_file.get_river_id_array()
          return_period_nc.variables['rivid'][:] = river_id_list
  
          return_period_nc.return_period_method = method
  
          return_period_nc.close()
  
          time_array = qout_nc_file.get_time_array()
  
      log("Extracting Data and Generating Return Periods ...")
      num_years = int((datetime.utcfromtimestamp(time_array[-1]) -
                       datetime.utcfromtimestamp(time_array[0])).days/365.2425)
      time_steps_per_day = (24 * 3600) / float(
          (datetime.utcfromtimestamp(time_array[1]) -
           datetime.utcfromtimestamp(time_array[0])).total_seconds())
      step = max(1, int(time_steps_per_day * storm_duration_days))
  
      # generate multiprocessing jobs
      # pylint: disable=no-member
      mp_lock = multiprocessing.Manager().Lock()
      job_combinations = []
      partition_index_list = partition(river_id_list, num_cpus*2)[1]
      for sub_partition_index_list in partition_index_list:
          # pylint: disable=len-as-condition
          if len(sub_partition_index_list) > 0:
              job_combinations.append((qout_file,
                                       return_period_file,
                                       sub_partition_index_list,
                                       step,
                                       num_years,
                                       method,
                                       mp_lock
                                       ))
  
      pool = multiprocessing.Pool(num_cpus)
      pool.map(generate_single_return_period,
               job_combinations)
      pool.close()
      pool.join()