Difference between revisions of "Grace/C3/Data-Fitting/English"

From Script | Spoken-Tutorial
Jump to: navigation, search
 
Line 58: Line 58:
  
 
|-
 
|-
|| Show screenshot of '''Grace read-sets''' dialogue box.
+
|| Show screenshot of '''Grace read-sets''' dialog box.
 
|| Next, open the '''Grace''' program and load this file to plot an '''XY''' graph.
 
|| Next, open the '''Grace''' program and load this file to plot an '''XY''' graph.
  
Line 103: Line 103:
 
|| Choose '''Regression''' from the list.
 
|| Choose '''Regression''' from the list.
  
A '''Regression''' dialogue box opens.
+
A '''Regression''' dialog box opens.
  
 
|-
 
|-
Line 172: Line 172:
 
|-
 
|-
 
|| Click on '''Apply''' and click to '''close'''.
 
|| Click on '''Apply''' and click to '''close'''.
|| Click on '''Apply''' and then click on '''Close''' to close the dialogue box.
+
|| Click on '''Apply''' and then click on '''Close''' to close the dialog box.
  
 
|-
 
|-
Line 313: Line 313:
 
|-
 
|-
 
|| Click on '''Close'''.
 
|| Click on '''Close'''.
|| Then '''Close''' the dialogue box.
+
|| Then '''Close''' the dialog box.
  
 
|-
 
|-
|| Show screenshot of '''save as''' dialogue box with name filled in as '''regression.agr'''.
+
|| Show screenshot of '''save as''' dialog box with name filled in as '''regression.agr'''.
 
|| Now save the project in the '''Desktop''' directory.
 
|| Now save the project in the '''Desktop''' directory.
  

Latest revision as of 16:15, 28 October 2020

Visual Cue Narration
Slide Number 1

Title Slide

Welcome to the tutorial on Data fitting in Grace.
Slide Number 2

Learning Objectives

In this tutorial, we will
  • Fit a given set of data points to a linear equation
  • Add two datasets to a graph panel
  • Add legends and format the legend properties
Slide Number 3

System and Software Requirement

To record this tutorial, I am using
  • Ubuntu Linux 16.04 OS
  • Grace 5.1.25 and
  • Gedit 3.18.3
Slide Number 4

Pre-requisites https://spoken-tutorial.org

To follow this tutorial,
  • Learner must be familiar with the Grace interface.
  • For pre-requisite tutorials, please visit this website.
Slide Number 5

Data fitting

* Data fitting is a process to find a mathematical relation between two variables.
  • An equation is used to describe the XY dataset pair.
Slide Number 6

Data fitting

  • Using an iterative process, the coefficients are optimized.
  • The process returns the best possible coefficients for the equation.
Go to Desktop. Go to Desktop.
Hover mouse over file, line-fit.txt. Notice the file, line-fit.txt.

This file is provided to you in the Code Files link.

I have downloaded, extracted and saved the file to the Desktop directory.

Show screenshot of Grace read-sets dialog box. Next, open the Grace program and load this file to plot an XY graph.
Show screenshot of XY data set, and autoscale data. Choose XY data set, and autoscale data.
Hover mouse over the data. Next I will format the plot.
Show screenshot for : change the symbol, size, pattern. choose filled circle adjust size to 35. I have changed the symbols, line style, tick marks and axis labels.
Move the cursor along the data points. The data points do not lie on a straight line.

The data points look scattered around a straight line.

Cursor on the graph. We will fit this data to a straight line.

For a straight line, this is process is called linear regression.

Slide Number 7

Equation in two variables

A straight line is described by an equation in two variables,

The equation has the form, y equals mx+c.

Here, m is the slope of the line and c is the intercept.

Go to Data,Transformations. Go to Data and select Transformations.

Notice the available options.

Choose Regression. Choose Regression from the list.

A Regression dialog box opens.

Hover mouse over S(0).

Choose dataset (S0).

Choose the data set of interest from Apply to set.

Currently only a single set is loaded and it is shown as S0.

The next number is the number of points that are present in the dataset.

Choose linear for Type of fit. If many datasets are loaded more sets will be seen, in the Apply to set box.

Choose linear for Type of fit.

for Load, choose Fitted values. In the Load drop-down, choose Fitted values.
For restrictions choose None. For restrictions choose None.

If only part of the data set needs to be fitted, enter the required range.

Hover mouse over start load at and stop load at values.

Click on Accept.

We can also specify the start load at and stop load at values in the form.

I will leave it as is and will not make changes here.

Click on Accept to run the data fitting.

Show the Grace console window, and output values. The data fitting algorithm runs.

A Grace console window appears with mathematical details.

Scroll in the Console window to show the values. We can see the equation used for the fitting.

The output values of residual, slope, intercept and other parameters are seen.

