Skip to content

Commit

Permalink
USAXS and RSoXS code changes
Browse files Browse the repository at this point in the history
Lots of changes in USAXS code and Nika RSoXS support. Fixes for
misbehavior of panel size restoration after start of experiment from
different computers. This required most procedures to be touched. Beta
version for ALS/RSoXS guys.
  • Loading branch information
jilavsky committed Dec 18, 2017
1 parent 0cc22fd commit 8cb26ce
Show file tree
Hide file tree
Showing 40 changed files with 382 additions and 260 deletions.
67 changes: 1 addition & 66 deletions Igor Procedures/Boot Indra2.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -128,76 +128,11 @@ Function LoadUSAXSMacros()
SVAR USAXSItem1Str = root:Packages:USAXSItem1Str
USAXSItem1Str= "---"
BuildMenu "USAXS"
IN2L_GenerateReadMe()
//IN2L_GenerateReadMe()
else
DoAlert 0, "Your version of Igor is lower than 7.05, these macros need version 7.05 or higher"
endif

end


//*****************************************************************************************************************
//*****************************************************************************************************************
//*****************************************************************************************************************
//*****************************************************************************************************************

Function IN2L_GenerateReadMe()
Dowindow USAXSQuickManual
if (V_flag)
Dowindow/F USAXSQuickManual
abort
endif
String nb = "USAXSQuickManual"
NewNotebook/N=$nb/F=1/V=1/K=3/W=(464,45,1152,768) as "Read Me"
Notebook $nb defaultTab=36, magnification=150
Notebook $nb showRuler=1, rulerUnits=2, updating={1, 3600}
Notebook $nb newRuler=Normal, justification=0, margins={0,0,468}, spacing={0,0,0}, tabs={}, rulerDefaults={"Arial",9,0,(0,0,0)}
Notebook $nb newRuler=Header, justification=0, margins={0,0,468}, spacing={0,0,0}, tabs={}, rulerDefaults={"Arial",14,0,(0,0,0)}
Notebook $nb ruler=Header, text="Quick Manual for Indra 2 version of USAXS macros\r"
Notebook $nb ruler=Normal, text="This is version 1.90 of Indra macros, date: 2/20/2017\r"
Notebook $nb text="\r"
Notebook $nb text="Data reduction summary:\r"
Notebook $nb ruler=Normal; Notebook $nb margins={0,35,468}
Notebook $nb text="1.\tImport data: menu \"USAXS\" - \"Import and Reduce USAXS data\". ", fStyle=1
Notebook $nb text="ONLY if you have Flyscan Nexus files as input", fStyle=-1, text=". ", fStyle=4, text="Most common"
Notebook $nb fStyle=-1
Notebook $nb text=". Opens GUI which can import data and process them at the same time. Follow procedure in step 3. \r"
Notebook $nb text="2.\tAlternative: \r"
Notebook $nb text="\ta.\tmenu \"USAXS\" - \"Other input methods\" - \"Import USAXS .... data\" - imports either Flyscan Nexus data,"
Notebook $nb text=" Step scan data from spec file or Osmic-Rigaku data. Opens separate GUI to import appropriate data type."
Notebook $nb text=" \r"
Notebook $nb text="\tb. \tmenu \"USAXS\" - \"Other input methods\" - \"Reduce data \" This will open GUI panel which is used to "
Notebook $nb text="reduce data imported in step 2a. Follow procedure in step 3. \r"
Notebook $nb text="3.\tProcess data - FIRST you need instrumental curve (\"Process as Blank\"). Save processed instrumental c"
Notebook $nb text="urve (Blank). With ", fStyle=1, text="correct", fStyle=-1, text=" Blank you can process samples. \r"
Notebook $nb text="\tIf you want absolute intensities, you will need to know the sample thickness at this time. If you don'"
Notebook $nb text="t have that \tnow, you will need to repeat this procedure from this step. [NOTE: not exactly true, you ca"
Notebook $nb text="n calculate it, if you \tknow linear absorption coefficient]\r"
Notebook $nb text="\tIf we measured USAXS transmission (most likely) using pinDiode, it will be used automatically ("
Notebook $nb fStyle=4, text="MSAXS correction is not needed", fStyle=-1
Notebook $nb text=") If we did not measure pinDIode, may be you need to use MSAXS correction - but only if data are contami"
Notebook $nb text="nated by mulitple scattering in the main tool. Check with staff. \r"
Notebook $nb text="\tIf you use FlyScan, you may need to select FlyScan rebin to number of points...\r"
Notebook $nb text="\tFor regular samples - 200 - 300 points\r"
Notebook $nb text="\tFor Samples with monodispersed systems/diff peaks: more (up to 1000-2000) may be necessary\r"
Notebook $nb text="\tDo NOT produce needlesly too many points - data will take much more time to analyze. \r"
Notebook $nb ruler=Normal, text="4.\tOther possible useful tools:\r"
Notebook $nb text="\tTo Desmear data you will need Irena package which contains the desmearing routine in \"Other tools\"\r"
Notebook $nb text="\t\"USAXS->USAXS Plotting tools\" - preferably use Irena \"Plotting tool I\"\r"
Notebook $nb text="\t\t\"Standard ....\"\t standard USAXS type plots (Int-Q, Porod plot, Guinier plot)\r"
Notebook $nb text="\t\t\"Basic ....\"\toffers wave variables most likely to be used in USAXS plots\r"
Notebook $nb text="\t\t\"Generic ....\"\tallows user to plot any available wave variables (only one for non-USAXS data)\r"
Notebook $nb ruler=Normal; Notebook $nb margins={0,34,468}
Notebook $nb text="5.\tTo export data use Irena, data export tool. But if you need to export ASCII data, they should be desm"
Notebook $nb text="eared first, very likely... Keep that in mind. \r"
Notebook $nb ruler=Normal, text="\t\r"
Notebook $nb text="Suggestions: \r"
Notebook $nb text="a.\tSave Igor experiment once in a while.\r"
Notebook $nb text="b.\tDo not work with Igor files over an NFS network connection, first copy those files to a local disk.\r"
Notebook $nb text="c.\tUse automatic logging functions - \r"
Notebook $nb text="\tmenu \"USAXS\" - \"Log in Notebook\" - \"Create logbook\" and \"Create Summary Notebook\". \r"
Notebook $nb text="\r"
Notebook $nb text="Make notes of any bugs and forward them to me. Make notes of any suggestions on changes in the wording o"
Notebook $nb text="f dialogs - I am opened to any reasonable changes....\r"
end

