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

From Script | Spoken-Tutorial
Jump to: navigation, search
Line 21: Line 21:
 
|| To record this tutorial, I am using
 
|| To record this tutorial, I am using
 
* '''Ubuntu Linux''' 16.04 OS
 
* '''Ubuntu Linux''' 16.04 OS
* '''Grace''' 5.1.25
+
* '''Grace''' 5.1.25 and
 
* '''Gedit''' 3.18.3
 
* '''Gedit''' 3.18.3
  
Line 47: Line 47:
 
|| Hover mouse over file, '''line-fit.txt'''.
 
|| Hover mouse over file, '''line-fit.txt'''.
 
|| Notice the file, '''line-fit.txt'''.
 
|| Notice the file, '''line-fit.txt'''.
 +
 
This file is provided to you in the '''Code Files''' link.  
 
This file is provided to you in the '''Code Files''' link.  
 +
 
I have downloaded, extracted and saved the file to the '''Desktop''' directory.
 
I have downloaded, extracted and saved the file to the '''Desktop''' directory.
  
Line 61: Line 63:
 
|| Hover mouse over the data.
 
|| Hover mouse over the data.
 
|| The data points look scattered around a straight line.
 
|| The data points look scattered around a straight line.
 +
 
Next I will format the plot.
 
Next I will format the plot.
  
Line 70: Line 73:
 
|| Move the cursor along the data points.
 
|| Move the cursor along the data points.
 
|| The data points do not lie on a straight line.  
 
|| The data points do not lie on a straight line.  
 +
 
The data points look scattered around a straight line.
 
The data points look scattered around a straight line.
  
Line 103: Line 107:
 
|| Choose the data set of interest from '''Apply to set'''.
 
|| Choose the data set of interest from '''Apply to set'''.
  
Currently only a single set is loaded and it is shown as ('''S0''').
+
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.
 
The next number is the number of points that are present in the dataset.
Line 115: Line 119:
 
|-
 
|-
 
|| for '''Load''', choose '''Fitted values'''.
 
|| for '''Load''', choose '''Fitted values'''.
|| In the '''Load '''drop-down, choose '''Fitted values'''.
+
|| In the '''Load''' drop-down, choose '''Fitted values'''.
  
 
|-
 
|-
Line 130: Line 134:
  
 
I will leave it as is and will not make changes here.
 
I will leave it as is and will not make changes here.
 +
 
Click on '''Accept''' to run the data fitting.
 
Click on '''Accept''' to run the data fitting.
  
Line 135: Line 140:
 
|| Show the '''Grace console''' window, and output values.
 
|| Show the '''Grace console''' window, and output values.
 
|| The data fitting algorithm runs.
 
|| The data fitting algorithm runs.
 +
 
A '''Grace console''' window appears with mathematical details.
 
A '''Grace console''' window appears with mathematical details.
  
Line 140: Line 146:
 
|| Scroll in the '''Console''' window to show the values.
 
|| Scroll in the '''Console''' window to show the values.
 
|| We can see the equation used for the fitting.
 
|| We can see the equation used for the fitting.
 +
 
The output values of residual, slope, intercept and other parameters are seen.
 
The output values of residual, slope, intercept and other parameters are seen.
  
Line 145: Line 152:
 
|| Show on screen '''S(1)''' dataset showing in panel.
 
|| Show on screen '''S(1)''' dataset showing in panel.
 
|| The fitted line appears on the screen.
 
|| The fitted line appears on the screen.
 +
 
The fitted values are loaded in a different set, '''S1'''.
 
The fitted values are loaded in a different set, '''S1'''.
  
 
|-
 
|-
 
|| Click on '''File''', '''Save'''.
 
|| Click on '''File''', '''Save'''.
|| Click on '''File,''' '''Save''' to save the parameters.
+
|| Click on '''File''', '''Save''' to save the parameters.
  
 
|-
 
|-
Line 178: Line 186:
 
|-
 
|-
 
|| In select set form, select ('''S1''') data set.  
 
