Exemplo n.º 1
0
#                Adapted from ComputePetrus.py
# -------------------------------------------------------------------
# - L@ST MODIFIED: 2018-01-19 15:20 on marvin
# -------------------------------------------------------------------

import sys, os
sys.path.append('PyModules')

# - Start as main script (not as module)
if __name__ == '__main__':

    import numpy as np
    # - Wetterturnier specific modules
    from pywetterturnier import utils, database
    # - Evaluating input arguments
    inputs = utils.inputcheck('ComputeStats')
    # - Read configuration file
    config = utils.readconfig('config.conf', inputs)

    # - Initializing class and open database connection
    db = database.database(config)
    post_id = config['input_param']
    t = config['input_tdate']

    excluded_users = ["WB-Berlin", "Foehni"]

    for i in ("Automaten", "Referenztipps", "MM-MOS", "WAV2", "Aviatik"):
        group_users = db.get_users_in_group(group=i)
        for j in group_users:
            excluded_users.append(j)
Exemplo n.º 2
0
# -------------------------------------------------------------------
# - Start as main script (not as module)
# -------------------------------------------------------------------
if __name__ == '__main__':

    import sys, os
    import numpy as np
    from glob import glob
    # - wetterturnier specific packages
    from pywetterturnier import utils, database
    from datetime import datetime as dt
    import numpy as np

    # - Evaluating input arguments
    inputs = utils.inputcheck('PrintMoses')
    # - Read configuration file
    config = utils.readconfig('config.conf', inputs)

    # - Initializing class and open database connection
    db = database.database(config)
    # - Loading tdate (day since 1970-01-01) for the tournament.
    #   Normaly Friday-Tornament (tdate is then Friday) while
    #   the bet-dates are for Saturday and Sunday if there was
    #   no input tournament date -t/--tdate.
    if config['input_tdate'] == None:
        tdates = [db.current_tournament()]
    else:
        tdates = [config['input_tdate']]

    # - Loading all different cities (active cities)
# - Start as main script (not as module)
if __name__ == '__main__':

    import sys, os
    import pandas as pd
    # - Wetterturnier specific methods
    from pywetterturnier import utils, database

    # - Evaluating input arguments
    inputs = utils.inputcheck('ComputeUserStats')

    # - Read configuration file
    config = utils.readconfig('config.conf', inputs)
    # - Initializing class and open database connection
    db = database.database(config)

    # - Loading all different cities (active cities)
    cities = db.get_cities()
    # - If input city set, then drop all other cities.
    if not config['input_city'] == None:
        tmp = []
        for elem in cities:
            if elem['name'] == config['input_city']: tmp.append(elem)
        cities = tmp

    #userIDs = db.get_all_users()
    userIDs = []
    #users = ["Moses","Petrus","Georg","Pfingstochse","Schneegewitter","Michi23","MOS-Mix"]
    users = ["Moses", "Petrus", "Georg", "Meteomedia"]

    if config["input_users"]:
   ax.set_xticklabels(hashes)
   ax.set_ylabel("Points")

   fig.set_size_inches( 16,9 )
   fig.savefig("plots/mean_sd", dpi=96)


# - Start as main script (not as module)
# -------------------------------------------------------------------
if __name__ == '__main__':

   # - need to import the database
   from pywetterturnier import database, utils

   # - Evaluating input arguments
   inputs = utils.inputcheck('PlotStats')
   # - Read configuration file
   config = utils.readconfig('config.conf',inputs)

   # - Initializing class and open database connection
   db        = database.database(config)

   # ----------------------------------------------------------------
   # - Loading all different cities (active cities)
   cities     = db.get_cities()

   #TODO: only accepted input should be city!
   # - If input city set, then drop all other cities.
   if not config['input_city'] == None:
      tmp = []
      for i in cities:
# -------------------------------------------------------------------
# - L@ST MODIFIED: 2017-06-27 12:58 on thinkreto
# -------------------------------------------------------------------

import sys, os
sys.path.append('PyModules')

