Ejemplo n.º 1
0
        def getDataHDF5():
            print('\nWill read data from HDF5')

            inputHDF5 = self.dataInfo['Input Data']['HDF5 File']
            h5_file = h5py.File(inputHDF5, 'r')

            for mom in self.moms:
                mTag = tags.momString(mom)
                mh5Tag = tags.momH5(mom)
                t0List = self.dSetAttr[mTag]['t0']
                Nrows = self.dSetAttr[mTag]['Nrows']

                self.plainData[mTag] = {}
                for t0 in t0List:
                    t0Tag = tags.t0(t0)
                    for iop, opPair in enumerate(
                            self.dSetAttr[mTag]['intOpList']):
                        opTag = tags.src_snk(opPair)
                        for row in range(1, Nrows + 1):
                            rowTag = tags.row(row)
                            dkey = (t0, iop, row)

                            # Get the plain data
                            dset = 'plain/%s/%s/%s/%s/data' % (mh5Tag, t0Tag,
                                                               opTag, rowTag)
                            self.plainData[mTag][dkey] = np.array(
                                h5_file[dset])

                print('Reading two-point data for momentum %s completed.' %
                      (mTag))
            h5_file.close()
Ejemplo n.º 2
0
    def writeHDF5(self):

        def computeNuITD(fit_,gamma_,ri_):
            # nNu = 0
            # for mom in self.momAvg:
            #     dispListAvg = self.dispAvg[mTag]
            #     nNu += len(dispListAvg)

            nuArr = []
            for mom in self.momAvg:
                mTag = tags.momString(mom)
                dispListAvg = self.dispAvg[mTag]
                for z3 in dispListAvg:
                    dkey_ = (mTag,z3,gamma_)
                    nu = mom[2]*z3*self.unitMom # Ioffe-time, nu = Pz*z3*unitMom
                    nuArr.append([nu,self.mean[fit_][dkey_][ri_][0],self.mean[fit_][dkey_][ri_][1]])
            nuArr = np.array(nuArr,dtype=np.float64)
            return nuArr
        #---------------------------


        h5_file = h5py.File(self.info['HDF5 Output File'],'w')

        for fType in self.fitTypes.keys():
            for fit in self.fitTypes[fType]:

                # Write momentum and z3 dependence
                for mom in self.momAvg:
                    mTag = tags.momString(mom)
                    mh5Tag = tags.momH5(mom)
                    dispListAvg = self.dispAvg[mTag]

                    for z3 in dispListAvg:
                        dispTag = tags.disp(z3)
                        for gamma in self.gammaList:
                            insTag = tags.insertion(gamma)
                            dkey = (mTag,z3,gamma)

                            for ri in self.RI:    
                                group = '%s/%s/%s/%s/%s'%(fit,mh5Tag,dispTag,insTag,ri)
                                dset_name_bins = 'bins/' + group 
                                dset_name_mean = 'mean/' + group 

                                h5_file.create_dataset(dset_name_bins, data = self.bins[fit][dkey][ri])
                                h5_file.create_dataset(dset_name_mean, data = self.mean[fit][dkey][ri],dtype='f')
                # End for momentum

                # Write the nu-dependence of the ITD
                for gamma in self.gammaList:
                    for ri in self.RI:
                        nuITD = computeNuITD(fit,gamma,ri)                    
                        group = '%s/%s/%s'%(fit,insTag,ri)
                        dset_name_nuMean = 'nuDep/' + group 
                        h5_file.create_dataset(dset_name_nuMean, data = nuITD)

        # End for fType

        h5_file.close()
        print('Reduced Ioffe-time distributions written in HDF5.')
