class StandardLabelledWorkflowComposite(BaseLabelledWorkflow):

	namespaceAttrs = misc.StandardComponentDescriptor("namespaceAttrs")
	label = misc.StandardComponentDescriptor("label")
	workFolder = misc.StandardComponentDescriptor("workFolder")
	preRunShellComms = misc.StandardComponentDescriptor("preRunShellComms")
	output = misc.StandardComponentDescriptor("output")
	def __init__(self, objs):
		self.objs = objs

	def run(self):
		for x in self.objs:
			x.run()
Beispiel #2
0
class GenSpectraOutputCompositeStandard(baseObjs.GenSpectraOutput):

    label = misc.StandardComponentDescriptor("label")
    spectralContributions = misc.StandardComponentDescriptor(
        "spectralContributions")

    @misc.getAssertAllLabelsUniqueUponCreationClassInitializerWrapper()
    @misc.getObjectsWithComponentsInstanceWrapper(isComposite=True)
    def __init__(self, objs):
        self.objs = list(objs)

    #Possibily a good candidate for caching if speed turns out to be an issue
    @property
    def totalSpectralContributions(self):
        allContribs = [np.array(x) for x in self.spectralContributions]
        startArray = allContribs[0]
        for x in allContribs[1:]:
            startArray[:, 1] += x[:, 1]
        return [(a, b) for a, b in startArray]
Beispiel #3
0
class GenSpectraInputCompositeStandard(baseObjs.GenSpectraInput):

    label = misc.StandardComponentDescriptor("label")

    @misc.getObjectsWithComponentsInstanceWrapper(isComposite=True)
    def __init__(self, objs, forceUniqueLabels=True):
        self.objs = list(objs)
        misc.checkAllLabelsUniqueOnInstance(self)

    def calculateSpectralContribs(self, xVals):
        outVals = list()
        for obj in self.objs:
            currContribs = obj.calculateSpectralContribs(xVals)
            outVals.extend(currContribs)
        return outVals
class BroadenFunctCompositeStandard(base_objs.BroadenFunctionStandard):

    leafObjs = misc.StandardComponentDescriptor("leafObjs")

    def __init__(self, objs: iter):
        """ Initializer for composite broadening function. When called, this objectsums all individual values from objs (i.e. used to get the sum of a list of broadening functions)
		
		Args:
			objs: (iter of BroadenFunctionBase). 
				 
		"""
        self.objs = list(objs)
        assert len(self.objs) > 0, "Len of iter needs to be greater than zero"

    def __call__(self, xVals):
        allVals = list()

        #Calculate individual broadening functions
        for x in self.objs:
            allVals.append(x(xVals))

        #Sum them all
        outVals = [0 for x in range(len(allVals[0]))]
        for currVals in allVals:  #gets list of y-vals
            for idx, yVal in enumerate(currVals):
                outVals[idx] += yVal

        return outVals

    @property
    def areas(self):
        outList = list()
        for x in self.objs:
            outList.extend(x.areas)
        return outList

    @areas.setter
    def areas(self, vals):
        allObjs = self.leafObjs
        assert len(allObjs) == len(
            vals
        ), "Exacltly one area must be given for each leaf; you gave {} areas for {} leafs".format(
            len(allObjs), len(vals))
        for area, obj in it.zip_longest(vals, allObjs):
            obj.areas = [area]
Beispiel #5
0
	def createTestCompObjWithLeafsOnly(self):
		setattr(DudClass, "testComp", tCode.StandardComponentDescriptor("testComp"))
		self.testCompObjLeafsOnly = DudClass( objs=[self.leafA,self.leafB] )