Esempio n. 1
0
    def __init__(self, dt, mp, cr):
        self.transformer = TransformerWrapper(cr)
        self.retrender = RetrenderWrapper(dt, mp)
        self.detrender = DetrenderWrapper(dt, mp)

        self.unrealizable = mp == 'false' and cr == 'mean-scale'
Esempio n. 2
0
                          'mp',
                          zlib=True,
                          shuffle=False,
                          complevel=9)
mpvar[:] = range(1, nmp + 1)
mpvar.units = 'mapping'
mpvar.long_name = ', '.join(mp)

for v in variables:
    var = fi.variables[v]

    vardt = masked_array(zeros(sh), mask=ones(sh))
    for latidx, lonidx in product(range(nlats), range(nlons)):
        varmat = var[:, latidx, lonidx]
        if not isMaskedArray(varmat) or not varmat.mask[0]:
            for d, c in product(range(ndt), range(nmp)):
                detrender = DetrenderWrapper(dt[d], mp[c])
                vardt[:, latidx, lonidx, d, c] = detrender.detrend(varmat)[0]

    vvar = fo.createVariable(v,
                             'f4', ('time', latname, lonname, 'dt', 'mp'),
                             zlib=True,
                             shuffle=False,
                             complevel=9,
                             fill_value=1e20)
    vvar[:] = vardt
    vvar.units = var.units if 'units' in var.ncattrs() else ''
    vvar.long_name = var.long_name if 'long_name' in var.ncattrs() else ''

fi.close()
fo.close()