#include "sgm_esl.h"

int SGM_ESL::OutObsPoints(const char* filename,_1dArray input_data){
	ofstream outfile;
	if (open_outfile(outfile,filename)) return -1;
	outfile << "# y-northing(m) x-easting(m) ele(m) obs-val(mGal|nT|Eo) obs-dev(mGal|nT|Eo) reproduced-data(mGal|nT|Eo)" << endl;
	for (int i = 0; i < obs_points_num_; i++)
	{
		outfile << setprecision(16) << obs_points_[i].y << " " << obs_points_[i].x << " "
		 << -1.0*obs_points_[i].z << " " << obs_points_[i].val << " "  << obs_points_[i].dev << " " << input_data[i] << endl;
	}
	outfile.close();
	return 0;
}

int SGM_ESL::OutObsPoints(const char* filename,_1dArray reg_data,_1dArray loc_data,_1dArray res_data){
	ofstream outfile;
	if (open_outfile(outfile,filename)) return -1;
	outfile << "# y-northing(m) x-easting(m) ele(m) obs-val(mGal|nT|Eo) \
	obs-dev(mGal|nT|Eo) total-recovered(mGal|nT|Eo) regional-recovered(mGal|nT|Eo) \
	local-recovered(mGal|nT|Eo) residual-recovered(mGal|nT|Eo) difference (mGal|nT|Eo)" << endl;
	for (int i = 0; i < obs_points_num_; i++)
	{
		outfile << setprecision(16) << obs_points_[i].y << " " << obs_points_[i].x << " "
		 << -1.0*obs_points_[i].z << " " << obs_points_[i].val << " "  << obs_points_[i].dev << " "
		 << reg_data[i]+loc_data[i] << " " << reg_data[i] << " " << loc_data[i] << " " << res_data[i] << " "
		 << reg_data[i]+loc_data[i] - obs_points_[i].val << endl;
	}
	outfile.close();
	return 0;
}