コード例 #1
0
ファイル: step1.py プロジェクト: wk1984/ccc-gistemp-1
def adjust_discont(stream):
    """Modifies records as specified in config/step1_adjust,
    by adding the delta to every datum for that station for the early
    part of the record up to and including the specified month.  The
    month is specified (in the file) as 1-based.

    Recently, this adjusts the record for Lihue and St Helena; in the
    corresponding GISTEMP code there is one function and one config file
    for each station.
    """
    adjust = read_config.step1_adjust()
    for record in stream:
        id = record.uid
        if adjust.has_key(id):
            series = record.series
            this_year, month, summand = adjust[id]
            begin = record.first_year
            # Index of month specified by *adjust*.
            M = (this_year - begin)*12 + month-1
            # All valid data up to and including M get adjusted.
            for i in range(M+1):
                datum = series[i]
                if invalid(datum):
                    continue
                series[i] += summand
            record.set_series(record.first_month, series)
            del adjust[id]
        yield record
コード例 #2
0
ファイル: step1.py プロジェクト: wk1984/ccc-gistemp-1
def offset_and_add(sums, wgts, diff, record):
    """Add the data from *record* to the *sums* and *wgts* arrays, first
    shifting it by subtracting *diff*.  The arrays and *record* are
    assumd to start with the same year.
    """

    for i,datum in enumerate(record.series):
        if invalid(datum):
            continue
        sums[i] += datum - diff
        wgts[i] += 1