|| In select set form, select ('''S1''') data set.  
|| In the '''select set''' form, select ('''S1''') data set.
+
|| In the '''select set''' form, select '''S1''' data set.
 
This is the fitted data.
 
This is the fitted data.
  
Line 185: Line 193:
 
|| Right click to open the context menu.  
 
|| Right click to open the context menu.  
 
Select '''Edit''', and in '''In spreadsheet''' option.  
 
Select '''Edit''', and in '''In spreadsheet''' option.  
 +
 
The '''Grace: Spreadsheet dataset editor''' appears.
 
The '''Grace: Spreadsheet dataset editor''' appears.
  
Line 190: Line 199:
 
|| Hover mouse over x and y columns.
 
|| Hover mouse over x and y columns.
 
|| Notice the x and corresponding fitted y values of the fitted data.
 
|| Notice the x and corresponding fitted y values of the fitted data.
 +
 
These values are different from the input data .
 
These values are different from the input data .
  
Line 203: Line 213:
 
|| Hover mouse over the two datasets.
 
|| Hover mouse over the two datasets.
 
|| The original data set and the fitted values are the 2 datasets in the graph.
 
|| 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.
 
Datasets are labeled as ['''S0'''] for first set and ['''S1'''] for the second set.
  
Line 212: Line 223:
  
 
|-
 
|-
|| Click on '''Close''' on the spreadsheet dataset editor and cursor on the interface.
+
|| Cursor on the plot window.
|| Close the Spreadsheet dataset editor.
+
|| Next, we will add legends to the plot.
 
+
Next, we will add legends to the plot.
+
  
 
|-
 
|-
Line 264: Line 273:
 
|| Open '''Graph appearance, Legend''' tab.
 
|| Open '''Graph appearance, Legend''' tab.
 
|| Next, open the '''Graph appearance''' window.
 
|| Next, open the '''Graph appearance''' window.
 +
 
In the window, click on the '''Legends''' tab, to format the '''legend''' fonts.
 
In the window, click on the '''Legends''' tab, to format the '''legend''' fonts.
  
Line 269: Line 279:
 
|| Move size slider to 70.
 
|| Move size slider to 70.
 
|| Under the '''text properties''', move the character size slider to 70.
 
|| Under the '''text properties''', move the character size slider to 70.
 +
 
The legends look very large compared to the graph.
 
The legends look very large compared to the graph.
 
|-
 
|-
Line 279: Line 290:
  
 
|-
 
|-
|| Click on the '''legend '''tab.
+
|| Click on the '''legend box'''tab.
 
|| Click on the '''legend box''' tab.
 
|| Click on the '''legend box''' tab.
  
Line 303: Line 314:
 
|| Show screenshot of '''save as''' dialogue box with name filled in as '''regression.agr'''.
 
|| Show screenshot of '''save as''' dialogue box with name filled in as '''regression.agr'''.
 
|| Now save the project in the '''Desktop''' directory.
 
|| Now save the project in the '''Desktop''' directory.
 +
 
I will use the file name '''regression dot agr'''.
 
I will use the file name '''regression dot agr'''.
  
Line 316: Line 328:
 
|| '''Slide Number 7'''
 
|| '''Slide Number 7'''
 
'''Summary'''
 
'''Summary'''
|| In this tutorial, we,
+
|| In this tutorial we learnt to,
 
* Performed data fitting of a straight line.
 
* Performed data fitting of a straight line.
 
* Added two datasets to a graph panel.
 
* Added two datasets to a graph panel.

Revision as of 11:13, 3 December 2019

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.
  • 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 dialogue 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. The data points look scattered around a straight line.

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 6

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 dialogue 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 accept and click to close. Click on Apply and then click on Close to close the text 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 dialogue box.
Show screenshot of save as dialogue 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 7

Summary

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

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 9

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 10

Spoken Tutorial Project

This video summarizes the Spoken Tutorial Project.

Please download and watch it.

Slide Number 11

Spoken Tutorial workshops

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

For more details, please write to us.

Slide Number 12

Forum for specific questions:

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

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