You can create analysis scripts for Analysis Automation using Visual Basic Script or Python. The analysis automation procedure contains a script (Main.vbsa or Main.py), in which you define your analyses. In this script, you can include additional scripts that you must add to the analysis automation procedure. The analysis script Main.vbsa or Main.py contains the following elements by default.
Script Code | Description |
---|---|
On_Initialize(oContext) | Initializes parallel evaluation. This method is called once before data processing. |
On_RunAnalysisProcedure(oContext) | Performs the actual evaluation of the retrieved data elements. |
On_Finalize(oContext) | Ends the parallel evaluation. The method is called once after data processing has finished. |
The oContext transfer parameter exchanges information between analysis automation and the analysis script and gives access to the retrieved data elements.
The analysis script main.py also contains the following elements.
Script Code | Description |
---|---|
Import DIAdem dd = DIAdem.Application |
Enables access to DIAdem commands, variables, and objects. You can use most DIAdem commands in the Python environment, but not all DIAdem commands have been tested in Python. |
The following table lists the most important DIAdem commands and methods for processing data.
Script Code | Description |
---|---|
ApplicationSetLocale("english") | Sets country-specific variables and quantities, such as time format, paper size, and margins. |
oContext.DataLinks | Contains the retrieved data elements. |
Navigator.LoadData | Loads data. |
ChannelsToArray | Converts DIAdem channels to arrays for processing in Python. |
ArrayToChannels | Converts Python arrays to DIAdem channels. |
DataFileSave | Saves data. |
You may not use the following commands in analysis scripts:
The following shows an example of an analysis script in Visual Basic Script. The On_Initialize procedure checks whether the result path from the transfer parameter exists. The On_Run_AnalysisProcedure procedure loads the elements for analyses, performs the analyses, and outputs the results in a PDF. The On_Finalize procedure checks whether the procedures On_Initialize and On_Run_AnalysisProcedure were successful:
Sub On_Initialize(oContext) Call ApplicationSetLocale("english") Dim ResultsPath If oContext.Procedure.Arguments.Exists("ResultsPath") Then ResultsPath = oContext.Procedure.Arguments.Item("ResultsPath").Value Call oContext.LogResult("Results path: " & ResultsPath) Else Call oContext.LogError("Results path missing") End If End Sub Sub On_Run_AnalysisProcedure(oContext) Call ApplicationSetLocale("english") Dim ResultsPath ResultsPath = oContext.Procedure.Arguments.Item("ResultsPath").Value Dim oMyDataLinks, iCount Set oMyDataLinks = oContext.DataLinks For iCount = 1 To oMyDataLinks.Count Call Navigator.LoadData(oContext.DataLinks.Item(iCount)) ' Enter your analysis commands Next Call Report.LoadLayout(oContext.Procedure.ScriptPath & "MyLayout.tdr") Call Report.Sheets.ExportToPDF(ResultsPath & & "MyResult.pdf",FALSE) End Sub Sub On_Finalize(oContext) Call oContext.LogResult("Init ok: " & oContext.Status.On_Initialize_Succeeded) Call oContext.LogResult("Analysis ok: " & oContext.Status.On_Run_AnalysisProcedure_Succeeded) End Sub