8 changes: 7 additions & 1 deletion User Procedures/CanSAS/IRNI_NexusSupport.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,12 @@ static Function IR1_UpdatePanelVersionNumber(panelName, CurentProcVersion, AddRe
if(AddResizeHookFunction==1)
IN2G_PanelAppendSizeRecordNote(panelName)
SetWindow $panelName,hook(ResizePanelControls)=IN2G_PanelResizePanelSize
IN2G_ResetPanelSize(panelName,1)
//Execute/P/Q("IN2G_ResetPanelSize(\""+PanelName+"\", 0)")
STRUCT WMWinHookStruct s
s.eventcode=6
s.winName=panelName
IN2G_PanelResizePanelSize(s)
endif
endif
end
Expand All @@ -123,7 +129,7 @@ Function Nexus_MainCheckVersion()
if(!NI1_CheckPanelVersionNumber("NEXUS_ConfigurationPanel", NexusVersionNumber))
DoAlert /T="The Nexus configuration panel was created by old version of Nika " 1, "Nexus Config needs to be reopened to work properly. Restart now?"
if(V_flag==1)
Execute/P("NEXUS_NikaCall(2)")
NEXUS_NikaCall(2)
else //at least reinitialize the variables so we avoid major crashes...
NEXUS_Initialize(0)
endif
Expand Down
31 changes: 19 additions & 12 deletions User Procedures/Indra 2/IN2_GeneralProcedures.ipf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#pragma rtGlobals=2 // Use modern global access method.
#pragma version = 2.09
#pragma version = 2.10
#pragma IgorVersion = 7.05

//control constants
Expand Down Expand Up @@ -27,6 +27,7 @@ constant useUserFileNames = 0 //this controls, if IN2G_ReturnUserSampleName(Fo
//* in the file LICENSE that is included with this distribution.
//*************************************************************************/
//
//2.10 Modifed startup panel controls to better handle rescaling panels on startup.
//2.09 fixed errro when both Nika and Irena check for update at the smae time and MeesageFromAuthor is already opened.
//2.08 Nika removed DoubleClickConverts=root:Packages:Convert2Dto1D:DoubleClickConverts as it is not needed anymore.
//2.07 ManualVersionNumber modifications for beta versions and release versions.
Expand Down Expand Up @@ -1612,7 +1613,7 @@ Function IN2G_PanelResizePanelSize(s)
MoveTop = top//*moveConvFac
MoveRight = (left+OriginalWidth)//*moveConvFac
moveBottom = (top+OriginalHeight)//*moveConvFac
MoveWindow moveLeft, MoveTop, MoveRight, moveBottom
MoveWindow/W=$(s.winName) moveLeft, MoveTop, MoveRight, moveBottom
// print "Moved to "+num2str(moveLeft) +", "+num2str(MoveTop) +", "+num2str(MoveRight) +", "+num2str(moveBottom)
horScale = 1*moveConvFac
verScale = 1*moveConvFac
Expand All @@ -1622,7 +1623,7 @@ Function IN2G_PanelResizePanelSize(s)
MoveTop = top//*moveConvFac
MoveRight = (left+OriginalWidth)//*moveConvFac
moveBottom = (top+CurHeight)//*moveConvFac
MoveWindow moveLeft, MoveTop, MoveRight, moveBottom
MoveWindow/W=$(s.winName) moveLeft, MoveTop, MoveRight, moveBottom
// print "Moved to "+num2str(moveLeft) +", "+num2str(MoveTop) +", "+num2str(MoveRight) +", "+num2str(moveBottom)
horScale = 1*moveConvFac
verScale = CurHeight / (OriginalHeight) *moveConvFac
Expand All @@ -1632,7 +1633,7 @@ Function IN2G_PanelResizePanelSize(s)
MoveTop = top//*moveConvFac
MoveRight = (left+CurWidth)//*moveConvFac
moveBottom = (top+OriginalHeight)//*moveConvFac
MoveWindow moveLeft, MoveTop, MoveRight, moveBottom
MoveWindow/W=$(s.winName) moveLeft, MoveTop, MoveRight, moveBottom
// print "Moved to "+num2str(moveLeft) +", "+num2str(MoveTop) +", "+num2str(MoveRight) +", "+num2str(moveBottom)
verScale = 1 *moveConvFac
horScale = curWidth/OriginalWidth*moveConvFac
Expand Down Expand Up @@ -1670,7 +1671,7 @@ Function IN2G_PanelResizePanelSize(s)
if(Strlen(SubwindowList)>0)
ListOfPanels+=SubwindowList
endif
controlslist = ControlNameList("", ";")
controlslist = ControlNameList(s.winName, ";")
For(i=0;i<ItemsInList(controlslist, ";");i+=1)
TmpNm = StringFromList(i, controlslist, ";")
OrigCntrlV_left=NumberByKey(TmpNm+"Left", OrigInfo, ":", ";")
Expand All @@ -1681,13 +1682,13 @@ Function IN2G_PanelResizePanelSize(s)
NewCntrlV_top = OrigCntrlV_top * verScale
NewWidth = OrigWidth * horScale
NewHeight = OrigHeight * verScale
ModifyControl $(TmpNm) pos = {NewCntrolV_left,NewCntrlV_top}, size={NewWidth,NewHeight}
ModifyControl $(TmpNm) pos = {NewCntrolV_left,NewCntrlV_top}, size={NewWidth,NewHeight}, win=$(s.winName)
//special cases...
ControlInfo $(TmpNm)
ControlInfo/W=$(s.winName) $(TmpNm)
if(abs(V_Flag)==5 ||abs(V_Flag)==3) //SetVariable
OrigBodyWidth=NumberByKey(TmpNm+"bodyWidth", OrigInfo, ":", ";")
if(numtype(OrigBodyWidth)==0)
ModifyControl $(TmpNm) bodywidth =horScale*OrigBodyWidth
ModifyControl $(TmpNm) bodywidth =horScale*OrigBodyWidth, win=$(s.winName)
endif
endif
endfor
Expand All @@ -1708,11 +1709,11 @@ Function IN2G_PanelResizePanelSize(s)
NewHeight = OrigHeight * verScale
ModifyControl $(TmpNm) win=$(tmpName1),pos = {NewCntrolV_left,NewCntrlV_top}, size={NewWidth,NewHeight}
//special cases...
ControlInfo $(TmpNm)
ControlInfo/W=$(tmpName1) $(TmpNm)
if(abs(V_Flag)==5 ||abs(V_Flag)==3) //SetVariable
OrigBodyWidth=NumberByKey(tmpPanelName+TmpNm+"bodyWidth", OrigInfo, ":", ";")
if(numtype(OrigBodyWidth)==0)
ModifyControl $(TmpNm) bodywidth =horScale*OrigBodyWidth
ModifyControl $(TmpNm) bodywidth =horScale*OrigBodyWidth, win=$(tmpName1)
endif
endif
endfor
Expand Down Expand Up @@ -1774,8 +1775,14 @@ Function IN2G_ResetSizesForALlPanels(WindowProcNames)
PanelName = StringFromList(0,(StringFromList(i, WindowProcNames, ";")+"="),"=")
DoWindow $PanelName
if(V_Flag)
Execute/P/Q("IN2G_ResetPanelSize(\""+PanelName+"\", 0)")
//print "Restored size"
//Execute/P/Q("IN2G_ResetPanelSize(\""+PanelName+"\", 0)")
//debugger
IN2G_ResetPanelSize(PanelName, 0)
DoWIndow/F $(PanelName)
STRUCT WMWinHookStruct s
s.eventcode=6
s.winName=panelName
IN2G_PanelResizePanelSize(s)
endif
endfor
end
Expand Down
47 changes: 5 additions & 42 deletions User Procedures/Indra 2/IN2_USAXS.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,10 @@ Function IN3_UpdatePanelVersionNumber(panelName, CurentProcVersion)
IN2G_PanelAppendSizeRecordNote(panelName)
SetWindow $panelName,hook(ResizePanelControls)=IN2G_PanelResizePanelSize
IN2G_ResetPanelSize(panelName,1)
STRUCT WMWinHookStruct s
s.eventcode=6
s.winName=panelName
IN2G_PanelResizePanelSize(s)
endif
end
//***********************************************************
Expand Down Expand Up @@ -917,48 +921,7 @@ Function IN2A_CalculateRWave(df, askForFactor) //Recalculate the R wave in fo
PD_Intensity=(USAXS_PD - MeasTime*LocalParameters[pd_range-1][1])*(1/(VToFFactor*LocalParameters[pd_range-1][0])) /((Monitor-I0AmpDark*MeasTime)/I0AmpGain)
else
PD_Intensity=(USAXS_PD - MeasTime*LocalParameters[pd_range-1][1])*(1/(VToFFactor*LocalParameters[pd_range-1][0])) /((Monitor-I0AmpDark*MeasTime)/I0_gain)
endif

//Fix for nonlinearity of the photodiode observed in August 2006
//removed 12/2013. This was wrong - this was bad tilt and it cannot be fixed this way anyway...
// variable DataCollectedEpoch
// DataCollectedEpoch = NumberByKey("EPOCH", note(PD_Intensity) ,"=" ,";")
// if (numtype(DataCollectedEpoch)!=0)
// DataCollectedEpoch = 1154542000
// endif
// //found correct number by comparing glassy carbon to be 1.095 - 1.105... measured by PD linearity 1.056
// //may be the right number is 1.056^2 = 1.115 ???
// //this is mystery.
// if(DataCollectedEpoch > 1154542500 && DataCollectedEpoch < (1154542500 + 24*60*60*35)) //set for data with EPOCH between
// NVAR/Z PowerLawCorrectionFactor=root:Packages:Indra3:PowerLawCorrectionFactor
// if(!NVAR_Exists(PowerLawCorrectionFactor))
// variable/g root:Packages:Indra3:PowerLawCorrectionFactor=1.13
// NVAR PowerLawCorrectionFactor=root:Packages:Indra3:PowerLawCorrectionFactor
// endif
// variable PowerLawCorrectionFactorL=PowerLawCorrectionFactor
// if(askForFactor)
// Prompt PowerLawCorrectionFactorL, "Diode linearity correction exponent"
// DoPrompt "Data in August 2006 may have problem of diode non linearity, check exponent", PowerLawCorrectionFactorL
// if(V_Flag==0)
// PowerLawCorrectionFactor=PowerLawCorrectionFactorL
// else
// PowerLawCorrectionFactor=0
// abort
// endif
// endif
// if(PowerLawCorrectionFactor>0.9 && PowerLawCorrectionFactor<1.2)
// //correct PD_Intensity
// //according to Andrew (8/10/2006) the corrected intensity is:
// // Icorrected = (Imeasured/Imax)^(1/ PowerLawCorrectionFactor) * Imax
// wavestats/Q PD_Intensity
// PD_Intensity = ((PD_Intensity/V_max)^(1/PowerLawCorrectionFactor)) * V_max
// else
// DoAlert 0, "Correction factor out of range, no correction applied"
// endif
// endif

//end of the fix...

endif
//OK, another incarnation of the error calculations...
Duplicate/O PD_Error, A
Duplicate/O/Free PD_Error, SigmaUSAXSPD, SigmaPDwDC, SigmaRwave, SigmaMonitor, ScaledMonitor
Expand Down
15 changes: 13 additions & 2 deletions User Procedures/Indra 2/IN3_Calculations.ipf
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
#pragma rtGlobals=1 // Use modern global access method.
#pragma version=1.34
#pragma version=1.35

//*************************************************************************\
//* Copyright (c) 2005 - 2017, Argonne National Laboratory
//* This file is distributed subject to a Software License Agreement found
//* in the file LICENSE that is included with this distribution.
//*************************************************************************/

//1.35 modify the sleep between multiple USAXS data reductions in IN3_InputPanelButtonProc to be more user friendly
//1.34 fixed which resulting waves are plotted to include M_DSM, DSM, M_SMR, and SMR waves in this order.
//1.33 modified graph size control to use IN2G_GetGraphWidthHeight and associated settings. Should work on various display sizes.
//1.32 changed main graph name and size is dynamic now.
Expand Down Expand Up @@ -65,6 +66,14 @@ Function IN3_InputPanelButtonProc(B_Struct) : ButtonControl
//Open www manual with the right page
IN2G_OpenWebManual("Indra/DataReductionPanel.html")
endif
if(cmpstr(ctrlName,"GetReadme")==0)
Dowindow USAXSQuickManual
if (V_flag)
Dowindow/F USAXSQuickManual
else
IN3_GenerateReadMe()
endif
endif

if (cmpstr(ctrlName,"SelectNextSampleAndProcess")==0)
SVAR DataFolderName=root:Packages:Indra3:DataFolderName
Expand Down Expand Up @@ -140,9 +149,11 @@ Function IN3_InputPanelButtonProc(B_Struct) : ButtonControl
UserSavedData=2
IN3_FixSaveData()
DoWIndow/F USAXSDataReduction
sleep/S ListProcDisplayDelay
UserSavedData=1
IN3_FixSaveData()
if(i<Items-1)
sleep/S/B/C=6/M="Delay "+num2str(ListProcDisplayDelay)+" seconds for user data review" ListProcDisplayDelay
endif
endif
endfor
endif
Expand Down
2 changes: 1 addition & 1 deletion User Procedures/Indra 2/IN3_FlyScan.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ Function IN3_FlyScanCheckVersion()
if(!IN3_CheckPanelVersionNumber("IN3_FlyScanImportPanel", IN3_FlyImportVersionNumber))
DoAlert /T="The Fly Scan Import panel was created by old version of Indra " 1, "FlyScan Import needs to be restarted to work properly. Restart now?"
if(V_flag==1)
Execute/P("IN3_FlyScanMain()")
IN3_FlyScanMain()
else //at least reinitialize the variables so we avoid major crashes...
IN3_FlyScanInitializeImport()
endif
Expand Down
Loading

0 comments on commit 8cb26ce

Please sign in to comment.