# - Start as main script (not as module)
if __name__ == '__main__':

   import numpy as np
   # - Wetterturnier specific modules
   from pywetterturnier import utils, database
   
   # - Evaluating input arguments
   inputs = utils.inputcheck('ComputePoints')
   # - Read configuration file
   config = utils.readconfig('config.conf',inputs)

   # - Initializing class and open database connection
   db        = database.database(config)
   # - Loading tdate (day since 1970-01-01) for the tournament.
   #   Normaly Friday-Tornament (tdate is then Friday) while
   #   the bet-dates are for Saturday and Sunday.
   if config['input_tdate'] == None:
      tdates     = [db.current_tournament()]
      print '  * Current tournament is %s' % utils.tdate2string( tdates[0] )
   else:
      tdates     = [config['input_tdate']]

from pywetterturnier import database, utils
import numpy
import moses as m


def coefs(cities):
    #calling the fortran program for each city
    for city in cities:
        m.moses.processmoses(city['name'][0].lower() + "pw")


if __name__ == "__main__":
    # - Evaluating input arguments
    inputs = utils.inputcheck('ComputeCoefs')
    # - Read configuration file
    config = utils.readconfig('config.conf', inputs)

    # - Initializing class and open database connection
    db = database.database(config)
    # - Loading tdate (day since 1970-01-01) for the tournament.
    #   Normaly Friday-Tornament (tdate is then Friday) while
    #   the bet-dates are for Saturday and Sunday if there was
    #   no input tournament date -t/--tdate.
    if config['input_tdate'] == None:
        tdates = [db.current_tournament()]
    else:
        tdates = [config['input_tdate']]

    # - Loading all different cities (active cities)
    cities = db.get_cities()
    print cities
Exemplo n.º 7
0
# -------------------------------------------------------------------
# - L@ST MODIFIED: 2018-12-16 11:47 on marvin
# -------------------------------------------------------------------

# - Start as main script (not as module)
if __name__ == '__main__':

    import sys, os
    import numpy as np
    # - Wetterturnier specific modules
    from pywetterturnier import utils
    from pywetterturnier import database
    from pywetterturnier import mitteltip

    # - Evaluating input arguments
    inputs = utils.inputcheck('ComputeMeanBets')
    # - Read configuration file
    config = utils.readconfig('config.conf', inputs)

    # - Initializing class and open database connection
    db = database.database(config)

    # - Loading tdate (day since 1970-01-01) for the tournament.
    #   Normaly Friday-Tornament (tdate is then Friday) while
    #   the bet-dates are for Saturday and Sunday.
    if config['input_tdate'] == None:
        tdates = [db.current_tournament()]
        print '  * Current tournament is %s' % utils.tdate2string(tdates[0])
    else:
        tdates = [config['input_tdate']]
# - Start as main script (not as module)
if __name__ == '__main__':

    import numpy as np
    # - Wetterturnier specific modules
    from pywetterturnier import utils, database
    # - Evaluating input arguments
    inputs = utils.inputcheck('UserVoting')
    # - Read configuration file
    config = utils.readconfig('config.conf', inputs)

    # - Initializing class and open database connection
    db = database.database(config)
    post_id = config['input_param']
    t = config['input_tdate']

    excluded_usernames = ["WB-Berlin", "Foehni", "Sleepy"]
    excluded_users = [db.get_user_id(i) for i in excluded_usernames]

    for i in ("Automaten", "Referenztipps", "MM-MOS", "WAV2", "Aviatik"):
        group_users = db.get_users_in_group(group=i)
        print(i)
        for j in group_users:
            print(j)
            excluded_users.append(int(j))

    #find out which users have at least played once in wetterturnier
    sql = "SELECT DISTINCT userID FROM %swetterturnier_betstat"
    cur = db.cursor()
    cur.execute(sql % db.prefix)
    data = cur.fetchall()
from pywetterturnier import database, utils
import pandas as pd

inputs = utils.inputcheck('ExportTables')
# - Read configuration file
config = utils.readconfig('config.conf', inputs)
# - Initializing class and open database connection
db = database.database(config)

cities = db.get_cities()

#sql = "SELECT wu.user_login, us.points_adj, %s FROM %swetterturnier_userstats us JOIN %susers wu ON userID = wu.ID WHERE cityID=%d AND max!=0 AND min!=0 and part >= 25 ORDER BY wu.user_login"

sql = "SELECT wu.user_login, bs.points, %s FROM %swetterturnier_betstat bs JOIN %susers wu ON userID = wu.ID WHERE cityID=%d AND wu.user_login NOT LIKE 'Sleepy' ORDER BY tdate"

