A colloquial plotting package to realize scientific diagrams

A colloquial plotting package to realize scientific diagrams

Computer Physics Communications North-Holland, Amsterdam A COLLOQUIAL 53 38 (1985) 53-60 PLOTTING PACKAGE TO REALIZE SCIENTIFIC DIAGRAMS * R...

469KB Sizes 5 Downloads 121 Views

Computer Physics Communications North-Holland, Amsterdam

A COLLOQUIAL

53

38 (1985) 53-60

PLOTTING

PACKAGE

TO REALIZE SCIENTIFIC

DIAGRAMS

*

R. POTENZA and C. TUVk Dipartimento Received

di Fisica, Universita di Catania, Corso Italia, 57, I 95129 Catania, Italy

9 October

PROGRAM

1984; in revised form 3 January

1985

SUMMARY Number of lines in combined program and test deck: 1915

Title of program: PLO Catalogue number:

AABQ

Keywords:

general,

graph,

linear-linear,

lin-log,

log-Iin,

Iog-

log Program obtainable from: CPC Program Library, Queen’s University of Belfast, N. Ireland (see application form in this issue) Computer: of Catania

PDP11/44 Digital; Section of INFN

Installation:

Computer

Centre

language used: FORTRAN

77

Restriction on the complexity of the program The only restriction on the program is the number be plotted which has a maximum of 360.

No. of bits in a word: 16 Overlay structure: yes Peripherals used: Tektronix 4113 Graphic colour Tektronix 4632 Hardcopy, Tektronix 4663 Plotter

* Work supported

in part by INFN

of scientific

Method of solution A sequence of subroutines is developed which is based on the Terminal Control System software package for linear-linear, Iin-log, log-lin, log-log plotting.

Operating system: RSX 11M V.4.0 Programming

Nature of the physical problem This program is concerned with the visual display plots.

terminal,

Typical running time Depending on the operator’s

and CRRNSM.

0010~4655/85/$03.30 0 Elsevier Science Publishers B.V. (North-Holland Physics Publishing Division)

ability.

of points

to

R. Potenra, C. TUVE?/Plotting package for scientific diagrams

54

LONG WRITE-UP 1. Introduction

The computer program described here allows one to draw and compare scientific plots on Cartesian coordinate systems with different types of scales, that is linear-linear, log-lin, lin-log or log-log ones. The main feature of this program is that it is entirely colloquial and in this it differs from similar programs already running at the University of London [l] and at the Centre de Recherches Nucleaires of Strasbourg [2]. The program itself can be used as a subroutine of any other FORTRAN program with no difficulty. The essential function of the program is to construct the coordinate axes upon which the results may be drawn, and to draw these results using user’s answers to the questions posed by the program itself. This program was realized at the Computer Centre of the Catania Section of INFN, which includes a Tektronix 4113 Graphic colour terminal connected to a PDP 11/44 Digital computer, a Tektronix 4632 Hardcopy and a Tektronix 4663 Plotter. As graphic subroutines package we have utilized the Terminal Control System software package realized by Tektronix Inc. Due to the smallness of the Tektronix 4113 memory (96 K) it is connected to the PDP11/44 (512 K), on which our program is stored. The second section of this paper describes the architecture of the graphic program. Sections 3 and 4 report the description of the main program PLO with its subroutines. These are divided into external and internal (that is already contained in the TCS) subroutines. Section 5 gives the results found in some characteristic examples.

the data communications line with the 4113 terminal. The graphic subroutine packages include: 1) High-level graphics routines, which carry out drawing, translations and rotations. 2) Device driving routines which depend on the different output devices to be used (display terminal, plotter, etc.). 3) Communication between routines which drive the interface between the host computer and the 4113 terminal. The program defines the segmentation of the drawing, calling the necessary subroutines. In fact, in the logic of the TCS a picture segment is a graphic object, or a part of it, that can be handled as a single entity by the commands at the terminal. Each segment is referenced by its name, which is a number in the range from 1 to 32767. When a segment has been defined, it may be only deleted and redefined if we wish to change its internal structure.

3. Description of the code The main program, PLO, directs the setting up of the graphs using the subroutines RIQUAD and DISCUR, which in turn call, respectively, the subroutines GRID and SPOS. It then calls, if requested, the subroutine WRITE to draw titles. Both the main PLO and the subroutines are addressed to the different options by the user’s answers to the questions posed during the execution. 3.1. The main program PLO This calls the subroutines which construct the drawing, assigning to it the right dimensions.

2. Architecture of the program The program PLO consists of a main program which calls some graphic subroutines of the Terminal Control System (TCS). In turn, the TCS communicates through the host computer software and

3.2. RIQUAD This is the central subroutine to construct the coordinate axes in which the curves will be drawn by DISCUR. The choice of the type of coordinate axes, the number of sectors which divide the axis

