Cloudy & Associates

Commit 2a764dfc authored by Robin Williams's avatar Robin Williams
Browse files

Recover functionality to optimize molecular species

Uses quoted syntax, e.g. "CO", for species other than atomic ions.
This should recover the functionality without re-introducing the
anomalous behaviours of the c17_branch implementation.

Modify output routine to scale automatically with label widths.
parent 6446d20a
......@@ -154,8 +154,18 @@ chi2_type optimize_func(const realnum param[],
cdWarnings(ioQQQ);
/* print header before any of the individual chi2 values are printed */
int wlab = 4;
for( i=0; i < long(optimize.chTempLab.size()); i++ )
{
wlab = max(wlab,optimize.chTempLab[i].size());
}
for( i=0; i < long(optimize.chColDen_label.size()); i++ )
{
wlab = max(wlab,optimize.chColDen_label[i].size());
}
if( optimize.lgOptimize )
fprintf( ioQQQ, " ID Model Observed error chi**2 Type\n" );
fprintf( ioQQQ, " %*.*s%7s%12.12s%12.12s%12.12s%12.12s Type\n",
wlab,wlab,"ID","","Model","Observed","error","chi**2");
else
ASSERT( grid.lgGrid );
......@@ -251,7 +261,8 @@ chi2_type optimize_func(const realnum param[],
nobs_cat[cat]++;
chi2_cat[cat] += chi1;
fprintf( ioQQQ, " %4.4s%7ld%12.4e%12.4e%12.5f%12.2e Temperature\n",
fprintf( ioQQQ, " %*.*s%7ld%12.4e%12.4e%12.5f%12.2e Temperature\n",
wlab, wlab,
optimize.chTempLab[i].c_str(), optimize.ionTemp[i], temp_theory,
optimize.temp_obs[i], optimize.temp_error[i], chi1 );
}
......@@ -272,8 +283,9 @@ chi2_type optimize_func(const realnum param[],
cat = 1;
nobs_cat[cat]++;
chi2_cat[cat] += chi1;
fprintf( ioQQQ, " %4.4s%7ld%12.4e%12.4e%12.5f%12.2e Column density\n",
fprintf( ioQQQ, " %*.*s%7ld%12.4e%12.4e%12.5f%12.2e Column density\n",
wlab,wlab,
optimize.chColDen_label[i].c_str(), optimize.ion_ColDen[i], theocl,
optimize.ColDen_Obs[i], optimize.ColDen_error[i], chi1 );
}
......
......@@ -304,31 +304,48 @@ STATIC void GetOptColDen(Parser &p )
while( !p.m_lgEOF )
{
/* order on line is element label (col 1-4), ionization stage, column density, err */
/* copy cap'd version of first 4 char of chCard to chColDen_label */
optimize.chColDen_label.push_back(elementnames.chElementNameShort[p.getElement()]);
/* now get the ion stage, this should be 1 for atom, up to element
* number plus one */
long ion = nint(p.FFmtRead());
if( p.lgEOL() )
string chLabel;
if ( p.GetQuote( chLabel ) == 0 )
{
p.PrintLine( ioQQQ );
fprintf( ioQQQ, " The ionization stage MUST appear on this line. Sorry.\n" );
cdEXIT(EXIT_FAILURE);
// Read a quote-delimited string, which will be interpreted
// by cdColm as a generic species label. It would be better
// to do the lookup earlier, to validate the input and save
// repeated effort.
/* order on line is species, column density, err */
optimize.chColDen_label.push_back(chLabel);
optimize.ion_ColDen.push_back(0);
}
/* the ion must be 1 or greater unless requesting a special,
* like a molecule or excited state population, in which
* case ion = 0
* can't check on upper limit yet since have not resolved element name */
if( ion < 0 )
else
{
p.PrintLine( ioQQQ );
fprintf( ioQQQ, " An ionization stage of %ld does not make sense. Sorry.\n", ion );
cdEXIT(EXIT_FAILURE);
/* order on line is element name (at least 4 characters), ionization stage, column density, err */
/* copy cap'd version of first 4 char of chCard to chColDen_label */
// The other branch can handle also ions, with the 'chemical'
// syntax '"H+"' (in quotes), rather than 'HYDR 2' below
optimize.chColDen_label.push_back(elementnames.chElementNameShort[p.getElement()]);
/* now get the ion stage, this should be 1 for atom, up to element
* number plus one */
long ion = nint(p.FFmtRead());
if( p.lgEOL() )
{
p.PrintLine( ioQQQ );
fprintf( ioQQQ, " The ionization stage MUST appear on this line. Sorry.\n" );
cdEXIT(EXIT_FAILURE);
}
/* the ion must be 1 or greater unless requesting a special,
* like a molecule or excited state population, in which
* case ion = 0
* can't check on upper limit yet since have not resolved element name */
if( ion < 0 )
{
p.PrintLine( ioQQQ );
fprintf( ioQQQ, " An ionization stage of %ld does not make sense. Sorry.\n", ion );
cdEXIT(EXIT_FAILURE);
}
optimize.ion_ColDen.push_back(ion);
}
optimize.ion_ColDen.push_back(ion);
optimize.ColDen_Obs.push_back( realnum(exp10(p.FFmtRead())) );
if( p.lgEOL() )
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment