Ejemplo n.º 1
0
def create_vana(EXPR_FILE, NoAbs=False, write_existingv=True):
    # ==== Vana loading
    (dum, uampstotal) = cry_sample.get_data_sum(EXPR_FILE.VanFile, "Vanadium", EXPR_FILE)
    # Subtract the empty instrument ===
    (dum, uampstotal) = cry_sample.get_data_sum(EXPR_FILE.VEmptyFile, "Empty", EXPR_FILE)
    if uampstotal > 1e-6:
        print " => Substract the Empty to the Vana"
        Minus(LHSWorkspace="Vanadium", RHSWorkspace="Empty", OutputWorkspace="Vanadium_align")
        mtd.remove("Empty")
    cry_load.align_fnc("Vanadium_align", EXPR_FILE)
    Divide(LHSWorkspace="Vanadium_align", RHSWorkspace="Corr", OutputWorkspace="Vanadium_corr")
    if not NoAbs:
        print " => Van Absortption correction"
        cry_utils.correct_abs(InputWkspc="Vanadium_corr", outputWkspc="Transmission",
                              TheCylinderSampleHeight=EXPR_FILE.VHeight,
                              TheCylinderSampleRadius=EXPR_FILE.VRadius,
                              TheAttenuationXSection=EXPR_FILE.VAttenuationXSection,
                              TheScatteringXSection=EXPR_FILE.VScatteringXSection,
                              TheSampleNumberDensity=EXPR_FILE.VanaNumberDensity,
                              TheNumberOfSlices=EXPR_FILE.VNumberOfSlices,
                              TheNumberOfAnnuli=EXPR_FILE.VNumberOfAnnuli,
                              TheNumberOfWavelengthPoints=EXPR_FILE.VNumberOfWavelengthPoints,
                              TheExpMethod=EXPR_FILE.VExpMethod)
    # --- Alternative way.
    # ConvertUnits(InputWorkspace="Vanadium", OutputWorkspace="Vanadium", Target="Wavelength")
    # CylinderAbsorption(InputWorkspace="Vanadium", OutputWorkspace="Vanadium",
    #	CylinderSampleHeight=      EXPR_FILE.VHeight,
    #	CylinderSampleRadius=      EXPR_FILE.VRadius,
    #	AttenuationXSection=       EXPR_FILE.VAttenuationXSection,
    #	ScatteringXSection=        EXPR_FILE.VScatteringXSection,
    #	SampleNumberDensity=       EXPR_FILE.VanaNumberDensity,
    #	NumberOfSlices =           EXPR_FILE.VNumberOfSlices,
    #	NumberOfAnnuli=            EXPR_FILE.VNumberOfAnnuli,
    #	NumberOfWavelengthPoints = EXPR_FILE.VNumberOfWavelengthPoints,
    #	ExpMethod=                 EXPR_FILE.VExpMethod               )
    # ConvertUnits(InputWorkspace="Vanadium", OutputWorkspace="Vanadium", Target="dSpacing")
    # (dum,uampstotal)=CRY_sample.get_data_sum(EXPR_FILE.VanFile,"Vanadium2",EXPR_FILE)
    # Divide("Vanadium2", "Vanadium", "Vanadium")
    ##ConvertUnits(InputWorkspace=InputWkspc, OutputWorkspace=InputWkspc, Target="dSpacing")
    # mtd.remove("Vanadium2")
    ##
    print " => Focus type : " + EXPR_FILE.VGrpfocus
    if EXPR_FILE.VGrpfocus == "sam":
        GrpFile = EXPR_FILE.Path2DatGrpFile
    else:
        GrpFile = EXPR_FILE.Path2VanGrpFile
    print " => Van Focused with the Cal file :" + GrpFile
    DiffractionFocussing(InputWorkspace="Vanadium_corr", OutputWorkspace="Vanadium_foc", GroupingFileName=GrpFile,
                         PreserveEvents=False)
    print " => VANADIUM FOCUSED"
    ReplaceSpecialValues(InputWorkspace="Vanadium_foc", OutputWorkspace="Vanadium", NaNValue="0", InfinityValue="0",
                         BigNumberThreshold="99999999.99999999")
    SaveNexusProcessed(Filename=EXPR_FILE.CorrVanFile + "_unstripped.nxs", InputWorkspace="Vanadium")
    SaveFocusedXYE(Filename=EXPR_FILE.CorrVanFile + "_unstripped.dat", InputWorkspace="Vanadium", SplitFiles=True)
    strip_the_vana(EXPR_FILE)
    if EXPR_FILE.ExistV == 'no' and EXPR_FILE.VGrpfocus == 'van' and write_existingv:
        EXPR_FILE.write_prefline("ExistingV", "yes")
        EXPR_FILE.ExistV = "yes"
    if not EXPR_FILE.debugMode:
        mtd.remove("Vanadium_foc")
        mtd.remove("Transmission")
        mtd.remove("Vanadium_corr")
        mtd.remove("Vanadium_align")
    return False
