mirror of
https://asciireactor.com/otho/cloudy-agn.git
synced 2025-04-11 09:45:43 +00:00
added bulk interpolation fix script
This commit is contained in:
parent
83dcad1348
commit
84c621f35e
25
scripts/meta/bulk_interpolation_fix.sh
Executable file
25
scripts/meta/bulk_interpolation_fix.sh
Executable file
@ -0,0 +1,25 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
script_dir=$( cd $(dirname $0) ; pwd -P |sed 's@^\(.*\)/scripts.*@\1/scripts@')
|
||||||
|
basedir=`pwd`
|
||||||
|
|
||||||
|
if [[ -x $script_dir/../bin/interpolate_fix]];
|
||||||
|
then
|
||||||
|
echo "Binary available. Proceeding."
|
||||||
|
else
|
||||||
|
echo "Binary unavailable. Exiting."
|
||||||
|
exit 9
|
||||||
|
fi
|
||||||
|
|
||||||
|
#for fortfile in $(echo fort.*);
|
||||||
|
for fortfile in $@
|
||||||
|
do
|
||||||
|
if [[ -e $(basename $fortfile) ]]
|
||||||
|
then
|
||||||
|
mkdir -p uninterpolated
|
||||||
|
mv $fortfile uninterpolated
|
||||||
|
echo $script_dir/../bin/interpolate_fix uninterpolated/$(basename $fortfile) $fortfile
|
||||||
|
else
|
||||||
|
echo $script_dir/../bin/interpolate_fix $fortfile $(basename $fortfile)
|
||||||
|
fi
|
||||||
|
exit 0
|
@ -34,7 +34,7 @@ int main(int argc, char const *argv[]) {
|
|||||||
<< outlier_it->second
|
<< outlier_it->second
|
||||||
<< "\n"
|
<< "\n"
|
||||||
<< std::scientific
|
<< std::scientific
|
||||||
<< "Old value: "
|
<< "Old value: "
|
||||||
<< jagged_table.value[outlier_it->first][outlier_it->second]
|
<< jagged_table.value[outlier_it->first][outlier_it->second]
|
||||||
<< "\t"
|
<< "\t"
|
||||||
<< "New value: "
|
<< "New value: "
|
||||||
@ -43,7 +43,7 @@ int main(int argc, char const *argv[]) {
|
|||||||
outlier_it++;
|
outlier_it++;
|
||||||
}
|
}
|
||||||
std::ofstream smoothed_table_file;
|
std::ofstream smoothed_table_file;
|
||||||
smoothed_table_file.open("smoothed_eqwidth_table");
|
smoothed_table_file.open(argv[2]);
|
||||||
smoothed_table_file << agn::format_eqwidth_table(smooth_table);
|
smoothed_table_file << agn::format_eqwidth_table(smooth_table);
|
||||||
smoothed_table_file.close();
|
smoothed_table_file.close();
|
||||||
|
|
||||||
@ -118,13 +118,13 @@ agn::eqwidth_table agn::smooth(agn::eqwidth_table & jagged_table,agn::gridcoordl
|
|||||||
if ( agn::debug ) {
|
if ( agn::debug ) {
|
||||||
std::cout
|
std::cout
|
||||||
<< std::scientific
|
<< std::scientific
|
||||||
<< "Smoothed: "
|
<< "Smoothed: "
|
||||||
<< newx
|
<< newx
|
||||||
<< ", "
|
<< ", "
|
||||||
<< oldy
|
<< oldy
|
||||||
<< " -> "
|
<< " -> "
|
||||||
<< newy
|
<< newy
|
||||||
<< "\n";
|
<< "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
coord_it++;
|
coord_it++;
|
||||||
@ -150,23 +150,23 @@ agn::gridcoordlist agn::known_outliers() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
agn::gridcoordlist agn::find_outliers(agn::eqwidth_table jagged_table) {
|
agn::gridcoordlist agn::find_outliers(agn::eqwidth_table jagged_table) {
|
||||||
if (agn::debug) std::cout
|
if (agn::debug) std::cout
|
||||||
<< "Scanning for outliers.\n";
|
<< "Scanning for outliers.\n";
|
||||||
agn::gridcoordlist outliers;
|
agn::gridcoordlist outliers;
|
||||||
|
|
||||||
// The distribution is
|
// The distribution is
|
||||||
// parameterised by x=log(jagged_table.hden) and
|
// parameterised by x=log(jagged_table.hden) and
|
||||||
// y=log(jagged_table.eqwidth).
|
// y=log(jagged_table.eqwidth).
|
||||||
|
|
||||||
agn::iterator2d hden_it = jagged_table.value.begin();
|
agn::iterator2d hden_it = jagged_table.value.begin();
|
||||||
while ( hden_it != jagged_table.value.end() ) {
|
while ( hden_it != jagged_table.value.end() ) {
|
||||||
agn::table1d slice = hden_it->second;
|
agn::table1d slice = hden_it->second;
|
||||||
if( agn::debug ) std::cout
|
if( agn::debug ) std::cout
|
||||||
<< "\nhden= "
|
<< "\nhden= "
|
||||||
<< (hden_it->first)
|
<< (hden_it->first)
|
||||||
<< ": ";
|
<< ": ";
|
||||||
|
|
||||||
// Crawl, checking slope, until a positive slope is found.
|
// Crawl, checking slope, until a positive slope is found.
|
||||||
agn::table1d::iterator phi_it = slice.begin();
|
agn::table1d::iterator phi_it = slice.begin();
|
||||||
double x1,x2,y1,y2,slope;
|
double x1,x2,y1,y2,slope;
|
||||||
std::vector<double> ref_curve_x,ref_curve_y,curve_back_x,curve_back_y;
|
std::vector<double> ref_curve_x,ref_curve_y,curve_back_x,curve_back_y;
|
||||||
@ -220,7 +220,7 @@ agn::gridcoordlist agn::find_outliers(agn::eqwidth_table jagged_table) {
|
|||||||
phi_it++;
|
phi_it++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( phi_it == slice.end() ) {
|
if ( phi_it == slice.end() ) {
|
||||||
if (agn::debug) std::cout
|
if (agn::debug) std::cout
|
||||||
<< "Clean";
|
<< "Clean";
|
||||||
hden_it++;
|
hden_it++;
|
||||||
@ -282,7 +282,7 @@ agn::gridcoordlist agn::find_outliers(agn::eqwidth_table jagged_table) {
|
|||||||
|
|
||||||
std::vector<double>::iterator curve_back_x_it = curve_back_x.begin();
|
std::vector<double>::iterator curve_back_x_it = curve_back_x.begin();
|
||||||
std::vector<double>::iterator curve_back_y_it = curve_back_y.begin();
|
std::vector<double>::iterator curve_back_y_it = curve_back_y.begin();
|
||||||
while ( curve_back_x_it != curve_back_x.end() &&
|
while ( curve_back_x_it != curve_back_x.end() &&
|
||||||
curve_back_y_it != curve_back_y.end() ) {
|
curve_back_y_it != curve_back_y.end() ) {
|
||||||
ref_curve_x.push_back(*curve_back_x_it);
|
ref_curve_x.push_back(*curve_back_x_it);
|
||||||
ref_curve_y.push_back(*curve_back_y_it);
|
ref_curve_y.push_back(*curve_back_y_it);
|
||||||
@ -329,7 +329,7 @@ agn::gridcoordlist agn::find_outliers(agn::eqwidth_table jagged_table) {
|
|||||||
// << ", ";
|
// << ", ";
|
||||||
phi_it = slice.find(anomalies_start_x);
|
phi_it = slice.find(anomalies_start_x);
|
||||||
while (phi_it != (++(slice.find(anomalies_end_x)))) {
|
while (phi_it != (++(slice.find(anomalies_end_x)))) {
|
||||||
y1 = log10(phi_it->second);
|
y1 = log10(phi_it->second);
|
||||||
x1 = phi_it->first;
|
x1 = phi_it->first;
|
||||||
y2 = testing_spline[x1];
|
y2 = testing_spline[x1];
|
||||||
//threshold = RATIO_THRESHOLD_MULTIPLIER * (y2 - EQWIDTH_MIN_VAL_LOG);
|
//threshold = RATIO_THRESHOLD_MULTIPLIER * (y2 - EQWIDTH_MIN_VAL_LOG);
|
||||||
|
@ -143,7 +143,7 @@ std::string agn::format_eqwidth_table_slice(agn::eqwidth_table table,agn::iterat
|
|||||||
|
|
||||||
|
|
||||||
std::ostream& agn::operator<< (std::ostream& outstream, agn::eqwidth_table table) {
|
std::ostream& agn::operator<< (std::ostream& outstream, agn::eqwidth_table table) {
|
||||||
outstream
|
outstream
|
||||||
<< table.header[0]
|
<< table.header[0]
|
||||||
<< std::endl
|
<< std::endl
|
||||||
<< table.header[1]
|
<< table.header[1]
|
||||||
@ -211,9 +211,9 @@ std::list<agn::eqwidth_table> agn::compile_eqwidth_tables(agn::cloudy_grid grid,
|
|||||||
double x,y;
|
double x,y;
|
||||||
agn::cloudy_line_data data;
|
agn::cloudy_line_data data;
|
||||||
agn::eqwidth_table new_table;
|
agn::eqwidth_table new_table;
|
||||||
if(agn::debug) std::cout
|
if(agn::debug) std::cout
|
||||||
<< "Processing label "
|
<< "Processing label "
|
||||||
<< *line_label_it
|
<< *line_label_it
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
new_table.header[0] = *line_label_it;
|
new_table.header[0] = *line_label_it;
|
||||||
new_table.header[0].append(" relative to Inci 1215.00A scaled to 1215.00A");
|
new_table.header[0].append(" relative to Inci 1215.00A scaled to 1215.00A");
|
||||||
|
Loading…
Reference in New Issue
Block a user