Ejemplo n.º 3
0
        def getDataHDF5():
            print('\nWill read data from HDF5')

            inputHDF5 = self.dataInfo['Input Data']['HDF5 File']
            h5_file = h5py.File(inputHDF5, 'r')

            for mom in self.moms:
                mTag = tags.momString(mom)
                mh5Tag = tags.momH5(mom)
                t0List = self.dSetAttr[mTag]['t0']
                tsepList = self.dSetAttr[mTag]['tsep']
                dispList = self.dSetAttr[mTag]['disp']
                Nrows = self.dSetAttr[mTag]['Nrows']

                for ri in self.RI:
                    self.plainData[ri][mTag] = {}

                    for z3 in dispList:
                        dispTag = tags.disp(z3)
                        for tsep in tsepList:
                            tsepTag = tags.tsep(tsep)
                            for t0 in t0List:
                                t0Tag = tags.t0(t0)
                                for iop, opPair in enumerate(
                                        self.dSetAttr[mTag]['intOpList']):
                                    opTag = tags.src_snk(opPair)
                                    for row in range(1, Nrows + 1):
                                        rowTag = tags.row(row)
                                        for gamma in self.gammaList:
                                            insTag = tags.insertion(gamma)

                                            dkey = (tsep, t0, z3, iop, row,
                                                    gamma)

                                            dset = 'plain/%s/%s/%s/%s/%s/%s/%s/%s/data' % (
                                                mh5Tag, dispTag, tsepTag,
                                                t0Tag, opTag, rowTag, insTag,
                                                ri)
                                            self.plainData[ri][mTag][
                                                dkey] = np.array(h5_file[dset])

                print('Reading three-point data for momentum %s completed.' %
                      (mTag))
Ejemplo n.º 4
0
        def dumpHDF5(fitSeq,h5_file):
            fType = fitSeq['Type']
            fLabel = fitSeq['Label']

            for mom in self.momAvg:
                mTag = tags.momString(mom)
                mh5Tag = tags.momH5(mom)
                tsepList = self.dSetAttr3pt[mTag]['tsep']
                dispListAvg = self.dispAvg[mTag]
                
                for z3 in dispListAvg:
                    dispTag = tags.disp(z3)
                    for gamma in self.gammaList:
                        insTag = tags.insertion(gamma)
                        for tsep in tsepList:
                            dkey = (tsep,z3,gamma)
                            tsepTag = tags.tsep(tsep)
                            fAttr = self.fitAttr[mTag][tsep]

                            for ri in self.RI:
                                # Write optimalFitValues
                                group = '%s/%s/%s/%s/%s'%(ri,mh5Tag,dispTag,insTag,tsepTag)
                                dset_name = 'OptimalFitRanges/' + group
                                h5_file.create_dataset(dset_name, data = np.array([self.optimalFit[fLabel][ri][mTag][dkey]]))

                                for nf in range(fAttr['Nfits']):
                                    tstart = fAttr['nf=%d'%(nf)]['tstart']
                                    tstop  = fAttr['nf=%d'%(nf)]['tstop']
                                    h5LabelNf = 'nf%d_%d-%d'%(nf,tstart,tstop)

                                    group = '%s/%s/%s/%s/%s/%s'%(ri,mh5Tag,dispTag,insTag,tsepTag,h5LabelNf)
                                    dset_name_Mbins = 'MatElem/bins/' + group 
                                    dset_name_Mmean = 'MatElem/mean/' + group 
                                    dset_name_chiBins = 'chiSquare/bins/' + group 
                                    dset_name_chiMean = 'chiSquare/mean/' + group 

                                    h5_file.create_dataset(dset_name_Mbins, data = self.Mbins[fLabel][ri][mTag][dkey][nf])
                                    h5_file.create_dataset(dset_name_Mmean, data = self.Mmean[fLabel][ri][mTag][dkey][nf],dtype='f')
                                    h5_file.create_dataset(dset_name_chiBins, data = self.chiBins[fLabel][ri][mTag][dkey][nf])
                                    h5_file.create_dataset(dset_name_chiMean, data = self.chiMean[fLabel][ri][mTag][dkey][nf],dtype='f')
            # End for momentum
            print('Plateau fitting data for type = %s, label = %s written in HDF5.'%(fType,fLabel))