R. Potenra, C. Tuvs?/ Plotting package for scientific diagrams

x, the number of the intervals in a linear axis (either x or y) and the number of decades in a logarithmic axis (base 10) (either x or y) depend on user’s answers to questions posed by this subroutine. The markers are placed at each chosen interval on the coordinate lines. Calling sequence CALL RIQUAD (LSE’IT, NDX, NDY, NSUDX, NSUDY, IPAR, NSEGI) All the parameters other than NSEGl are given by user’s answers. LSETT number of sectors which divide the display along the x axis, to draw different adjacent plots. NDX refer to the logarithmic scale on the x or NDY y axis, respecitvely. Number of logarithmic decades in each sector, the same for all the sectors. NSUDX refer to the linear scale on the x or y NSUDY axis, respectively. Number of intervals in each sectors, the same for all the sectors. index concerning the type of Cartesian IPAR coordinate axis 1 x log y lin 2 x lin y log 3 x log y log 4 x lin y lin NSEGl number which references the segment corresponding to the coordinate axes themselves. All the drawing of the interval markers of the coordinate axes constitutes one segment in the sense given in section 2. GRID

Subroutine called by RIQUAD. Its essential function is to draw the coordinate axes with markers. Calling sequence CALL GRID (L, JX, I, JY, JSX, IK, JJ, AX, AY, IPAR, NSUDX, l$SUDY)

55

IPAR as for RIQUAD NSUDX NSUDY j progressive number of decades I in /v \ logarithmic scales maximum number of decades JY in y number of sectors in x JSX number of intervals in x IK linear scales number of intervals in y ) JY maximum value of virtual fixed and given AX window in x and y AY 1 by RIQUAD L progressive number of the logarithmic decades in x scales maximum number of decades JX in x I 3.3. DISCUR DISCUR draws: 9 the theoretical curves, connecting each two successive points of the tabulated curves by a line. ii) The experimental results, as markers of different types with or without error bars in x and/or y directions. These markers can be bound by a line depending on the user’s choice. The types of lines of markers are chosen by the user from those displayed by the computer when it poses the appropriate questions. DISCUR allows, calling SPOS (see later), the shift of each drawn plot towards the bottom of the y axis, to compare different results in the same x sector. Calling sequence CALL DISCUR (X, Y, ERRORX, ERRORY, IPAR, ICC, AXMAX, AYMIN, AYMAX, NSUDY, XMIN, XMAX, YMIN, YMAX) IPAR NSUDY X Y

ERRORX

as for RIQUAD array of the data (x and y are the coordinates of the input points). These arrays are tabulated in the input file. array of errors in x and in y, tabu-

R. Potenra, C. TuvP/ Plotting package for scieniific diagrams

56

ERRORY ICC AXMAX

lated in the input file together with the points number of points in the array virtual maximum value in the scale of each sector of the x axis to allow the entire plot to enter in the terminal screen the same for the y axis

AYMIN AYMAX minimum and maximum value of the XMIN x coordinate of the data XMAX YMIN the same for the y coordinate of the YMAX data XMIN, XMAX, YMIN, YMAX are chosen by the user. SPOS SPOS is called by DISCUR. Its function is to shift the drawing along the y axis towards the bottom. Calling sequence CALL SPOS (IPAR, Y, AYMIN, NSUDY, ERRORY, NDEC, ICC)

IPAR Y AYMIN AYMAX NSUDY ERRORY ICC : NDEC

AYMAX,

given by DISCUR

number of shifted decades, chosen by the user.

3.4. WRITE

4. Internal subroutines

4.1. LOGTRN,

They are called by RIQUAD and define either the x or y axis or both as logarithmically or linearly scaled, respectively. A logarithmic or linear window is, respectively, assumed for all TCS routines called after these. 4.2. BEGSEG, ENDSEG,

DELSEG,

NEWPAG

These routines are called by the main program and by the subroutine RIQUAD, respectively. The first three assign the new segment number or close the segment or delete it, respectively. The fourth deletes the whole page. 4.3. D WIND0 DWINDO which is called by RIQUAD or by the main program defines the virtual window for the data and connects the virtual space with the display terminal. Graphic lines and portions of lines which lie outside the virtual window are automatically eliminated or clipped by the graphic routines, while those which lie inside the window are fitted appropriately on it. 4.4. TWINDO TWINDO is called in sequence after DWINDO and defines the rectangular portion of the screen which can be used as display area. The display boundaries are to be chosen bearing in mind that one must leave space in the screen for the dialogue area. 4.5. MOVEA,

This subroutine writes by means of GTOTST any alpha-numeric string in the dimension (GTSIZE), colour (TXTIND) and place (MOVABS) selected by means of cursors called by GIN. The string may be rotated (GTROT) and/or shifted.

LINTRN

DRA WA, POINTA

These are graphic routines and are called in the alternative sequences MOVEA, POINTA or MOVEA, DRAWA. The first sequence draws points, the second one straight lines when initial and final coordinates are given.