measures = ["tdate", "rank"]
#measures = ["mean","median","Qlow","Qupp","max","min","sd","part"]
cols = ",".join(measures)

if config['input_filename'] == None:
    filename = "test"
else:
    filename = config['input_filename']

#generating ranking table output, write to .xls file
with pd.ExcelWriter("plots/%s.xls" % filename) as writer:
    for city in cities:
        table = pd.read_sql_query(
            sql % (cols, db.prefix, db.prefix, city['ID']), db)
        table.to_excel(writer, sheet_name=city["hash"])
# - ComputeFortuna.py- #
# -------------------- #
# - Start as main script (not as module)
if __name__ == '__main__':

    import sys, os
    import numpy as np
    from scipy.stats import mode
    from glob import glob
    # - Wetterturnier specific methods
    from pywetterturnier import getobs, utils, database, mitteltip

    # - Evaluating input arguments
    inputs = utils.inputcheck('ComputeFortuna')
    # - Read configuration file
    config = utils.readconfig('config.conf', inputs)

    # - Initializing class and open database connection
    db = database.database(config)

    # - Loading tdate (day since 1970-01-01) for the tournament.
    #   Normaly Friday-Tornament (tdate is then Friday) while
    #   the bet-dates are for Saturday and Sunday if there was
    #   no input tournament date -t/--tdate.
    if config['input_tdate'] == None:
        tdates = db.current_tournament()
    else:
        tdates = config['input_tdate']

    print('  * Current tournament is %s' % utils.tdate2string(tdates))
    # - Loading all different cities (active cities)
Exemplo n.º 11
0
    from pywetterturnier import importbets
    from pywetterturnier.utils import nicename

    # Some MOS systems have been renamed. Loading conversion table.
    fid = open("data/MOSrenaming.txt", "r")
    conversion_table = {}
    for line in fid.readlines():
        if line.strip()[0] == "#": continue
        line = line.split(";")
        conversion_table[nicename(line[1].strip())] = nicename(line[0].strip())
        print line[1].strip(), nicename(line[1].strip())
        print "   - Old: %-20s  New: %-20s" % (nicename(
            line[1]), nicename(line[0]))

    # - Reading configuration file first
    inputs = utils.inputcheck('archive')
    config = utils.readconfig(inputs=inputs, conversion_table=conversion_table)

    # ----------------------------------------------------------------
    # - Because of the observations we have to compute the
    #   points city by city. Loading city data here first.
    # ----------------------------------------------------------------
    from pywetterturnier import database
    # - Initializing class and open database connection
    db = database.database(config)

    # - Loading all different cities (active cities)
    cities = db.get_cities()
    # - If input city set, then drop all other cities.
    if not config['input_city'] == None:
        tmp = []
# - EDITORIAL:   2015-07-29, RS: Adapted from ComputeMoses.py
# -------------------------------------------------------------------
# - L@ST MODIFIED: 2018-01-20 13:15 on prognose2
# -------------------------------------------------------------------

# - Start as main script (not as module)
if __name__ == '__main__':

    import sys, os
    import numpy as np
    from glob import glob
    # - Wetterturnier specific methods
    from pywetterturnier import utils, database, mitteltip

    # - Evaluating input arguments
    inputs = utils.inputcheck('ComputePersistenzen')
    # - Read configuration file
    config = utils.readconfig('config.conf', inputs)

    # - Initializing class and open database connection
    db = database.database(config)
    # - Loading tdate (day since 1970-01-01) for the tournament.
    #   Normaly Friday-Tornament (tdate is then Friday) while
    #   the bet-dates are for Saturday and Sunday if there was
    #   no input tournament date -t/--tdate.
    if config['input_tdate'] == None:
        tdates = [db.current_tournament()]

    else:
        tdates = [config['input_tdate']]
    print "Current tournament is %s" % utils.tdate2string(tdates[0])
