示例#1
0
def add_product(ops_list, reduce_list, cleaner_list, grid_data,
                product_metadata):

    product_type = product_metadata[PRODUCT_TYPE]

    #allocate space for the gridded result and initialize with max int
    metadata = {'units': 'm', 'long_name': 'maximum on shore oil thickness'}
    reduce_array = grid_data.allocate(product_name,
                                      DT.SPRECISION,
                                      metadata=metadata)

    # Make a temporary array that will be used in the operation
    map_array = reduce_array.copy()

    # Calculate cell diagonal:
    cell_diagonal = grid_data._grid.cell_diagonal

    coroutine = max_shore_grid_thickness_op(map_array, cell_diagonal)

    # Append the operation coroutine to the list
    ops_list.append(coroutine)

    # use the array allocated in grid data as the result in the reduce method
    coroutine = max_reduce(reduce_array)

    # append the reduce coroutine and the argument it will be passed to the reduce list
    reduce_list.append((coroutine, map_array))

    # Now add a reset value for the map array
    cleaner_list.append((map_array, DT.SPRECISION(0.0)))
示例#2
0
def add_product(ops_list, reduce_list, cleaner_list, grid_data,
                product_metadata):

    product_type = product_metadata[PRODUCT_TYPE]

    config = get_config()
    # This method now uses a quadratic index space
    cell_depth_range = config[
        product_type].products.max_concentration.cell_depth_range

    #allocate space for the gridded result

    metadata = {'units': 'g/cm^3', 'long_name': 'Maximum Oil Concentration'}
    reduce_array = grid_data.allocate(product_name,
                                      DT.SPRECISION,
                                      metadata=metadata)

    # Calculate cell area:
    cell_area = grid_data._grid.cell_area  # m**2

    # Make a temporary array that will be used in the operation
    map_array = reduce_array.copy()
    coroutine = max_concentration_op(map_array, cell_depth_range, cell_area)

    # Append the operation coroutine to the list
    ops_list.append(coroutine)

    coroutine = max_reduce(reduce_array)

    reduce_list.append((coroutine, map_array))

    # Now add a reset value for the map array
    cleaner_list.append((map_array, DT.SPRECISION(0.0)))
    def make_particles(self, iteration=0):

        particles = numpy.zeros((self.blocksize, ), dtype=DT.IDEAL_PARTICLE)
        # Grrr - no way to pass the buffer to put random numbers in ?

        particles['loc'] = util.random_sample(particles['loc'].shape,
                                              dtype=DT.PRECISION)
        particles['prev_loc'] = util.random_sample(particles['loc'].shape,
                                                   dtype=DT.PRECISION)

        particles[
            'lifetime'][:] = (  # Cheat and make time a function of block number
                DT.SPRECISION(iteration))

        mass_offset = DT.SPRECISION(0.9)
        mass_scale = DT.SPRECISION(.1)
        mass_time_param = DT.SPRECISION(1) / numpy.log10(
            DT.SPRECISION(iteration + 2))
        # 1/log10(i+2) * (rand[0.9 - 1.0) ) )
        particles['mass'] = (
            mass_time_param *
            (util.random_sample(*particles['mass'].shape) * mass_scale +
             mass_offset))

        dens_offset = DT.SPRECISION(0.9)
        dens_scale = DT.SPRECISION(.1)
        # dens = rand[0.9 - 1.0)
        particles['density'] = (
            numpy.random.rand(*particles['density'].shape) * dens_scale +
            dens_offset)

        return particles
示例#4
0
def add_product(ops_list, reduce_list, cleaner_list, grid_data,
                product_metadata):

    product_type = product_metadata[PRODUCT_TYPE]

    #allocate space for the gridded result

    metadata = {
        'units': 'm',
        'long_name': 'Maximum of spillet thickness',
        'fill_value': DT.SPRECISION(0.0)
    }
    reduce_array = grid_data.allocate(product_name,
                                      DT.SPRECISION,
                                      metadata=metadata)

    # Calculate cell area:
    cell_area = grid_data._grid.cell_area

    # Make a temporary array that will be used in the operation
    map_array = reduce_array.copy()

    #config = get_config()
    #advective_dispersion = config[product_type].products.max_of_spillet_thickness.get('advective_dispersion',numpy.nan)
    #spillet_dispersion = advective_dispersion * 0.2 # m^2/s
    #coroutine = thickest_spillet_op(map_array, spillet_dispersion)

    coroutine = thickest_spillet_op(map_array)

    # Append the operation coroutine to the list
    ops_list.append(coroutine)

    coroutine = max_reduce(reduce_array)

    reduce_list.append((coroutine, map_array))

    # Now add a reset value for the map array
    cleaner_list.append((map_array, DT.SPRECISION(0.0)))
示例#5
0
def add_product(ops_list, reduce_list, cleaner_list, grid_data,
                product_metadata):

    product_type = product_metadata[PRODUCT_TYPE]

    #allocate space for the gridded result
    metadata = {'units': 'm^3', 'long_name': 'Aggregate Oil Volume'}
    reduce_array = grid_data.allocate(product_name,
                                      DT.SPRECISION,
                                      metadata=metadata)

    # Make a temporary array that will be used in the operation
    map_array = reduce_array.copy()
    coroutine = oil_volume_op(map_array)

    # Append the operation coroutine to the list
    ops_list.append(coroutine)

    coroutine = max_reduce(reduce_array)

    reduce_list.append((coroutine, map_array))

    # Now add a reset value for the map array
    cleaner_list.append((map_array, DT.SPRECISION(0.0)))