Пример #1
0
def TMs2Form( style, tempInfo, TM_1, TM_E ) :

    from fudge.processing import transportables as transportablesModule
    from fudge.gnd.productData.distributions import multiGroup as multiGroupModule

    reactionSuite = tempInfo['reactionSuite']
    productName = tempInfo['productName']
    transportable = style.transportables[productName]
    conserve = transportable.conserve
    energyUnit = tempInfo['incidentEnergyUnit']

# BRB hardwired.
    crossSectionUnit = 'b'                          # ?????? 'b' should not be hardwired.
    axes = axesModule.axes( rank = 4 )
    axes[0] = axesModule.axis( 'C_l(energy_in,energy_out)', 0, crossSectionUnit )
    lMaxPlus1 = len( TM_1[0][0] )
    lGrid = valuesModule.values( [ i1 for i1 in range( lMaxPlus1 ) ], valueType = standardsModule.types.integer32Token )
    axes[1] = axesModule.grid( 'l',                         1,         '', axesModule.parametersGridToken, lGrid )
    energyOutGrid = style.transportables[productName].group.boundaries.values.copy( )
    axes[2] = axesModule.grid( 'energy_out',                2, energyUnit, axesModule.boundariesGridToken, energyOutGrid )
    energyInGrid = style.transportables[reactionSuite.projectile].group.boundaries.values.copy( )
    axes[3] = axesModule.grid( 'energy_in',                 3, energyUnit, axesModule.boundariesGridToken, energyInGrid )
    if( conserve == transportablesModule.conserve.number ) :
        TM = TM_1
    else :
        raise NotImplementedError( 'Need to implement' )

    n1 = len( TM )
    n2 = len( TM[0] )
    n3 = len( TM[0][0] )
    data, starts, lengths = [], [], []
    for i1 in sorted( TM.keys( ) ) :
        TM_i1 = TM[i1]
        start, length = None, 0
        for i2 in sorted( TM_i1.keys( ) ) :
            TM_i1_i2 = TM_i1[i2]
            cellMin = min( TM_i1_i2 )
            cellMax = max( TM_i1_i2 )
            if( ( cellMin != 0 ) or ( cellMax != 0 ) ) :
                if( start is None ) : start = n3 * ( n2 * i1 + i2 )
                length += n3
                data += TM_i1_i2
            else :
                if( start is not None ) : 
                    starts.append( start )
                    lengths.append( length )
                    start, length = None, 0
        if( start is not None ) : 
            starts.append( start )
            lengths.append( length )
    shape = [ n1, n2, n3 ]
    data = valuesModule.values( data )
    starts = valuesModule.values( starts, valueType = standardsModule.types.integer32Token )
    lengths = valuesModule.values( lengths, valueType = standardsModule.types.integer32Token )
    flattened = arrayModule.flattened( shape = shape, data = data, starts = starts, lengths = lengths, 
            dataToString = multiGroupModule.gridded3d.dataToString )
    gridded3d = multiGroupModule.gridded3d( axes = axes, array = flattened )
    return( multiGroupModule.form( style.label, standardsModule.frames.labToken, gridded3d ) )
Пример #2
0
def toMultiGroup1d( cls, style, tempInfo, _axes, data, addLabel = True ) :
    """
    This function takes 1-d multi-group data as a list of floats and return to 1-d gridded instance
    containing the multi-group data. The list of data must contain n values where n is the
    number of groups.
    """

    reactionSuite = tempInfo['reactionSuite']

    axes = axesModule.axes( rank = 2 )
    axes[0] = axesModule.axis( _axes[0].label, 0, _axes[0].unit )
    energyInGrid = style.transportables[reactionSuite.projectile].group.boundaries.values.copy( )
    axes[1] = axesModule.grid( _axes[1].label, 1, _axes[1].unit, axesModule.boundariesGridToken, energyInGrid )
    shape = [ len( data ) ]
    data = valuesModule.values( data )
    for start, datum in enumerate( data ) :
        if( datum != 0 ) : break
    end = 0
    for i1, datum in enumerate( data ) :
        if( datum != 0 ) : end = i1
    if( start > end ) :                     # Only happens when all values are 0.
        start = 0
    else :
        end += 1
    data = data[start:end]
    starts = valuesModule.values( [ start ], valueType = standardsModule.types.integer32Token )
    lengths = valuesModule.values( [ len( data ) ], valueType = standardsModule.types.integer32Token )
    flattened = arrayModule.flattened( shape = shape, data = data, starts = starts, lengths = lengths )
    label = None
    if( addLabel ) : label = style.label
    return( cls( label = label, axes = axes, array = flattened ) )