Exemplo n.º 13
0
# - Start as main script (not as module)
if __name__ == '__main__':

    import sys, os
    # - Wetterturnier specific modules
    from pywetterturnier import utils, database, mitteltip

    # - Evaluating input arguments
    inputs = utils.inputcheck('CleanBets')
    # - Read configuration file
    config = utils.readconfig('config.conf', inputs)

    # - If input_user was given as string we have to find the
    #   corresponding userID first!
    if not config['input_user'] == None:
        print '[!] NOTE: got input -u/--user. Will be ignored in CleanBets.'
        config['input_user'] = None

    # - Initializing class and open database connection
    db = database.database(config)
    # - Loading tdate (day since 1970-01-01) for the tournament.
    #   Normaly Friday-Tornament (tdate is then Friday) while
    #   the bet-dates are for Saturday and Sunday if there was
    #   no input tournament date -t/--tdate.
    if config['input_tdate'] == None:
        tdates = [db.current_tournament()]
    else:
        tdates = [config['input_tdate']]

    print '  * Current tournament is %s' % utils.tdate2string(tdates[0])
    # - Loading all different cities (active cities)
Exemplo n.º 14
0
# - Start as main script (not as module)
if __name__ == '__main__':
    """
   ComputeSleepy: the sleepy is the player who contains
   points only - these are the points which will be applied
   to all users which did not join the tournament.
   Used by the ranking routines and stuff.
   """

    import sys, os
    import numpy as np
    # - Wetterturnier specific modules
    from pywetterturnier import utils, database

    # - Evaluating input arguments
    inputs = utils.inputcheck('ComputeSleepy')
    # - Read configuration file
    config = utils.readconfig('config.conf', inputs)

    # - Initializing class and open database connection
    db = database.database(config)
    # - Loading tdate (day since 1970-01-01) for the tournament.
    #   Normaly Friday-Tornament (tdate is then Friday) while
    #   the bet-dates are for Saturday and Sunday.
    if config['input_tdate'] == None:
        tdates = [db.current_tournament()]
        print('  * Current tournament is %s' % utils.tdate2string(tdates[0]))
    else:
        tdates = [config['input_tdate']]

    # - Loading all different cities (active cities)
# -------------------------------------------------------------------
# - L@ST MODIFIED: 2017-06-27 12:58 on thinkreto
# -------------------------------------------------------------------

import sys, os
sys.path.append('PyModules')

# - Start as main script (not as module)
if __name__ == '__main__':

    import numpy as np
    # - Wetterturnier specific modules
    from pywetterturnier import utils, database

    # - Evaluating input arguments
    inputs = utils.inputcheck('ComputeRanksOnly')
    # - Read configuration file
    config = utils.readconfig('config.conf', inputs)

    # - Initializing class and open database connection
    db = database.database(config)
    # - Loading tdate (day since 1970-01-01) for the tournament.
    #   Normaly Friday-Tornament (tdate is then Friday) while
    #   the bet-dates are for Saturday and Sunday.
    if config['input_tdate'] == None:
        tdates = [db.current_tournament()]
        print('  * Current tournament is %s' % utils.tdate2string(tdates[0]))
    else:
        tdates = [config['input_tdate']]

    # - If input_user was given as string we have to find the
Exemplo n.º 16
0

# - Start as main script (not as module)
if __name__ == '__main__':

   import numpy as np
   import sys, os
   # - Wetterturnier specific modules
   from pywetterturnier import utils
   from pywetterturnier import database
   from pywetterturnier import getobs

   os.environ['TZ'] = 'UTC' # Important!
   
   # - Evaluating input arguments
   inputs = utils.inputcheck('Observations')
   # - Read configuration file
   config = utils.readconfig('config.conf',inputs)

   # - Reading WMO WW conversion file
   wmoww = utils.wmowwConversion( "wmo_ww.conf" )
   #wmoww.show()

   # - Initializing class and open database connection
   db        = database.database(config)
   # - Loading tdate (day since 1970-01-01) for the tournament.
   #   Normaly Friday-Tornament (tdate is then Friday) while
   #   the bet-dates are for Saturday and Sunday.
   if config['input_tdate'] == None:
      tdates     = [db.current_tournament()]
      print '  * Current tournament is %s' % utils.tdate2string( tdates[0] )
# -------------------------------------------------------------------

# - Start as main script (not as module)
if __name__ == '__main__':

    import sys, os
    import numpy as np
    from glob import glob
    # - wetterturnier specific packages
    from pywetterturnier import utils, database, mitteltip
    from datetime import datetime as dt
    import numpy as np
    from PrintMoses import print_moses

    # - Evaluating input arguments
    inputs = utils.inputcheck('ComputeMoses')
    # - Read configuration file
    config = utils.readconfig('config.conf', inputs)

    # - Initializing class and open database connection
    db = database.database(config)

    # - Loading all different cities (active cities)
    cities = db.get_cities()

    # - Loading tdate (day since 1970-01-01) for the tournament.
    #   Normaly Friday-Tornament (tdate is then Friday) while
    #   the bet-dates are for Saturday and Sunday if there was
    #   no input tournament date -t/--tdate.
    if config['input_tdate'] == None:
        tdates = [db.current_tournament()]
