00001
00002
00003
00004
00005 #include "cddefines.h"
00006 #include "plot.h"
00007 #include "rfield.h"
00008 #include "parser.h"
00009
00010
00011 STATIC void ParsePlotRangeOption(Parser &p);
00012
00013
00014 STATIC void ParsePlotRangeContin(Parser &p);
00015
00016 void ParsePlot(Parser &p )
00017 {
00018
00019 DEBUG_ENTRY( "ParsePlot()" );
00020
00021
00022 plotCom.nplot += 1;
00023
00024
00025 plotCom.lgPlotON = true;
00026
00027
00028 if( plotCom.nplot > NDPLOT )
00029 {
00030 fprintf( ioQQQ,
00031 " Too many plots; the limit is%3ld This one ignored.\n",
00032 NDPLOT );
00033 plotCom.nplot = NDPLOT;
00034 }
00035
00036 if( p.nMatch(" MAP") )
00037 {
00038
00039 strcpy( plotCom.chPType[plotCom.nplot-1], " MAP" );
00040 }
00041
00042 else if( p.nMatch("CONT") )
00043 {
00044
00045 if( p.nMatch(" RAW") )
00046 {
00047 strcpy( plotCom.chPType[plotCom.nplot-1], "CRAW" );
00048
00049 }
00050 else if( p.nMatch("DIFF") )
00051 {
00052 strcpy( plotCom.chPType[plotCom.nplot-1], "DIFF" );
00053
00054 }
00055 else if( p.nMatch("EMIT") )
00056 {
00057 strcpy( plotCom.chPType[plotCom.nplot-1], "EMIT" );
00058
00059 }
00060 else if( p.nMatch("OUTW") )
00061 {
00062 strcpy( plotCom.chPType[plotCom.nplot-1], "OUTW" );
00063
00064 }
00065 else if( p.nMatch("REFL") )
00066 {
00067 strcpy( plotCom.chPType[plotCom.nplot-1], "REFL" );
00068
00069 }
00070 else if( p.nMatch("PHOT") )
00071 {
00072 strcpy( plotCom.chPType[plotCom.nplot-1], "CPHT" );
00073 }
00074 else
00075 {
00076 strcpy( plotCom.chPType[plotCom.nplot-1], "CONT" );
00077 }
00078 }
00079
00080 else if( p.nMatch("OPAC") )
00081 {
00082 if( p.nMatch("ABSO") )
00083 {
00084
00085 strcpy( plotCom.chPType[plotCom.nplot-1], "OPAA" );
00086 }
00087 else if( p.nMatch("SCAT") )
00088 {
00089
00090 strcpy( plotCom.chPType[plotCom.nplot-1], "OPAS" );
00091 }
00092 else if( p.nMatch("TOTA") )
00093 {
00094
00095 strcpy( plotCom.chPType[plotCom.nplot-1], "OPAT" );
00096 }
00097 else
00098 {
00099
00100 strcpy( plotCom.chPType[plotCom.nplot-1], "OPAT" );
00101 }
00102 }
00103 else
00104 {
00105 fprintf( ioQQQ, " The second keyword on the PLOT command must be CONTINUUM, _MAP, or OPACITY.\n" );
00106 cdEXIT(EXIT_FAILURE);
00107 }
00108
00109
00110 if( p.nMatch("TRAC") )
00111 {
00112 plotCom.lgPltTrace[plotCom.nplot-1] = true;
00113 }
00114 else
00115 {
00116 plotCom.lgPltTrace[plotCom.nplot-1] = false;
00117 }
00118
00119
00120 if( strcmp(plotCom.chPType[plotCom.nplot-1]," MAP") == 0 )
00121 {
00122
00123 ParsePlotRangeOption(p);
00124 }
00125 else
00126 {
00127
00128 ParsePlotRangeContin(p);
00129 }
00130
00131 return;
00132 }
00133
00134
00135 STATIC void ParsePlotRangeOption(Parser &p )
00136 {
00137 bool
00138 lgLogOn;
00139 realnum a;
00140
00141 DEBUG_ENTRY( "ParsePlotRangeOption()" );
00142
00143
00144 plotCom.pltxmn[plotCom.nplot-1] = (realnum)p.FFmtRead();
00145
00146 if( !p.nMatch("RANG") )
00147 {
00148
00149 plotCom.pltxmn[plotCom.nplot-1] = 1.;
00150 plotCom.pltxmx[plotCom.nplot-1] = 9.;
00151 lgLogOn = true;
00152 }
00153 else if( p.lgEOL() )
00154 {
00155
00156 plotCom.pltxmn[plotCom.nplot-1] = 1.;
00157 plotCom.pltxmx[plotCom.nplot-1] = 9.;
00158 lgLogOn = true;
00159 }
00160 else
00161 {
00162
00163 if( plotCom.pltxmn[plotCom.nplot-1] <= 10. )
00164 {
00165 lgLogOn = true;
00166 }
00167 else
00168 {
00169 lgLogOn = false;
00170 }
00171
00172 if( p.nMatch("LINE") )
00173 lgLogOn = false;
00174
00175 plotCom.pltxmx[plotCom.nplot-1] = (realnum)p.FFmtRead();
00176 if( p.lgEOL() )
00177 {
00178 if( lgLogOn )
00179 {
00180 plotCom.pltxmx[plotCom.nplot-1] = 9.;
00181 }
00182 else
00183 {
00184 plotCom.pltxmx[plotCom.nplot-1] = 1e9;
00185 }
00186 }
00187 else
00188 {
00189
00190 if( plotCom.pltxmx[plotCom.nplot-1] <= plotCom.pltxmn[plotCom.nplot-1] )
00191 {
00192 fprintf( ioQQQ,
00193 " The second (maximum) temperature for the map is%10.2e, but this is less than the first (minimum) temperature,%10.2e\n",
00194 plotCom.pltxmx[plotCom.nplot-1], plotCom.pltxmn[plotCom.nplot-1] );
00195 fprintf( ioQQQ, " HELP! I am confused!!\n" );
00196 cdEXIT(EXIT_FAILURE);
00197 }
00198 }
00199 }
00200
00201
00202 if( !lgLogOn )
00203 {
00204 if( plotCom.pltxmx[plotCom.nplot-1] <= 0. || plotCom.pltxmn[plotCom.nplot-1] <=
00205 0. )
00206 {
00207 fprintf( ioQQQ,
00208 " Limits for temperature are negative. This is impossible. Sorry.\n" );
00209 cdEXIT(EXIT_FAILURE);
00210 }
00211 plotCom.pltxmx[plotCom.nplot-1] = (realnum)log10(plotCom.pltxmx[plotCom.nplot-1]);
00212 plotCom.pltxmn[plotCom.nplot-1] = (realnum)log10(plotCom.pltxmn[plotCom.nplot-1]);
00213 }
00214
00215
00216 if( plotCom.pltxmn[plotCom.nplot-1] == plotCom.pltxmx[plotCom.nplot-1] )
00217 {
00218 fprintf( ioQQQ, " Upper and lower plot boundaries are equal.\n" );
00219 cdEXIT(EXIT_FAILURE);
00220 }
00221 else if( plotCom.pltxmn[plotCom.nplot-1] > plotCom.pltxmx[plotCom.nplot-1] )
00222 {
00223 a = plotCom.pltxmx[plotCom.nplot-1];
00224 plotCom.pltxmx[plotCom.nplot-1] = plotCom.pltxmn[plotCom.nplot-1];
00225 plotCom.pltxmn[plotCom.nplot-1] = a;
00226 }
00227
00228 return;
00229 }
00230
00231
00232 STATIC void ParsePlotRangeContin(Parser &p )
00233 {
00234 bool
00235 lgLogOn;
00236 realnum a;
00237
00238 DEBUG_ENTRY( "ParsePlotRangeContin()" );
00239
00240 plotCom.pltxmn[plotCom.nplot-1] = (realnum)p.FFmtRead();
00241
00242 if( !p.nMatch("RANG") )
00243 {
00244
00245 plotCom.pltxmn[plotCom.nplot-1] = (realnum)log10(rfield.emm);
00246 plotCom.pltxmx[plotCom.nplot-1] = (realnum)log10(rfield.egamry);
00247 lgLogOn = true;
00248 }
00249 else if( p.lgEOL() )
00250 {
00251
00252 plotCom.pltxmn[plotCom.nplot-1] = (realnum)log10(rfield.emm);
00253 plotCom.pltxmx[plotCom.nplot-1] = (realnum)log10(rfield.egamry);
00254 lgLogOn = true;
00255 }
00256 else
00257 {
00258
00259 if( plotCom.pltxmn[plotCom.nplot-1] < 0. )
00260 {
00261 lgLogOn = true;
00262 }
00263 else if( plotCom.pltxmn[plotCom.nplot-1] == 0.0 )
00264 {
00265
00266 lgLogOn = false;
00267 plotCom.pltxmn[plotCom.nplot-1] = rfield.emm;
00268 }
00269 else
00270 {
00271
00272 lgLogOn = false;
00273 }
00274
00275
00276 plotCom.pltxmx[plotCom.nplot-1] = (realnum)p.FFmtRead();
00277 if( p.lgEOL() || plotCom.pltxmx[plotCom.nplot-1] == 0.0 )
00278 {
00279
00280 if( lgLogOn )
00281 {
00282 plotCom.pltxmx[plotCom.nplot-1] = (realnum)log10(rfield.egamry);
00283 }
00284 else
00285 {
00286 plotCom.pltxmx[plotCom.nplot-1] = rfield.egamry;
00287 }
00288 }
00289 }
00290
00291
00292 if( !lgLogOn )
00293 {
00294 plotCom.pltxmx[plotCom.nplot-1] = (realnum)log10(plotCom.pltxmx[plotCom.nplot-1]);
00295 plotCom.pltxmn[plotCom.nplot-1] = (realnum)log10(plotCom.pltxmn[plotCom.nplot-1]);
00296 }
00297
00298
00299 if( plotCom.pltxmn[plotCom.nplot-1] == plotCom.pltxmx[plotCom.nplot-1] )
00300 {
00301 fprintf( ioQQQ, " Upper and lower plot boundaries are equal.\n" );
00302 cdEXIT(EXIT_FAILURE);
00303 }
00304 else if( plotCom.pltxmn[plotCom.nplot-1] > plotCom.pltxmx[plotCom.nplot-1] )
00305 {
00306 a = plotCom.pltxmx[plotCom.nplot-1];
00307 plotCom.pltxmx[plotCom.nplot-1] = plotCom.pltxmn[plotCom.nplot-1];
00308 plotCom.pltxmn[plotCom.nplot-1] = a;
00309 }
00310
00311 return;
00312 }