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 puts( "[Stop in ParsePlot]" );
00107 cdEXIT(EXIT_FAILURE);
00108 }
00109
00110
00111 if( nMatch("TRAC",chCard) )
00112 {
00113 plotCom.lgPltTrace[plotCom.nplot-1] = true;
00114 }
00115 else
00116 {
00117 plotCom.lgPltTrace[plotCom.nplot-1] = false;
00118 }
00119
00120
00121 if( strcmp(plotCom.chPType[plotCom.nplot-1]," MAP") == 0 )
00122 {
00123
00124 ParsePlotRangeOption(chCard);
00125 }
00126 else
00127 {
00128
00129 ParsePlotRangeContin(chCard);
00130 }
00131
00132
00133 DEBUG_EXIT( "ParsePlot()" );
00134 return;
00135 }
00136
00137
00138 static void ParsePlotRangeOption(char *chCard )
00139 {
00140 bool lgEOL,
00141 lgLogOn;
00142 long int i;
00143 float a;
00144
00145 DEBUG_ENTRY( "ParsePlotRangeOption()" );
00146
00147 i = 4;
00148
00149 plotCom.pltxmn[plotCom.nplot-1] = (float)FFmtRead(chCard,&i,INPUT_LINE_LENGTH,&lgEOL);
00150
00151 if( !nMatch("RANG",chCard) )
00152 {
00153
00154 plotCom.pltxmn[plotCom.nplot-1] = 1.;
00155 plotCom.pltxmx[plotCom.nplot-1] = 9.;
00156 lgLogOn = true;
00157 }
00158 else if( lgEOL )
00159 {
00160
00161 plotCom.pltxmn[plotCom.nplot-1] = 1.;
00162 plotCom.pltxmx[plotCom.nplot-1] = 9.;
00163 lgLogOn = true;
00164 }
00165 else
00166 {
00167
00168 if( plotCom.pltxmn[plotCom.nplot-1] <= 10. )
00169 {
00170 lgLogOn = true;
00171 }
00172 else
00173 {
00174 lgLogOn = false;
00175 }
00176
00177 if( nMatch("LINE",chCard) )
00178 lgLogOn = false;
00179
00180 plotCom.pltxmx[plotCom.nplot-1] = (float)FFmtRead(chCard,&i,INPUT_LINE_LENGTH,&lgEOL);
00181 if( lgEOL )
00182 {
00183 if( lgLogOn )
00184 {
00185 plotCom.pltxmx[plotCom.nplot-1] = 9.;
00186 }
00187 else
00188 {
00189 plotCom.pltxmx[plotCom.nplot-1] = 1e9;
00190 }
00191 }
00192 else
00193 {
00194
00195 if( plotCom.pltxmx[plotCom.nplot-1] <= plotCom.pltxmn[plotCom.nplot-1] )
00196 {
00197 fprintf( ioQQQ,
00198 " The second (maximum) temperature for the map is%10.2e, but this is less than the first (minimum) temperature,%10.2e\n",
00199 plotCom.pltxmx[plotCom.nplot-1], plotCom.pltxmn[plotCom.nplot-1] );
00200 fprintf( ioQQQ, " HELP! I am confused!!\n" );
00201 puts( "[Stop in ParsePlotRangeOption]" );
00202 cdEXIT(EXIT_FAILURE);
00203 }
00204 }
00205 }
00206
00207
00208 if( !lgLogOn )
00209 {
00210 if( plotCom.pltxmx[plotCom.nplot-1] <= 0. || plotCom.pltxmn[plotCom.nplot-1] <=
00211 0. )
00212 {
00213 fprintf( ioQQQ,
00214 " Limits for temperature are negative. This is impossible. Sorry.\n" );
00215 puts( "[Stop in ParsePlotRangeOption]" );
00216 cdEXIT(EXIT_FAILURE);
00217 }
00218 plotCom.pltxmx[plotCom.nplot-1] = (float)log10(plotCom.pltxmx[plotCom.nplot-1]);
00219 plotCom.pltxmn[plotCom.nplot-1] = (float)log10(plotCom.pltxmn[plotCom.nplot-1]);
00220 }
00221
00222
00223 if( plotCom.pltxmn[plotCom.nplot-1] == plotCom.pltxmx[plotCom.nplot-1] )
00224 {
00225 fprintf( ioQQQ, " Upper and lower plot boundaries are equal.\n" );
00226 puts( "[Stop in ParsePlotRangeOption]" );
00227 cdEXIT(EXIT_FAILURE);
00228 }
00229 else if( plotCom.pltxmn[plotCom.nplot-1] > plotCom.pltxmx[plotCom.nplot-1] )
00230 {
00231 a = plotCom.pltxmx[plotCom.nplot-1];
00232 plotCom.pltxmx[plotCom.nplot-1] = plotCom.pltxmn[plotCom.nplot-1];
00233 plotCom.pltxmn[plotCom.nplot-1] = a;
00234 }
00235
00236
00237 DEBUG_EXIT( "ParsePlotRangeOption()" );
00238 return;
00239 }
00240
00241
00242 static void ParsePlotRangeContin(char *chCard )
00243 {
00244 bool lgEOL,
00245 lgLogOn;
00246 long int i;
00247 float a;
00248
00249 DEBUG_ENTRY( "ParsePlotRangeContin()" );
00250
00251 i = 4;
00252 plotCom.pltxmn[plotCom.nplot-1] = (float)FFmtRead(chCard,&i,INPUT_LINE_LENGTH,&lgEOL);
00253
00254 if( !nMatch("RANG",chCard) )
00255 {
00256
00257 plotCom.pltxmn[plotCom.nplot-1] = (float)log10(rfield.emm);
00258 plotCom.pltxmx[plotCom.nplot-1] = (float)log10(rfield.egamry);
00259 lgLogOn = true;
00260 }
00261 else if( lgEOL )
00262 {
00263
00264 plotCom.pltxmn[plotCom.nplot-1] = (float)log10(rfield.emm);
00265 plotCom.pltxmx[plotCom.nplot-1] = (float)log10(rfield.egamry);
00266 lgLogOn = true;
00267 }
00268 else
00269 {
00270
00271 if( plotCom.pltxmn[plotCom.nplot-1] < 0. )
00272 {
00273 lgLogOn = true;
00274 }
00275 else if( plotCom.pltxmn[plotCom.nplot-1] == 0.0 )
00276 {
00277
00278 lgLogOn = false;
00279 plotCom.pltxmn[plotCom.nplot-1] = rfield.emm;
00280 }
00281 else
00282 {
00283
00284 lgLogOn = false;
00285 }
00286
00287
00288 plotCom.pltxmx[plotCom.nplot-1] = (float)FFmtRead(chCard,&i,INPUT_LINE_LENGTH,&lgEOL);
00289 if( lgEOL || plotCom.pltxmx[plotCom.nplot-1] == 0.0 )
00290 {
00291
00292 if( lgLogOn )
00293 {
00294 plotCom.pltxmx[plotCom.nplot-1] = (float)log10(rfield.egamry);
00295 }
00296 else
00297 {
00298 plotCom.pltxmx[plotCom.nplot-1] = rfield.egamry;
00299 }
00300 }
00301 }
00302
00303
00304 if( !lgLogOn )
00305 {
00306 plotCom.pltxmx[plotCom.nplot-1] = (float)log10(plotCom.pltxmx[plotCom.nplot-1]);
00307 plotCom.pltxmn[plotCom.nplot-1] = (float)log10(plotCom.pltxmn[plotCom.nplot-1]);
00308 }
00309
00310
00311 if( plotCom.pltxmn[plotCom.nplot-1] == plotCom.pltxmx[plotCom.nplot-1] )
00312 {
00313 fprintf( ioQQQ, " Upper and lower plot boundaries are equal.\n" );
00314 puts( "[Stop in ParsePlotRangeContin]" );
00315 cdEXIT(EXIT_FAILURE);
00316 }
00317 else if( plotCom.pltxmn[plotCom.nplot-1] > plotCom.pltxmx[plotCom.nplot-1] )
00318 {
00319 a = plotCom.pltxmx[plotCom.nplot-1];
00320 plotCom.pltxmx[plotCom.nplot-1] = plotCom.pltxmn[plotCom.nplot-1];
00321 plotCom.pltxmn[plotCom.nplot-1] = a;
00322 }
00323
00324
00325 DEBUG_EXIT( "ParsePlotRangeContin()" );
00326 return;
00327 }
00328