Source code for pycif.plugins.transforms.basic.vertical_interpolation.adjoint
import numpy as np
import pandas as pd
import xarray as xr
try:
import cPickle as pickle
except ImportError:
import pickle
from .utils.sparse.adjoint import sparse_adjoint
from .utils.array.adjoint import array_adjoint
[docs]
def adjoint(
transf,
inout_datastore,
controlvect,
obsvect,
mapper,
di,
df,
mode,
runsubdir,
workdir,
onlyinit=False,
**kwargs
):
ddi = min(di, df)
is_sparse_out = transf.sparse_out
is_sampled_out = transf.sampled_out
# Force sparse or sampled, process batch computation altogether,
# Otherwise, loop over trid
if is_sparse_out or is_sampled_out:
sparse_adjoint(transf, mapper, inout_datastore,
ddi, onlyinit, **kwargs)
else:
# Do nothing for non-sparse data and onlyinit mode
if onlyinit:
return
for trid in mapper["outputs"]:
# Deal with full data
array_adjoint(
transf, mapper, inout_datastore,
trid, ddi, onlyinit, **kwargs
)