home *** CD-ROM | disk | FTP | other *** search
- : Prof2d, The 2D Scientific Spreadsheet IBM-PC Version
- : by Gertjan L. Ouwerling, Electrical Materials Lab, Delft University
- : -------------------------------------------------------------------
- : Execute this tutorial by typing: prof2d tutorial.pr2 <enter>
- :
- : NOTE: some steps may be slow without a co-processor!
- : Graphical pictures are terminated by giving <enter>
- : -------------------------------------------------------------------
- :
- : In this tutorial the following subjects are treated:
- :
- : 1. Prof2d on the IBM-PC (and its video adaptor card)
- : 2. Prof2d data structures (variables and data types)
- : 3. Internal generation of data and making graphs
- : 4. Reading and writing data from and to file
- : 5. Escaping to the operating system (on the PC MS-DOS)
- : 6. Integration of 2D data to find a volume
- : 7. Data manipulation (reduction, partial removal, transformations)
- : 8. List of interesting but not demonstrated commands
- :
- :
- :
- pause
- : -------------------------------------------------------------------
- :
- : 1. Prof2d on the IBM-PC (and its video adaptor card)
- :
- : Prof2d runs on (among many computers) IBM-PCs or true compatibles with
- : Hercules, CGA, EGA, VGA or AT&T 6300 (Olivetti) graphics adaptors. It
- : automatically senses which adaptor is present, but sometimes makes a mistake.
- :
- : The command adapt is used to ask which card is sensed and to set another
- : one if this is wrong. If the wrong card is sensed, edit tutorial.pr2 and
- : remove one of the five comment colons (: means comment in Prof2d) below:
-
- : adapt Hercules
- : adapt Olivetti/AT&T
- : adapt CGA
- : adapt EGA
- : adapt VGA
-
- : we will now ask Prof2d what adaptor card it is currently sensing:
-
- adapt ?
- pause
- :
- : 2. Prof2d data structures (variables and data types)
- :
- : Basic data structures of Prof2d are:
- :
- : - integer and real variables (scalar)
- : - horizontal 1D arrays of data (rows)
- : - vertical 1D arrays of data (columns)
- : - 2D arrays of data (fields)
- :
- : Most data structures must be declared before using with the commands
- : var, row, column and field.
- :
- : However, some variables and rows and columns are present by
- : default and need not be declared. Most notable examples are:
- :
- : -> integer variable nx, active number of elements in rows
- : -> integer variable ny, active number of elements in columns
- : -> row xcount, counts from 0 to nx-1
- : -> column ycount, counts from 0 to ny-1
- :
- :
- pause
- :
- : We will now declare some data structures to be used further. Later
- : on we will declare some more (this is always possible).
-
-
- var int nx1 ny1 $
- row x1 $
- column y1 $
- field gauss $
-
- : Declarations end in $ to indicate the end of the argument list.
- : Currently, the maximum field dimension is 64x64 elements (IBM-PC).
-
- pause
- :
- : 3. Internal generation of data and making graphs
- :
- : Prof2d accepts either commands (such as adapt or field) or
- : mathematical expressions containing variables, data types and constants.
- : If an = sign is present, assignment is made. Otherwise the result is
- : printed. Some much used constants are present by default, for example
-
- pi
-
- : The default row and column xcount and ycount may be used for
- : data generation. A 2D gaussian (normal distribution) is synthesized
- : by using the default row xcount and column ycount:
-
- nx = 21
- x1 = -2.0 + 4.0*xcount/(nx-1)
- ny = 21
- y1 = -2.5 + 5.0*ycount/(ny-1)
- : This may take a while!
- gauss = exp(-(x1*x1+y1*y1))
-
- pause
-
- : The cview command may be used to make a contour plot on the screen
- : of the data. The default number of contours is 10, and they run between
- : 10% and 90% of the interval that the viewed field spans.
- :
- : The number of contours can be specified by the (default) integer variable
- : ncont. We will do only 5 contours (to save computation time on PCs without
- : a mathematical coprocessor).
- :
- : After completion, give <enter> to leave the picture.
-
- ncont = 5
-
- pause
- cview x1 y1 gauss
-
- : Some Prof2d variables choose the region of the contour plot:
- :
- : nxs (starting x mesh line) if nxs >= nxe, the whole row is used
- : nxe (ending x mesh line)
- : nys (starting y mesh line) if nys >= nye, the whole column is used
- : nye (ending y mesh line)
- :
- : Naturally, the contour plot also depends on the row and column used!
- : A small demonstration is given by perturbing x1 and y1 and
- : selecting part of the field region to be plotted.
-
-
- row x2 $ column y2 $
- x2 = sqrt(x1+2.0)
- y2 = 0.05*sgn(y1)*(y1*y1)
-
- nxs=8
- nxe=16
-
- : remember to finish the cview with <enter>
-
- pause
- cview x2 y2 gauss
-
- : the default full region contour plotting is restored:
-
- nxs=nxe
-
- : other possibilities of cview are:
- :
- : - use default row xmesh and default column ymesh to select mesh lines
- : to be shown in the picture (with the assign command)
- :
- : - use command setcont to select contour values to be used by hand
- :
- : Please read the cview, assign and setcont manual pages to find out
- : more about this (with the help command).
- :
-
- pause
-
- : 1D Cross Sections through a field with view.
- : -------------------------------------------
- :
- : The view command makes 1D cross-sections through a 2D data field
- : along either a selected row or a selected column. By default, up to
- : 10 lines are selected for cross-sectioning in one graph.
- :
- : The default row xplot and column yplot can be used to assign cross-
- : section lines to be used. Here we use assign to view the first 8
- : horizontal cross sections.
- :
- : View commands are also ended by <enter>.
-
- assign yplot 1 1 2 1 3 1 4 1 5 1 6 1 7 1 8 1 $
- pause
- view x1 gauss
-
- : In fact, the Prof2d view command was directly derived from the Profile
- : view command (Profile is the 1D scientific spreadsheet and optimizer,
- : also available in the Public Domain). The use of the (again present by
- : default) scaling variables xls, xrs, yus and yls is explained in the
- : view manual page and in the Profile tutorial.
-
- pause
- :
- : Now, using the expression evaluation capabilities of Prof2d, we will
- : produce a so called 'Schmoo' plot of our Gaussian field.
- : The built-in function pos(x) returns 1 if x > 0, otherwise it returns 0.
- : A formula is defined and remembered with the define command.
-
- field s t $
- var real c1 c2 c3 c4 c5 $
-
- define schmoo=pos(t-c1)+pos(t-c2)+pos(t-c3)+pos(t-c4)+pos(t-c5)
-
- c1=0.1
- c2=0.3
- c3=0.5
- c4=0.7
- c5=0.9
-
- t=gauss
- s=schmoo
-
- : the plot is produced by evaluating the very simple expression 's'
-
- pause
- s
- pause
-
- :
- : 4. Reading and writing data from and to file
- :
- : Of course, often you will use Prof2d to view or transform externally
- : generated or measured data.
- :
- : Prof2d has two formats in which it can read and write data:
- :
- : 1. The list format (commands get & put)
- : 2. The matrix format (commands mget & mput)
- :
- : In the list format, you can read or write more than 1 field at the time:
- :
- : x(i) y(j) z1(i,j) z2(i,j) z3(i,j) ..... (one line from a file)
- :
- : In the matrix format, only one field can be filed, optionally together
- : with a row and column. Give <help formats> for more detailed information.
- :
- : We will now put a file in list format and then read back its contents
- : into different rows, columns and fields.
-
- pause
-
- : reduce number of lines a little ...
- nx=5
- ny=4
-
- put tutor.dat x1 y1 gauss s $
-
- get tutor.dat x2 y2 s t $
-
- pause
-
- : 5. Escaping to the operating system (on the PC MS-DOS)
- :
- : Many operating system commands (such as dir and del, etc) can be typed
- : to the Prof2d prompt ("pr2d> ", only shown interactively). They are
- : executed if a command.com file can be loaded by the system.
- :
- : If Prof2d doesn't recognize a command (e.g. because it is not a standard
- : MS-DOS command or one of the DOS commands that is also a Prof2d command),
- : you can use the 'shell escape' sign %
- :
- : An example (typing the data file tutor.dat):
- :
- pause
- % type tutor.dat
- pause
-
- : Now look at the directory and delete our data file tutor.dat:
-
- dir
- del tutor.dat
-
- pause
-
- : Run your application program (e.g. in development) from Prof2d
- : and use the Prof2d history mechanism to rapidly see your results:
- :
- : % myprog mydata.in : execute the external program MYPROG
- : get myprog.out x y z $ : read output from MYPROG
- : cview x y z : look at output
- : % edit mydata.in : change input for myprog with your editor
- : % myprog mydata.in : re-run the external program MYPROG
- : !get : repeat the last line starting with 'get'
- : !cvi : repeat the last line starting with 'cvi'
- : .... etc
-
- pause
-
- : 6. Integration of a field to find the volume below a surface.
- :
- : Prof2d offers a facility for numerical integration. This command uses
- : a 2D trapezium derived by integration of the bilinear approximation
- : of the 2D function on each mesh rectangle.
- :
- : The gaussian is integrated over the entire region. This should yield
- : a volume of Pi (apart from discretisation error and error due to the
- : finite integration area).
-
- : Reset number of lines from get/put demonstration
- nx=21
- ny=21
-
- : Real variable to contain the volume and integration by command inte2d
- var real volume $
- inte volume x1 y1 gauss
-
- : Print result and compare with Pi
- volume
- volume/pi
-
- pause
-
- : 7. Data manipulation (reduction, partial removal, transformations)
- :
- : One of the applications of the Prof2d (and also the Profile) package
- : is the manipulation of data to bring it in another form, e.g. conversion
- : of the output from one program to the input of the next program.
- :
- : Prof2d offers several possibilities for data manipulation:
- :
- : - expression evaluation to compute and create new data; use of the pos(),
- : neg() and pls() functions to select only part of a data field to be used;
- : - getting data in list format and putting it in matrix format, or vice versa;
- : - reduction of the number of data elements in the x- and/or the y-direction
- : with the commands redx and redy;
- : - partial removal of data with the commands remx and remy;
- : - mirroring a data field (with a row or column) in the x- or y-axis
- : with the command mirror;
- : - transposing a data field (and optionally interchanging a row with a
- : column) with the command transpose.
- :
- :
- : Not everything can be demonstrated here. One small example:
- :
- pause
- :
- : The middle horizontal section of the gaussian is removed and
- : the result is looked at:
-
- var int nstart nend $
- nstart = ny/2 -1
- nend = ny/2 +2
- remy nstart nend
-
- pause
- cview x1 y1 gauss
-
- : Gauss is transposed together with x1 and y1 and re-cviewed
- : Note that x1 and y1 are interchanged (x1 has become a column, y1 a row)
-
- show rows
-
- transpose x1 y1 gauss
-
- show columns
-
- pause
- cview y1 x1 gauss
-
- :
- : ------------------------------------------------------------------
- :
- : This completes the Prof2d tutorial introduction.
- :
- : Many things were not treated. Some omissions are the cplot and plot
- : commands to create contour and cross section plots with an HP7550A or
- : HP7475 pen plotter, and the bget and bput commands to read and create
- : data files in binary format.
- :
- :
- : Please continue playing a little with Prof2d and use
- :
- : - help <command> for help on a specific command
- : - help help for a list of all help pages
- : - show for a list of variables and data structures in use
- : - history or h for a list of recently given commands (to be repeated)
- :
- : Note that Prof2d runs on UNIX and VAX/VMS computers as well. Give
- : help public to read Copyright information and find the address to
- : apply for a licence agreement to obtain the source code (in C).
- :
- : Give <quit enter> to leave Prof2d.
- :
-