R. Potenra, C. TI&/

4.6. MOVER,

DRA WR

The sequence MOVER, DRAWR allows one to draw straight lines when initial coordinates and lengths of them are given.

continuum . ..... _._._.

3 4 5

______ --_..._...

I

.

16 -

r-r-nnn

.

..111...

.

STOPPING

.

.l-rwwl

.I.

. . . .

____

7

---

MRKTYP chooses the type of marker for the points. The correspondence between the value of the argument and the type of marker is as follows: 0 a dot (single point) 1 the period character 2 a plus sign 3 an asterisk 4 the letter 0 5 the letter x 6 a square 7 a diamond 8 a square with a dot in its centre 9 a diamond with dot in its centre 10 a square with diagonals

DASHA is analogous to DRAWA, but it plots a dashed line, and has a third argument which controls the type of dashed line displayed. The value of this argument and the corresponding type of line are as follows:

2

6

4.8. MRKTYP

4.7. DASHA

0 1

5-l

Plotting package for scientific diagrams

I

.

.

. . ..I.

POWER

.

m.1.

. .. .

STOPPING

.

.

.

. . . . ..

.

..m

POWER

t Z,=l

u)

(HI

2,=6(C)

Z,-l(H)

__

Z,-l(H)

a

-0 .-8

0

L 1 1 *~~fi~.. * 1 -a**1

10’

10

’ ’ .LLYU ’ ’ . . . ...I 10’

10’1

E(KeU) Fig. 1. Logarithmic-linear

plot.

’ “““‘D

’ “““‘1 10

’ ’ ““*a. ld

ld

_

R. Potenra, C. Tuuk/ Plotting pockoge for scienfific diagrams

58 4.9.

1 2 3 4 5 6 7

5. I. Logarithmic-linear plot

LININD LININD chooses the colours following white red green blue cyan magenta yellow

Fig. 1 shows the stopping power vs. energy of H on C and H on H including the electronic and nuclear contributions [3].

the code:

5.2. Linear-logarithmic plot Fig. 2 shows the cross-sections for the transfer of one proton or of one neutron, respectively, in the reactions 34S + 32S + “P -I-“Cl and 34S + 32S + 33S f 3.7S for different Q-values of the reactions

5. Examples

t41.

We give now some examples, one for each combination of scales, with comparison among various curves in each figure. The examples are taken from different fields of physics.

5.3. Logarithmic-logarithmic plot The free nucleon densities vs. temperature in MeV are shown (fig. 3) for protons’ and for neuI

1

I

34s+3%-Jp ‘Lab _A

a

30

60

90

= Y u I-Ie

1

TH(cm1 Fig. 2. Linear-logarithmic

plot.

1

I

I

+35c 1

.

.

.

R. Potenza, C. Tuv~/ Plotting package for scientific diagrams

59

10’ 1

T(MeU) Fig. 3. Logarithmic-logarithmic

plot.

trons emitted from nuclear regions exploding light clusters in heavy ion collisions [5]. 5.4. Linear-linear

into

plot

The reflection coefficient q, as a function of orbital angular momentum is shown (fig. 4) on the

left side with, on the other side, the corresponding deflection function 0, for the reaction 34S + 32S + ‘jS +-“S [4,6]. It is noted that the y-scales are different for the two sectors. This possibility is included in the program PLO. In fact, for the sectors following the first one it is possible also to multiply their scale by an arbitrary factor.

R. Potenro, C. Tue.+/ Plotting package for scientific diogroms

60

E

Lob

=SOMeU

- 90

-J

F W

- 60

- 30

,,‘I/ 0

h-_

a,,,

30

Fig. 4. Linear-linear

60

. . . . . 90

120

.I...,....,,,,,,,,.10

..a

150

L

il

1

3o

6o

90

120

150

plot.

Acknowledgements The authors wish to acknowledge Mr. E. Cangiano and Mr. G. Sava for their assistance at the computer and the authors of refs. [3-61 for their kindness in suppling the data for the examples.

References [I] J. Anderson and K.J.M. mun. 9 (1975) 85.

Moriarty,

Comput.

Phys.

Com-

[2] B. Bilwes and R. Bilwes, CRNS Report 1980, CRN 81-01, Strasbourg (1981). [3] H.H. Anderson and J.F. Ziegler, The Stopping and Ranges of Ions in Matter, vol. 3 (Pergamon, London, New York, lQll\

-” “’

[4] B. Bilwes, R. Bilwes, V. D’Amico, J.L. Ferrero, G. Giardina and R. Potenza, Nucl. Phys. A408 (1983) 173. [5] S. Albergo, S. Costa, E. Costanzo and A. Rubbino, Contribution to Ital. Sot. Phys. Conf., Genova (1984) and private communication. [6] R. Potenza, private communication.