本文整理汇总了C++中Units::olength方法的典型用法代码示例。如果您正苦于以下问题:C++ Units::olength方法的具体用法?C++ Units::olength怎么用?C++ Units::olength使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Units
的用法示例。
在下文中一共展示了Units::olength方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: calibrateAndWriteDataFrames
void InstrumentFrame::calibrateAndWriteDataFrames(int ell, QList<Array*> farrays, QStringList fnames)
{
PeerToPeerCommunicator* comm = find<PeerToPeerCommunicator>();
if (!comm->isRoot()) return;
Units* units = find<Units>();
WavelengthGrid* lambdagrid = find<WavelengthGrid>();
// conversion from bolometric luminosities (units W) to monochromatic luminosities (units W/m)
// --> divide by delta-lambda
double dlambda = lambdagrid->dlambda(ell);
// correction for the area of the pixels of the images; the units are now W/m/sr
// --> divide by area
double xpresang = 2.0*atan(_xpres/(2.0*_distance));
double ypresang = 2.0*atan(_ypres/(2.0*_distance));
double area = xpresang*ypresang;
// calibration step 3: conversion of the flux per pixel from monochromatic luminosity units (W/m/sr)
// to flux density units (W/m3/sr) by taking into account the distance
// --> divide by fourpid2
double fourpid2 = 4.0*M_PI*_distance*_distance;
// conversion from program SI units (at this moment W/m3/sr) to the correct output units
// --> multiply by unit conversion factor
double unitfactor = units->osurfacebrightness(lambdagrid->lambda(ell), 1.);
// perform the conversion, in place
foreach (Array* farr, farrays)
{
(*farr) *= (unitfactor / (dlambda * area * fourpid2));
}
// write a FITS file for each array
for (int q = 0; q < farrays.size(); q++)
{
QString filename = find<FilePaths>()->output(_instrument->instrumentName()
+ "_" + fnames[q] + "_" + QString::number(ell) + ".fits");
find<Log>()->info("Writing " + fnames[q] + " flux " + QString::number(ell)
+ " to FITS file " + filename + "...");
FITSInOut::write(filename, *(farrays[q]), _Nxp, _Nyp, 1,
units->olength(_xpres), units->olength(_ypres),
units->usurfacebrightness(), units->ulength());
}
}
示例2: write
void PanDustSystem::write() const
{
DustSystem::write();
// If requested, output the interstellar radiation field in every dust cell to a data file
if (_writeISRF)
{
WavelengthGrid* lambdagrid = find<WavelengthGrid>();
Units* units = find<Units>();
// Create a text file
TextOutFile file(this, "ds_isrf", "ISRF");
// Write the header
file.writeLine("# Mean field intensities for all dust cells with nonzero absorption");
file.addColumn("dust cell index", 'd');
file.addColumn("x coordinate of cell center (" + units->ulength() + ")", 'g');
file.addColumn("y coordinate of cell center (" + units->ulength() + ")", 'g');
file.addColumn("z coordinate of cell center (" + units->ulength() + ")", 'g');
for (int ell=0; ell<_Nlambda; ell++)
file.addColumn("J_lambda (W/m3/sr) for lambda = "
+ QString::number(units->owavelength(lambdagrid->lambda(ell)))
+ " " + units->uwavelength(), 'g');
// Write one line for each dust cell with nonzero absorption
for (int m=0; m<_Ncells; m++)
{
double Ltotm = Labs(m);
if (Ltotm>0.0)
{
QList<double> values;
Position bfr = _grid->centralPositionInCell(m);
values << m << units->olength(bfr.x()) << units->olength(bfr.y()) << units->olength(bfr.z());
for (auto J : meanintensityv(m)) values << J;
file.writeRow(values);
}
}
}
// If requested, output temperate map(s) along coordiate axes cuts
if (_writeTemp)
{
// construct a private class instance to do the work (parallelized)
WriteTemp wt(this);
Parallel* parallel = find<ParallelFactory>()->parallel();
// get the dimension of the dust grid
int dimDust = _grid->dimension();
// Create an assigner that assigns all the work to the root process
RootAssigner* assigner = new RootAssigner(0);
assigner->assign(Np);
// For the xy plane (always)
{
wt.setup(1,1,0);
parallel->call(&wt, assigner);
wt.write();
}
// For the xz plane (only if dimension is at least 2)
if (dimDust >= 2)
{
wt.setup(1,0,1);
parallel->call(&wt, assigner);
wt.write();
}
// For the yz plane (only if dimension is 3)
if (dimDust == 3)
{
wt.setup(0,1,1);
parallel->call(&wt, assigner);
wt.write();
}
}
}
示例3: write
void PanDustSystem::write() const
{
DustSystem::write();
PeerToPeerCommunicator* comm = find<PeerToPeerCommunicator>();
bool dataParallel = comm->dataParallel();
// If requested, output the interstellar radiation field in every dust cell to a data file
if (_writeISRF)
{
WavelengthGrid* lambdagrid = find<WavelengthGrid>();
Units* units = find<Units>();
// Create a text file
TextOutFile file(this, "ds_isrf", "ISRF");
// Write the header
file.writeLine("# Mean field intensities for all dust cells with nonzero absorption");
file.addColumn("dust cell index", 'd');
file.addColumn("x coordinate of cell center (" + units->ulength() + ")", 'g');
file.addColumn("y coordinate of cell center (" + units->ulength() + ")", 'g');
file.addColumn("z coordinate of cell center (" + units->ulength() + ")", 'g');
for (int ell=0; ell<_Nlambda; ell++)
file.addColumn("J_lambda (W/m3/sr) for lambda = "
+ QString::number(units->owavelength(lambdagrid->lambda(ell)))
+ " " + units->uwavelength(), 'g');
// Write one line for each dust cell with nonzero absorption
for (int m=0; m<_Ncells; m++)
{
if (!dataParallel)
{
double Ltotm = Labs(m);
if (Ltotm>0.0)
{
QList<double> values;
Position bfr = _grid->centralPositionInCell(m);
values << m << units->olength(bfr.x()) << units->olength(bfr.y()) << units->olength(bfr.z());
for (auto J : meanintensityv(m)) values << J;
file.writeRow(values);
}
}
else // for distributed mode
{
QList<double> values;
Position bfr = _grid->centralPositionInCell(m);
values << m << units->olength(bfr.x()) << units->olength(bfr.y()) << units->olength(bfr.z());
// the correct process gets Jv
Array Jv(_Nlambda);
if (_assigner->validIndex(m)) Jv = meanintensityv(m);
// and broadcasts it
int sender = _assigner->rankForIndex(m);
comm->broadcast(Jv,sender);
if (Jv.sum()>0)
{
for (auto J : Jv) values << J;
file.writeRow(values);
}
}
}
}
// If requested, output temperature map(s) along coordinate axes and temperature data for each dust cell
if (_writeTemp)
{
// Parallelize the calculation over the threads
Parallel* parallel = find<ParallelFactory>()->parallel();
// If the necessary data is distributed over the processes, do the calculation on all processes.
// Else, let the root do everything.
bool isRoot = comm->isRoot();
// Output temperature map(s) along coordinate axes
{
// Construct a private class instance to do the work (parallelized)
WriteTempCut wt(this);
// Get the dimension of the dust grid
int dimDust = _grid->dimension();
// For the xy plane (always)
{
wt.setup(1,1,0);
if (dataParallel) parallel->call(&wt, Np);
else if (isRoot) parallel->call(&wt, Np);
wt.write();
}
// For the xz plane (only if dimension is at least 2)
if (dimDust >= 2)
{
wt.setup(1,0,1);
if (dataParallel) parallel->call(&wt, Np);
else if (isRoot) parallel->call(&wt, Np);
wt.write();
}
//.........这里部分代码省略.........