cloudy trunk
Loading...
Searching...
No Matches
parse_plot.cpp
Go to the documentation of this file.
1/* This file is part of Cloudy and is copyright (C)1978-2013 by Gary J. Ferland and
2 * others. For conditions of distribution and use see copyright notice in license.txt */
3/*ParsePlot parse the plot command */
4/*ParsePlotRangeOption parse range from plot command */
5#include "cddefines.h"
6#include "plot.h"
7#include "rfield.h"
8#include "parser.h"
9
10/*ParsePlotRangeOption parse range from plot command, located below */
12
13/*ParsePlotRangeContin parse range option for continuum on map command, located below */
15
17{
18
19 DEBUG_ENTRY( "ParsePlot()" );
20
21 /* total number of plots so far */
22 plotCom.nplot += 1;
23
24 /* plots are turned on */
25 plotCom.lgPlotON = true;
26
27 /* make sure we have not hit the limit, the dimension of variables in plot.h */
28 if( plotCom.nplot > NDPLOT )
29 {
30 fprintf( ioQQQ,
31 " Too many plots; the limit is%3ld This one ignored.\n",
32 NDPLOT );
33 plotCom.nplot = NDPLOT;
34 }
35
36 if( p.nMatch(" MAP") )
37 {
38 /* option to make plot of heating - cooling map */
39 strcpy( plotCom.chPType[plotCom.nplot-1], " MAP" );
40 }
41
42 else if( p.nMatch("CONT") )
43 {
44 /* option to make "raw" plot, in internal units */
45 if( p.nMatch(" RAW") )
46 {
47 strcpy( plotCom.chPType[plotCom.nplot-1], "CRAW" );
48 /* option to make diffuse continuum plot */
49 }
50 else if( p.nMatch("DIFF") )
51 {
52 strcpy( plotCom.chPType[plotCom.nplot-1], "DIFF" );
53 /* this is emitted continuum */
54 }
55 else if( p.nMatch("EMIT") )
56 {
57 strcpy( plotCom.chPType[plotCom.nplot-1], "EMIT" );
58 /* this is outward and attenuated continuum */
59 }
60 else if( p.nMatch("OUTW") )
61 {
62 strcpy( plotCom.chPType[plotCom.nplot-1], "OUTW" );
63 /* this is reflected continuum */
64 }
65 else if( p.nMatch("REFL") )
66 {
67 strcpy( plotCom.chPType[plotCom.nplot-1], "REFL" );
68 /* this is continuum in photons */
69 }
70 else if( p.nMatch("PHOT") )
71 {
72 strcpy( plotCom.chPType[plotCom.nplot-1], "CPHT" );
73 }
74 else
75 {
76 strcpy( plotCom.chPType[plotCom.nplot-1], "CONT" );
77 }
78 }
79
80 else if( p.nMatch("OPAC") )
81 {
82 if( p.nMatch("ABSO") )
83 {
84 /* plot absorption opacity */
85 strcpy( plotCom.chPType[plotCom.nplot-1], "OPAA" );
86 }
87 else if( p.nMatch("SCAT") )
88 {
89 /* plot scattering opacity */
90 strcpy( plotCom.chPType[plotCom.nplot-1], "OPAS" );
91 }
92 else if( p.nMatch("TOTA") )
93 {
94 /* plot total opacity */
95 strcpy( plotCom.chPType[plotCom.nplot-1], "OPAT" );
96 }
97 else
98 {
99 /* plot total opacity for default */
100 strcpy( plotCom.chPType[plotCom.nplot-1], "OPAT" );
101 }
102 }
103 else
104 {
105 fprintf( ioQQQ, " The second keyword on the PLOT command must be CONTINUUM, _MAP, or OPACITY.\n" );
107 }
108
109 /* option to turn on trace of plot logic */
110 if( p.nMatch("TRAC") )
111 {
112 plotCom.lgPltTrace[plotCom.nplot-1] = true;
113 }
114 else
115 {
116 plotCom.lgPltTrace[plotCom.nplot-1] = false;
117 }
118
119 /* option to set min and max x-axis */
120 if( strcmp(plotCom.chPType[plotCom.nplot-1]," MAP") == 0 )
121 {
122 /* this will be map of cooling and heating vs temp */
124 }
125 else
126 {
127 /* continuum map */
129 }
130
131 return;
132}
133
134/*ParsePlotRangeOption parse range from plot command */
136{
137 bool
138 lgLogOn;
139 realnum a;
140
141 DEBUG_ENTRY( "ParsePlotRangeOption()" );
142
143 /* pltxmn is min for x axis of plot */
144 plotCom.pltxmn[plotCom.nplot-1] = (realnum)p.FFmtRead();
145
146 if( !p.nMatch("RANG") )
147 {
148 /* no lines were enterd, so use default temperature limits */
149 plotCom.pltxmn[plotCom.nplot-1] = 1.;
150 plotCom.pltxmx[plotCom.nplot-1] = 9.;
151 lgLogOn = true;
152 }
153 else if( p.lgEOL() )
154 {
155 /* no lines were enterd, so use default temperature limits */
156 plotCom.pltxmn[plotCom.nplot-1] = 1.;
157 plotCom.pltxmx[plotCom.nplot-1] = 9.;
158 lgLogOn = true;
159 }
160 else
161 {
162 /* number entered, now interprete it */
163 if( plotCom.pltxmn[plotCom.nplot-1] <= 10. )
164 {
165 lgLogOn = true;
166 }
167 else
168 {
169 lgLogOn = false;
170 }
171 /* linear option for temperature */
172 if( p.nMatch("LINE") )
173 lgLogOn = false;
174 /* lower temp was entered, now how about upper temp */
175 plotCom.pltxmx[plotCom.nplot-1] = (realnum)p.FFmtRead();
176 if( p.lgEOL() )
177 {
178 if( lgLogOn )
179 {
180 plotCom.pltxmx[plotCom.nplot-1] = 9.;
181 }
182 else
183 {
184 plotCom.pltxmx[plotCom.nplot-1] = 1e9;
185 }
186 }
187 else
188 {
189 /* second number was entered, check for sanity */
190 if( plotCom.pltxmx[plotCom.nplot-1] <= plotCom.pltxmn[plotCom.nplot-1] )
191 {
192 fprintf( ioQQQ,
193 " The second (maximum) temperature for the map is%10.2e, but this is less than the first (minimum) temperature,%10.2e\n",
194 plotCom.pltxmx[plotCom.nplot-1], plotCom.pltxmn[plotCom.nplot-1] );
195 fprintf( ioQQQ, " HELP! I am confused!!\n" );
197 }
198 }
199 }
200
201 /* now force to be log */
202 if( !lgLogOn )
203 {
204 if( plotCom.pltxmx[plotCom.nplot-1] <= 0. || plotCom.pltxmn[plotCom.nplot-1] <=
205 0. )
206 {
207 fprintf( ioQQQ,
208 " Limits for temperature are negative. This is impossible. Sorry.\n" );
210 }
211 plotCom.pltxmx[plotCom.nplot-1] = (realnum)log10(plotCom.pltxmx[plotCom.nplot-1]);
212 plotCom.pltxmn[plotCom.nplot-1] = (realnum)log10(plotCom.pltxmn[plotCom.nplot-1]);
213 }
214
215 /* check that min is less than max */
216 if( plotCom.pltxmn[plotCom.nplot-1] == plotCom.pltxmx[plotCom.nplot-1] )
217 {
218 fprintf( ioQQQ, " Upper and lower plot boundaries are equal.\n" );
220 }
221 else if( plotCom.pltxmn[plotCom.nplot-1] > plotCom.pltxmx[plotCom.nplot-1] )
222 {
223 a = plotCom.pltxmx[plotCom.nplot-1];
224 plotCom.pltxmx[plotCom.nplot-1] = plotCom.pltxmn[plotCom.nplot-1];
225 plotCom.pltxmn[plotCom.nplot-1] = a;
226 }
227
228 return;
229}
230
231/*ParsePlotRangeContin set range for map to parse range option on map command */
233{
234 bool
235 lgLogOn;
236 realnum a;
237
238 DEBUG_ENTRY( "ParsePlotRangeContin()" );
239
240 plotCom.pltxmn[plotCom.nplot-1] = (realnum)p.FFmtRead();
241
242 if( !p.nMatch("RANG") )
243 {
244 /* no numbers on line, just set default limits to energy array */
245 plotCom.pltxmn[plotCom.nplot-1] = (realnum)log10(rfield.emm);
246 plotCom.pltxmx[plotCom.nplot-1] = (realnum)log10(rfield.egamry);
247 lgLogOn = true;
248 }
249 else if( p.lgEOL() )
250 {
251 /* no numbers on line, just set default limits to energy array */
252 plotCom.pltxmn[plotCom.nplot-1] = (realnum)log10(rfield.emm);
253 plotCom.pltxmx[plotCom.nplot-1] = (realnum)log10(rfield.egamry);
254 lgLogOn = true;
255 }
256 else
257 {
258 /* lower limit entered, now interprete it */
259 if( plotCom.pltxmn[plotCom.nplot-1] < 0. )
260 {
261 lgLogOn = true;
262 }
263 else if( plotCom.pltxmn[plotCom.nplot-1] == 0.0 )
264 {
265 /* option for first number to be zero, lower edge of array */
266 lgLogOn = false;
267 plotCom.pltxmn[plotCom.nplot-1] = rfield.emm;
268 }
269 else
270 {
271 /* a positive number was entered */
272 lgLogOn = false;
273 }
274
275 /* now look at upper limit */
276 plotCom.pltxmx[plotCom.nplot-1] = (realnum)p.FFmtRead();
277 if( p.lgEOL() || plotCom.pltxmx[plotCom.nplot-1] == 0.0 )
278 {
279 /* option for second number to be omitted or zero */
280 if( lgLogOn )
281 {
282 plotCom.pltxmx[plotCom.nplot-1] = (realnum)log10(rfield.egamry);
283 }
284 else
285 {
286 plotCom.pltxmx[plotCom.nplot-1] = rfield.egamry;
287 }
288 }
289 }
290
291 /* now force to be log */
292 if( !lgLogOn )
293 {
294 plotCom.pltxmx[plotCom.nplot-1] = (realnum)log10(plotCom.pltxmx[plotCom.nplot-1]);
295 plotCom.pltxmn[plotCom.nplot-1] = (realnum)log10(plotCom.pltxmn[plotCom.nplot-1]);
296 }
297
298 /* check that min is less than max */
299 if( plotCom.pltxmn[plotCom.nplot-1] == plotCom.pltxmx[plotCom.nplot-1] )
300 {
301 fprintf( ioQQQ, " Upper and lower plot boundaries are equal.\n" );
303 }
304 else if( plotCom.pltxmn[plotCom.nplot-1] > plotCom.pltxmx[plotCom.nplot-1] )
305 {
306 a = plotCom.pltxmx[plotCom.nplot-1];
307 plotCom.pltxmx[plotCom.nplot-1] = plotCom.pltxmn[plotCom.nplot-1];
308 plotCom.pltxmn[plotCom.nplot-1] = a;
309 }
310
311 return;
312}
FILE * ioQQQ
Definition cddefines.cpp:7
#define STATIC
Definition cddefines.h:97
#define EXIT_FAILURE
Definition cddefines.h:140
#define cdEXIT(FAIL)
Definition cddefines.h:434
float realnum
Definition cddefines.h:103
#define DEBUG_ENTRY(funcname)
Definition cddefines.h:684
double FFmtRead(void)
Definition parser.cpp:353
bool nMatch(const char *chKey) const
Definition parser.h:135
bool lgEOL(void) const
Definition parser.h:98
STATIC void ParsePlotRangeOption(Parser &p)
STATIC void ParsePlotRangeContin(Parser &p)
void ParsePlot(Parser &p)
t_plotCom plotCom
Definition plot.cpp:19
#define NDPLOT
Definition plot.h:13
t_rfield rfield
Definition rfield.cpp:8