示例#1
0
from knmiDATA import DataSelector
import os

MINDATE = 20080100
MAXDATE = 20090101

for DATA in ["CC", "DD", "FG", "FX", "HU", "PP", "RR", "SD", "SS", "TG", "TN", "TX"]:
    RR = DataSelector(DATA)
    RR.getStations()

    # Total number of stations
    print "Number of stations: ", len(RR.stations.data["STAID"])

    # Rewrite if not done yet.
    if not os.path.isdir("rewritten/{0}".format(DATA)):
        os.makedirs("rewritten/{0}".format(DATA))
        print 'Rewriting'
        for station in RR.stations.data["STAID"]:
            f = RR.getSingleStation(station, mindate=MINDATE, maxdate=MAXDATE)
            f.rewrite()
            RR.wipe_files()
示例#2
0
def fixDate(date):
    return "{0}/{1}/{2}".format(date[0:4], date[4:6], date[6:8])

iso2to3 = {}
with open("countrycodes.txt", "r") as f:
    lines = f.readlines()
    for line in lines:
        line = line.split(",")
        iso2to3[line[0]] = line[1].strip()

for DATA in ["CC", "DD", "FG", "FX", "HU", "PP", "RR", "SD", "SS", "TG", "TN", "TX"]:
#for DATA in ["TG"]:
    rewrite = False

    RR = DataSelector(DATA)
    RR.getStations()

    # Total number of stations
    print "Number of stations: ", len(RR.stations.data["STAID"])

    # Rewrite if not done yet.
    if not os.path.isdir("rewritten/{0}".format(DATA)):
        os.makedirs("rewritten/{0}".format(DATA))
        print 'Rewriting'
        for station in RR.stations.data["STAID"]:
            f = RR.getSingleStation(station, mindate=20080101, maxdate=20090101)
            f.rewrite()
            RR.wipe_files()

    # Select the rewritten files
示例#3
0
country_table = dom.by_tag("div.devsite-article-body")[0]
letter2 = []
letter3 = []

with open("countrycodes.txt") as f:
    lines = f.readlines()

    for line in lines:
        line = line.split(",")
        letter2.append(line[0])
        letter3.append(line[1].strip())

#for DATA in ["CC", "DD", "FG", "FX", "HU", "PP", "RR", "SD", "SS", "TG", "TN", "TX"]:

for DATA in ["TG"]:
    RR = DataSelector(DATA)
    RR.getStations()

    print RR.stations.info
    country_stations = {}
    for i in range(len(RR.stations.data["STAID"])):

        station_data = []
        for key in RR.stations.info:
            station_data.append(RR.stations.data[key][i].strip())

        d = {"name": station_data[1], "lat": convertToDegrees(station_data[3]), "lon": convertToDegrees(station_data[4]),
              "alt": int(station_data[5]), "id": int(station_data[0])}

        if not station_data[2] in country_stations:
            country_stations[station_data[2]] = []