Ejemplo n.º 2
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)
Ejemplo n.º 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)
Ejemplo n.º 4
0
def create_vana(EXPR_FILE, NoAbs=False, write_existingv=True):
    # ==== Vana loading
    (dum, uampstotal) = cry_sample.get_data_sum(EXPR_FILE.VanFile, "Vanadium",
                                                EXPR_FILE)
    # Subtract the empty instrument ===
    (dum, uampstotal) = cry_sample.get_data_sum(EXPR_FILE.VEmptyFile, "Empty",
                                                EXPR_FILE)
    if uampstotal > 1e-6:
        print " => Substract the Empty to the Vana"
        Minus(LHSWorkspace="Vanadium",
              RHSWorkspace="Empty",
              OutputWorkspace="Vanadium_align")
        mtd.remove("Empty")
    cry_load.align_fnc("Vanadium_align", EXPR_FILE)
    Divide(LHSWorkspace="Vanadium_align",
           RHSWorkspace="Corr",
           OutputWorkspace="Vanadium_corr")
    if not NoAbs:
        print " => Van Absortption correction"
        cry_utils.correct_abs(
            InputWkspc="Vanadium_corr",
            outputWkspc="Transmission",
            TheCylinderSampleHeight=EXPR_FILE.VHeight,
            TheCylinderSampleRadius=EXPR_FILE.VRadius,
            TheAttenuationXSection=EXPR_FILE.VAttenuationXSection,
            TheScatteringXSection=EXPR_FILE.VScatteringXSection,
            TheSampleNumberDensity=EXPR_FILE.VanaNumberDensity,
            TheNumberOfSlices=EXPR_FILE.VNumberOfSlices,
            TheNumberOfAnnuli=EXPR_FILE.VNumberOfAnnuli,
            TheNumberOfWavelengthPoints=EXPR_FILE.VNumberOfWavelengthPoints,
            TheExpMethod=EXPR_FILE.VExpMethod)
    # --- Alternative way.
    # ConvertUnits(InputWorkspace="Vanadium", OutputWorkspace="Vanadium", Target="Wavelength")
    # CylinderAbsorption(InputWorkspace="Vanadium", OutputWorkspace="Vanadium",
    #	CylinderSampleHeight=      EXPR_FILE.VHeight,
    #	CylinderSampleRadius=      EXPR_FILE.VRadius,
    #	AttenuationXSection=       EXPR_FILE.VAttenuationXSection,
    #	ScatteringXSection=        EXPR_FILE.VScatteringXSection,
    #	SampleNumberDensity=       EXPR_FILE.VanaNumberDensity,
    #	NumberOfSlices =           EXPR_FILE.VNumberOfSlices,
    #	NumberOfAnnuli=            EXPR_FILE.VNumberOfAnnuli,
    #	NumberOfWavelengthPoints = EXPR_FILE.VNumberOfWavelengthPoints,
    #	ExpMethod=                 EXPR_FILE.VExpMethod               )
    # ConvertUnits(InputWorkspace="Vanadium", OutputWorkspace="Vanadium", Target="dSpacing")
    # (dum,uampstotal)=CRY_sample.get_data_sum(EXPR_FILE.VanFile,"Vanadium2",EXPR_FILE)
    # Divide("Vanadium2", "Vanadium", "Vanadium")
    ##ConvertUnits(InputWorkspace=InputWkspc, OutputWorkspace=InputWkspc, Target="dSpacing")
    # mtd.remove("Vanadium2")
    ##
    print " => Focus type : " + EXPR_FILE.VGrpfocus
    if EXPR_FILE.VGrpfocus == "sam":
        GrpFile = EXPR_FILE.Path2DatGrpFile
    else:
        GrpFile = EXPR_FILE.Path2VanGrpFile
    print " => Van Focused with the Cal file :" + GrpFile
    DiffractionFocussing(InputWorkspace="Vanadium_corr",
                         OutputWorkspace="Vanadium_foc",
                         GroupingFileName=GrpFile,
                         PreserveEvents=False)
    print " => VANADIUM FOCUSED"
    ReplaceSpecialValues(InputWorkspace="Vanadium_foc",
                         OutputWorkspace="Vanadium",
                         NaNValue="0",
                         InfinityValue="0",
                         BigNumberThreshold="99999999.99999999")
    SaveNexusProcessed(Filename=EXPR_FILE.CorrVanFile + "_unstripped.nxs",
                       InputWorkspace="Vanadium")
    SaveFocusedXYE(Filename=EXPR_FILE.CorrVanFile + "_unstripped.dat",
                   InputWorkspace="Vanadium",
                   SplitFiles=True)
    strip_the_vana(EXPR_FILE)
    if EXPR_FILE.ExistV == 'no' and EXPR_FILE.VGrpfocus == 'van' and write_existingv:
        EXPR_FILE.write_prefline("ExistingV", "yes")
        EXPR_FILE.ExistV = "yes"
    if not EXPR_FILE.debugMode:
        mtd.remove("Vanadium_foc")
        mtd.remove("Transmission")
        mtd.remove("Vanadium_corr")
        mtd.remove("Vanadium_align")
    return False