00001
00002
00003
00004
00005 #include "cddefines.h"
00006 #include "plot.h"
00007 #include "rfield.h"
00008 #include "parse.h"
00009
00010
00011 STATIC void ParsePlotRangeOption(char*);
00012
00013
00014 STATIC void ParsePlotRangeContin(char*);
00015
00016 void ParsePlot(char *chCard )
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( nMatch(" MAP",chCard) )
00037 {
00038
00039 strcpy( plotCom.chPType[plotCom.nplot-1], " MAP" );
00040 }
00041
00042 else if( nMatch("CONT",chCard) )
00043 {
00044
00045 if( nMatch(" RAW",chCard) )
00046 {
00047 strcpy( plotCom.chPType[plotCom.nplot-1], "CRAW" );
00048
00049 }
00050 else if( nMatch("DIFF",chCard) )
00051 {
00052 strcpy( plotCom.chPType[plotCom.nplot-1], "DIFF" );
00053
00054 }
00055 else if( nMatch("EMIT",chCard) )
00056 {
00057 strcpy( plotCom.chPType[plotCom.nplot-1], "EMIT" );
00058
00059 }
00060 else if( nMatch("OUTW",chCard) )
00061 {
00062 strcpy( plotCom.chPType[plotCom.nplot-1], "OUTW" );
00063
00064 }
00065 else if( nMatch("REFL",chCard) )
00066 {
00067 strcpy( plotCom.chPType[plotCom.nplot-1], "REFL" );
00068
00069 }
00070 else if( nMatch("PHOT",chCard) )
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( nMatch("OPAC",chCard) )
00081 {
00082 if( nMatch("ABSO",chCard) )
00083 {
00084
00085 strcpy( plotCom.chPType[plotCom.nplot-1], "OPAA" );
00086 }
00087 else if( nMatch("SCAT",chCard) )
00088 {
00089
00090 strcpy( plotCom.chPType[plotCom.nplot-1], "OPAS" );
00091 }
00092 else if( nMatch("TOTA",chCard) )
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( nMatch("TRAC",chCard) )
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(chCard);
00124 }
00125 else
00126 {
00127
00128 ParsePlotRangeContin(chCard);
00129 }
00130
00131 return;
00132 }
00133
00134
00135 STATIC void ParsePlotRangeOption(char *chCard )
00136 {
00137 bool lgEOL,
00138 lgLogOn;
00139 long int i;
00140 realnum a;
00141
00142 DEBUG_ENTRY( "ParsePlotRangeOption()" );
00143
00144 i = 4;
00145
00146 plotCom.pltxmn[plotCom.nplot-1] = (realnum)FFmtRead(chCard,&i,INPUT_LINE_LENGTH,&lgEOL);
00147
00148 if( !nMatch("RANG",chCard) )
00149 {
00150
00151 plotCom.pltxmn[plotCom.nplot-1] = 1.;
00152 plotCom.pltxmx[plotCom.nplot-1] = 9.;
00153 lgLogOn = true;
00154 }
00155 else if( lgEOL )
00156 {
00157
00158 plotCom.pltxmn[plotCom.nplot-1] = 1.;
00159 plotCom.pltxmx[plotCom.nplot-1] = 9.;
00160 lgLogOn = true;
00161 }
00162 else
00163 {
00164
00165 if( plotCom.pltxmn[plotCom.nplot-1] <= 10. )
00166 {
00167 lgLogOn = true;
00168 }
00169 else
00170 {
00171 lgLogOn = false;
00172 }
00173
00174 if( nMatch("LINE",chCard) )
00175 lgLogOn = false;
00176
00177 plotCom.pltxmx[plotCom.nplot-1] = (realnum)FFmtRead(chCard,&i,INPUT_LINE_LENGTH,&lgEOL);
00178 if( lgEOL )
00179 {
00180 if( lgLogOn )
00181 {
00182 plotCom.pltxmx[plotCom.nplot-1] = 9.;
00183 }
00184 else
00185 {
00186 plotCom.pltxmx[plotCom.nplot-1] = 1e9;
00187 }
00188 }
00189 else
00190 {
00191
00192 if( plotCom.pltxmx[plotCom.nplot-1] <= plotCom.pltxmn[plotCom.nplot-1] )
00193 {
00194 fprintf( ioQQQ,
00195 " The second (maximum) temperature for the map is%10.2e, but this is less than the first (minimum) temperature,%10.2e\n",
00196 plotCom.pltxmx[plotCom.nplot-1], plotCom.pltxmn[plotCom.nplot-1] );
00197 fprintf( ioQQQ, " HELP! I am confused!!\n" );
00198 cdEXIT(EXIT_FAILURE);
00199 }
00200 }
00201 }
00202
00203
00204 if( !lgLogOn )
00205 {
00206 if( plotCom.pltxmx[plotCom.nplot-1] <= 0. || plotCom.pltxmn[plotCom.nplot-1] <=
00207 0. )
00208 {
00209 fprintf( ioQQQ,
00210 " Limits for temperature are negative. This is impossible. Sorry.\n" );
00211 cdEXIT(EXIT_FAILURE);
00212 }
00213 plotCom.pltxmx[plotCom.nplot-1] = (realnum)log10(plotCom.pltxmx[plotCom.nplot-1]);
00214 plotCom.pltxmn[plotCom.nplot-1] = (realnum)log10(plotCom.pltxmn[plotCom.nplot-1]);
00215 }
00216
00217
00218 if( plotCom.pltxmn[plotCom.nplot-1] == plotCom.pltxmx[plotCom.nplot-1] )
00219 {
00220 fprintf( ioQQQ, " Upper and lower plot boundaries are equal.\n" );
00221 cdEXIT(EXIT_FAILURE);
00222 }
00223 else if( plotCom.pltxmn[plotCom.nplot-1] > plotCom.pltxmx[plotCom.nplot-1] )
00224 {
00225 a = plotCom.pltxmx[plotCom.nplot-1];
00226 plotCom.pltxmx[plotCom.nplot-1] = plotCom.pltxmn[plotCom.nplot-1];
00227 plotCom.pltxmn[plotCom.nplot-1] = a;
00228 }
00229
00230 return;
00231 }
00232
00233
00234 STATIC void ParsePlotRangeContin(char *chCard )
00235 {
00236 bool lgEOL,
00237 lgLogOn;
00238 long int i;
00239 realnum a;
00240
00241 DEBUG_ENTRY( "ParsePlotRangeContin()" );
00242
00243 i = 4;
00244 plotCom.pltxmn[plotCom.nplot-1] = (realnum)FFmtRead(chCard,&i,INPUT_LINE_LENGTH,&lgEOL);
00245
00246 if( !nMatch("RANG",chCard) )
00247 {
00248
00249 plotCom.pltxmn[plotCom.nplot-1] = (realnum)log10(rfield.emm);
00250 plotCom.pltxmx[plotCom.nplot-1] = (realnum)log10(rfield.egamry);
00251 lgLogOn = true;
00252 }
00253 else if( lgEOL )
00254 {
00255
00256 plotCom.pltxmn[plotCom.nplot-1] = (realnum)log10(rfield.emm);
00257 plotCom.pltxmx[plotCom.nplot-1] = (realnum)log10(rfield.egamry);
00258 lgLogOn = true;
00259 }
00260 else
00261 {
00262
00263 if( plotCom.pltxmn[plotCom.nplot-1] < 0. )
00264 {
00265 lgLogOn = true;
00266 }
00267 else if( plotCom.pltxmn[plotCom.nplot-1] == 0.0 )
00268 {
00269
00270 lgLogOn = false;
00271 plotCom.pltxmn[plotCom.nplot-1] = rfield.emm;
00272 }
00273 else
00274 {
00275
00276 lgLogOn = false;
00277 }
00278
00279
00280 plotCom.pltxmx[plotCom.nplot-1] = (realnum)FFmtRead(chCard,&i,INPUT_LINE_LENGTH,&lgEOL);
00281 if( lgEOL || plotCom.pltxmx[plotCom.nplot-1] == 0.0 )
00282 {
00283
00284 if( lgLogOn )
00285 {
00286 plotCom.pltxmx[plotCom.nplot-1] = (realnum)log10(rfield.egamry);
00287 }
00288 else
00289 {
00290 plotCom.pltxmx[plotCom.nplot-1] = rfield.egamry;
00291 }
00292 }
00293 }
00294
00295
00296 if( !lgLogOn )
00297 {
00298 plotCom.pltxmx[plotCom.nplot-1] = (realnum)log10(plotCom.pltxmx[plotCom.nplot-1]);
00299 plotCom.pltxmn[plotCom.nplot-1] = (realnum)log10(plotCom.pltxmn[plotCom.nplot-1]);
00300 }
00301
00302
00303 if( plotCom.pltxmn[plotCom.nplot-1] == plotCom.pltxmx[plotCom.nplot-1] )
00304 {
00305 fprintf( ioQQQ, " Upper and lower plot boundaries are equal.\n" );
00306 cdEXIT(EXIT_FAILURE);
00307 }
00308 else if( plotCom.pltxmn[plotCom.nplot-1] > plotCom.pltxmx[plotCom.nplot-1] )
00309 {
00310 a = plotCom.pltxmx[plotCom.nplot-1];
00311 plotCom.pltxmx[plotCom.nplot-1] = plotCom.pltxmn[plotCom.nplot-1];
00312 plotCom.pltxmn[plotCom.nplot-1] = a;
00313 }
00314
00315 return;
00316 }