Changeset 935


Ignore:
Timestamp:
May 8, 2020 9:33:18 AM (2 years ago)
Author:
ilavsky
Message:

Bug fixes as code is being used. Some small improvements to WAXS - JCPDS cards reading now uses name for the card and added "Distacen correction" for sticks in WAXS display

Location:
trunk/User Procedures/Irena
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/User Procedures/Irena/IR1_Main.ipf

    r934 r935  
    203203        SubMenu "3D Models"
    204204                "Mass Fractal Aggregate", IR3A_MassFractalAggregate()
    205                 "Two Phase Solids", IR3T_TwoPhaseSystem()
     205                //"Two Phase Solids", IR3T_TwoPhaseSystem()
    206206                "Display 3D data", IR3A_Display3DData()
    207207                "Import POV or PDB", IR3P_ImportPOVPDB()
     
    32413241        ListOfWindows += "IR3D_DataMergePanel;IRB1_PDDFInterfacePanel;IR3J_SimpleFitsPanel;IRB1_DataManipulationPanel;IR3J_LinDataDisplay;"
    32423242        ListOfWindows += "IR3L_MultiSamplePlotPanel;IR3J_LogLogDataDisplay;IR3L_MultiSamplePlotPanel;IRB1_ImportBioSAXSASCIIData;"
     3243        ListOfWindows += "IR2E_MultipleDataSelectionPnl;IR3W_WAXSPanel;"
    32433244       
    32443245       
  • trunk/User Procedures/Irena/IR2_DataMiner.ipf

    r932 r935  
    354354                        break
    355355        endswitch
    356         DoWIndow/F IR3L_MultiSamplePlotPanel
     356        DoWIndow/F IR3B_MetadataBrowserPanel
    357357        return 0
    358358End
  • trunk/User Procedures/Irena/IR3_3DModels.ipf

    r934 r935  
    764764        //pick the parameters...
    765765        variable voxelSize = PrimarySize/10
    766         variable IsoValue = 0.5
     766        variable IsoValue = 0.1
    767767        variable Qmin = 0.5 * pi/AggSize
    768768        variable Qmax = 6 * pi/PrimarySize
     
    770770        variable PrimarySphereRadius = 6                //this is RADIUS of sphere in voxels, not in angstroms.
    771771        //Internally, each particle volume is made 10xx10x10, 8 seems to be value when the spheres are exactly touching in xy direction, 9 when in xyz direction.
    772         Wave/Z ThreeDVoxelGram = Wave3DwithPrimary              //this is voxelgram     
     772        Wave/Z ThreeDVoxelGram = Wave3DwithPrimaryShrunk                //this is voxelgram shrunk to min size 
    773773        if(!WaveExists(ThreeDVoxelGram) || isInWorkFolder || recalculate3D)
    774774                //convert to voxelgram
    775775                IR3T_ConvertToVoxelGram(MassFractalAggregate, PrimarySphereRadius)
    776                 Wave ThreeDVoxelGram = Wave3DwithPrimary                //thsi is voxelgram
     776                Wave ThreeDVoxelGram = Wave3DwithPrimaryShrunk                  //this is voxelgram shrunk to min size...
    777777        endif
    778778
     
    787787        Wave PDFIntensityWv
    788788        IR3A_Append1DInMassFracAgg(PDFIntensityWv,PDFQWv)
     789
     790        Wave/Z ThreeDVoxelGram = Wave3DwithPrimary              //this is voxelgram with even number of rows/columns/layers.   
     791        SetScale /P x, 0, VoxelSize, "A" ,ThreeDVoxelGram
     792        SetScale /P y, 0, VoxelSize, "A" ,ThreeDVoxelGram
     793        SetScale /P z, 0, VoxelSize, "A" ,ThreeDVoxelGram
     794        IR3T_CalcAutoCorelIntensity(ThreeDVoxelGram, IsoValue,  Qmin, Qmax, NumQSteps)
     795        //these are autocorrelation calculated intensities...
     796        Wave AutoCorIntensityWv
     797        Wave AutoCorQWv
     798        IR3A_Append1DInMassFracAgg(AutoCorIntensityWv,AutoCorQWv)
     799
    789800        //display the intensity.
    790801//      DoWIndow IR1_LogLogPlotU
  • trunk/User Procedures/Irena/IR3_3DSupportFunctions.ipf

    r934 r935  
    284284        KillWaves/Z RadialWaveProfile
    285285        //RadialWaveProfile[0] = 1 and at infinity is = VolumeFraction.
     286       
    286287        //scaling to match volume fraction needed,
    287         TwoPntCorrelationsWv = VOlumeFraction * TwoPntCorrelationsWv - VOlumeFraction^2
     288        TwoPntCorrelationsWv = VOlumeFraction * (TwoPntCorrelationsWv - VOlumeFraction^2)
     289
     290        Duplicate/O TwoPntDebyePhCorrFnct, ModelFFTAutoCorelGr
     291       
    288292
    289293        FindLevel/EDGE=2/Q/P TwoPntCorrelationsWv, 0
     
    377381                //MatrixOp/Free/NTHR=0 My1DDistanceWv = My3DDistacneWv                  //this convert 3D wave in 1D wave.
    378382                //Sort My1DDistanceWv, My1DDistanceWv, My1DValuesWave
    379                 make/Free/N=(maxDist) HistogramWvIndx, HistogramWv
     383                make/Free/N=(10*maxDist) HistogramWvIndx, HistogramWv
    380384                Histogram /B={0,1,maxDist}/W=My3DWaveIn/Dest=HistogramWv  My3DDistacneWv
    381385                //Wave W_SqrtN          //this does not work with /W flag 
     
    565569        IN2G_ConvertTologspacing(PDFQWv,0)                                                                      //creates log-q spacing in the PDFQWv
    566570        multithread PDFIntensityWv =  IR3T_CalcIntensityPDF(PDFQWv[p],PDFWave,RadiiWave)       
    567         KillWaves/Z PDFWave,RadiiWave
     571        //KillWaves/Z PDFWave,RadiiWave
     572        Duplicate/O PDFWave, PDFGrCalculatedWave
     573        PDFGrCalculatedWave = PDFWave / RadiiWave^2
    568574end
    569575//******************************************************************************************************************************************************
     
    715721                ImageTransform/F=0 shrinkBox Wave3DwithPrimary
    716722                Wave M_shrunkCube
    717                 Duplicate/O M_shrunkCube, Wave3DwithPrimary
     723                Duplicate/O M_shrunkCube, Wave3DwithPrimaryShrunk
    718724        endif
    719725        print "Done with creating Voxelgram spherical structure in :"+num2str((ticks-startTicks)/60)
  • trunk/User Procedures/Irena/IR3_3DTwoPhaseSolid.ipf

    r934 r935  
    9595
    9696        SetVariable BoxSideSize,limits={100,100000,50},value= root:Packages:TwoPhaseSolidModel:BoxSideSize, proc=IR3T_SetVarProc
    97         SetVariable BoxSideSize,pos={10,265},size={200,16},title="Box size [A]           ", help={"Physical size of the box for modeling in Angstroms"}
    98 
    99         SetVariable BoxResolution,limits={10,500,50},proc=IR3T_SetVarProc, value= root:Packages:TwoPhaseSolidModel:BoxResolution
    100         SetVariable BoxResolution,pos={10,290},size={200,16},title="Box divisions           ", help={"How many steps per side to take"}
     97        SetVariable BoxSideSize,pos={10,265},size={200,16},title="Box Physical size [A] ", help={"Physical size of the box for modeling in Angstroms"}
     98
     99//      SetVariable BoxResolution,limits={10,500,50},proc=IR3T_SetVarProc, value= root:Packages:TwoPhaseSolidModel:BoxResolution
     100//      SetVariable BoxResolution,pos={10,290},size={200,16},title="Box divisions           ", help={"How many steps per side to take"}
     101        NVAR BoxResolution=root:Packages:TwoPhaseSolidModel:BoxResolution
     102        PopupMenu BoxResolution,pos={20,290},size={180,21},proc=IR3T_PopupControl,title="Box divisions : ", help={"Select how many divisions per side"}
     103        PopupMenu BoxResolution,mode=1,value= "64x64x64;128x128x128;256x256x256;512x512x512;"
     104        BoxResolution = 64
    101105
    102106        SetVariable VoxelResolution,limits={0,inf,0},value= root:Packages:TwoPhaseSolidModel:VoxelResolution, noedit=1, frame=0 //proc=IR1A_PanelSetVarProc
     
    106110        SetVariable TotalNumberOfVoxels,pos={230,290},size={200,16},title="No of Voxels ",noproc, help={"How many voxels is in box, impacts speed!"}
    107111
    108         CheckBox useSAXSMorphCode,pos={100,310},size={250,14},proc=IR3T_InputPanelCheckboxProc,title="USAXS SAXSMorph code (slower)"
     112        CheckBox useSAXSMorphCode,pos={100,310},size={250,14},proc=IR3T_InputPanelCheckboxProc,title="use SAXSMorph code (slower)"
    109113        CheckBox useSAXSMorphCode,variable=root:Packages:TwoPhaseSolidModel:useSAXSMorphCode, help={"To use GRF generation using SAXSMorph method"}
    110114
     
    137141
    138142        //these are advanced parameters. Need to move to Tab 2...
    139         CheckBox RKParametersManual,pos={100,345},size={200,14},proc=IR3T_InputPanelCheckboxProc,title="Manual R/K parameters?"
     143        CheckBox RKParametersManual,pos={100,355},size={200,14},proc=IR3T_InputPanelCheckboxProc,title="Manual R/K parameters?"
    140144        CheckBox RKParametersManual,variable= root:packages:TwoPhaseSolidModel:RKParametersManual, help={"Check to select manually R/K parameetrs below. "}
    141145        SetVariable NumberofRPoints,limits={100,10000,50},value= root:Packages:TwoPhaseSolidModel:NumberofRPoints
     
    199203
    200204//******************************************************************************************************************************************************
     205 
     206Function IR3T_PopupControl(PU_Struct): PopupMenuControl
     207        STRUCT WMPopupAction &PU_Struct
     208
     209        if(PU_Struct.eventCode==2)
     210                NVAR BoxResolution = root:Packages:TwoPhaseSolidModel:BoxResolution
     211                NVAR VoxelResolution = root:Packages:TwoPhaseSolidModel:VoxelResolution
     212                NVAR BoxSideSize = root:Packages:TwoPhaseSolidModel:BoxSideSize
     213                NVAR Voxels=root:Packages:TwoPhaseSolidModel:TotalNumberOfVoxels
     214                //"64x64x64;128x128x128;256x256x256;512x512x512;"
     215                BoxResolution=str2num(PU_Struct.popStr)
     216                Voxels = BoxResolution^3
     217                VoxelResolution = BoxSideSize / BoxResolution
     218        endif
     219
     220end
     221
    201222//******************************************************************************************************************************************************
    202223///******************************************************************************************
     
    378399                                        //This thing does not work - we always get scattering from the box size, not from internal strucutre. So this is probably not realistic to do... 
    379400                                        //IR3T_CreatePDF(TwoPhaseSolidMatrix,VoxelSize, NumStepsToUse, 0.5, oversample, 0.001, 0.5, 200)
    380                                         IR3T_AppendModelIntToGraph()
     401                                        //IR3T_AppendModelIntToGraph()
    381402                                        IR3T_CalculateAchievedValues()
    382403                        endif
     
    438459                        CheckDisplayed /W=TwoPhaseSystemData AutoCorIntensityWv
    439460                        if(V_flag==0)
    440                                 AppendToGraph/W=TwoPhaseSystemData/R  AutoCorIntensityWv vs AutoCorQWv
     461                                AppendToGraph/W=TwoPhaseSystemData  AutoCorIntensityWv vs AutoCorQWv
    441462                        endif
    442463                        //ModifyGraph lstyle(PDFIntensityWv)=9,lsize(PDFIntensityWv)=3,rgb(PDFIntensityWv)=(1,16019,65535)
     
    873894                                Rmin = 0.1
    874895                                //Rmax = IN2G_roundSignificant(35/lowQExtrapolationStart,2)
    875                                 Rmax = IN2G_roundSignificant(10*RgValue,2)                     
     896                                variable Rmax1 = IN2G_roundSignificant(10*RgValue,2)   
     897                                variable RadMax2 = ceil(1.1*sqrt(BoxSideSize^2+BoxSideSize^2+BoxSideSize^2))
     898                                Rmax = max(RadMax2,Rmax1)
    876899                                Kmin =IN2G_roundSignificant(lowQExtrapolationStart/10,1)
    877900                                Kmax = IN2G_roundSignificant(highQExtrapolationStart*10, 1)     
    878901                                Kmax =  Kmax>6.28 ? Kmax : 2*pi         
     902                        else
     903                                //Rmax = ceil(1.3*sqrt(BoxSideSize^2+BoxSideSize^2+BoxSideSize^2))     
    879904                        endif
    880905                        DoWIndow TwoPhaseSystems
     
    11281153        NVAR RadMin = root:Packages:TwoPhaseSolidModel:RMin
    11291154        NVAR RadMax = root:Packages:TwoPhaseSolidModel:RMax
     1155        RadMax = ceil(1.1*sqrt(BoxSideSize^2+BoxSideSize^2+BoxSideSize^2))
    11301156
    11311157        make/O/N=(NumberOfKPoints)/D Kvalues
     
    12391265        multithread SpectralFk = IR3T_Formula4_SpectralFnct(Kvalues[p],AutoCorfnctGr,PhaseAutocorFnctRadii)
    12401266        // spectral function is ridiculously noisy, lets smooth it.
    1241 
    12421267        //display/K=1 SpectralFk vs Kvalues as "SpectralFk"
    1243 
    12441268        print "Spectral function calculation time was "+num2str((ticks-startTicks)/60) +" sec"
    12451269                                //********************************************
     
    12481272                                //Step 5. Compute a nonnegative approximation of SpectralFk by solving the following convex quadratic programming problem:
    12491273        Duplicate/O SpectralFk, PositiveSpectralFk
    1250 
    12511274        //note: this makes HUGE difference and results look lot closer to SAXSMorph and expectations...
    12521275        variable SMoothBy = ceil(numpnts(PositiveSpectralFk)/60)
    12531276        Smooth/EVEN/B SMoothBy, PositiveSpectralFk
    12541277        //this gets some differeces between SAXSMorph and Igor code, but it may be just different rounding and methods. Not sure which one is actually right here anyway.
    1255 
    1256         //display/K=1 PositiveSpectralFk vs Kvalues as "PositiveSpectralFk"
    1257                                
     1278        //display/K=1 PositiveSpectralFk vs Kvalues as "PositiveSpectralFk"             
    12581279        ///display/K=1 PositiveAutoCorfnctGr vs Radii as "PositiveAutoCorfnctGr"
    12591280        startTicks=ticks
     
    12651286                startTicks=ticks
    12661287                print "Calculating Matrix"             
    1267                 //this is SAXSMoprh way
     1288                //this is SAXSMorph way
    12681289                IR3T_GenerateMatrix(Kvalues, SpectralFk, BoxSideSize, BoxResolution, alfaValue)
    12691290        else
     
    12791300                print "Using FFT to generate 2 phase solid, this is not optimized yet"
    12801301                //here we can take over by use of FFT...
    1281                 IR3T_UseFFTtoGenerateMatrix(PositiveAutoCorfnctGr,Radii, alfaValue, BoxResolution, BoxSideSize)
     1302                Duplicate AutoCorfnctGr, PositiveAutoCorfnctGr
     1303                PositiveAutoCorfnctGr = PositiveAutoCorfnctGr[p]>0 ? PositiveAutoCorfnctGr : 0
     1304                IR3T_UseFFTtoGenerateMatrix(AutoCorfnctGr,PositiveAutoCorfnctGr, alfaValue, BoxResolution, BoxSideSize)
     1305
     1306//              IR3T_UseFFTtoGenerateMatrix(PositiveAutoCorfnctGr,Radii, alfaValue, BoxResolution, BoxSideSize)
    12821307        endif
    12831308        print "GenerateMatrix time is "+num2str((ticks-startTicks)/60) +" sec"
     
    13281353
    13291354Function IR3T_UseFFTtoGenerateMatrix(Gr,Radii, alfaValue, BoxDivisions, BoxSide )
    1330         wave Gr, radii                                  //this is covariance function (1D)
    1331         variable alfaValue                                      //this is cut off value
     1355        wave Gr, radii                                                  //this is covariance function (1D)
     1356        variable alfaValue                                              //this is cut off value
    13321357        variable BoxDivisions, BoxSide          //Divisions is number of pixels per side, Side is length in A
    13331358       
     
    13651390               
    13661391        Make/N=(BoxDivisions,BoxDivisions,BoxDivisions)/O RandomField, CovarFunction3D
     1392        multithread RandomField = gnoise(1)
    13671393        variable HalfBox = BoxSide/2
    1368         SetScale x 0,BoxSide,"A", RandomField
    1369         SetScale y 0,BoxSide,"A", RandomField
    1370         SetScale z 0,BoxSide,"A", RandomField
    1371         multithread RandomField = gnoise(1)
    1372         SetScale y -1*BoxSide,BoxSide,"A", CovarFunction3D
    1373         SetScale x -1*BoxSide,BoxSide,"A", CovarFunction3D
    1374         SetScale z -1*BoxSide,BoxSide,"A", CovarFunction3D
    1375         //thsi does not fix anything... This is generating too small particles, something is off here.
    1376         //Need to increase size of the particles twice, but cannot find way to scaqle them up.
    1377         //      SetScale y -1*HalfBox,HalfBox,"A", CovarFunction3D
    1378         //      SetScale x -1*HalfBox,HalfBox,"A", CovarFunction3D
    1379         //      SetScale z -1*HalfBox,HalfBox,"A", CovarFunction3D
    1380         //      SetScale x -1*HalfBox,HalfBox,"A", RandomField
    1381         //      SetScale y -1*HalfBox,HalfBox,"A", RandomField
    1382         //      SetScale z -1*HalfBox,HalfBox,"A", RandomField
    1383 
    1384         multithread CovarFunction3D = CovarFunction1D(sqrt(x^2+y^2+z^2))                //this causes error at this time.
     1394//      SetScale x 0,BoxSide,"A", RandomField
     1395//      SetScale y 0,BoxSide,"A", RandomField
     1396//      SetScale z 0,BoxSide,"A", RandomField
     1397//      SetScale y 0,BoxSide,"A", CovarFunction3D
     1398//      SetScale x 0,BoxSide,"A", CovarFunction3D
     1399//      SetScale z 0,BoxSide,"A", CovarFunction3D
     1400        SetScale x -HalfBox, HalfBox,"A", RandomField, CovarFunction3D
     1401        SetScale y -HalfBox, HalfBox,"A", RandomField, CovarFunction3D
     1402        SetScale z -HalfBox, HalfBox,"A", RandomField, CovarFunction3D
     1403        //this is generating too small particles, something is off here.
     1404//      variable BoxCenterX, BoxCenterY, BoxCenterZ
     1405//      BoxCenterX = BoxSide/2
     1406//      BoxCenterY = BoxSide/2
     1407//      BoxCenterZ = BoxSide/2
     1408        multithread CovarFunction3D = CovarFunction1D(sqrt((x)^2+(y)^2+(z)^2))         
    13851409
    13861410        //Now FFT the two components:
    1387         FFT/OUT=1/Free/DEST=RandomField_FFT  RandomField                                        // this is random field after FFT, it should be more or less another random Gauss field.
    1388         FFT/OUT=1/Free/DEST=CovarFunction3D_FFT  CovarFunction3D                // this is FFT of covariance function
    1389 
    1390         //cannot make this below work somehow....
    1391         matrixOp/NTHR=0/O CovarFunction3D_FFTpwr = powC(CovarFunction3D_FFT, 1/2)       //      << even for 3D this needs to be sqrt, so why is it for 1D not sqrt???
     1411        FFT/OUT=1/DEST=RandomField_FFT  RandomField                                     // this is random field after FFT, it should be more or less another random Gauss field.
     1412        FFT/OUT=1/DEST=CovarFunction3D_FFT  CovarFunction3D             // this is FFT of covariance function
     1413
     1414        //cannot make this below work somehow.... this is what causes my GRF to be wrong and narrow...
     1415        //matrixOp does not preserve wave scaling, we need to copy scales after MatrixOps here!
     1416        //still, this is incorrect. I am unable to get proper GRF generation here.
     1417        matrixOp/NTHR=0/O CovarFunction3D_FFTpwr = powC(CovarFunction3D_FFT, 1/2)                                       //      << even for 3D this needs to be sqrt, so why is it for 1D not sqrt???
    13921418        matrixOp/NTHR=0/O RandomField_FFT_Covar = RandomField_FFT * CovarFunction3D_FFTpwr
     1419        //return the wave scaling here so IFFT can work...
     1420        CopyScales /P RandomField_FFT, RandomField_FFT_Covar
    13931421
    13941422        IFFT/DEST=RandomField_FFT_Covar_IFFT  RandomField_FFT_Covar
     
    13961424       
    13971425        MatrixOp/NTHR=0/O TwoPhaseSolidMatrix = greater(RandomField_FFT_Covar_IFFT,alfaValue)
     1426        CopyScales /P RandomField_FFT_Covar_IFFT, TwoPhaseSolidMatrix
    13981427
    13991428        KillWaves/Z CovarFunction3D_FFTpwr, RandomField_FFT_Covar, RandomField_FFT_Covar_IFFT
    1400 
    1401         SetScale x 0,BoxSide,"A", TwoPhaseSolidMatrix
    1402         SetScale y 0,BoxSide,"A", TwoPhaseSolidMatrix
    1403         SetScale z 0,BoxSide,"A", TwoPhaseSolidMatrix
     1429//
     1430//      SetScale/I x 0,BoxSide,"A", TwoPhaseSolidMatrix
     1431//      SetScale/I y 0,BoxSide,"A", TwoPhaseSolidMatrix
     1432//      SetScale/I z 0,BoxSide,"A", TwoPhaseSolidMatrix
    14041433
    14051434        print "Done"
     
    14231452end
    14241453///*************************************************************************************************************************************
    1425 Function IR3T_AppendModelIntToGraph()
    1426         DoWindow TwoPhaseSystemData
    1427         if(V_Flag)
    1428                 DoWIndow/F TwoPhaseSystemData
    1429                 Wave/Z PDFQWv = root:Packages:TwoPhaseSolidModel:PDFQWv
    1430                 Wave/Z PDFIntensityWv = root:Packages:TwoPhaseSolidModel:PDFIntensityWv
    1431                 Wave ExtrapolatedIntensity = root:Packages:TwoPhaseSolidModel:ExtrapolatedIntensity
    1432                 Wave ExtrapolatedQvector = root:Packages:TwoPhaseSolidModel:ExtrapolatedQvector
    1433                 Wave OriginalQvector = root:Packages:TwoPhaseSolidModel:OriginalQvector
    1434                 Wave OriginalIntensity = root:Packages:TwoPhaseSolidModel:OriginalIntensity
    1435                 Wave/Z TheoreticalIntensityDACF = root:Packages:TwoPhaseSolidModel:TheoreticalIntensityDACF
    1436                 Wave/Z QvecTheorIntensityDACF=root:Packages:TwoPhaseSolidModel:QvecTheorIntensityDACF
    1437                 NVAR Qmin = root:Packages:TwoPhaseSolidModel:LowQExtrapolationStart
    1438                 NVAR Qmax = root:Packages:TwoPhaseSolidModel:HighQExtrapolationEnd
    1439                 variable InvarModel
    1440                 variable InvarData
    1441 //              if(WaveExists(PDFQWv))
    1442 //                      //need to renormalzie this together...
    1443 //                      InvarModel=areaXY(PDFQWv, PDFIntensityWv )
    1444 //                      InvarData=areaXY(ExtrapolatedQvector, ExtrapolatedIntensity )
    1445 //                      PDFIntensityWv*=InvarData/InvarModel
    1446 //                      CheckDisplayed /W=TwoPhaseSystemData PDFIntensityWv
    1447 //                      if(V_flag==0)
    1448 //                              AppendToGraph/W=TwoPhaseSystemData  PDFIntensityWv vs PDFQWv
    1449 //                      endif
    1450 //                      ModifyGraph lstyle(PDFIntensityWv)=9,lsize(PDFIntensityWv)=3,rgb(PDFIntensityWv)=(1,16019,65535)
    1451 //                      ModifyGraph mode(PDFIntensityWv)=4,marker(PDFIntensityWv)=19
    1452 //                      ModifyGraph msize(PDFIntensityWv)=3
    1453 //              endif
    1454 //              if(WaveExists(TheoreticalIntensityDACF))
    1455 //                      //need to renormalzie this together...
    1456 //                      InvarModel=areaXY(QvecTheorIntensityDACF, TheoreticalIntensityDACF, Qmin, QvecTheorIntensityDACF[numpnts(QvecTheorIntensityDACF)-2] )
    1457 //                      InvarData=areaXY(OriginalQvector, OriginalIntensity, Qmin, QvecTheorIntensityDACF[numpnts(QvecTheorIntensityDACF)-2]  )
    1458 //                      TheoreticalIntensityDACF*=InvarData/InvarModel
    1459 //                      CheckDisplayed /W=TwoPhaseSystemData TheoreticalIntensityDACF
    1460 //                      if(V_flag==0)
    1461 //                              AppendToGraph/W=TwoPhaseSystemData  TheoreticalIntensityDACF vs QvecTheorIntensityDACF
    1462 //                      endif
    1463 //                      ModifyGraph lstyle(TheoreticalIntensityDACF)=9,lsize(TheoreticalIntensityDACF)=3,rgb(TheoreticalIntensityDACF)=(1,16019,65535)
    1464 //                      ModifyGraph mode(TheoreticalIntensityDACF)=4,marker(TheoreticalIntensityDACF)=19
    1465 //                      ModifyGraph msize(TheoreticalIntensityDACF)=3
    1466 //              endif
    1467         endif
    1468 
    1469 end
     1454//Function IR3T_AppendModelIntToGraph()
     1455//      DoWindow TwoPhaseSystemData
     1456//      if(V_Flag)
     1457//              DoWIndow/F TwoPhaseSystemData
     1458//              Wave/Z PDFQWv = root:Packages:TwoPhaseSolidModel:PDFQWv
     1459//              Wave/Z PDFIntensityWv = root:Packages:TwoPhaseSolidModel:PDFIntensityWv
     1460//              Wave ExtrapolatedIntensity = root:Packages:TwoPhaseSolidModel:ExtrapolatedIntensity
     1461//              Wave ExtrapolatedQvector = root:Packages:TwoPhaseSolidModel:ExtrapolatedQvector
     1462//              Wave OriginalQvector = root:Packages:TwoPhaseSolidModel:OriginalQvector
     1463//              Wave OriginalIntensity = root:Packages:TwoPhaseSolidModel:OriginalIntensity
     1464//              Wave/Z TheoreticalIntensityDACF = root:Packages:TwoPhaseSolidModel:TheoreticalIntensityDACF
     1465//              Wave/Z QvecTheorIntensityDACF=root:Packages:TwoPhaseSolidModel:QvecTheorIntensityDACF
     1466//              NVAR Qmin = root:Packages:TwoPhaseSolidModel:LowQExtrapolationStart
     1467//              NVAR Qmax = root:Packages:TwoPhaseSolidModel:HighQExtrapolationEnd
     1468//              variable InvarModel
     1469//              variable InvarData
     1470////            if(WaveExists(PDFQWv))
     1471////                    //need to renormalzie this together...
     1472////                    InvarModel=areaXY(PDFQWv, PDFIntensityWv )
     1473////                    InvarData=areaXY(ExtrapolatedQvector, ExtrapolatedIntensity )
     1474////                    PDFIntensityWv*=InvarData/InvarModel
     1475////                    CheckDisplayed /W=TwoPhaseSystemData PDFIntensityWv
     1476////                    if(V_flag==0)
     1477////                            AppendToGraph/W=TwoPhaseSystemData  PDFIntensityWv vs PDFQWv
     1478////                    endif
     1479////                    ModifyGraph lstyle(PDFIntensityWv)=9,lsize(PDFIntensityWv)=3,rgb(PDFIntensityWv)=(1,16019,65535)
     1480////                    ModifyGraph mode(PDFIntensityWv)=4,marker(PDFIntensityWv)=19
     1481////                    ModifyGraph msize(PDFIntensityWv)=3
     1482////            endif
     1483////            if(WaveExists(TheoreticalIntensityDACF))
     1484////                    //need to renormalzie this together...
     1485////                    InvarModel=areaXY(QvecTheorIntensityDACF, TheoreticalIntensityDACF, Qmin, QvecTheorIntensityDACF[numpnts(QvecTheorIntensityDACF)-2] )
     1486////                    InvarData=areaXY(OriginalQvector, OriginalIntensity, Qmin, QvecTheorIntensityDACF[numpnts(QvecTheorIntensityDACF)-2]  )
     1487////                    TheoreticalIntensityDACF*=InvarData/InvarModel
     1488////                    CheckDisplayed /W=TwoPhaseSystemData TheoreticalIntensityDACF
     1489////                    if(V_flag==0)
     1490////                            AppendToGraph/W=TwoPhaseSystemData  TheoreticalIntensityDACF vs QvecTheorIntensityDACF
     1491////                    endif
     1492////                    ModifyGraph lstyle(TheoreticalIntensityDACF)=9,lsize(TheoreticalIntensityDACF)=3,rgb(TheoreticalIntensityDACF)=(1,16019,65535)
     1493////                    ModifyGraph mode(TheoreticalIntensityDACF)=4,marker(TheoreticalIntensityDACF)=19
     1494////                    ModifyGraph msize(TheoreticalIntensityDACF)=3
     1495////            endif
     1496//      endif
     1497//
     1498//end
    14701499
    14711500///*************************************************************************************************************************************
     
    20522081       
    20532082
    2054         NewGizmo/K=1/T="TwoPhaseSolid3D"/W=(627,70,1142,530)
     2083        NewGizmo/K=1/N=TwoPhaseSolid3D/T="TwoPhaseSolid3D"/W=(627,70,1142,530)
    20552084        ModifyGizmo startRecMacro=700
    20562085        ModifyGizmo scalingOption=63
  • trunk/User Procedures/Irena/IR3_MultiDataPlot.ipf

    r934 r935  
    188188
    189189        SVAR SelectedStyle = root:Packages:Irena:MultiSamplePlot:SelectedStyle
    190         PopupMenu ApplyStyle,pos={280,680},size={400,20},proc=IR3L_PopMenuProc, title="Apply style:",help={"Set tool setting to defined conditions and apply to graph"}
     190        PopupMenu ApplyStyle,pos={280,660},size={400,20},proc=IR3L_PopMenuProc, title="Apply style:",help={"Set tool setting to defined conditions and apply to graph"}
    191191        PopupMenu ApplyStyle,value=#"root:Packages:Irena:MultiSamplePlot:ListOfDefinedStyles",popvalue=SelectedStyle
    192192        Button ApplyPresetFormating,pos={260,710},size={160,20}, proc=IR3L_ButtonProc,title="Apply All Formating", help={"Apply Preset Formating to update graph based on these choices"}
  • trunk/User Procedures/Irena/IR3_WAXSDiffraction.ipf

    r930 r935  
    126126        DrawText 10,20,"Background if needed for fitting"
    127127        //fix case when neither is selected and default to qrs
    128         root:Packages:Irena:WAXSBackground:DataFolderName=""
     128        root:Packages:Irena:WAXSBackground:DataFolderName =""
    129129        //note, this sets up the dependence for same type of data for background and fit data, seems logical.
    130130        root:Packages:Irena:WAXSBackground:UseIndra2Data := root:Packages:Irena:WAXS:UseIndra2Data
    131         root:Packages:Irena:WAXSBackground:UseQRSdata := root:Packages:Irena:WAXS:UseQRSdata
     131        root:Packages:Irena:WAXSBackground:UseQRSdata  := root:Packages:Irena:WAXS:UseQRSdata
    132132        // done...
    133133        Checkbox UseIndra2Data, pos={100,5}, disable=1
     
    144144        //TitleBox FakeLine1 title=" ",fixedSize=1,size={200,3},pos={290,130},frame=0,fColor=(0,0,52224), labelBack=(0,0,52224)
    145145        //Data Tabs definition
    146         TabControl AnalysisTabs,pos={265,135},size={280,400}
     146        TabControl AnalysisTabs,pos={265,135},size={280,420}
    147147        TabControl AnalysisTabs,tabLabel(0)="Peak Fit",tabLabel(1)="Diff. Lines"
    148148        TabControl AnalysisTabs proc=IR3W_PDF4TabProc
     
    192192        Button AMSImportAMStxt, pos={375,491}, size={160,20}, title="Import AMS txt card", proc=IR3W_WAXSButtonProc, help={"Add Diffraction lines from http://rruff.geo.arizona.edu/AMS/amcsd.php"}
    193193        Button PDF4AddManually, pos={300,513}, size={200,20}, title="Add manually or Edit PDF card", proc=IR3W_WAXSButtonProc, help={"Add/Edit manually card, e.g. type from JCPDS PDF2 or 4 cards"}
     194
     195        SetVariable DistanceCorrection,pos={280,535},size={200,15}, proc=IR3W_SetVarProc,title="Distance correction   ", help={"This corrects for distance calibration of instrument. Should be close to 1."}
     196        Setvariable DistanceCorrection, variable=root:Packages:Irena:WAXS:DistanceCorrection, limits={0.9,1.1,0.0005}
     197
    194198
    195199        TitleBox txt1 title="\Zr100Double click to add data to graph.",pos={4,665},frame=0,fstyle=3,size={300,24},fColor=(1,4,52428)
     
    251255                                Button PDF4ExportImport, win=IR3W_WAXSPanel, disable=(tab!=1)                   
    252256                                Checkbox PDF4_DisplayHKLTags, win=IR3W_WAXSPanel, disable=(tab!=1)
     257                                SetVariable DistanceCorrection, win=IR3W_WAXSPanel, disable=(tab!=1)
    253258                        break
    254259                case -1: // control being killed
     
    339344        ListOfVariables+="ProcessManually;ProcessSequentially;OverwriteExistingData;AutosaveAfterProcessing;"
    340345        ListOfVariables+="Energy;Wavelength;"
    341         ListOfVariables+="PDF4_DisplayHKLTags;"
     346        ListOfVariables+="PDF4_DisplayHKLTags;DistanceCorrection;"
    342347
    343348        //and here we create them
     
    403408        endif
    404409        Energy = 12.39842 / Wavelength
     410       
     411        NVAR DistanceCorrection
     412        DistanceCorrection = 1
    405413
    406414        Make/O/T/N=(0) ListOfAvailableData
     
    902910                                Energy = 12.39842 / wavelength
    903911                                IR3W_ConvertXdataToTTH(Data2ThetaWave,DataD2ThetaWave,XaxisType,wavelength)
     912                        endif
     913                        if(stringmatch(sva.ctrlName,"DistanceCorrection"))
     914                                IR3W_WAXSCorForDistance()
    904915                        endif
    905916                        if(stringmatch(sva.ctrlName,"Energy"))
     
    28182829        Open /R /Z refNum  as PathToFile
    28192830        if(V_Flag!=0) //no success
    2820                 abort "Could not load file correctly"
     2831                abort //"Could not load file correctly"
    28212832        endif
    28222833        FReadLine  refNum, MaterialName
     
    29472958        string pdfNumber
    29482959        pdfNumber = IR3W_ReadXMLJCPDSCard(PathToFile)
     2960        SVAR chemical_formula = root:Packages:Irena_JCPDSImport:chemical_formula
     2961        SVAR empirical_formula = root:Packages:Irena_JCPDSImport:empirical_formula
     2962        SVAR chemical_name = root:Packages:Irena_JCPDSImport:chemical_name
     2963
    29492964        string OldCardName, NewCardNumber, NewCardName, NewCardNote, DeleteCardName
    29502965        DeleteCardName="---"
    29512966        OldCardName = "---"
    29522967        NewCardNumber = pdfNumber
    2953         NewCardName=StringFromList(0,StringFromList(ItemsInList(PathToFile,":")-1, PathToFile, ":"),".")+" "+pdfNumber
    2954         NewCardNote =""
     2968        if(strlen(chemical_name)>1)
     2969                NewCardName=chemical_name+" "+pdfNumber
     2970        elseif(strlen(chemical_formula)>1)
     2971                NewCardName=chemical_formula+" "+pdfNumber
     2972        elseif(strlen(empirical_formula)>1)
     2973                NewCardName=empirical_formula+" "+pdfNumber
     2974        else
     2975                NewCardName=StringFromList(0,StringFromList(ItemsInList(PathToFile,":")-1, PathToFile, ":"),".")+" "+pdfNumber
     2976        endif
     2977        NewCardName = IN2G_CreateUserName(NewCardName,23, 0, 0)
     2978        NewCardNote ="JPCDSnumber:"+pdfNumber+";chemical_name:"+chemical_name+";chemical_formula:"+chemical_formula+";empirical_formula:"+empirical_formula+";"
    29552979        Prompt OldCardName, "Select existing card to overwrite", popup "---;"+IR3W_PDF4CreateListOfCards()
    29562980        Prompt NewCardName, "Enter new card name, e.g. Corundum"
     
    29632987        endif
    29642988        if(stringmatch(OldCardName,"---"))
    2965                 NewCardFullName=((NewCardName)[0,23])
     2989                NewCardFullName=NewCardName
    29662990                if(CheckName(NewCardFullName,1)!=0)
    29672991                        KillWIndow/Z JCPDS_Input
     
    29943018                Print "Could not figure out what to do..."
    29953019        endif
     3020        Note /NOCR NewCard, NewCardNote
     3021        Note /NOCR NewCard_hkl, NewCardNote
    29963022        KillDataFOlder/Z root:Packages:Irena_JCPDSImport
    29973023        Edit/K=1/W=(351,213,873,819) NewCard
     
    30673093        continueLoop = 1
    30683094        pdfNumber = XMLstrFmXpath(fileID,"/pdfcard/pdf_data/pdf_number","","")
     3095        //and read materials names etc.
     3096        string/g chemical_formula, empirical_formula, chemical_name
     3097        chemical_formula = XMLstrFmXpath(fileID,"/pdfcard/pdf_data/chemical_formula","","")
     3098        empirical_formula = XMLstrFmXpath(fileID,"/pdfcard/pdf_data/empirical_formula","","")
     3099        chemical_name = XMLstrFmXpath(fileID,"/pdfcard/pdf_data/chemical_name","","")
    30693100        DO
    30703101                i+=1
     
    31653196        SelectionOfAvailableData[][][0] = 0x20
    31663197        SelectionOfAvailableData[][][1] = p
    3167 
     3198        string tempNameStr
    31683199        For(i=0;i<ItemsInList(AvailableCards , ";");i+=1)
    31693200                TempStr =  StringFromList(i, AvailableCards , ";")
    31703201                //let's also check that hklStr waves are correct...
    31713202                Wave DtaWv=$("root:WAXS_PDF:"+possiblyquotename(TempStr))
    3172                 Wave/T/Z DtaWvHklDStr=$("root:WAXS_PDF:"+possiblyquotename(TempStr[0,23]+"_hklStr"))
     3203                //Wave/T/Z DtaWvHklDStr=$("root:WAXS_PDF:"+possiblyquotename(TempStr[0,23]+"_hklStr"))
     3204                tempNameStr = IN2G_CreateUserName(TempStr,24, 0, 1)
     3205                Wave/T/Z DtaWvHklDStr=$("root:WAXS_PDF:"+possiblyquotename(tempNameStr+"_hklStr"))
    31733206                if(!WaveExists(DtaWvHklDStr))
    3174                         make/O/T/N=(DimSize(DtaWv, 0 )) $("root:WAXS_PDF:"+possiblyquotename(TempStr[0,23]+"_hklStr"))
    3175                         Wave/T DtaWvHklDStr=$("root:WAXS_PDF:"+possiblyquotename(TempStr[0,23]+"_hklStr"))
     3207                        //make/O/T/N=(DimSize(DtaWv, 0 )) $("root:WAXS_PDF:"+possiblyquotename(TempStr[0,23]+"_hklStr"))
     3208                        make/O/T/N=(DimSize(DtaWv, 0 )) $("root:WAXS_PDF:"+possiblyquotename(tempNameStr+"_hklStr"))
     3209                        Wave/T DtaWvHklDStr=$("root:WAXS_PDF:"+possiblyquotename(tempNameStr+"_hklStr"))
    31763210                endif
    31773211                if(strlen(DtaWvHklDStr[0])<1)   //empty wave, not filled...
     
    32713305                        if(PDF4_DisplayHKLTags)
    32723306                                TmpStrName=IN2G_RemoveExtraQuote(listWave[i][0],1,1)
    3273                                 Wave LabelWave=$("root:WAXS_PDF:"+PossiblyQUoteName(TmpStrName[0,23]+"_hklStr"))
     3307                                //Wave LabelWave=$("root:WAXS_PDF:"+PossiblyQUoteName(TmpStrName[0,23]+"_hklStr"))
     3308                                Wave LabelWave=$("root:WAXS_PDF:"+PossiblyQUoteName(IN2G_CreateUserName(TmpStrName,23, 0, 0)+"_hklStr"))
    32743309                                IR3W_PDF4AddTagsFromWave("IR3W_WAXSMainGraph", listWave[i][0], labelWave, ListOfPDF4DataColors[i][0], ListOfPDF4DataColors[i][1],ListOfPDF4DataColors[i][2])
    32753310                        endif
     
    33003335End
    33013336
     3337
     3338//**************************************************************************************
     3339//**************************************************************************************
     3340
     3341static Function IR3W_WAXSCorForDistance()
     3342
     3343        IN2G_PrintDebugStatement(IrenaDebugLevel, 5,"")
     3344        DFref oldDf= GetDataFolderDFR()
     3345       
     3346        if(DataFolderExists("root:Packages:Irena:WAXSTemp"))   
     3347                setDataFolder root:Packages:Irena:WAXSTemp
     3348               
     3349                NVAR DistanceCorrection = root:Packages:Irena:WAXS:DistanceCorrection                   //when DistanceCorrection=1, distacne calibration is perfect, based on my sketch, correction is linear fix.
     3350                NVAR  Wavelength = root:Packages:Irena:WAXS:Wavelength
     3351                string AllWaves = WaveList("*", ";", "DIMS:2,TEXT:0,MINCOLS:8" )
     3352                variable i
     3353                string DimensionUnit
     3354                For(i=0;i<ItemsInList(AllWaves);i+=1)
     3355                        Wave TheCardNew = $(StringFromList(i, AllWaves))
     3356                        DimensionUnit=GetDimLabel(TheCardNew, 1, 0 )
     3357                        if(stringmatch(DimensionUnit,"d_A"))            //manually inserted, dimension is in d and A
     3358                                TheCardNew[][4] =   114.592 * asin((2 * pi / (DistanceCorrection*TheCardNew[p][0]))* wavelength / (4*pi))
     3359                        else            //other choice is "Q_nm" from LaueGo
     3360                                TheCardNew[][4] =  114.592 * asin((TheCardNew[p][0]*wavelength/125.664 ))               //this is conversion to A and from Q
     3361                        endif
     3362                endfor
     3363        endif
     3364        setDataFolder oldDf
     3365end
    33023366//**************************************************************************************
    33033367//**************************************************************************************
     
    33113375        NVAR  Wavelength = root:Packages:Irena:WAXS:Wavelength
    33123376        wave TheCard=$("root:WAXS_PDF:"+possiblyquotename(CardName))
    3313         wave/T TheCardHKL=$("root:WAXS_PDF:"+possiblyquotename(CardName[0,23]+"_hklStr"))
     3377        wave/T TheCardHKL=$("root:WAXS_PDF:"+possiblyquotename(IN2G_CreateUserName(CardName,23, 0, 0)+"_hklStr"))
    33143378        NewDataFolder/O/S root:Packages:Irena:WAXSTemp
    33153379        Duplicate/O TheCard, $(CardName)
    3316         Duplicate/O/T TheCardHKL, $(CardName[0,23]+"_hklStr")
     3380        Duplicate/O/T TheCardHKL, $(IN2G_CreateUserName(CardName,23, 0, 0)+"_hklStr")
    33173381        Wave TheCardNew = $((CardName))
    33183382        string DimensionUnit=GetDimLabel(TheCardNew, 1, 0 )
     3383        NVAR DistanceCorrection = root:Packages:Irena:WAXS:DistanceCorrection                   //when DistanceCorrection=1, distacne calibration is perfect, based on my sketch, correction is linear fix.
    33193384        if(stringmatch(DimensionUnit,"d_A"))            //manually inserted, dimension is in d and A
    3320                 TheCardNew[][4] =   114.592 * asin((2 * pi / TheCard[p][0])* wavelength / (4*pi))
     3385                TheCardNew[][4] =   114.592 * asin((2 * pi / (DistanceCorrection*TheCard[p][0]))* wavelength / (4*pi))
    33213386        else            //other choice is "Q_nm" from LaueGo
    33223387                TheCardNew[][4] =  114.592 * asin((TheCard[p][0]*wavelength/125.664 ))          //this is conversion to A and from Q
  • trunk/User Procedures/Irena/Modification history.txt

    r928 r935  
    1111Modification history:
    1212********************************************
    13 2.691 (beta)
     132.262 (beta)
     14WAXS - changed how JCPDS cards are named (using chemical name or formula+PDF number) + enabled long name support for Igor 8 and when user chooses.
     15WAXS - added "Distance correction" for sticks. Tweaks calculated 2Theta angle using distance ratio correction. 
    1416Fractals - added optional use of Unified Fit Sphere form factor. This removes high-q Bessel function oscillations which are nto reasonable for most cases.
    1517Added Multi Data Plot tool, new tool to plot quickly many data sets. New ipf file...
Note: See TracChangeset for help on using the changeset viewer.