Example #1
0
void CompareFits(const ES::Spectrum &i_cTarget, XDATASET & i_cOpacity_Map_A, XDATASET & i_cOpacity_Map_B, unsigned int i_uiIon, const double &i_dDay, const double & i_dPS_Vel, const double &i_dPS_Temp, const double & i_dPS_Ion_Temp, const double &i_dPS_Log_Tau, const double & i_dHVF_Ion_Temp, const double &i_dHVF_Log_Tau, ES::Spectrum &o_cOutput)
{
	ES::Spectrum cOutput(i_cTarget);

	unsigned int uiParameters = 7;
	if (i_cOpacity_Map_B.GetNumElements() == 0 || isnan(i_dHVF_Ion_Temp) || isnan(i_dHVF_Log_Tau))
		uiParameters = 5; // don't look for HVF component separately

	XVECTOR cResult(uiParameters);
//	printf("\n");
//	cResult.Print();
	unsigned int uiI = 1;
	while (uiI < i_cOpacity_Map_A.GetNumElements() && i_cOpacity_Map_A.GetElement(uiI,0) < i_dDay)
		uiI++;
	if (uiI > 0)
		uiI--;

	cResult.Set(0,uiI);
	cResult.Set(1,i_dPS_Vel);
	cResult.Set(2,i_dPS_Temp);
	cResult.Set(3,i_dPS_Ion_Temp);
	cResult.Set(4,i_dPS_Log_Tau);
	if (uiParameters > 5)
	{
		cResult.Set(5,i_dHVF_Ion_Temp);
		cResult.Set(6,i_dHVF_Log_Tau);
	}
//	printf("Generating\n");

	Generate_Synow_Spectra(i_cTarget,i_cOpacity_Map_A,i_cOpacity_Map_B,i_uiIon,cResult,cOutput);
	o_cOutput = cOutput; // not completely sure why this has to be done instead of passing o_cOutput as a parameter to Generate_Synow_Spectra, but if I do the latter it returns with flux set to zero...
}
Example #2
0
void CompareFits(const ES::Spectrum &i_cTarget, ES::Spectrum &o_cOutput, double & o_dTemp)
{
	ES::Spectrum cOutput(i_cTarget);
	printf("Generating vector\n");
	XVECTOR cResult(7);
	unsigned int uiParameters = cResult.Get_Size();
	XVECTOR vBest_Fit(uiParameters);
//	printf("\n");
//	cResult.Print();

	cResult.Set(0,10.0);//ps vel
	cResult.Set(1,12.0); // ps temp
	cResult.Set(2,-10.0); // PS ion log tau
	cResult.Set(3,10.0); // PS ion exctication temp
	cResult.Set(4,10.0); // PS ion vmin
	cResult.Set(5,11.0); // PS ion vmax
	cResult.Set(6,1.0); // PS ion vscale

	Generate_Synow_Spectra_Exp(i_cTarget,2001,cResult,cOutput); // ion irrelevant for this 

	//ameoba algorithm to refine fit
//	double	dBest_Fit = Get_Fit(i_cTarget,cOutput,i_cTarget.wl(0),i_cTarget.wl(i_cTarget.size() - 1));
	double dBest_Fit = Get_Fit(i_cTarget, cOutput, 7750.0 - 25.0, 7750.0 + 25.0) + Get_Fit(i_cTarget, cOutput, 6700.0 - 25.0, 6700.0 + 25.0);
//	double dBest_Fit = Get_Fit(i_cTarget,cOutput,FIT_BLUE_WL,FIT_RED_WL);
	double	dFit = dBest_Fit;
//	printf("Starting fit %.2e\n",dBest_Fit);
	vBest_Fit = cResult;
	double dRange = 2.0;
	double dBest_Fit_Range = dRange;
	printf("Fit = %.2e\n",dBest_Fit);

	{
		unsigned int iNo_Update_Counter = 0;

		for (double dTemp = 7.0; dTemp < 22.0 && (dTemp < 11.0 || (dFit / dBest_Fit) < 1.5); dTemp += 0.1)
//		double	dTemp = 12.0;
		{
			XVECTOR vCurr(cResult);
			vCurr.Set(1,dTemp); // set PS LGR temp to PS temp
			fprintf(stdout,"Trying %.1f\t",vCurr.Get(1));
			fflush(stdout);
			Generate_Synow_Spectra_Exp(i_cTarget,2001,vCurr,cOutput); // ion irrelevant for this 
			dFit = Get_Fit(i_cTarget, cOutput, 7750.0 - 25.0, 7750.0 + 25.0) + Get_Fit(i_cTarget, cOutput, 6700.0 - 25.0, 6700.0 + 25.0);
	//		dFit = Get_Fit(i_cTarget,cOutput,FIT_BLUE_WL,FIT_RED_WL);
			printf("Fit = %.2e",dFit);
			if (dFit < dBest_Fit)
			{
				dBest_Fit = dFit;
				printf("\tBF");
				vBest_Fit = vCurr;
			}
			printf("\n");
		}
	}
	cResult = vBest_Fit;
	Generate_Synow_Spectra_Exp(i_cTarget,2001,vBest_Fit,cOutput); // ion irrelevant for this 
	o_cOutput = cOutput; // not completely sure why this has to be done instead of passing o_cOutput as a parameter to Generate_Synow_Spectra, but if I do the latter it returns with flux set to zero...
	o_dTemp = vBest_Fit.Get(1);
}
Example #3
0
void cdecl TERMWINDOWMEMBER cPrintf(const char *fmt, ...)
    {
    va_list ap;
    va_start(ap, fmt);
    vsprintf(OC.prtf_buff, fmt, ap);
    va_end(ap);

    cOutput(OC.prtf_buff);
    }