示例#1
0
def focus_all(EXPR_FILE,
              samplelistTexte,
              scale=0,
              NoVabs=False,
              NoSAC=False,
              Eff=True,
              Norm=True,
              Write_ExtV=True):
    if scale == 0:
        scale = float(EXPR_FILE.scale)
    # === Norm boolean flag used to Optionally correct to a Vana ===
    if Norm:
        print 'Existing Vana Status:' + EXPR_FILE.ExistV
        # SAC/EFF corrections loads the Vana
        load_sac_eff(EXPR_FILE, NoSAC=NoSAC, Eff=Eff)
        if EXPR_FILE.ExistV == "load":
            for i in EXPR_FILE.bankList:
                spec = i - 1
                vanfil = EXPR_FILE.CorrVanFile + "-" + str(spec) + ".nxs"
                LoadNexusProcessed(Filename=vanfil,
                                   OutputWorkspace="Vanadium-" + str(i))
                # CORRECT
        elif EXPR_FILE.ExistV == "no" and EXPR_FILE.VGrpfocus == "van":
            print "was here?"
            cry_vana.create_vana(EXPR_FILE,
                                 NoAbs=NoVabs,
                                 write_existingv=Write_ExtV)
    else:
        load_sac_eff(EXPR_FILE, NoSAC=True)
    # === Construct a list of runs, sum of runs
    sampleSumLists = cry_utils.get_sample_list(EXPR_FILE.basefile,
                                               samplelistTexte,
                                               EXPR_FILE.RawDir)
    # to loop over
    isfirst = True
    for sample2Add in sampleSumLists:
        print '--------------------------'
        print '         Start focus here        '
        print '--------------------------'
        print " ---> " + focus_one(
            EXPR_FILE, sample2Add, scale, Norm, isfirst, NoAbs=NoVabs)
        isfirst = False
    #
    # changed by WAK 8/3/2011:delete workspaces
    if not EXPR_FILE.debugMode:
        mtd.remove("Corr")
        mtd.remove("Sample")
        for i in EXPR_FILE.bankList:
            mtd.remove("Sample-" + str(i))
        for i in EXPR_FILE.bankList:
            mtd.remove("Vanadium-" + str(i))
示例#2
0
def focus_all(EXPR_FILE, samplelistTexte, scale=0, NoVabs=False, NoSAC=False, Eff=True, Norm=True,
              Write_ExtV=True):
    if scale == 0:
        scale = float(EXPR_FILE.scale)
    # === Norm boolean flag used to Optionally correct to a Vana ===
    if Norm:
        print 'Existing Vana Status:' + EXPR_FILE.ExistV
        # SAC/EFF corrections loads the Vana
        load_sac_eff(EXPR_FILE, NoSAC=NoSAC, Eff=Eff)
        if EXPR_FILE.ExistV == "load":
            for i in EXPR_FILE.bankList:
                spec = i - 1
                vanfil = EXPR_FILE.CorrVanFile + "-" + str(spec) + ".nxs"
                LoadNexusProcessed(Filename=vanfil, OutputWorkspace="Vanadium-" + str(i))
                # CORRECT
        elif EXPR_FILE.ExistV == "no" and EXPR_FILE.VGrpfocus == "van":
            print "was here?"
            cry_vana.create_vana(EXPR_FILE, NoAbs=NoVabs, write_existingv=Write_ExtV)
    else:
        load_sac_eff(EXPR_FILE, NoSAC=True)
    # === Construct a list of runs, sum of runs
    sampleSumLists = cry_utils.get_sample_list(EXPR_FILE.basefile, samplelistTexte, EXPR_FILE.RawDir)
    # to loop over
    isfirst = True
    for sample2Add in sampleSumLists:
        print '--------------------------'
        print '         Start focus here        '
        print '--------------------------'
        print " ---> " + focus_one(EXPR_FILE, sample2Add, scale, Norm, isfirst, NoAbs=NoVabs)
        isfirst = False
    #
    # changed by WAK 8/3/2011:delete workspaces
    if not EXPR_FILE.debugMode:
        mtd.remove("Corr")
        mtd.remove("Sample")
        for i in EXPR_FILE.bankList:
            mtd.remove("Sample-" + str(i))
        for i in EXPR_FILE.bankList:
            mtd.remove("Vanadium-" + str(i))
