1
/*===========================================================================
2
Copyright (C) 1993-2009 European Southern Observatory (ESO)
4
This program is free software; you can redistribute it and/or
5
modify it under the terms of the GNU General Public License as
6
published by the Free Software Foundation; either version 2 of
7
the License, or (at your option) any later version.
9
This program is distributed in the hope that it will be useful,
10
but WITHOUT ANY WARRANTY; without even the implied warranty of
11
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
GNU General Public License for more details.
14
You should have received a copy of the GNU General Public
15
License along with this program; if not, write to the Free
16
Software Foundation, Inc., 675 Massachusetss Ave, Cambridge,
19
Corresponding concerning ESO-MIDAS should be addressed as follows:
20
Internet e-mail: midas@eso.org
21
Postal address: European Southern Observatory
22
Data Management Division
23
Karl-Schwarzschild-Strasse 2
24
D 85748 Garching bei Muenchen
26
===========================================================================*/
28
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
30
.AUTHOR R.M. van Hees IPG-ESO Garching
31
.KEYWORDS low level plot routine
33
.PURPOSE Overplot error bars from one or two columns of a TABLE
34
input: int tid Table identifier
35
int nrow number of rows
37
int *ilog logarithm flag: 0) Lineair, 1) LOG10, 2) LN
38
int loc orientation of the error bar:
39
1) pos X, 3) neg X, 5) both
40
2) pos Y, 4) neg Y, 6) both
41
char *bar cross bar (y) or not (n)
44
.ENVIRONment MIDAS and AGL
45
#include <agl.h> Prototypes for AGL application programs
46
#include <midas_def.h> Prototypes for MIDAS interfaces
47
#include <plot_def.h> Symbols used by the PLT interfaces
49
.VERSION 1.1 10-Sep-1993 FORTRAN --> ANSI-C RvH
52
------------------------------------------------------------*/
54
* Define _POSIX_SOURCE to indicate
55
* that this is a POSIX program
57
#define _POSIX_SOURCE 1
60
* definition of the used functions in this module
66
#include <midas_def.h>
69
* define some macros and constants
74
* here start the code of the function
76
void PLERR( tid, nrow, col, ilog, loc, bar )
78
int tid, nrow, *col, *ilog, loc;
81
register int ii, jj, nc;
82
int actvals, isel, inull, ltype, nopoint, stat;
84
float xmin, ymin, xerr, yerr, xbar[2], ybar[2], xval[2], yval[2],
85
xn[2], yn[2], xch[3], ych[3], pval[3], wcfram[8];
90
* pick up the frame settings
92
PCKRDR( "XWNDL", 4, &actvals, wcfram );
93
PCKRDR( "YWNDL", 4, &actvals, wcfram+FOR_Y );
95
xmin = MYMIN( *wcfram, wcfram[1] );
96
ymin = MYMIN( wcfram[FOR_Y], wcfram[FOR_Y+1] );
99
* initialise plot settings to normal
101
(void) AG_IGET( "lstyl", <ype );
102
AG_SSET( "lstyl=0" ); /*set line style to solid*/
104
AG_TGET( "M", xch, ych );
108
for ( ii = 1; ii <= nrow; ii++ )
110
stat = TCSGET( tid, ii, &isel );
114
* pick up the values for resp. X-pos, Y-pos, Error bar:
116
for ( nc = 0; nc < 3; nc++ )
117
{ if ( col[nc] == 0 )
119
else if ( ! nopoint )
120
{ stat = TCERDR( tid, ii, col[nc], pval+nc, &inull );
121
if ( inull || stat != ERR_NORMAL ) nopoint = TRUE;
124
if ( pval[2] < 0.0 ) pval[2] *= -1;
128
{ case 1: /* error bars in pos. X */
130
xval[1] = *pval + pval[2];
131
yval[0] = yval[1] = pval[1];
133
case 3: /* error bars in neg. X */
135
xval[1] = *pval - pval[2];
136
yval[0] = yval[1] = pval[1];
138
case 5: /* two error bars in X dir. */
139
xval[0] = *pval - pval[2];
140
xval[1] = *pval + pval[2];
141
yval[0] = yval[1] = pval[1];
143
case 2: /* error bars in pos. Y */
144
xval[0] = xval[1] = *(pval);
146
yval[1] = pval[1] + pval[2];
148
case 4: /* error bars in neg. Y */
149
xval[0] = xval[1] = *(pval);
151
yval[1] = pval[1] - pval[2];
153
case 6: /* two error bars in Y dir. */
154
xval[0] = xval[1] = *(pval);
155
yval[0] = pval[1] - pval[2];
156
yval[1] = pval[1] + pval[2];
159
if ( ! nopoint && ilog[0] != 0 ) /* log. X-values */
160
{ if ( xval[1] > 0.0)
161
{ if ( xval[0] <= 0) xval[0] = xmin;
162
for ( jj = 0; jj < PLDIM2; jj++ )
163
{ if ( xval[jj] > 0.0)
166
xval[jj] = (float) log10( xval[jj] );
168
xval[jj] = (float) log( xval[jj] );
176
if ( ! nopoint && ilog[1] != 0 ) /* log. Y-values */
177
{ if ( yval[1] > 0.0)
178
{ if (yval[0] <= 0) yval[0] = ymin;
179
for ( jj = 0; jj < PLDIM2; jj++ )
183
yval[jj] = (float) log10( yval[jj] );
185
yval[jj] = (float) log( yval[jj] );
193
* check on logarithmic axes settings
196
{ if ( xval[1] <= 0 )
198
else if ( *xval <= 0 )
199
{ if ( CGN_NINT( wcfram[3] ) == -1 )
200
*xval = (float) pow( 10.0, xmin );
202
*xval = (float) exp( xmin );
205
if ( wcfram[FOR_Y+3] < 0 )
206
{ if ( yval[1] <= 0 )
208
else if ( *yval <= 0 )
209
{ if ( CGN_NINT( wcfram[FOR_Y+3] ) == -1 )
210
*yval = (float) pow( 10.0, ymin );
212
*yval = (float) exp( ymin );
220
{ AG_GPLL( xval, yval, 2 );
224
if ( *bar == 'y' || *bar == 'Y' )
227
AG_VU2N( xval[0], yval[0], xn, yn );
230
*(yn+1) = *yn + yerr;
231
AG_VN2U( *xn, *yn, xbar, ybar );
232
AG_VN2U( *(xn+1), *(yn+1), xbar+1, ybar+1 );
233
AG_GPLL( xbar, ybar, 2 );
236
AG_VU2N( xval[1], yval[0], xn, yn );
239
*(yn+1) = *yn + yerr;
240
AG_VN2U( *xn, *yn, xbar, ybar );
241
AG_VN2U( *(xn+1), *(yn+1), xbar+1, ybar+1 );
242
AG_GPLL( xbar, ybar, 2 );
245
AG_VU2N( xval[0], yval[0], xn, yn );
247
*(xn+1) = *xn + xerr;
249
AG_VN2U( *xn, *yn, xbar, ybar );
250
AG_VN2U( *(xn+1), *(yn+1), xbar+1, ybar+1 );
251
AG_GPLL( xbar, ybar, 2 );
254
AG_VU2N( xval[0], yval[1], xn, yn );
256
*(xn+1) = *xn + xerr;
258
AG_VN2U( *xn, *yn, xbar, ybar );
259
AG_VN2U( *(xn+1), *(yn+1), xbar+1, ybar+1 );
260
AG_GPLL( xbar, ybar, 2 );
268
{ (void) sprintf( buff, "lstyl=%1d", ltype );