当前位置: 首页>>代码示例>>C++>>正文


C++ cube::readngrid方法代码示例

本文整理汇总了C++中cube::readngrid方法的典型用法代码示例。如果您正苦于以下问题:C++ cube::readngrid方法的具体用法?C++ cube::readngrid怎么用?C++ cube::readngrid使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在cube的用法示例。


在下文中一共展示了cube::readngrid方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: emissionfromdatacube

cube emissionfromdatacube(cube datacube)
{
// construct the G(T) using CHIANTI tables
	int ng=datacube.readngrid();
	int nvars=5; // G(T), width, vx, vy, vz
	// take the last 3 from datacube
	
	cube emission(nvars, ng);
	tgrid grid=datacube.readgrid();
	emission.setgrid(grid);
	emission.settype(emisscube);

	// copy velocity vectors
	for (int i=2; i<nvars; i++)
	{
		tphysvar velcomp=datacube.readvar(i);
		emission.setvar(i,velcomp);
	};
	
	tphysvar logrho = log10(datacube.readvar(0));
	tphysvar T = datacube.readvar(1);
	tphysvar logT = log10(T);
	// writearray(logT,"empty");
	
	string ion="";// better to be aia for AIA tables this will be checked for correct table [DY]
	double lambda0=.0;
	double atweight=1;
	cube gofttab=readgoftfromchianti(chiantifile,ion,lambda0,atweight);


// fit the G(T) function to the data points
	tphysvar fittedgoft=goft(logT,logrho,gofttab);
// calculate the line width at each data point
    	tphysvar fittedwidth=linefwhm(T,lambda0,atweight);

// calculate the maximum of the emission profile at each grid point
// The emission in the CHIANTItables is calculated with the sun_coronal.abund file
// There are 2 cases:
// 	- we are doing spectroscopic calculations: the fittedemission should normalised with the alphaconst, and if a different abundance is used, we should renormalise to the new abundance
// 	- we are doing intensity calculations (for e.g. AIA): the tables are already in the correct units, and the fittedemission needs to only be multiplied with 1. 
	double normaliseconst=1.;
	double abundratio=1.;
	if (lambda_pixel>1) // for spectroscopic study
	{
               cout << "This code is configured to do spectroscopic modelling" << endl;        
               // tphysvar fittedwidth=linefwhm(T,lambda0,atweight);
		normaliseconst=1./alphaconst;
		if (abundfile != string("/empty"))
		{
			ifstream abundfilestream (abundfile);
			cout << "Reading abundances from " << abundfile << "... " << flush;
			double abundnew=abundfromchianti(abundfilestream, ion);
			cout << "Done!" << endl << flush;
			istringstream standardabundfile (______chiantitables_sun_coronal_abund_string);
			double abundold=abundfromchianti(standardabundfile,ion);
			abundratio=abundnew/abundold;
		}
	}
        if (lambda_pixel==1) // for imaging study 
        {
        
        if (atoi(ion.c_str())!=int(lambda0+0.5)) 
          {// check if it is AIA GOFT table
           cout << "GOFT table is not correct!" << endl; 
           exit(EXIT_FAILURE);
         }
 
          fittedwidth=T/T;// =1.0
        }

// Spectral modelling: ne^2 [cm^-3] * G(ne,Te) [erg cm^3 s^1] = emis [erg cm^-3 s^-1] 
// for integration *[cm] [D.Y 12 Nov 2014]
// AIA modelling: Temperature response function K(ne,Te)[cm^5 DN S^-1]*ne[cm^-3]=emis [DN cm^-1 s^-1]; 
// for integration *[cm] [D.Y 12 Nov 20
//        cout << "normaliseconst" <<normaliseconst << endl;
//        cout << "abundratio"<<abundratio<<endl;
	tphysvar fittedemission=normaliseconst*abundratio*pow(10.,2.*logrho)*fittedgoft;
	fittedemission=fittedemission/fittedwidth;

// load the emission and width into the emission-cube variable	
	emission.setvar(0,fittedemission);

	emission.setvar(1,fittedwidth);


	return emission;
};
开发者ID:TomVeeDee,项目名称:FoMo,代码行数:87,代码来源:emissioncube.cpp


注:本文中的cube::readngrid方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。