Ejemplo n.º 5
0
    def writeHDF5(self):
        h5_file = h5py.File(self.dataInfo['HDF5 Output File'], 'w')

        for mom in self.momAvg:
            mTag = tags.momString(mom)
            mh5Tag = tags.momH5(mom)

            tsepList = self.dSetAttr3pt[mTag]['tsep']
            tsepList_rs = self.dSetAttr3pt[mTag]['tsep'][:-1]
            dispListAvg = self.dispAvg[mTag]
            Ntsep = len(tsepList)
            Ntsep_rs = len(tsepList_rs)

            for z3 in dispListAvg:
                dispTag = tags.disp(z3)
                for gamma in self.gammaList:
                    insTag = tags.insertion(gamma)
                    for ri in self.RI:

                        sumRatioH5 = (np.zeros(Ntsep), np.zeros(Ntsep),
                                      np.zeros(Ntsep))
                        for its, tsep in enumerate(tsepList):
                            dkey = (tsep, z3, gamma)
                            tsepTag = tags.tsep(tsep)

                            # Write the plain ratio bins and mean
                            rType = 'plain'
                            group = '%s/%s/%s/%s/%s/%s' % (
                                rType, mh5Tag, tsepTag, dispTag, insTag, ri)
                            dset_name_bins = 'bins/' + group
                            dset_name_mean = 'mean/' + group

                            h5_file.create_dataset(
                                dset_name_bins,
                                data=self.bins[rType][ri][mTag][dkey])
                            h5_file.create_dataset(
                                dset_name_mean,
                                data=self.mean[rType][ri][mTag][dkey],
                                dtype='f')
                            #---------------------------------------------------------------

                            # Write the summed ratio bins
                            rType = 'sum'
                            group = '%s/%s/%s/%s/%s/%s' % (
                                rType, mh5Tag, tsepTag, dispTag, insTag, ri)
                            dset_name_bins = 'bins/' + group
                            h5_file.create_dataset(
                                dset_name_bins,
                                data=self.bins[rType][ri][mTag][dkey])

                            # Convert the summed ratio mean into arrays that depend on tsep
                            sumRatioH5[0][its] = tsep  # tsep (x)
                            sumRatioH5[1][its] = self.mean[rType][ri][mTag][
                                dkey][0]  # ratio mean  (y)
                            sumRatioH5[2][its] = self.mean[rType][ri][mTag][
                                dkey][1]  # ratio error (y-error)
                        # End for tsep

                        # Write the summed ratio means
                        rType = 'sum'
                        group = '%s/%s/%s/%s/%s' % (rType, mh5Tag, dispTag,
                                                    insTag, ri)
                        dset_name_mean = 'mean/' + group
                        h5_file.create_dataset(dset_name_mean,
                                               data=sumRatioH5,
                                               dtype='f')
                        #-----------------------------

                        # Reduced-summed ratio
                        rSumRatioH5 = (np.zeros(Ntsep_rs), np.zeros(Ntsep_rs),
                                       np.zeros(Ntsep_rs))
                        for its, tsep in enumerate(tsepList_rs):
                            dkey = (tsep, z3, gamma)
                            tsepTag = tags.tsep(tsep)

                            # Write the summed ratio bins
                            rType = 'r-sum'
                            group = '%s/%s/%s/%s/%s/%s' % (
                                rType, mh5Tag, tsepTag, dispTag, insTag, ri)
                            dset_name_bins = 'bins/' + group
                            h5_file.create_dataset(
                                dset_name_bins,
                                data=self.bins[rType][ri][mTag][dkey])

                            # Convert the reduced-summed ratio mean into arrays that depend on tsep
                            rSumRatioH5[0][its] = tsep  # tsep (x)
                            rSumRatioH5[1][its] = self.mean[rType][ri][mTag][
                                dkey][0]  # ratio mean  (y)
                            rSumRatioH5[2][its] = self.mean[rType][ri][mTag][
                                dkey][1]  # ratio error (y-error)
                        # End for tsep

                        # Write the reduced-summed ratio means
                        rType = 'r-sum'
                        group = '%s/%s/%s/%s/%s' % (rType, mh5Tag, dispTag,
                                                    insTag, ri)
                        dset_name_mean = 'mean/' + group
                        h5_file.create_dataset(dset_name_mean,
                                               data=rSumRatioH5,
                                               dtype='f')
                    #-----------------------------
        # End for momentum

        h5_file.close()
        print('Ratio data written in HDF5.')
