Gsharp in 10 minutes

This document is designed for users who are familiar with graphics packages and want a quick introduction to how Gsharp works. If you require a more thorough introduction please read the Gsharp Tutorial.

Reading Your Data

Gsharp can read a number of different file formats, ASCII or binary.

  • Use the CSV reader for comma separated files output from Excel.
  • For text files with the each dataset in a separate column use the report reader.
  • For more complex text files use the ASCII reader alongside the documentation
  • For binary files use the binary reader
  • Gsharp can read netCDF files.
  • You can also link in your own C and FORTRAN input routines into Gsharp

Read more ...

Data Structures

Gsharp stores data in datasets.
  • Datasets can be one of four types - float, string, date or time. There is no separate data type for integers.
  • Datasets can be of up to 3 dimensions - single values (0D), columns or rows (1D), grids (2D) or blocks (3D) (there are no graph types that plot 3D blocks of data - but it is possible to take slices of a block and plot them together).

Read more ...

Data Processing

There are hundreds of functions for processing your data. Each one works on whole datasets at a time. e.g. x2 = sin(x) will create an array called x2 containing the sine of every element in x and
diffgrid = grid1 - grid2 will create a grid called diffgrid containing the differences between corresponding values in grid1 and grid2.

You can either enter commands on the command line or use the Gsharp Script Language (GSL) to make an algorithm for reading and processing your data. e.g.

filename = input_file("Select data file");
import_report(filename);
gridx = range(T1,20);  gridy = range(T2,20);
grid = bilinear(T1, T2, T3, gridx, gridy);

Datasets can be organized into folders. A folder is created like so:

create Folder WORK2;

and you can change the current folder using

scope WORK2;

Plotting Your Data

Each Gsharp plot is made up of objects. There are ten object types in total - page, viewport, domain, graph, axis, legend, note, arrow, title and logo.

Each object belongs to another object. e.g. a title must belong to a viewport. If a viewport is moved or resized then all the objects that belong to that viewport are moved or resized with it. The full hierarchy of objects is as follows:

The object toolbar (below the canvas) has icons for each of the objects that you can create. Click on the viewport icon now and drag out a rectangle on the canvas where you would like your viewport to appear.

Every object in Gsharp has a number of resources that control how the object should appear. For example the viewport has resources which control its position, its background color and its frame attributes. You can edit the resources using the resource editors. Double click on the viewport and its resource editor will appear.

Here you can see that the first diagonal point and the second diagonal point have already been set. These were set when we dragged out the position of the viewport using the mouse. If a resource is followed by a button that looks like this then you can click on the button to see more choices. Set the background color of the viewport to be orange and the frame width to be 0.1. Click on OK. You can create as many viewports as you like.

The Hierarchy Browser

The Hierarchy Browser gives an overview of the objects that you have created. You can see it either by clicking on its icon in the command toolbar or by selecting Hierarchy Browser from the Tools menu. You can select an object by clicking on it in the canvas or by clicking on its icon in the browser. You can also edit an object using the popup menu of the browser.

When you create a new object you must first select the object that you would like it to belong to. Make sure that your viewport is selected and then create a Title. The title belongs to the selected viewport and will move around with the viewport.

The Domain object

The domain object is a container for graphs. You can have multiple graphs within a domain and they will all use the axis limits specified by the domain. The domain also contains resources such as graph clipping and graph stacking and controls the
classes and colours used by all contour plots within the domain. You can have multiple domains in the same viewport.

Create a domain in your viewport. A set of axes will appear. Four axes and a legend are automatically created with every domain. By default only one x-axis and one y-axis is enabled. The easiest way to enable the other axes and the legend is from the browser.

Now create a graph inside your domain. Set the desired graph type and then select the datasets by clicking on the Data tag. Each of the resources that takes a dataset (X, Y etc. ) is followed by a which brings up a list of all datasets of the appropriate type and dimension. If you haven't read any data you can experiment now by using a function such as "rnd(10)" - 10 random numbers.

Saving your work

The graph you have created can be saved using the Gsharp Script Language (GSL). Click on the save button and specify the name of your GSL Script. If you would like to view the GSL commands bring up the ScriptBuilder from the Tools menu and then choose Generate GSL from its Tools menu.

The saved script only includes the graphics. If you start Gsharp again you will need to read your data again before opening the GSL script containing your plot. There are several ways to get your data back into Gsharp.

  1. Before quiting Gsharp archive your data into a folder file and then read it back in again
  2. Read it again as you did before. You may also need to process and interpolate your data again.
  3. Write a GSL script to read, process and interpolate your data (as described above in the Data Processing section) and then execute your script to create the graphics. e.g. readAreaData.gsl:
filename = input_file("Select a width/height data file");
if (filename=undef)  stop;
import_report(filename);
area = width * height;
exec("makeAreaPlot.gsl");

When you want to read your data next time open this master script not your graphics script. Gsharp will then read your data and plot it for you. If you change the plot - save it again in makeAreaPlot.gsl

What we haven't covered

Gsharp is a very versatile product. GSL can be used to fully configure the interface to your liking and to create new functions for processing or reading your data. It's even possible to design your own application using GSL with your own menus, your own data readers, graphical templates and dialogs. You can use the Gsharp Web Edition to dynamically generate your plots on a web server. There are examples of all these in the example directory.

Learning more

  • There are numerous examples available in the Example menu for you to learn some of the graphical possibilities of Gsharp

  • The tutorial is a more thorough introduction to Gsharp

  • The technical support option of the Help menu contains a list of people waiting to help you.