Пример #3
0
    def processMultiGroup(self, style, tempInfo, indent):

        reactionSuite = tempInfo['reactionSuite']
        axes = self.data.axes.copy()
        axes[1] = axesModule.grid(
            axes[1].label,
            1,
            axes[1].unit,
            style=axesModule.parametersGridToken,
            values=valuesModule.values(
                [0], valueType=standardsModule.types.integer32Token))
        axes[2] = style.transportables[
            reactionSuite.projectile].group.boundaries.copy([])
        data = self.data.processMultiGroup(style, tempInfo, indent)
        starts = valuesModule.values(
            [0], valueType=standardsModule.types.integer32Token)
        lengths = valuesModule.values(
            [len(data)], valueType=standardsModule.types.integer32Token)
        array = arrayModule.flattened(shape=(len(data), 1),
                                      data=data,
                                      starts=starts,
                                      lengths=lengths)
        data = gridded2d(axes=axes, array=array)
        return (data)
Пример #4
0
    def toCovarianceMatrix(self, label="composed"):
        """
        Sum all parts together to build a single matrix.
        """
        if len(self.components) == 1:
            return self.components[0].toCovarianceMatrix()
        import fudge.gnd.covariances.base as base
        import numpy
        import xData.values as valuesModule
        import xData.array as arrayModule

        # Set up common data using first component
        firstCovMtx = self.components[0].toCovarianceMatrix()
        if not isinstance(firstCovMtx, base.covarianceMatrix):
            raise TypeError(
                "Shoudd have gotten base.covarianceMatrix, instead got %s" %
                str(firstCovMtx.__class__))
        commonRowAxis = firstCovMtx.matrix.axes[2].copy(
            [])  #FIXME: unresolvedLinks are still unresolved!
        if firstCovMtx.matrix.axes[1].style == 'link':
            commonColAxis = firstCovMtx.matrix.axes[2].copy(
                [])  #FIXME: unresolvedLinks are still unresolved!
        else:
            commonColAxis = firstCovMtx.matrix.axes[1].copy(
                [])  #FIXME: unresolvedLinks are still unresolved!
        commonMatrixAxis = firstCovMtx.matrix.axes[0].copy(
            [])  #FIXME: unresolvedLinks are still unresolved!
        commonType = firstCovMtx.type

        # We need all the covariances to be either absolute or relative
        def make_common_type(cm):
            if commonType == 'relative': return cm.toRelative()
            else: return cm.toAbsolute()

        # We're going to have to merge grids, so we'll need this function to do the dirty work
        def add_values(v1, v2):
            v = set()
            v.update(v1.values)
            v.update(v2.values)
            return valuesModule.values(sorted(v))

        # First pass through components is to collect bins to set up the common grid + do assorted checking
        for c in self.components[1:]:
            cc = make_common_type(c.toCovarianceMatrix(
            ))  # a little recursion to take care of nested covariances
            if cc.type != commonType:
                raise ValueError("Incompatible types in %s: %s vs. %s" %
                                 (self.__class__, commonType, cc.type))
            if cc.matrix.axes[0].unit != commonMatrixAxis.unit:
                raise ValueError(
                    "covariance matrix components with different units?!? %s vs. %s"
                    % (cc.matrix.axes[0].unit, commonMatrixAxis.unit))
            if cc.matrix.axes[1].style != 'link':
                cc.matrix.axes[1].convertToUnit(commonColAxis.unit)
            cc.matrix.axes[2].convertToUnit(commonRowAxis.unit)
            commonRowAxis.values.values = add_values(commonRowAxis.values,
                                                     cc.matrix.axes[2].values)
            if cc.matrix.axes[1].style == 'link':
                commonColAxis.values.values = add_values(
                    commonColAxis.values, cc.matrix.axes[2].values)
            else:
                commonColAxis.values.values = add_values(
                    commonColAxis.values, cc.matrix.axes[1].values)

        # Now sum up the components
        commonMatrix = numpy.mat(
            firstCovMtx.group(
                (commonRowAxis.values.values, commonColAxis.values.values),
                (commonRowAxis.unit,
                 commonColAxis.unit)).matrix.array.constructArray())
        for c in self.components[1:]:
            cc = make_common_type(c.toCovarianceMatrix(
            ))  # a little recursion to take care of nested covariances
            commonMatrix += numpy.mat(
                cc.group(
                    (commonRowAxis.values.values, commonColAxis.values.values),
                    (commonRowAxis.unit,
                     commonColAxis.unit)).matrix.array.constructArray())

        # Now create the instance of the resulting covarianceMatrix
        if all([
                component.toCovarianceMatrix().matrix.axes[1].style == 'link'
                for component in self.components
        ]):
            commonColAxis = self.components[0].toCovarianceMatrix(
            ).matrix.axes[1].copy(
                [])  #FIXME: unresolvedLinks are still unresolved!
        newAxes = axesModule.axes(
            labelsUnits={
                0: (commonMatrixAxis.label, commonMatrixAxis.unit),
                1: (commonColAxis.label, commonColAxis.unit),
                2: (commonRowAxis.label, commonRowAxis.unit)
            })
        newAxes[2] = axesModule.grid(commonRowAxis.label,
                                     commonRowAxis.index,
                                     commonRowAxis.unit,
                                     style=axesModule.boundariesGridToken,
                                     values=commonRowAxis.values)
        newAxes[1] = axesModule.grid(commonColAxis.label,
                                     commonColAxis.index,
                                     commonColAxis.unit,
                                     style=axesModule.linkGridToken,
                                     values=linkModule.link(
                                         link=commonRowAxis.values,
                                         relative=True))
        newAxes[0] = axesModule.axis(commonMatrixAxis.label,
                                     commonMatrixAxis.index,
                                     commonMatrixAxis.unit)
        trigdata = commonMatrix[numpy.tri(commonMatrix.shape[0]) ==
                                1.0].tolist()[0]
        gridded = griddedModule.gridded2d(
            axes=newAxes,
            array=arrayModule.full(shape=commonMatrix.shape,
                                   data=trigdata,
                                   symmetry=arrayModule.symmetryLowerToken))
        newCov = base.covarianceMatrix(label=label,
                                       type=commonType,
                                       matrix=gridded)
        newCov.setAncestor(self.ancestor)
        return newCov
