Beispiel #1
0
         print "\n  * Observations for station %s" % city['name']

         # ----------------------------------------------------------------
         # - Looping trough tournament/bet dates.
         #   Note that 'tdate' is the tournament date (e.g., friday)
         #   and we need the observations for the day before (therefore
         #   starting the range at -1) for the persistence user,
         #   plus two days. Actually the day of the tournament would not
         #   be necessary, processing it just in case we need it somewhere.
         # ----------------------------------------------------------------
         for day in range(-1,ndays):

            date = tdate + dt.timedelta( day ) 
            print "\n  * Processing obsevations for day: %s\n" % date

            obs = getobs.getobs(config, db, city, date, wmoww )

            # - Temperatures
            obs.prepare('TTm') #,special='T today 06:00 to today 18:00')
            obs.prepare('TTn') #,special='T yesterday 18:00 to today 6:00 ')
            obs.prepare('TTd')
            # - Wind speed and direction
            obs.prepare('dd')
            obs.prepare('ff')
            obs.prepare('fx')
            # - Mean sea level Pressure
            obs.prepare('PPP')
            # - Cloud cover
            obs.prepare('N')
            # - Significant weather
            obs.prepare('Wv')
        for station in db.get_stations_for_city(city["ID"]):
            stations.append(station.wmo)

    # Store results in an ndarray of length ndays
    res = np.ndarray((ndays, len(stations)), dtype="float")

    # Base date
    base_date = dt.date(2019, 1, 1)  # Has to be a leap year!

    # - Looping over all cities
    j = -1
    for city in cities:

        # We don't need the obs but use this object as in the computation
        # of the points as it includes the get_maximum_Sd method.
        obj = getobs.getobs(config, db, city, base_date)

        # Looping over stations
        for station in db.get_stations_for_city(city.get("ID")):

            # Increase column index
            j += 1

            # Dummy
            for i in range(0, ndays):

                # Loop date
                date = base_date + dt.timedelta(i)

                # Getting maximum sunshine duration
                sd = obj.get_maximum_Sd([station], date)