Show on screen S(1) dataset showing in panel. The fitted line appears on the screen.

The fitted values are loaded in a different set, S1.

Click on File, Save. Click on File, Save to save the parameters.
Show the opened Grace: Save logs. The Grace: Save logs window opens.
Type line-regression.txt in Save to file. In Save to file text box, type the filename as line-regression.txt.
Click on Apply and click to close. Click on Apply and then click on Close to close the dialog box.
Close Grace:Console by File, Close or Esc Close the Grace Console by File, Close or press theEsc key.
Click on Close in Regression window. Click on Close in the Regression window.
Double click on the line in the graph. Double click on the line in the graph.

Grace Set appearance window opens.

In select set form, select (S1) data set. In the select set form, select S1 data set.

This is the fitted data.

Right-click, select Edit, In spreadsheet option. Right click to open the context menu.

Select Edit, and in In spreadsheet option.

The Grace: Spreadsheet dataset editor appears.

Hover mouse over x and y columns. Notice the x and corresponding fitted y values of the fitted data.

These values are different from the input data.

Hover mouse over the fitted line. This line fits the input data best, with a linear equation.
Close the Spreadsheet dataset Editor. Close the Spreadsheet dataset Editor.
Hover mouse over the two datasets. The original data set and the fitted values are the 2 datasets in the graph.

Datasets are labeled as [S0] for first set and [S1] for the second set.

Cursor on the graph. We can add more datasets to this graph panel.

For this load the data using the Data, import, ASCII option from the menu.

Cursor on the plot window. Next, we will add legends to the plot.
Double click on the line to open Set Appearance window. Open the Set Appearance window and choose the dataset S0.
Type Data in String field.

Click on Apply.

Under Legend, in the String field, type Data as the legend label.

Click on Apply.

Choose S1 dataset. Next choose S1 dataset from the Select set data form.
Type Fitted data for the legend string and click on Apply. Here, I will type Fitted data for the legend and click on Apply.
Click on Close to close Set Appearance window. Close the Set Appearance window.
Cursor the the legend. For some users, the legend position may be outside the graph border.
Cursor in the legend box and press Ctrl+L . To reposition the legends, place the cursor in the legend box.

Then press Control and L keys together.

Show the cursor change on the screen. The cursor changes to a pointer.
Left click and drag the legend box to the desired position. Left click and drag the legend box to the desired position.
Press Enter and then press Esc key. Then, press Enter.

Press the Escape key to exit the movement mode.

Open Graph appearance, Legend tab. Next, open the Graph appearance window.

In the window, click on the Legends tab, to format the legend fonts.

Move size slider to 70. Under the text properties, move the character size slider to 70.

The legends look very large compared to the graph.

Click on the font drop-down. I will retain the font type as Times-Roman.
Click on Apply. Click on Apply to apply the changes.
Click on the legend boxtab. Click on the legend box tab.
Hover mouse next to Legend location. We can also specify the position of the legend in the location section.

I will leave it as is.

In pattern drop-down, choose None. In the Frame line section, for Pattern, I will choose None.
Click on Apply. Click on Apply.

This will remove the legend frame box.

Click on Close. Then Close the dialog box.
Show screenshot of save as dialog box with name filled in as regression.agr. Now save the project in the Desktop directory.

I will use the file name regression dot agr.

Press Ctrl+Q Press Control Q or Click on File, Exit to exit Grace.
Let’s summarize.
Slide Number 8

Summary

In this tutorial we,
  • Performed data fitting for a straight line.
  • Added two datasets in the graph panel.
  • Added legends to the plot and
  • Formatted the legend properties.
Slide Number 9

Assignment

For assignment activity, please do the following.
  • Two assignment files are provided in the Code files link.

(parabola1.txt & parabola2.txt)

  • Plot them in the same graph panel.
  • Perform quadratic regression on the parabola1.txt file.
Slide Number 10

Assignment

  • Load the fitted data in the graph.
  • Add legend strings and reposition them inside the graph panel.
  • Format the appearance of the three datasets to distinguish them.
Show the glimpse of assignment. Your completed assignment may look similar to this.
Slide Number 11

Spoken Tutorial Project

This video summarizes the Spoken Tutorial Project.

Please download and watch it.

Slide Number 12

Spoken Tutorial workshops

The Spoken Tutorial Project team:
  • conducts workshops and
  • gives certificates.

For more details, please write to us.

Slide Number 13

Forum for specific questions:

Please post your timed queries in this forum.
Slide Number 14

Acknowledgement

Spoken Tutorial Project is funded by NMEICT, MHRD, Government of India.

More information on this mission is available at this link.

This is Rani from IIT Bombay.

Thank you for joining.

Contributors and Content Editors

Madhurig, PoojaMoolya, Ranipv076