# - L@ST MODIFIED: 2017-06-27 16:00 on thinkreto
# -------------------------------------------------------------------

import sys, os

sys.path.append('PyModules')

# - Start as main script (not as module)
if __name__ == '__main__':

    import numpy as np
    # - Wetterturnier specific modules
    from pywetterturnier import utils, database

    # - Evaluating input arguments
    inputs = utils.inputcheck('CheckMergeUsers')
    # - Read configuration file
    config = utils.readconfig('config.conf', inputs)
    # - Initializing class and open database connection
    db = database.database(config)
    tdates = db.all_tournament_dates(None)

    # ----------------------------------------------------------------
    # Usage notification
    # ----------------------------------------------------------------
    if not config['input_user']:
        print "[!] Stop. Input -u/--user has to be set"
        print "    Example: --user reto,rto,tro would"
        print "    check whether we can merge these three"
        print "    users in the database. The FIRST one "
        print "    is the leading user (the others will be"
Exemplo n.º 19
0
# -------------------------------------------------------------------



# - Start as main script (not as module)
if __name__ == '__main__':

   import sys, os
   import numpy as np
   # - Wetterturnier specific modules
   from pywetterturnier import utils
   from pywetterturnier import database
   from pywetterturnier import mitteltip 

   # - Evaluating input arguments
   inputs = utils.inputcheck('ComputePetrus')
   # - Read configuration file
   config = utils.readconfig('config.conf',inputs)

   # - If input_user was given as string we have to find the
   #   corresponding userID first!
   if not config['input_user'] == None:
      print '[!] NOTE: got input -u/--user. Will be ignored in ComputePetrus.'
      config['input_user'] = None
   
   
   # - Initializing class and open database connection
   db        = database.database(config)
   # - Loading tdate (day since 1970-01-01) for the tournament.
   #   Normaly Friday-Tornament (tdate is then Friday) while
   #   the bet-dates are for Saturday and Sunday if there was
Exemplo n.º 20
0
   - ...
   - ComputeSumPoints.py (computes points)
   - ComputeSleepy.py   (relies on the sumpoints)
   
   Script stops if one of the processes has non-zero exit state.
   """

    import sys, os
    from pywetterturnier import utils, database
    import numpy as np

    # - Store input arguments - need them later
    #   to call the subscripts. Only for the Chain.py script.
    main_args = sys.argv[1:]
    # - Evaluating input arguments
    inputs = utils.inputcheck('Chain')
    # - Read configuration file
    config = utils.readconfig('config.conf', inputs)

    # - Initializing class and open database connection
    db = database.database(config)
    current_tdate = db.current_tournament()
    today = utils.today_tdate()

    # - Loading tdate (day since 1970-01-01) for the tournament.
    #   Normaly Friday-Tornament (tdate is then Friday) while
    #   the bet-dates are for Saturday and Sunday.
    is_latest_tournament = False
    if config['input_tdate'] == None:
        config['input_tdate'] = current_tdate
        print '  * Using latest tournament date: %d' % config['input_tdate']
Exemplo n.º 21
0
# - L@ST MODIFIED: 2018-01-22 18:10 on marvin
# -------------------------------------------------------------------

if __name__ == "__main__":

    import datetime as dt
    import sys, os
    # - Wetterturnier specific modules
    from pywetterturnier import utils, database, getobs
    # - Astral package
    import astral
    # - Numpy for the computation
    import numpy as np

    # - Evaluating input arguments
    inputs = utils.inputcheck('AstralTable')
    # - Read configuration file
    config = utils.readconfig('config.conf', inputs)

    # - If input_user was given ignore it
    if not config['input_user'] == None:
        print('[!] NOTE: got input -u/--user. Will be ignored in AstralTable.')
        config['input_user'] = None

    # - Initializing class and open database connection
    db = database.database(config)

    # - Looping over cities
    cities = db.get_cities()
    # - If input city set, then drop all other cities.
    if not config['input_city'] == None: