Esempio n. 1
0
    print(('aggregating timeseries for comid {} at {}, {}\n'.format(*i)))

    # create weighting factors using the inverse-distance squared

    weights = []

    # get the distances between each station and the centroid

    for name, x, y in zip(names, lons, lats):

        point = x, y

        # the processor has "get_distance" method to estimate the distance in
        # kilometers between two points given as (lon1, lat1), (lon2, lat2)

        distance = processor.get_distance(point, (lon, lat))

        print(
            ('the distance to station {} is {:.1f} km'.format(name, distance)))

        weights.append(1 / distance**2)

    # convert weights to a numpy array

    weights = numpy.array(weights)

    # generate a mask array to hide missing values (as shown previously)

    mask = numpy.invert(numpy.isnan(precipitations))

    # go through each hour and get the weighted average of the available values
Esempio n. 2
0
    print('aggregating timeseries for comid {} at {}, {}\n'.format(*i))

    # create weighting factors using the inverse-distance squared
    
    weights = []

    # get the distances between each station and the centroid

    for name, x, y in zip(names, lons, lats):

        point = x,y

        # the processor has "get_distance" method to estimate the distance in 
        # kilometers between two points given as (lon1, lat1), (lon2, lat2)

        distance = processor.get_distance(point, (lon, lat))

        print('the distance to station {} is {:.1f} km'.format(name, distance))

        weights.append(1 / distance**2)

    # convert weights to a numpy array

    weights = numpy.array(weights)

    # generate a mask array to hide missing values (as shown previously)

    mask = numpy.invert(numpy.isnan(precipitations))

    # go through each hour and get the weighted average of the available values