Beispiel #1
0
void PanDustSystem::setupSelfBefore()
{
    DustSystem::setupSelfBefore();

    // if there is no dust emission, turn off the irrelevant flags just to be sure
    if (!_dustemissivity)
    {
        setDustLib(0);
        setSelfAbsorption(false);
        setWriteTemperature(false);
        setWriteISRF(false);
        setWriteEmissivity(false);
    }
    // if there is dust emission, make sure that there is a dust library as well
    else
    {
        if (!_dustlib) throw FATALERROR("There should be a dust library when dust emission is turned on");
    }

    // verify that the wavelength range includes the V-band center 0.55 micron (needed for normalization of dust)
    WavelengthGrid* lambdagrid = find<WavelengthGrid>();
    if (lambdagrid->nearest(0.55e-6) < 0)
        throw FATALERROR("Wavelength range should include 0.55 micron for a panchromatic simulation with dust");

    // cache size of wavelength grid
    _Nlambda = lambdagrid->Nlambda();
}
Array GreyBodyDustEmissivity::emissivity(const DustMix* mix, const Array& Jv) const
{
    // get basic information about the wavelength grid
    WavelengthGrid* lambdagrid = find<WavelengthGrid>();
    int Nlambda = lambdagrid->Nlambda();

    // get basic information about the dust mix
    int Npop = mix->Npop();

    // accumulate the emissivities at the equilibrium temperature for all populations in the dust mix
    Array ev(Nlambda);
    for (int c=0; c<Npop; c++)
    {
        double T = mix->equilibrium(Jv,c);
        PlanckFunction B(T);
        for (int ell=0; ell<Nlambda; ell++)
        {
            ev[ell] += mix->sigmaabs(ell,c) * B(lambdagrid->lambda(ell));
        }
    }

    // convert emissivity from "per hydrogen atom" to "per unit mass"
    ev /= mix->mu();
    return ev;
}
Beispiel #3
0
Array PanDustSystem::meanintensityv(int m) const
{
    WavelengthGrid* lambdagrid = find<WavelengthGrid>();
    Array Jv(lambdagrid->Nlambda());
    double fac = 4.0*M_PI*volume(m);
    for (int ell=0; ell<lambdagrid->Nlambda(); ell++)
    {
        double kappaabsrho = 0.0;
        for (int h=0; h<_Ncomp; h++)
        {
            double kappaabs = mix(h)->kappaabs(ell);
            double rho = density(m,h);
            kappaabsrho += kappaabs*rho;
        }
        double J = Labs(m,ell) / (kappaabsrho*fac) / lambdagrid->dlambda(ell);
        // guard against (rare) situations where both Labs and kappa*fac are zero
        Jv[ell] = std::isfinite(J) ? J : 0.0;
    }
    return Jv;
}
Beispiel #4
0
void SED::write(const QString& filename) const
{
    WavelengthGrid* lambdagrid = find<WavelengthGrid>();
    Units* units = find<Units>();

    ofstream file(filename.toLocal8Bit().constData());
    file << setprecision(8) << scientific;
    for (int ell=0; ell<lambdagrid->Nlambda(); ell++)
    {
        double lambda = lambdagrid->lambda(ell);
        double dlambda = lambdagrid->dlambda(ell);
        file << units->owavelength(lambda)
             << '\t'
             << _Lv[ell]/dlambda*lambda
             << endl;
    }
    file.close();
}
Beispiel #5
0
void QuasarSED::setupSelfBefore()
{
    StellarSED::setupSelfBefore();

    WavelengthGrid* lambdagrid = find<WavelengthGrid>();
    double Nlambda = lambdagrid->Nlambda();

    Array jv(Nlambda);
    for (int ell=0; ell<Nlambda; ell++)
    {
        double lambda = lambdagrid->lambda(ell);

        lambda *= 1e6; // conversion from m to micron (the Quasar SED is defined using microns)
        double j = 0.0;
        double a = 1.0;
        double b = 0.003981072;
        double c = 0.001258926;
        double d = 0.070376103;

        if (lambda<0.001)
            j = 0.0;
        else if (lambda<0.01)
            j = a*pow(lambda,0.2);
        else if (lambda<0.1)
            j = b*pow(lambda,-1.0);
        else if (lambda<5.0)
            j = c*pow(lambda,-1.5);
        else if (lambda<1000.0)
            j = d*pow(lambda,-4.0);
        else
            j = 0.0;
        jv[ell] = j;
    }

    setemissivities(jv);
}
void SingleFrameInstrument::calibrateAndWriteDataCubes(QList< Array*> farrays, QStringList fnames)
{
    WavelengthGrid* lambdagrid = find<WavelengthGrid>();
    int Nlambda = lambdagrid->Nlambda();

    // calibration step 1: conversion from bolometric luminosities (units W) to monochromatic luminosities (units W/m)

    for (int ell=0; ell<Nlambda; ell++)
    {
        double dlambda = lambdagrid->dlambda(ell);
        for (int i=0; i<_Nxp; i++)
        {
            for (int j=0; j<_Nyp; j++)
            {
                int m = i + _Nxp*j + _Nxp*_Nyp*ell;
                foreach (Array* farr, farrays)
                {
                    (*farr)[m] /= dlambda;
                }
            }
        }
    }

    // calibration step 2: correction for the area of the pixels of the images; the units are now W/m/sr

    double xpresang = 2.0*atan(_xpres/(2.0*_distance));
    double ypresang = 2.0*atan(_ypres/(2.0*_distance));
    double area = xpresang*ypresang;
    foreach (Array* farr, farrays)
    {
        (*farr) /= area;
    }

    // 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

    double fourpid2 = 4.0*M_PI*_distance*_distance;
    foreach (Array* farr, farrays)
    {
        (*farr) /= fourpid2;
    }

    // conversion from program SI units (at this moment W/m3/sr) to the correct output units;
    // we use lambda*flambda for the surface brightness (in units like W/m2/arcsec2)

    Units* units = find<Units>();
    for (int ell=0; ell<Nlambda; ell++)
    {
        double lambda = lambdagrid->lambda(ell);
        for (int i=0; i<_Nxp; i++)
        {
            for (int j=0; j<_Nyp; j++)
            {
                int m = i + _Nxp*j + _Nxp*_Nyp*ell;
                foreach (Array* farr, farrays)
                {
                    (*farr)[m] = units->obolsurfacebrightness(lambda*(*farr)[m]);
                }
            }
        }
    }