示例#3
0
def focus_one(EXPR_FILE, sampleAdd, scale, Norm, isfirst=False, NoAbs=False):
    (outname, uampstotal) = cry_sample.get_data_sum(sampleAdd, "sample", EXPR_FILE)
    if uampstotal < 1e-6:
        return "No usable data, Raw files probably not found: cannot create " + outname + "\n"
    newCalFile = join(EXPR_FILE.user, EXPR_FILE.GrpFile)  # where user and GrpFile is appended
    Integration(InputWorkspace="sample", OutputWorkspace="sampleSum")
    MaskDetectorsIf(InputWorkspace="sampleSum", InputCalFile=EXPR_FILE.Path2GrpFile, OutputCalFile=newCalFile,
                    Mode="DeselectIf", Operator="Equal", Value=10)
    mtd.remove("sampleSum")
    EXPR_FILE.Path2DatGrpFile = newCalFile
    # isfirst always true when called from FocusAll
    if EXPR_FILE.VGrpfocus == "sam" and isfirst:
        cry_vana.create_vana(EXPR_FILE, NoAbs)
    if EXPR_FILE.SEmptyFile[0] != "none":
        # === Optionally loads Sample Empty ===
        (dum1, uamps) = cry_sample.get_data_sum(EXPR_FILE.SEmptyFile, "Sempty", EXPR_FILE)
        Minus(LHSWorkspace="sample", RHSWorkspace="Sempty", OutputWorkspace="sample")
        mtd.remove("Sempty")
    cry_load.align_fnc("sample", EXPR_FILE)
    Divide(LHSWorkspace="sample", RHSWorkspace="Corr", OutputWorkspace="sample")
    cry_load.scale_wspc("sample", scale)
    if EXPR_FILE.CorrectSampleAbs == "yes":
        if EXPR_FILE.SampleAbsCorrected == False:
            cry_utils.correct_abs(InputWkspc="sample", outputWkspc="SampleTrans", \
                                  TheCylinderSampleHeight=EXPR_FILE.SampleHeight, \
                                  TheCylinderSampleRadius=EXPR_FILE.SampleRadius, \
                                  TheAttenuationXSection=EXPR_FILE.SampleAttenuationXSection, \
                                  TheScatteringXSection=EXPR_FILE.SampleScatteringXSection, \
                                  TheSampleNumberDensity=EXPR_FILE.SampleNumberDensity, \
                                  TheNumberOfSlices=EXPR_FILE.SampleNumberOfSlices, \
                                  TheNumberOfAnnuli=EXPR_FILE.SampleNumberOfAnnuli, \
                                  TheNumberOfWavelengthPoints=EXPR_FILE.SampleNumberOfWavelengthPoints, \
                                  TheExpMethod=EXPR_FILE.SampleExpMethod)
            EXPR_FILE.SampleAbsCorrected = True
        else:
            ConvertUnits(InputWorkspace="sample", OutputWorkspace="sample", Target="Wavelength")
            Divide(LHSWorkspace="sample", RHSWorkspace="SampleTrans", OutputWorkspace="sample")
            ConvertUnits(InputWorkspace="sample", OutputWorkspace="sample", Target="dSpacing")
    DiffractionFocussing(InputWorkspace="sample", OutputWorkspace="sample",
                         GroupingFileName=EXPR_FILE.Path2DatGrpFile,
                         PreserveEvents=False)
    divide_samp_vana(EXPR_FILE, Norm)
    # === Cleans results in D and TOF before outputing bank by bank ===
    cry_load.bin_bank("ResultD", EXPR_FILE.bankList, EXPR_FILE.Drange)
    for i in EXPR_FILE.bankList:
        ConvertUnits(InputWorkspace="ResultD-" + str(i), OutputWorkspace="ResultTOF-" + str(i), Target="TOF")
        ReplaceSpecialValues(InputWorkspace="ResultD-" + str(i), OutputWorkspace="ResultD-" + str(i), NaNValue="0",
                             InfinityValue="0", BigNumberThreshold="99999999.99999999")
        ReplaceSpecialValues(InputWorkspace="ResultTOF-" + str(i), OutputWorkspace="ResultTOF-" + str(i), NaNValue="0",
                             InfinityValue="0", BigNumberThreshold="99999999.99999999")
    # === Output===
    # GSS
    GrpList = "ResultTOF-" + str(EXPR_FILE.bankList[0])
    if len(EXPR_FILE.bankList[1:]) > 1:
        for i in EXPR_FILE.bankList[1:]:
            GrpList = GrpList + ",ResultTOF-" + str(i)
        GroupWorkspaces(OutputWorkspace="ResultTOFgrp", InputWorkspaces=GrpList)
    if EXPR_FILE.OutSuf == "":
        OutputFile = join(EXPR_FILE.user, outname)
    else:
        OutputFile = join(EXPR_FILE.user, outname + "_" + EXPR_FILE.OutSuf)
    # Gss
    rearrang4gss(OutputFile, EXPR_FILE)
    # Nexus
    rearrange_4nex(OutputFile, EXPR_FILE)
    # XYE
    OutputFile = OutputFile + "_"
    rearrange_4xye(OutputFile, EXPR_FILE, units="TOF")
    rearrange_4xye(OutputFile, EXPR_FILE, units="D")
    return outname + "  focused with uampstotal=" + str(uampstotal)
