geometry.rec_positions,
                                     dpred.data[:],
                                     u=u0,
                                     is_residual=True,
                                     op_forward=opF,
                                     tsub_factor=12,
                                     space_order=space_order)
t2 = time.time()
print("Save in memory. Time [s]: ", t2 - t1)

# Remove pml
g = g[model.nbpml:-model.nbpml, model.nbpml:-model.nbpml]  # remove padding
g = np.reshape(g, -1, order='F')

# Chunk up gradient and write to bucket. Add gradients to SQS queue
chunk_size = get_chunk_size(len(g), num_chunks)
idx_count = 0
for j in range(num_chunks):

    # Save to bucket
    file_ext = ''.join(random.sample(chars * 12, 12))
    key = partial_gradient_path + 'chunk_' + str(j + 1) + '/' + gradient_name
    gwrite = g[idx_count:idx_count + chunk_size[j]]
    array_put(gwrite, bucket, key)
    idx_count += chunk_size[j]

    # Add to queue
    queue_name = queue_names + str(j + 1)
    msg = bucket + '&' + partial_gradient_path + '&' + full_gradient_path + '&' + \
        gradient_name + '&' + file_ext + '&' + str(iteration) + '&1&' + str(batchsize) + \
        '&' + str(j+1) + '&' + queue_name + '&' + variable_path + '&' + variable_name + \
示例#2
0
fval = np.array([.5*norm(dpred)**2], dtype='float32')
print("fval, dpred.shape, dobs.shape: ", fval, dpred.shape, dobs.shape)

# Wavefields in memory
t1 = time.time()
opF, u0 = forward_modeling(model, geometry.src_positions, geometry.src.data, geometry.rec_positions, save=True, u_return=True, op_return=True, tsub_factor=16)
g, summary1, summary2 = adjoint_born(model, geometry.rec_positions, dpred.data[:], u=u0, is_residual=True, op_forward=opF, tsub_factor=16)
t2 = time.time()
print("Save in memory. Time [s]: ", t2 - t1)

gfull = g[model.nbpml:-model.nbpml, model.nbpml:-model.nbpml]  # remove padding
gfull = extent_gradient(shape_full, origin_full, shape, origin, spacing, gfull)
gfull = np.reshape(gfull, -1, order='F')

# Chunk up gradient and write to bucket. Add gradients to SQS queue
chunk_size = get_chunk_size(len(gfull), num_chunks)
idx_count = 0
for j in range(num_chunks):

    # Save to bucket
    file_ext = '0'
    key = partial_gradient_path + 'chunk_' + str(j+1) + '/' + gradient_name
    gwrite = gfull[idx_count:idx_count + chunk_size[j]]
    array_put(gwrite, bucket, key)
    idx_count += chunk_size[j]

    # Add to queue
    queue_name = queue_names + str(j+1)
    print("Queue name: ", queue_name)
    msg = bucket + '&' + partial_gradient_path + '&' + full_gradient_path + '&' + \
        gradient_name + '&' + file_ext + '&' + str(iteration) + '&1&' + str(batchsize) + \