Пример #5
0
if not (args.gid == None):
    for gidVal in args.gid:
        key, value = gidVal.split('=')
        if key not in gids:
            raise UserWarning(
                "particle grouping specified for unknown particle name : %s " %
                (key))
        gids[key] = value

transportables = []
for particle in gids:
    gbs = valuesModule.values([
        PQUModule.PQU(boundary, 'MeV').getValueAs(args.energyUnit)
        for boundary in bdfls.group(gids[particle]).gb
    ])
    grid = axesModule.grid('energy_in', 0, args.energyUnit,
                           axesModule.boundariesGridToken, gbs)
    group = groupModule.group(gids[particle], grid)
    transportables.append(
        transportablesModule.transportable(
            particle, transportablesModule.conserve.number, group))

#### read in GND file
reactionSuite = reactionSuiteModule.readXML(args.gnd)

if (reactionSuite.projectile != IDsPoPsModule.neutron): tempsDefault = 0
if (args.temperatures == None): args.temperatures = [tempsDefault]

### fail on detection of existing processed data
for style in reactionSuite.styles:
    if (isinstance(style, stylesModule.heated)
            or isinstance(style, stylesModule.MC)
Пример #6
0
def readMF7(mt, mf7):

    ZA, AWR, LTHR, LAT, LASYM, dum = endfFileToGNDMisc.sixFunkyFloatStringsToIntsAndFloats(
        mf7[0], range(2, 6))

    if LTHR == 1:  # coherent elastic scattering

        line, temps, energies, dummy, data, e_interp, t_interp = readSTable(
            1, mf7)
        temps, energies = map(valuesModule.values, (temps, energies))

        if e_interp != 'flat':
            raise ValueError("unexpected energy interpolation encountered")

        axes = axesModule.axes(rank=3)
        axes[2] = axesModule.grid('temperature',
                                  2,
                                  'K',
                                  axesModule.pointsGridToken,
                                  values=temps,
                                  interpolation=t_interp)
        axes[1] = axesModule.grid('energy_in',
                                  1,
                                  'eV',
                                  axesModule.pointsGridToken,
                                  values=energies,
                                  interpolation=e_interp)
        axes[0] = axesModule.axis('S_cumulative', 0, 'eV*b')
        array = arrayModule.full(shape=(len(temps), len(energies)), data=data)
        Stab = griddedModule.gridded2d(axes, array, label="eval")

        section = TS.coherentElastic(TS.S_table(Stab))

    elif LTHR == 2:  # incoherent elastic
        line, dat = endfFileToGNDMisc.getTAB1(1, mf7)
        SB = TS.characteristicCrossSection(float(dat['C1']), 'b')

        e_interp = dat['interpolationInfo']
        if len(e_interp) > 1:
            raise ValueError(
                "only one interpolation region allowed for T_eff data")
        e_interp = endfFileToGNDMisc.ENDFInterpolationToGND1d(e_interp[0][1])

        t_axes = axesModule.axes(labelsUnits={
            1: ('temperature', 'K'),
            0: ('DebyeWallerIntegral', '1/eV')
        })
        if len(dat['data']) == 2 and dat['data'][0] == dat['data'][1]:
            dat['data'] = dat['data'][0:1]
        DbW = TS.DebyeWaller(dat['data'], axes=t_axes, interpolation=e_interp)
        section = TS.incoherentElastic(SB, DbW)

    elif LTHR == 0:  # incoherent inelastic
        line, listy = endfFileToGNDMisc.getList(1, mf7)
        LLN, NI, NS, b_n = listy['L1'], listy['NPL'], listy['N2'], listy[
            'data']
        if LLN:
            raise NotImplementedError("LLN != 0 not yet handled!")

        # b_n array contains information about principal / secondary scattering atoms
        atoms = [
            TS.scatteringAtom(label="0",
                              numberPerMolecule=int(b_n[5]),
                              mass=TS.mass(b_n[2], 'amu'),
                              freeAtomCrossSection=TS.freeAtomCrossSection(
                                  b_n[0], 'b'),
                              e_critical=TS.e_critical(b_n[1], 'eV'),
                              e_max=TS.e_max(b_n[3], 'eV'))
        ]
        for idx in range(1, NS + 1):
            functionalForm = {
                0.0: 'SCT',
                1.0: 'free_gas',
                2.0: 'diffusive_motion'
            }[b_n[6 * idx]]
            atoms.append(
                TS.scatteringAtom(label=str(idx),
                                  numberPerMolecule=b_n[6 * idx + 5],
                                  mass=TS.mass(b_n[6 * idx + 2], 'amu'),
                                  freeAtomCrossSection=TS.freeAtomCrossSection(
                                      b_n[6 * idx + 1], 'b'),
                                  functionalForm=functionalForm))

        line, t2header = endfFileToGNDMisc.getTAB2Header(line, mf7)
        n_betas = int(t2header['NZ'])

        # read first beta:
        line, temps, alphas, beta, data, a_interp, t_interp = readSTable(
            line, mf7)
        betas = [beta]

        # read in remaining betas:
        for idx in range(n_betas - 1):
            line, temps_, alphas_, beta, data_, a_interp_, t_interp_ = readSTable(
                line, mf7)
            if (temps_ != temps or alphas_ != alphas or a_interp_ != a_interp
                    or t_interp_ != t_interp):
                raise ValueError("inconsistent values!")
            betas.append(beta)
            data.extend(data_)

        temps, betas, alphas = map(valuesModule.values, (temps, betas, alphas))

        axes = axesModule.axes(rank=4)
        axes[3] = axesModule.grid('temperature',
                                  3,
                                  'K',
                                  axesModule.pointsGridToken,
                                  values=temps,
                                  interpolation=t_interp)
        axes[2] = axesModule.grid(
            'beta',
            2,
            '',
            axesModule.pointsGridToken,
            values=betas,
            interpolation=standardsModule.interpolation.flatToken)
        axes[1] = axesModule.grid('alpha',
                                  1,
                                  '',
                                  axesModule.pointsGridToken,
                                  values=alphas,
                                  interpolation=a_interp)
        axes[0] = axesModule.axis('S_alpha_beta', 0, 'eV*b')

        arrayShape_orig = (len(betas), len(temps), len(alphas))
        data = numpy.array(data).reshape(arrayShape_orig)
        # ENDF data are stored as 'beta,T,alpha'. Switch order to 'T,beta,alpha':
        data = numpy.transpose(data, axes=(1, 0, 2))
        arrayShape_new = (len(temps), len(betas), len(alphas))
        array = arrayModule.full(shape=arrayShape_new, data=data.flatten())
        Stab = griddedModule.gridded3d(axes, array, label="eval")

        S_tables = TS.S_alpha_beta(Stab)

        # last read T_eff tables. There must be at least one (for the principal scattering atom), plus more for
        # any other atoms that specify the short-collision-time approximation:
        line, t_eff = readT_effective(line, mf7)
        atoms[0].T_effective = t_eff
        for atom in atoms[1:]:
            if atom.functionalForm == 'SCT':
                line, t_eff = readT_effective(line, mf7)
                atom.T_effective = t_eff

        section = TS.incoherentInelastic(S_tables,
                                         calculatedAtThermal=LAT,
                                         asymmetric=LASYM,
                                         atoms=atoms)

    if line != len(mf7):
        raise ValueError("Trailing data left in MT%i MF7!" % mt)
    return LTHR, section
Пример #7
0
    def setUp(self):
        # ...................... example matrix 'a' ......................
        axes = axesModule.axes(
            labelsUnits={
                0: ('matrix_elements', 'b**2'),
                1: ('column_energy_bounds', 'MeV'),
                2: ('row_energy_bounds', 'MeV')
            })
        axes[2] = axesModule.grid(axes[2].label,
                                  axes[2].index,
                                  axes[2].unit,
                                  style=axesModule.boundariesGridToken,
                                  values=valuesModule.values([
                                      1.0000E-07, 1.1109E-01, 1.3534E+00,
                                      1.9640E+01
                                  ]))
        axes[1] = axesModule.grid(axes[1].label,
                                  axes[1].index,
                                  axes[1].unit,
                                  style=axesModule.linkGridToken,
                                  values=linkModule.link(link=axes[2].values,
                                                         relative=True))
        myMatrix = arrayModule.full((3, 3), [4.0, 1.0, 9.0, 0.0, 0.0, 25.0],
                                    symmetry=arrayModule.symmetryLowerToken)
        self.a = covariances.covarianceMatrix(
            'eval',
            matrix=griddedModule.gridded2d(axes, myMatrix),
            type=covariances.tokens.relativeToken)

        # ...................... example matrix 'b' ......................
        axes = axesModule.axes(
            labelsUnits={
                0: ('matrix_elements', 'b**2'),
                1: ('column_energy_bounds', 'MeV'),
                2: ('row_energy_bounds', 'MeV')
            })
        axes[2] = axesModule.grid(axes[2].label,
                                  axes[2].index,
                                  axes[2].unit,
                                  style=axesModule.boundariesGridToken,
                                  values=valuesModule.values(
                                      [1.0e-5, 0.100, 1.0, 20.0]))
        axes[1] = axesModule.grid(axes[1].label,
                                  axes[1].index,
                                  axes[1].unit,
                                  style=axesModule.linkGridToken,
                                  values=linkModule.link(link=axes[2].values,
                                                         relative=True))
        myMatrix = arrayModule.full((3, 3), [4.0, 1.0, 9.0, 0.0, 0.0, 25.0],
                                    symmetry=arrayModule.symmetryLowerToken)
        self.b = covariances.covarianceMatrix(
            'eval',
            matrix=griddedModule.gridded2d(axes, myMatrix),
            type=covariances.tokens.relativeToken)

        # ...................... example matrix 'c' ......................
        axes = axesModule.axes(
            labelsUnits={
                0: ('matrix_elements', 'b**2'),
                1: ('column_energy_bounds', 'MeV'),
                2: ('row_energy_bounds', 'MeV')
            })
        axes[2] = axesModule.grid(axes[2].label,
                                  axes[2].index,
                                  axes[2].unit,
                                  style=axesModule.boundariesGridToken,
                                  values=valuesModule.values([
                                      1.0000E-07, 6.7380E-02, 1.1109E-01,
                                      1.3534E+00
                                  ]))
        axes[1] = axesModule.grid(axes[1].label,
                                  axes[1].index,
                                  axes[1].unit,
                                  style=axesModule.linkGridToken,
                                  values=linkModule.link(link=axes[2].values,
                                                         relative=True))
        myMatrix = arrayModule.full((3, 3), [4.0, 1.0, 9.0, 0.0, 0.0, 25.0],
                                    symmetry=arrayModule.symmetryLowerToken)
        self.c = covariances.covarianceMatrix(
            'eval',
            matrix=griddedModule.gridded2d(axes, myMatrix),
            type=covariances.tokens.relativeToken)

        # ...................... combine them for example matrix 'abc' ......................
        abc = covariances.mixed.mixedForm(components=[self.a, self.b, self.c])
        # FIXME: learn how to add abc to a section & to a covarianceSuite!, sumabc is built wrong!

        # ...................... 'sumabc' is just a way to exercise the summed class ......................
        bds = abc.getRowBounds()
        self.sumabc = covariances.summed.summedCovariance(
            label='test',
            domainMin=float(bds[0]),
            domainMax=float(bds[1]),
            domainUnit=abc[0].matrix.axes[-1].unit,
            pointerList=[
                linkModule.link(link=abc, path=abc.toXLink(), coefficient=1.0)
            ])
Пример #8
0
    def toCovarianceMatrix(self, label="composed"):
        """
        Sum the parts to construct the covariance matrix.
        Note, each part must be converted to an absolute covariance before summing.
        """
        if len(self.pointerList) == 1:
            return self.pointerList[0].link['eval'].toCovarianceMatrix()
        import numpy, copy
        from .mixed import mixedForm
        from .base import covarianceMatrix
        from xData import values as valuesModule
        from xData import axes as axesModule
        from xData import array as arrayModule
        from xData import gridded as griddedModule

        # We need all the covariances to be either absolute or relative
        commonType = None

        def make_common_type(p):
            cm = p.link['eval']
            if isinstance(cm, covarianceMatrix): cm = cm.toCovarianceMatrix()
            elif isinstance(cm, mixedForm):

                def inRange(thisBounds, otherBounds):
                    return otherBounds[0] >= thisBounds[0] and otherBounds[
                        1] <= thisBounds[1]

                newMixed = mixedForm()
                for ic, c in enumerate(cm.components):
                    if c.getRowBounds() != c.getColumnBounds():
                        raise ValueError(
                            "All components must have their row and column covarianceAxes matching."
                        )
                    c = copy.copy(c)
                    # prune zero rows/columns covarianceMatrices, just in case
                    if isinstance(c, covarianceMatrix):
                        c.removeExtraZeros()
                        # newMixed.addComponent(c)
                    elif isinstance(c, mixedForm):
                        c.makeSafeBounds()
                    # add sub matrix if it fits
                    if inRange(self.getRowBounds(), c.getRowBounds()):
                        newMixed.addComponent(c)
                cm = newMixed.toCovarianceMatrix()
            if commonType == 'relative': return cm.toRelative()
            elif commonType == 'absolute': return cm.toAbsolute()
            else: return cm

        # Set up common data using first element in pointerList
        firstCovMtx = make_common_type(self.pointerList[0])
        commonRowAxis = firstCovMtx.matrix.axes[2].copy(
            [])  #FIXME: unresolvedLinks are still unresolved!
        if firstCovMtx.matrix.axes[1].style == 'link':
            commonColAxis = firstCovMtx.matrix.axes[2].copy(
                [])  #FIXME: unresolvedLinks are still unresolved!
        else:
            commonColAxis = firstCovMtx.matrix.axes[1].copy(
                [])  #FIXME: unresolvedLinks are still unresolved!
        commonMatrixAxis = firstCovMtx.matrix.axes[0].copy(
            [])  #FIXME: unresolvedLinks are still unresolved!
        commonType = firstCovMtx.type

        # We're going to have to merge grids, so we'll need this function to do the dirty work
        def add_values(v1, v2):
            v = set()
            v.update(v1.values)
            v.update(v2.values)
            return valuesModule.values(sorted(v))

        # First pass through components is to collect bins to set up the common grid + do assorted checking
        for p in self.pointerList[1:]:
            cc = make_common_type(
                p
            )  #__get_abs_cov_mtx(p) #.link['eval'].toCovarianceMatrix().toAbsolute() # a little recursion to take care of nested covariances
            if cc.type != commonType:
                raise ValueError("Incompatable types in " +
                                 str(self.__class__) + ": " + str(commonType) +
                                 ' vs. ' + str(cc.type))
            cc.matrix.axes[0].unit = commonMatrixAxis.unit
            cc.matrix.axes[1].convertToUnit(commonColAxis.unit)
            cc.matrix.axes[2].convertToUnit(commonRowAxis.unit)
            commonRowAxis.values.values = add_values(commonRowAxis.values,
                                                     cc.matrix.axes[2].values)
            if cc.matrix.axes[1].style == 'link':
                commonColAxis.values.values = add_values(
                    commonColAxis.values, cc.matrix.axes[2].values)
            else:
                commonColAxis.values.values = add_values(
                    commonColAxis.values, cc.matrix.axes[1].values)

        # Now sum up the components
        commonMatrix = self.pointerList[0]['coefficient'] * firstCovMtx.group(
            (commonRowAxis.values.values, commonColAxis.values.values),
            (commonRowAxis.unit,
             commonColAxis.unit)).matrix.array.constructArray()
        for p in self.pointerList[1:]:
            cc = make_common_type(
                p)  # a little recursion to take care of nested covariances
            commonMatrix += p['coefficient'] * cc.group(
                (commonRowAxis.values.values, commonColAxis.values.values),
                (commonRowAxis.unit,
                 commonColAxis.unit)).matrix.array.constructArray()

        # Now create the instance of the resulting covarianceMatrix
        newAxes = axesModule.axes(
            labelsUnits={
                0: (commonMatrixAxis.label, commonMatrixAxis.unit),
                1: (commonColAxis.label, commonColAxis.unit),
                2: (commonRowAxis.label, commonRowAxis.unit)
            })

        newAxes[2] = axesModule.grid(commonRowAxis.label,
                                     commonRowAxis.index,
                                     commonRowAxis.unit,
                                     style=axesModule.boundariesGridToken,
                                     values=commonRowAxis.values)
        newAxes[1] = axesModule.grid(commonColAxis.label,
                                     commonColAxis.index,
                                     commonColAxis.unit,
                                     style=axesModule.linkGridToken,
                                     values=linkModule.link(
                                         link=commonRowAxis.values,
                                         relative=True))
        newAxes[0] = axesModule.axis(commonMatrixAxis.label,
                                     commonMatrixAxis.index,
                                     commonMatrixAxis.unit)
        trigdata = commonMatrix[numpy.tri(commonMatrix.shape[0]) ==
                                1.0].tolist()
        gridded = griddedModule.gridded2d(
            axes=newAxes,
            array=arrayModule.full(shape=commonMatrix.shape,
                                   data=trigdata,
                                   symmetry=arrayModule.symmetryLowerToken))
        newCov = covarianceMatrix(label=label, type=commonType, matrix=gridded)
        newCov.setAncestor(self.ancestor)
        return newCov