Talk:Create Plots/Notes: Difference between revisions

From ReliaWiki
Jump to navigation Jump to search
No edit summary
(Replaced content with '=DRAFT=')
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
=DRAFT=
=DRAFT=
{{Template:API}}{{Template:BacktoPrevPage}}
In the [[Perform_Life_Data_Analysis_on_External_Data_Source|Weibull++ data set]] and [[Perform_Accelerated_Life_Testing_Data_Analysis_on_External_Data_Source|ALTA data set]] tutorials, you learned how to use the Synthesis API to analyze a data set and obtain calculated results. In this tutorial, you'll use the Synthesis API to generate a plot of the results.
Note that this tutorial is for demonstration purposes only; it doesn't take efficiency into account and doesn't include any exception handling.
==Prerequisites==
This tutorial uses a Windows Form application that displays a plot at a click of a button. Before you begin, please create a Windows Form Application project, and add a '''Button''' and '''PictureBox''' control to the form.   
Need help with creating Windows Forms? See this [https://msdn.microsoft.com/en-us/library/b201w61t%28v=vs.100%29.aspx Microsoft tutorial].
==Tutorial: Weibull++/ALTA Plots ==
The following example demonstrates how to use the Synthesis API to create a Weibull++ probability plot and display it in a Windows application. To run this example, paste the code to the Button Click event handler in your project, as shown in the example below. A discussion of the example follows.
'''VB.NET'''
{{APIPrefix|Imports}} SynthesisAPI
{{APIPrefix|Public Class}} Form1
    {{APIPrefix|Private Sub}} Button1_Click(sender {{APIPrefix|As}} Object, e {{APIPrefix|As}} EventArgs) {{APIPrefix|Handles}} Button1.Click
 
  {{APIComment|'Create a Weibull++ data set.}}
    {{APIPrefix|Dim}} WDS {{APIPrefix|As New}} WeibullDataSet
    WDS.AddFailure(16, 1)
    WDS.AddFailure(34, 1)
    WDS.AddFailure(53, 1) 
    WDS.AddFailure(75, 1)
    WDS.AddFailure(93, 1)
    WDS.AddSuspension(120, 5) 
  {{APIComment|'Analyze the data set using the 2-parameter Weibull distribution and}}
  {{APIComment|'the RRX analysis method. Keep all other analysis settings at default.}}
    WDS.AnalysisSettings.Distribution = WeibullSolverDistribution.Weibull
    WDS.AnalysisSettings.Parameters = WeibullSolverNumParameters.MS_2Parameter
    WDS.AnalysisSettings.Analysis = WeibullSolverMethod.RRX
 
  {{APIComment|'Analyze the data set.}}
    WDS.Calculate()
  {{APIComment|'Declare a new WAPlots object.}}
    {{APIPrefix|Dim}} WPlot {{APIPrefix|As New}} WAPlots
  {{APIComment|'Add the analyzed data set to the plot.}}
    WPlot.AddDataset(WDS)
{{APIComment|'Create a probability plot and display it in the PictureBox.}}
  PictureBox1.Image = WPlot.CreatePlot(WAPlotType.Probability)
  PictureBox1.SizeMode = PictureBoxSizeMode.AutoSize
 
    {{APIPrefix|End Sub}}
{{APIPrefix|End Class}}
===Discussion===
You'll first need an analyzed Weibull++ or ALTA data set before you can create a plot. The first three sections of code in this example demonstrate how to create and analyze a simple Weibull++ data set (for a full discussion, see [[Perform_Life_Data_Analysis_on_External_Data_Source|this tutorial]]). From this data set, we'll create a plot.
  {{APIComment|'Create a Weibull++ data set.}}
    {{APIPrefix|Dim}} WDS {{APIPrefix|As New}} WeibullDataSet
    WDS.AddFailure(16, 1)
    WDS.AddFailure(34, 1)
    WDS.AddFailure(53, 1) 
    WDS.AddFailure(75, 1)
    WDS.AddFailure(93, 1)
    WDS.AddSuspension(120, 5) 
  {{APIComment|'Analyze the data set using the 2-parameter Weibull distribution and}}
  {{APIComment|'the RRX analysis method. Keep all other analysis settings at default.}}
    WDS.AnalysisSettings.Distribution = WeibullSolverDistribution.Weibull
    WDS.AnalysisSettings.Parameters = WeibullSolverNumParameters.MS_2Parameter
    WDS.AnalysisSettings.Analysis = WeibullSolverMethod.RRX
  {{APIComment|'Analyze the data set.}}
    WDS.Calculate()
Next, create a new [[WAPlots Class|WAPlots]] object to represent the plot and then use the [[WAPlots.AddDataset|AddDataset]] method to assign the data set to the plot. 
  {{APIComment|'Declare a new WAPlots object.}}
    {{APIPrefix|Dim}} WPlot {{APIPrefix|As New}} WAPlots
  {{APIComment|'Add the analyzed data set to the plot.}}
    WPlot.AddDataset(WDS)
Use the [[WAPlots.CreatePlot|CreatePlot]] method to create the plot. The type of plot it creates is specified by the [[WAPlotType Enumeration|WAPlotType]] enumeration. In this example, we've chosen a probability plot.
To display the plot, assign it to the <code>Image</code> property of the PictureBox. The <code>SizeMode</code> property is optional; it resizes the PictureBox to fit the image.
{{APIComment|'Create a probability plot and display it in the PictureBox.}}
  PictureBox1.Image = WPlot.CreatePlot(WAPlotType.Probability)
  PictureBox1.SizeMode = PictureBoxSizeMode.AutoSize
==Note==
'''For ALTA Data Sets'''
In ALTA data sets, you have the option to create a use level probability plot based on a specified use stress level. Use the <code>ALTADataSet.PlotUseStress(''index'')</code> property to specify the use stress value to be plotted. The ''Index'' parameter is an integer that specifies the stress index, where 0 = first stress, 1 = second stress, etc.
For example, for an ALTA single-stress analysis:
{{APIComment|'Declare a new ALTADataSet object.}}
    {{APIPrefix|Dim}} ADS {{APIPrefix|As New}} ALTADataSet
{{APIComment|'Add code to create an ALTA data set and analyze it.}}
{{APIComment|...}} 
  {{APIComment|'Declare a new WAPlots object.}}
    {{APIPrefix|Dim}} APlot {{APIPrefix|As New}} WAPlots
 
  {{APIComment|'Add the analyzed data set to the plot.}}
    APlot.AddDataset(ADS)
{{APIComment|'Create a use level probability plot for use stress &#61; 200.}}
    ADS.PlotUseStress(0) = 200 
    PictureBox1.Image = APlot.CreatePlot(WAPlotType.UseLevelProbability)
    PictureBox1.SizeMode = PictureBoxSizeMode.AutoSize
'''For Models'''
You can also plot the results of any [[CModel Class|cModel]] object by using the [[WAPlots.AddModel]] method. For example:
{{APIComment|'Declare a new cModel object.}}
  {{APIPrefix|Dim}} model {{APIPrefix|As New}} cModel
{{APIComment|'Add code to either create a new model or get an existing model from a Synthesis repository.}}
{{APIComment|...}}
 
{{APIComment|'Declare a new WAPlots object.}}
  {{APIPrefix|Dim}} plot {{APIPrefix|As New}} WAPlots
 
{{APIComment|'Add the model to the plot.}}
  plot.AddModel(model)
===References===
*[[WAPlots Class]]
**[[WAPlots.AddDataset|WAPlots.AddDataset Method]]
**[[WAPlots.CreatePlot|WAPlots.CreatePlot Method]]
*[[WAPlotType Enumeration]]

Latest revision as of 00:49, 7 September 2016

DRAFT