示例#4
0
def focus_one(EXPR_FILE, sampleAdd, scale, Norm, isfirst=False, NoAbs=False):
    (outname, uampstotal) = cry_sample.get_data_sum(sampleAdd, "sample", EXPR_FILE)
    if uampstotal < 1e-6:
        return "No usable data, Raw files probably not found: cannot create " + outname + "\n"
    newCalFile = join(EXPR_FILE.user, EXPR_FILE.GrpFile) # where user and GrpFile is appended
    Integration(InputWorkspace="sample", OutputWorkspace="sampleSum")
    MaskDetectorsIf(InputWorkspace="sampleSum", InputCalFile=EXPR_FILE.Path2GrpFile, OutputCalFile=newCalFile,
                    Mode="DeselectIf", Operator="Equal", Value=10)
    mtd.remove("sampleSum")
    EXPR_FILE.Path2DatGrpFile = newCalFile
    # isfirst always true when called from FocusAll
    if EXPR_FILE.VGrpfocus == "sam" and isfirst:
        cry_vana.create_vana(EXPR_FILE, NoAbs)
    if EXPR_FILE.SEmptyFile[0] != "none":
        # === Optionally loads Sample Empty ===
        # (dum1, uamps) = CRY_sample.get_data_sum(EXPR_FILE.SEmptyFile, "Sempty", EXPR_FILE)
        Minus(LHSWorkspace="sample", RHSWorkspace="Sempty", OutputWorkspace="sample")
        mtd.remove("Sempty")
    cry_load.align_fnc("sample", EXPR_FILE)
    Divide(LHSWorkspace="sample", RHSWorkspace="Corr", OutputWorkspace="sample")
    cry_load.scale_wspc("sample", scale)
    if EXPR_FILE.CorrectSampleAbs == "yes":
        if EXPR_FILE.SampleAbsCorrected == False:
            cry_utils.correct_abs(InputWkspc="sample", outputWkspc="SampleTrans", \
                                  TheCylinderSampleHeight=EXPR_FILE.SampleHeight, \
                                  TheCylinderSampleRadius=EXPR_FILE.SampleRadius, \
                                  TheAttenuationXSection=EXPR_FILE.SampleAttenuationXSection, \
                                  TheScatteringXSection=EXPR_FILE.SampleScatteringXSection, \
                                  TheSampleNumberDensity=EXPR_FILE.SampleNumberDensity, \
                                  TheNumberOfSlices=EXPR_FILE.SampleNumberOfSlices, \
                                  TheNumberOfAnnuli=EXPR_FILE.SampleNumberOfAnnuli, \
                                  TheNumberOfWavelengthPoints=EXPR_FILE.SampleNumberOfWavelengthPoints, \
                                  TheExpMethod=EXPR_FILE.SampleExpMethod)
            EXPR_FILE.SampleAbsCorrected = True
        else:
            ConvertUnits(InputWorkspace="sample", OutputWorkspace="sample", Target="Wavelength")
            Divide(LHSWorkspace="sample", RHSWorkspace="SampleTrans", OutputWorkspace="sample")
            ConvertUnits(InputWorkspace="sample", OutputWorkspace="sample", Target="dSpacing")
    DiffractionFocussing(InputWorkspace="sample", OutputWorkspace="sample",
                         GroupingFileName=EXPR_FILE.Path2DatGrpFile,
                         PreserveEvents=False)
    divide_samp_vana(EXPR_FILE, Norm)
    # === Cleans results in D and TOF before outputing bank by bank ===
    cry_load.bin_bank("ResultD", EXPR_FILE.bankList, EXPR_FILE.Drange)
    for i in EXPR_FILE.bankList:
        ConvertUnits(InputWorkspace="ResultD-" + str(i), OutputWorkspace="ResultTOF-" + str(i), Target="TOF")
        ReplaceSpecialValues(InputWorkspace="ResultD-" + str(i), OutputWorkspace="ResultD-" + str(i), NaNValue="0",
                             InfinityValue="0", BigNumberThreshold="99999999.99999999")
        ReplaceSpecialValues(InputWorkspace="ResultTOF-" + str(i), OutputWorkspace="ResultTOF-" + str(i), NaNValue="0",
                             InfinityValue="0", BigNumberThreshold="99999999.99999999")
    # === Output===
    # GSS
    GrpList = "ResultTOF-" + str(EXPR_FILE.bankList[0])
    if len(EXPR_FILE.bankList[1:]) > 1:
        for i in EXPR_FILE.bankList[1:]:
            GrpList = GrpList + ",ResultTOF-" + str(i)
        GroupWorkspaces(OutputWorkspace="ResultTOFgrp", InputWorkspaces=GrpList)
    if EXPR_FILE.OutSuf == "":
        OutputFile = join(EXPR_FILE.user, outname)
    else:
        OutputFile = join(EXPR_FILE.user, outname + "_" + EXPR_FILE.OutSuf)
    # Gss
    rearrang4gss(OutputFile, EXPR_FILE)
    # Nexus
    rearrange_4nex(OutputFile, EXPR_FILE)
    # XYE
    OutputFile = OutputFile + "_"
    rearrange_4xye(OutputFile, EXPR_FILE, units="TOF")
    rearrange_4xye(OutputFile, EXPR_FILE, units="D")
    return outname + "  focused with uampstotal=" + str(uampstotal)