Example #1
0
 def getInputCrossSections(self, inputs: EDASDatasetCollection ) -> Dict[str,EDASDataset]:
     inputCrossSections = {}
     for dsKey, dset in inputs.items():
         for index, (akey, array) in enumerate(dset.arrayMap.items()):
             merge_set: EDASDataset = inputCrossSections.setdefault( index, EDASDataset(OrderedDict(), inputs.attrs ) )
             merge_set[dsKey + "-" + akey] = array
     return inputCrossSections
Example #2
0
    def preprocessInputs( self, request: TaskRequest, op: OpNode, inputDataset: EDASDataset ) -> EDASDataset:
#         interp_na = bool(op.getParm("interp_na", False))
#         if interp_na:   inputs: Dict[str,EDASArray] = { id: input.updateXa( input.xr.interpolate_na( dim="t", method='linear' ),"interp_na" ) for (id, input) in inputDset.arrayMap.items() }
#         else:           inputs: Dict[str,EDASArray] = { id: input for (id, input) in inputDset.arrayMap.items() }
        if op.isSimple and not self.requiresAlignment:
           result = inputDataset
        else:
            resultArrays: OrderedDict[str,EDASArray] = OrderedDict()
            arrayList = list(inputDataset.arrayMap.values())
            for aid,array in inputDataset.arrayMap.items():
                unapplied_domains: Set[str] = array.unapplied_domains(arrayList, op.domain)
                if len( unapplied_domains ) > 0:
                    merged_domain: str = request.intersectDomains(unapplied_domains, False)
                    processed_domain: Domain = request.cropDomain(merged_domain, arrayList )
                    sub_array = array.subset( processed_domain, unapplied_domains )
                    resultArrays[aid] = sub_array
                else:
                    resultArrays[aid] = array
            resultDataset = EDASDataset( resultArrays, inputDataset.attrs )
            alignmentTarget = resultDataset.getAlignmentVariable( op.getParm("align","lowest") )
            preprop_result = resultDataset.align( alignmentTarget )
            result: EDASDataset = preprop_result.groupby( op.grouping ).resample( op.resampling )
        print( " $$$$ processInputCrossSection: " + op.name + " -> " + str( result.ids ) )
        return result.purge()