Ejemplo n.º 6
0
    def writeHDF5(self):
        h5_file = h5py.File(self.dataInfo['HDF5 Output File'], 'w')

        # Write the Pz- and z3-averaged data
        for mom in self.momAvg:
            mTag = tags.momString(mom)
            mh5Tag = tags.momH5(mom)

            tsepList = self.dSetAttr[mTag]['tsep']
            dispListAvg = self.dispAvg[mTag]

            for z3 in dispListAvg:
                dispTag = tags.disp(z3)
                for tsep in tsepList:
                    tsepTag = tags.tsep(tsep)
                    for gamma in self.gammaList:
                        insTag = tags.insertion(gamma)
                        dkeyAvg = (tsep, z3, gamma)

                        # Write the averaged data
                        for ri in self.RI:
                            avg_group = 'fullavg/%s/%s/%s/%s/%s' % (
                                mh5Tag, dispTag, tsepTag, insTag, ri)
                            dset_name_data = avg_group + '/data'
                            dset_name_bins = avg_group + '/bins'
                            dset_name_mean = avg_group + '/mean'
                            h5_file.create_dataset(
                                dset_name_data,
                                data=self.data[ri][mTag][dkeyAvg])
                            h5_file.create_dataset(
                                dset_name_bins,
                                data=self.bins[ri][mTag][dkeyAvg])
                            h5_file.create_dataset(
                                dset_name_mean,
                                data=self.mean[ri][mTag][dkeyAvg],
                                dtype='f')
        #--------------------------------------

        for mom in self.moms:
            mTag = tags.momString(mom)
            mh5Tag = tags.momH5(mom)
            t0List = self.dSetAttr[mTag]['t0']
            tsepList = self.dSetAttr[mTag]['tsep']
            dispList = self.dSetAttr[mTag]['disp']
            Nrows = self.dSetAttr[mTag]['Nrows']

            for z3 in dispList:
                dispTag = tags.disp(z3)
                for tsep in tsepList:
                    tsepTag = tags.tsep(tsep)
                    for gamma in self.gammaList:
                        insTag = tags.insertion(gamma)
                        dkeyAvg = (tsep, z3, gamma)

                        # Write Avg data
                        for ri in self.RI:
                            avg_group = 'avg/%s/%s/%s/%s/%s' % (
                                mh5Tag, dispTag, tsepTag, insTag, ri)
                            dset_name_avgData = avg_group + '/data'
                            dset_name_avgBins = avg_group + '/bins'
                            dset_name_avgMean = avg_group + '/mean'

                            h5_file.create_dataset(
                                dset_name_avgData,
                                data=self.avgData[ri][mTag][dkeyAvg])
                            h5_file.create_dataset(
                                dset_name_avgBins,
                                data=self.avgBins[ri][mTag][dkeyAvg])
                            h5_file.create_dataset(
                                dset_name_avgMean,
                                data=self.avgMean[ri][mTag][dkeyAvg],
                                dtype='f')

                        for t0 in t0List:
                            t0Tag = tags.t0(t0)
                            for iop, opPair in enumerate(
                                    self.dSetAttr[mTag]['intOpList']):
                                opTag = tags.src_snk(opPair)
                                for row in range(1, Nrows + 1):
                                    rowTag = tags.row(row)
                                    dkey = (tsep, t0, z3, iop, row, gamma)

                                    # Write the plain data
                                    for ri in self.RI:
                                        plain_group = 'plain/%s/%s/%s/%s/%s/%s/%s/%s' % (
                                            mh5Tag, dispTag, tsepTag, insTag,
                                            t0Tag, opTag, rowTag, ri)
                                        dset_name_plainData = plain_group + '/data'
                                        dset_name_plainBins = plain_group + '/bins'
                                        dset_name_plainMean = plain_group + '/mean'

                                        h5_file.create_dataset(
                                            dset_name_plainData,
                                            data=self.plainData[ri][mTag]
                                            [dkey])
                                        h5_file.create_dataset(
                                            dset_name_plainBins,
                                            data=self.plainBins[ri][mTag]
                                            [dkey])
                                        h5_file.create_dataset(
                                            dset_name_plainMean,
                                            data=self.plainMean[ri][mTag]
                                            [dkey],
                                            dtype='f')
        #--------------------------------------

        h5_file.close()
        print('Three-point function data written in HDF5.')
