Changeset 1186


Ignore:
Timestamp:
Feb 19, 2022 4:16:12 PM (9 months ago)
Author:
ilavsky
Message:

Nika add semi transparent beamstop calculation

Location:
trunk/User Procedures/Nika
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/User Procedures/Nika/NI1_ConvProc.ipf

    r1180 r1186  
    22#pragma rtGlobals=3             // Use modern global access method.
    33//#pragma rtGlobals=1           // Use modern global access method.
    4 #pragma version=2.73
     4#pragma version=2.74
    55#include <TransformAxis1.2>
    66
     
    1111//*************************************************************************/
    1212
     13//2.74 ~2022 sometimes.
     14//                      added ability to calculate transmission using semi transparent beamstop.
    1315//2.73 5-24-2021 changed resolution to be FWHM/2, same as USAXS and as expected by Modeling package and sasView.
    1416//              modifed NI1A_CalculateQresolution to return FWHM and use only Q steps and Beam size. Pixel size used before is wrong, that is accounted for in Q stepping already, Nika cannot oversample in Q points.
     
    31543156                NVAR UseSampleTransmission=root:Packages:Convert2Dto1D:UseSampleTransmission
    31553157                NVAR UseSampleTransmFnct=root:Packages:Convert2Dto1D:UseSampleTransmFnct
     3158                NVAR UseTranspBeamstop = root:Packages:Convert2Dto1D:UseTranspBeamstop
    31563159                SVAR SampleTransmFnct=root:Packages:Convert2Dto1D:SampleTransmFnct
    31573160                NVAR SampleTransmission=root:Packages:Convert2Dto1D:SampleTransmission
    3158                 if(UseSampleTransmission && UseSampleTransmFnct)
     3161                if(UseSampleTransmission && (UseSampleTransmFnct||UseTranspBeamstop))
    31593162                        Execute("root:Packages:Convert2Dto1D:temp ="+SampleTransmFnct+"(\""+SelectedFileToLoad+"\")")
    31603163                        if(numtype(temp)!=0 || temp<=0)// || temp >1.5)
     
    39403943        CheckBox UseSampleTransmFnct,help={"Check is transmission=Function(sampleName) for function name input."}
    39413944        CheckBox UseSampleTransmFnct,variable= root:Packages:Convert2Dto1D:UseSampleTransmFnct
     3945
     3946        CheckBox UseTranspBeamstop,pos={75,380},size={50,14},title="Transp. Beamstop?",proc=NI1A_CheckProc
     3947        CheckBox UseTranspBeamstop,help={"Check if want to use calculation when using tsemi trasparent beamstop."}
     3948        CheckBox UseTranspBeamstop,variable= root:Packages:Convert2Dto1D:UseTranspBeamstop
     3949
    39423950        SetVariable SampleTransmFnct,pos={93,380},size={300,16},title="Sa Transmis =", proc=NI1A_SetVarProcMainPanel
    39433951        SetVariable SampleTransmFnct,help={"Input function name which returns transmission (0 - 1)."}
     
    47754783        NVAR UseSampleThicknFnct= root:Packages:Convert2Dto1D:UseSampleThicknFnct
    47764784        NVAR UseSampleTransmFnct= root:Packages:Convert2Dto1D:UseSampleTransmFnct
     4785        NVAR UseTranspBeamstop= root:Packages:Convert2Dto1D:UseTranspBeamstop
    47774786        NVAR UseSampleMonitorFnct= root:Packages:Convert2Dto1D:UseSampleMonitorFnct
    47784787        NVAR UseSampleMeasTimeFnct= root:Packages:Convert2Dto1D:UseSampleMeasTimeFnct
     
    48434852        SetVariable SampleThicknFnct,disable=(tabNum!=1 || !UseSampleThickness || !UseSampleThicknFnct||UseCalib2DData), win=NI1A_Convert2Dto1DPanel
    48444853
    4845         SetVariable SampleTransmission,disable=(tabNum!=1 || !UseSampleTransmission || UseSampleTransmFnct||UseCalib2DData), win=NI1A_Convert2Dto1DPanel
    4846         CheckBox UseSampleTransmFnct,disable=(tabNum!=1 || !UseSampleTransmission||UseCalib2DData), win=NI1A_Convert2Dto1DPanel
    4847         SetVariable SampleTransmFnct,disable=(tabNum!=1 || !UseSampleTransmission || !UseSampleTransmFnct||UseCalib2DData), win=NI1A_Convert2Dto1DPanel
     4854        SetVariable SampleTransmission,disable=(tabNum!=1 || !UseSampleTransmission || UseSampleTransmFnct||UseCalib2DData||UseTranspBeamstop), win=NI1A_Convert2Dto1DPanel
     4855        CheckBox UseSampleTransmFnct,disable=(tabNum!=1 || !UseSampleTransmission||UseCalib2DData||UseTranspBeamstop), win=NI1A_Convert2Dto1DPanel
     4856        CheckBox UseTranspBeamstop,disable=(tabNum!=1 || !UseSampleTransmission||UseCalib2DData), win=NI1A_Convert2Dto1DPanel
     4857        SetVariable SampleTransmFnct,disable=(tabNum!=1 || !UseSampleTransmission || !UseSampleTransmFnct||UseCalib2DData || UseTranspBeamstop), win=NI1A_Convert2Dto1DPanel
    48484858
    48494859        SetVariable SampleI0,disable=(tabNum!=1 || (!UseI0ToCalibrate && !UseMonitorForEF) || UseSampleMonitorFnct||UseCalib2DData), win=NI1A_Convert2Dto1DPanel
     
    57405750                SetVariable SampleTransmission,disable=(checked), win=NI1A_Convert2Dto1DPanel
    57415751                SetVariable SampleTransmFnct,disable=(!checked), win=NI1A_Convert2Dto1DPanel
     5752                CheckBox UseTranspBeamstop,disable=(checked), win=NI1A_Convert2Dto1DPanel
     5753        endif
     5754        if(cmpstr("UseTranspBeamstop",ctrlName)==0)
     5755                NVAR UseSampleTransmFnct = root:Packages:Convert2Dto1D:UseSampleTransmFnct
     5756                SetVariable SampleTransmission,disable=(checked), win=NI1A_Convert2Dto1DPanel
     5757                SetVariable SampleTransmFnct,disable=(checked || !UseSampleTransmFnct), win=NI1A_Convert2Dto1DPanel
     5758                CheckBox UseSampleTransmFnct,disable=(checked), win=NI1A_Convert2Dto1DPanel
     5759                if(checked)
     5760                        NI1A_SetupTransparentBeamstop()
     5761                endif
    57425762        endif
    57435763       
     
    59485968        setDataFolder OldDf
    59495969End
     5970//*******************************************************************************************************************************************
     5971//*******************************************************************************************************************************************
     5972
     5973Function NI1A_SetupTransparentBeamstop()
     5974        //sets up calculation for transparent beamstop use
     5975        //setup use of Function...
     5976        SVAR SampleTransmFnct = root:Packages:Convert2Dto1D:SampleTransmFnct
     5977        SampleTransmFnct = "NI1A_CalcTransUsingTranspBS"
     5978        NVAR UseTranspBeamstop = root:Packages:Convert2Dto1D:UseTranspBeamstop
     5979        NVAR TranspBSRadius = root:Packages:Convert2Dto1D:TranspBSRadius
     5980        NVAR BCY = root:Packages:Convert2Dto1D:BeamCenterY
     5981        NVAR BCX = root:Packages:Convert2Dto1D:BeamCenterX
     5982        Wave/Z Sample = root:Packages:Convert2Dto1D:CCDImageToConvert
     5983        if(!WaveExists(Sample))
     5984                abort "Samples 2D image does not exist, load image in first and then setup this."
     5985        endif
     5986        //get redius in pixels from user through missing parameter dialog
     5987        variable BeamstopRadius = TranspBSRadius
     5988        Prompt BeamstopRadius, "Beamstop Radius [pixels] ?"
     5989        DoPrompt /HELP="Input semi transparent beamstop radius" "Semi transparent beamstop radius input dialog", BeamstopRadius
     5990        if(V_Flag)
     5991                abort
     5992        endif
     5993        TranspBSRadius = BeamstopRadius
     5994        //now need to generate ROI for the image...
     5995        ///MatrixOP/O TranspBeamstopROI = Sample
     5996        Make /O/B/U/N=(DimSize(Sample,0),DimSize(Sample,1)) TranspBeamstopROI
     5997        TranspBeamstopROI = sqrt((p-BCX)^2+(q-BCY)^2)<TranspBSRadius ? 0 : 1
     5998        //done, this now has 0 in raneg of +/- BeamstopRadius from center.
     5999       
     6000end
     6001
     6002
     6003//*******************************************************************************************************************************************
     6004//*******************************************************************************************************************************************
     6005        //this function calculates the transmission for measurements with semi transparentl beamstop.
     6006        //this is using Function name
     6007Function NI1A_CalcTransUsingTranspBS(FileNameToLoad)
     6008        string FileNameToLoad
     6009        variable Transmission
     6010        Wave/Z Empty = root:Packages:Convert2Dto1D:EmptyData
     6011        Wave/Z Sample = root:Packages:Convert2Dto1D:CCDImageToConvert
     6012        Wave/Z TranspBeamstopROI = root:Packages:Convert2Dto1D:TranspBeamstopROI
     6013        if(!WaveExists(Empty)||!WaveExists(Sample))
     6014                abort "Sample or Empty image does not exist, load images first"
     6015        endif
     6016        if(!WaveExists(TranspBeamstopROI))
     6017                //needed ROI wave does not exist, create it
     6018                NI1A_SetupTransparentBeamstop()
     6019        endif
     6020        //ImageStats gives you average pixel value - V_avg - over ROI (region of interest)
     6021        //sample
     6022        ImageStats /R=TranspBeamstopROI Sample
     6023        variable SampleI0avg = V_avg
     6024        ImageStats /R=TranspBeamstopROI Empty
     6025        variable EmptyI0avg = V_avg
     6026        Transmission = SampleI0avg /EmptyI0avg 
     6027        return Transmission
     6028end
     6029
    59506030//*******************************************************************************************************************************************
    59516031//*******************************************************************************************************************************************
  • trunk/User Procedures/Nika/NI1_MainPanel.ipf

    r1180 r1186  
    22#pragma rtGlobals=3             // Use modern global access method.
    33#pragma version=2.71
    4 Constant NI1AversionNumber = 2.71
     4Constant NI1AversionNumber = 2.72
    55
    66//*************************************************************************\
     
    1010//*************************************************************************/
    1111
     12//2.72 add Use Transparent Beamstop transmission calculation
    1213//2.71 add Eiger types
    1314//2.70 fixed Max number of points selection which did not account for Qmin and Qmax and was therefore producing too many points
     
    313314        ListOfVariables+="Process_DisplayAve;Process_Individually;Process_Average;Process_AveNFiles;Process_ReprocessExisting;"
    314315        //and now the function calls variables
    315         ListOfVariables+="UseSampleThicknFnct;UseSampleTransmFnct;UseSampleMonitorFnct;UseSampleCorrectFnct;UseSampleMeasTimeFnct;UseSampleNameFnct;"
     316        ListOfVariables+="UseSampleThicknFnct;UseSampleTransmFnct;UseTranspBeamstop;UseSampleMonitorFnct;UseSampleCorrectFnct;UseSampleMeasTimeFnct;UseSampleNameFnct;"
    316317        ListOfVariables+="UseEmptyTimeFnct;UseBackgTimeFnct;UseEmptyMonitorFnct;"
    317         ListOfVariables+="ProcessNImagesAtTime;SaveGSASdata;FIlesSortOrder;"
     318        ListOfVariables+="ProcessNImagesAtTime;SaveGSASdata;FIlesSortOrder;TranspBSRadius;"
    318319        //errors control
    319320        ListOfVariables+="ErrorCalculationsUseOld;ErrorCalculationsUseStdDev;ErrorCalculationsUseSEM;"
     
    660661        RemoveLastNRows=0
    661662       
     663        NVAR UseSampleTransmFnct
     664        NVAR UseTranspBeamstop
     665        if(UseSampleTransmFnct+UseTranspBeamstop>1)
     666                UseSampleTransmFnct=0
     667                UseTranspBeamstop=0
     668        endif
    662669       
    663670        NVAR  DisplayRaw2DData
Note: See TracChangeset for help on using the changeset viewer.