des_coef.C

00001 /* Basic routine for plot of spectral coefficients.
00002  *
00003  * (see file graphique.h for the documentation).
00004  */
00005 
00006 /*
00007  *   Copyright (c) 1999-2001 Eric Gourgoulhon
00008  *
00009  *   This file is part of LORENE.
00010  *
00011  *   LORENE is free software; you can redistribute it and/or modify
00012  *   it under the terms of the GNU General Public License as published by
00013  *   the Free Software Foundation; either version 2 of the License, or
00014  *   (at your option) any later version.
00015  *
00016  *   LORENE is distributed in the hope that it will be useful,
00017  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00018  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019  *   GNU General Public License for more details.
00020  *
00021  *   You should have received a copy of the GNU General Public License
00022  *   along with LORENE; if not, write to the Free Software
00023  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00024  *
00025  */
00026 
00027 
00028 char des_coef_C[] = "$Header: /cvsroot/Lorene/C++/Source/Non_class_members/Graphics/des_coef.C,v 1.3 2008/08/19 06:42:00 j_novak Exp $" ;
00029 
00030 
00031 /*
00032  * $Id: des_coef.C,v 1.3 2008/08/19 06:42:00 j_novak Exp $
00033  * $Log: des_coef.C,v $
00034  * Revision 1.3  2008/08/19 06:42:00  j_novak
00035  * Minor modifications to avoid warnings with gcc 4.3. Most of them concern
00036  * cast-type operations, and constant strings that must be defined as const char*
00037  *
00038  * Revision 1.2  2002/10/16 14:36:57  j_novak
00039  * Reorganization of #include instructions of standard C++, in order to
00040  * use experimental version 3 of gcc.
00041  *
00042  * Revision 1.1.1.1  2001/11/20 15:19:29  e_gourgoulhon
00043  * LORENE
00044  *
00045  * Revision 1.2  1999/12/20  10:57:17  eric
00046  * Modif commentaires.
00047  *
00048  * Revision 1.1  1999/12/10  12:14:37  eric
00049  * Initial revision
00050  *
00051  *
00052  * $Header: /cvsroot/Lorene/C++/Source/Non_class_members/Graphics/des_coef.C,v 1.3 2008/08/19 06:42:00 j_novak Exp $
00053  *
00054  */
00055 
00056 
00057 // C++ headers:
00058 #include"headcpp.h"
00059 
00060 // C headers:
00061 #include <math.h>
00062 
00063 // PGPLOT headers:
00064 #include <cpgplot.h>
00065 
00066 //******************************************************************************
00067  
00068 void des_coef(const double* cf, int n, double pzero,
00069           const char* nomx, const char* nomy, const char* title, const char* device, 
00070           int newgraph, int nxpage, int nypage) {
00071 
00072     float xdes[2], ydes[2] ;
00073 
00074     double pzerol = log10(pzero) ; 
00075     ydes[0] = float(pzerol) ; 
00076 
00077     // Figure frame
00078     // ------------
00079 
00080     double xmin = - 1 ; 
00081     double xmax = n ; 
00082     double ymin = pzerol ; 
00083     double ymax = pzerol ; 
00084     
00085     for (int i=0; i<n; i++) {
00086     double yl = log10(fabs(cf[i])) ;
00087     if ( yl > ymax ) ymax = yl ; 
00088     }
00089     double yamp = ymax - ymin ;
00090     ymax = ymax + 0.05 * yamp ; 
00091     ymin = ymin - 0.05 * yamp ; 
00092     
00093     if (ymax <= pzerol) ymax = 2*pzerol ;   // assure que le cadre existe
00094     
00095     // Graphics display
00096     // ----------------
00097 
00098     if ( (newgraph == 1) || (newgraph == 3) ) {
00099 
00100     if (device == 0x0) device = "?" ; 
00101    
00102     int ier = cpgbeg(0, device, nxpage, nypage) ;
00103     if (ier != 1) {
00104     cout << "des_coef: problem in opening PGPLOT display !" << endl ;
00105     }
00106 
00107     }
00108 
00109     // Taille des caracteres:
00110     float size = float(1.3) ;
00111     cpgsch(size) ;
00112     
00113     // Epaisseur des traits:
00114     int lepais = 1 ; 
00115     cpgslw(lepais) ;
00116     
00117     // Fonte axes: caracteres romains:
00118     cpgscf(2) ;
00119 
00120     // Figure frame
00121     float xmin1 = float(xmin) ; 
00122     float xmax1 = float(xmax) ; 
00123     float ymin1 = float(ymin) ; 
00124     float ymax1 = float(ymax) ; 
00125     cpgenv(xmin1, xmax1, ymin1, ymax1, 0, 0 ) ; 
00126     cpglab(nomx, nomy, title) ;
00127     
00128     // Drawing of vertical lines to represent the coefficients
00129     for (int i=0; i<n; i++) {
00130     int lstyle ; 
00131     xdes[0] = float( i ) ;
00132     xdes[1] = xdes[0] ;
00133     if ( fabs(cf[i]) < pzero ) {
00134         ydes[1] = float(pzerol) ; 
00135         lstyle = 1 ; 
00136     }
00137     else {
00138         ydes[1] = float( log10(fabs(cf[i])) ) ;
00139         if (cf[i] < 0) lstyle = 2 ; 
00140         else lstyle = 1 ; 
00141     }
00142     cpgsls(lstyle) ;    // line en trait plein (lstyle=1) 
00143                     //   ou pointilles (lstyle=2)
00144     cpgline(2, xdes, ydes) ; 
00145     }
00146        
00147     cpgsls(1) ;     // restitution de la valeur par defaut 
00148     
00149     // Closing the graphical output
00150     // ----------------------------
00151 
00152     if ( (newgraph == 2) || (newgraph == 3) ) {    
00153     cpgend() ; 
00154     }
00155     
00156 }
00157 
00158 

Generated on Tue Feb 7 01:35:16 2012 for LORENE by  doxygen 1.4.6