Ejemplo n.º 7
0
    def writeHDF5(self):
        h5_file = h5py.File(self.dataInfo['HDF5 Output File'],'w')

        for mom in self.moms:
            mTag = tags.momString(mom)
            mh5Tag = tags.momH5(mom)
            t0List = self.dSetAttr[mTag]['t0']
            Nrows = self.dSetAttr[mTag]['Nrows']

            # Write the averaged data
            avg_group = 'data/avg/%s'%(mh5Tag)
            dset_name_bins = avg_group + '/bins'
            dset_name_mean = avg_group + '/mean'

            h5_file.create_dataset(dset_name_bins, data = self.avgBins[mTag])
            h5_file.create_dataset(dset_name_mean, data = self.avgMean[mTag],dtype='f')

            for t0 in t0List:
                t0Tag = tags.t0(t0)

                for iop,opPair in enumerate(self.dSetAttr[mTag]['intOpList']):
                    opTag = tags.src_snk(opPair)
                    for row in range(1,Nrows+1):
                        rowTag = tags.row(row)

                        dkey = (t0,iop,row)

                        # Write the plain data
                        plain_group = 'data/plain/%s/%s/%s/%s'%(mh5Tag,t0Tag,opTag,rowTag)
                        dset_name_plainBins = plain_group + '/bins'
                        dset_name_plainMean = plain_group + '/mean'

                        h5_file.create_dataset(dset_name_plainBins, data = self.plainBins[mTag][dkey])
                        h5_file.create_dataset(dset_name_plainMean, data = self.plainMean[mTag][dkey],dtype='f')                                
        #--------------------------------

        # Write the momentum-averaged data
        for mom in self.momAvg:
            mTag = tags.momString(mom)
            mh5Tag = tags.momH5(tags.momVec(mTag))

            momAvg_group = 'data/momAvg/%s'%(mh5Tag)
            dset_name_bins = momAvg_group + '/bins'
            dset_name_mean = momAvg_group + '/mean'

            h5_file.create_dataset(dset_name_bins, data = self.bins[mTag])
            h5_file.create_dataset(dset_name_mean, data = self.mean[mTag],dtype='f')
        #--------------------------------

        # Write the Fit data
        for fitSeq in self.fitInfo:
            fType = fitSeq['Type']

            for mTag in fitSeq['Ranges'].keys():
                mh5Tag = tags.momH5(tags.momVec(mTag))

                fit_group = 'fits/%s/momAvg/%s'%(fType,mh5Tag)
                dset_name_fitBins = fit_group + '/bins'
                dset_name_fitMean = fit_group + '/mean'
                dset_name_chiMean = fit_group + '/chiSquare'

                h5_file.create_dataset(dset_name_fitBins, data = self.fitBins[fType][mTag])
                h5_file.create_dataset(dset_name_fitMean, data = self.fitMean[fType][mTag],dtype='f')
                h5_file.create_dataset(dset_name_chiMean, data = self.chiMean[fType][mTag],dtype='f')
        #--------------------------------


        h5_file.close()
        print('Effective Energy data written in HDF5.')
Ejemplo n.º 8
0
    def writeHDF5(self):
        h5_file = h5py.File(self.dataInfo['HDF5 Output File'], 'w')

        for mom in self.moms:
            mTag = tags.momString(mom)
            mh5Tag = tags.momH5(mom)
            t0List = self.dSetAttr[mTag]['t0']
            Nrows = self.dSetAttr[mTag]['Nrows']

            # Write the averaged data
            avg_group = 'avg/%s' % (mh5Tag)
            dset_name_data = avg_group + '/data'
            dset_name_bins = avg_group + '/bins'
            dset_name_mean = avg_group + '/mean'

            h5_file.create_dataset(dset_name_data, data=self.avgData[mTag])
            h5_file.create_dataset(dset_name_bins, data=self.avgBins[mTag])
            h5_file.create_dataset(dset_name_mean,
                                   data=self.avgMean[mTag],
                                   dtype='f')

            for t0 in t0List:
                t0Tag = tags.t0(t0)

                # Write cov. matrix mean
                cov_group = 'cov/%s/%s' % (mh5Tag, t0Tag)
                dset_name_covMean = cov_group + '/mean'
                h5_file.create_dataset(dset_name_covMean,
                                       data=self.covMean[mTag][t0],
                                       dtype='f')

                for iop, opPair in enumerate(self.dSetAttr[mTag]['intOpList']):
                    opTag = tags.src_snk(opPair)
                    for row in range(1, Nrows + 1):
                        rowTag = tags.row(row)

                        dkey = (t0, iop, row)

                        # Write the plain data
                        plain_group = 'plain/%s/%s/%s/%s' % (mh5Tag, t0Tag,
                                                             opTag, rowTag)
                        dset_name_plainData = plain_group + '/data'
                        dset_name_plainBins = plain_group + '/bins'
                        dset_name_plainMean = plain_group + '/mean'

                        h5_file.create_dataset(dset_name_plainData,
                                               data=self.plainData[mTag][dkey])
                        h5_file.create_dataset(dset_name_plainBins,
                                               data=self.plainBins[mTag][dkey])
                        h5_file.create_dataset(dset_name_plainMean,
                                               data=self.plainMean[mTag][dkey],
                                               dtype='f')

        # Write the momentum-averaged data
        for mom in self.momAvg:
            mTag = tags.momString(mom)
            mh5Tag = tags.momH5(mom)

            momAvg_group = 'momAvg/%s' % (mh5Tag)
            dset_name_momData = momAvg_group + '/data'
            dset_name_momBins = momAvg_group + '/bins'
            dset_name_momMean = momAvg_group + '/mean'

            h5_file.create_dataset(dset_name_momData, data=self.data[mTag])
            h5_file.create_dataset(dset_name_momBins, data=self.bins[mTag])
            h5_file.create_dataset(dset_name_momMean,
                                   data=self.mean[mTag],
                                   dtype='f')
        #--------------------------------

        h5_file.close()
        print('Two-point function data written in HDF5.')
