<commit_before>import logging
logger = logging.getLogger(__name__)


def get_configfile(files, timewin=1, varname='slp', seacyc=False,
                   cycsmooth=91, nanalog=20, 
                   seasonwin=30, 
                   distfun='rms', outformat='.txt',
                   period=["1973-01-01","2012-12-31"], 
                   bbox="-80.0,50.0,22.5,70.0",
                   calccor=True, silent=False, ): 
  """
  Generating the configuration file for CASTf90 calculation

  :param files: input files (reference period and period for analyses)
  :param timewin:
  :param varname: variable name in input files
  :param seacyc:
  :param cycsmooth:
  :param nanalog: Number of analogs to be detect
  :param distfun:
  :param outformat: file format for output ('txt' or 'nc' (default))
  :param period: reference period for analogs to be picked
  :param bbox: cooridates for the region to be analysed
  :param calccor:
  :param silent: handling of log file output

  :returns: configuration file
  """
  from datetime import datetime as dt
  from os.path import abspath
  from tempfile import mkstemp
  
  date_stamp = dt.strftime(dt.now(), format='%Y%m%d_%H%M%S')
  logger.info('start configuraion file preparation at: %s' %(date_stamp))

  # convert True/False to Fortran syntax
  seacyc=str(seacyc)
  calccor=str(calccor)
  silent=str(silent)


  # write stuff to configuration file
  ip, config_file = mkstemp(dir='.',suffix='.txt')

  config = open(config_file, "w")
  
  config.write('!Configuration file for flyingpigeon analogs process\n')
  config.write('!Created : %s \n' % ( date_stamp ))
  config.write('!Version : 0.1 \n')
  config.write('&FILES \n')
  config.write(' my_files%archivefile = "{file}" \n'.format(file=files[0]) ) 
  config.write(' my_files%simulationfile = "{file}" \n'.format(file=files[1]) )<commit_msg>added some documentation to analogs.get_configfile<commit_after>import logging
logger = logging.getLogger(__name__)


def get_configfile(files, timewin=1, varname='slp', seacyc=False,
                   cycsmooth=91, nanalog=20, 
                   seasonwin=30, 
                   distfun='rms', outformat='.txt',
                   period=["1973-01-01","2012-12-31"], 
                   bbox="-80.0,50.0,22.5,70.0",
                   calccor=True, silent=False, ): 
  """
  Generating the configuration file for CASTf90 calculation

  :param files: input files (reference period and period for analyses)
  :param timewin: number of days the distance is averaged
  :param varname: variable name in input files
  :param seacyc: remove the smoothed seasonal cycle from the input fields (True/False)
  :param cycsmooth: smoothing window for the seasonal cycle in days (should be an odd integer)
  :param nanalog: Number of analogs to be detect
  :param distfun: Name of the distance function used to calculate the analogs. 
   (Supported values: 'rms' 'mahalanobis', 'S1' (Teweles and wobus), 'cosine' (correlation) 
   and - still experimental - 'of' (displacement and amplitude score based on optical flow image distortion)
  :param outformat: file format for output ('txt' or 'nc' (default))
  :param period: reference period for analogs to be picked (for netcdf output attributes)
  :param bbox: cooridates for the region to be analysed
  :param calccor: calculate rank correlation for analog fields (True/False)
  :param silent: handling of log file output

  :returns: configuration file
  """
  from datetime import datetime as dt
  from os.path import abspath
  from tempfile import mkstemp
  
  date_stamp = dt.strftime(dt.now(), format='%Y%m%d_%H%M%S')
  logger.info('start configuraion file preparation at: %s' %(date_stamp))

  # convert True/False to Fortran syntax
  seacyc=str(seacyc)
  calccor=str(calccor)
  silent=str(silent)


  # write stuff to configuration file
  ip, config_file = mkstemp(dir='.',suffix='.txt')

  config = open(config_file, "w")
  
  config.write('!Configuration file for flyingpigeon analogs process\n')
  config.write('!Created : %s \n' % ( date_stamp ))
  config.write('!Version : 0.1 \n')
  config.write('&FILES \n')
  config.write(' my_files%archivefile = "{file}" \n'.format(file=files[0]) ) 
  config.write(' my_files%simulationfile = "{file}" \n'.format(file=files[1]) )
{'fraction_non_alphanumeric': 0.11817116060961314, 'fraction_numerical': 0.019460726846424383, 'mean_word_length': 3.6069114470842334, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7022471', 'n_tokens_mistral': 1435, 'n_tokens_neox': 1329, 'n_words': 407}