Ejemplo n.º 9
0
        def dumpLinearFitsHDF5(fitSeq, h5_file):
            fType = fitSeq['Type']
            fLabel = fitSeq['Label']
            tsepLowList = fitSeq['tsepLow']

            for mom in self.momAvg:
                mTag = tags.momString(mom)
                mh5Tag = tags.momH5(mom)
                dispListAvg = self.dispAvg[mTag]

                for z3 in dispListAvg:
                    dispTag = tags.disp(z3)
                    for gamma in self.gammaList:
                        insTag = tags.insertion(gamma)
                        dkeyF = (z3, gamma)

                        for ri in self.RI:
                            for tL in tsepLowList:
                                sLTag = 'tL%d' % (tL)
                                tini = self.tsepFitX[fLabel][mTag][sLTag][0]
                                tfin = self.tsepFitX[fLabel][mTag][sLTag][-1]
                                h5LabelT = 'tsep_%d-%d' % (tini, tfin)

                                # Write Chi^2
                                group = '%s/%s/%s/%s/%s' % (
                                    ri, mh5Tag, dispTag, insTag, h5LabelT)
                                dset_name_chiBins = 'chiSquare/bins/' + group
                                dset_name_chiMean = 'chiSquare/mean/' + group
                                h5_file.create_dataset(
                                    dset_name_chiBins,
                                    data=self.chiBins[fLabel][sLTag][ri][mTag]
                                    [dkeyF])
                                h5_file.create_dataset(
                                    dset_name_chiMean,
                                    data=self.chiMean[fLabel][sLTag][ri][mTag]
                                    [dkeyF],
                                    dtype='f')

                                # Write fit bands
                                dset_name_fitBands = 'fitBands/' + group
                                h5_file.create_dataset(
                                    dset_name_fitBands,
                                    data=(self.fitBands[fLabel][sLTag][ri]
                                          [mTag][dkeyF]['x'],
                                          self.fitBands[fLabel][sLTag][ri]
                                          [mTag][dkeyF]['v'],
                                          self.fitBands[fLabel][sLTag][ri]
                                          [mTag][dkeyF]['e']),
                                    dtype='f')

                                # Write Fit parameters
                                for fP, fpH5 in zip(self.fitParams[fType],
                                                    self.fitParamsH5[fType]):
                                    fpTag = fP + '_%s' % (sLTag)

                                    dset_name_bins = '%s/bins/' % (
                                        fpH5) + group
                                    dset_name_mean = '%s/mean/' % (
                                        fpH5) + group
                                    h5_file.create_dataset(
                                        dset_name_bins,
                                        data=self.bins[fLabel][fpTag][ri][mTag]
                                        [dkeyF])
                                    h5_file.create_dataset(
                                        dset_name_mean,
                                        data=self.mean[fLabel][fpTag][ri][mTag]
                                        [dkeyF],
                                        dtype='f')
            # End for momentum
            print(
                'Summation fitting data for type = %s, label = %s written in HDF5.'
                % (fType, fLabel))