Changeset 19763


Ignore:
Timestamp:
10/12/19 15:48:08 (5 years ago)
Author:
tbretz
Message:
Moved the atmosphere code to its own files and make it accessible from teh interpreter.
Location:
trunk/Mars/msim
Files:
2 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Mars/msim/MSimAtmosphere.cc

    r19009 r19763  
    5353#include "MPhotonData.h"
    5454
     55#include "MAtmosphere.h"
     56
    5557ClassImp(MSimAtmosphere);
    5658
    5759using namespace std;
    58 
     60/*
    5961// ==========================================================================
    6062//
     
    253255    }
    254256
    255     /*
    256      // The "orginal" code for the vertical thickness
    257     Double_t GetVerticalThickness(Double_t obslev, Double_t height) const
    258     {
    259         // This is a C++-version of the original code from attenu.c
    260 
    261         // Limits (height in cm) of the four layers in which atmosphere is parametrized:
    262         const double lahg[5] =
    263         {
    264             obslev,
    265             TMath::Max(obslev, 4e5),
    266             1.0e6,
    267             4.0e6,
    268             1.0e7
    269         };
    270 
    271         Double_t Rho_Tot = 0.0;
    272         for (int i=0; i<4; i++)
    273         {
    274             const Double_t b = fAtmB[i];
    275             const Double_t c = fAtmC[i];
    276 
    277             const Double_t h0 = TMath::Min(height, lahg[i+1]);
    278             const Double_t h1 =                    lahg[i];
    279 
    280             // Calculate rho for the i-th layer from the lower
    281             // to the higher layer boundary.
    282             // If height is within the layer only calculate up to height.
    283             Rho_Tot += b*(exp(-h1/c) - exp(-h0/c));
    284 
    285             if (lahg[i+1] > height)
    286                 break;
    287         }
    288 
    289         return Rho_Tot;
    290     }
    291     */
    292257    Double_t CalcTransmission(Double_t height, Double_t wavelength, Double_t sin2) const
    293258    {
     
    334299        // Calculate the traversed "vertical thickness" of air using the
    335300        // US Standard atmosphere:
    336         const Double_t Rho_tot = GetVerticalThickness(/*fObsLevel,*/ height);
     301        const Double_t Rho_tot = GetVerticalThickness(height);
    337302
    338303        // We now convert from "vertical thickness" to "slanted thickness"
     
    387352        // checks are done for each call!
    388353        return g.GetN()==0 ? 0 : g.Eval(wavelength)*1e-5; // from km^-1 to cm^-1
    389 /*
    390         // Linear interpolation
    391         // (FIXME: Is it faster to be replaced with a binary search?)
    392         // (       This might be faster because we have more photons
    393         //         with smaller wavelengths)
    394         //int index;
    395         //for (index = 1; index <g.GetN()-1; index++)
    396         //    if (wavelength < g.GetX()[index])
    397         //        break;
    398         const Int_t index = TMath::BinarySearch(g.GetN(), g.GetX(), wavelength)+1;
    399 
    400         const Double_t t0 = g.GetY()[index-1];
    401         const Double_t t1 = g.GetY()[index];
    402 
    403         const Double_t w0 = g.GetX()[index-1];
    404         const Double_t w1 = g.GetX()[index];
    405 
    406         const Double_t beta0 = t0+(t1-t0)*(wavelength-w0)/(w1-w0);
    407 
    408         return beta0 * 1e-5; // from km^-1 to cm^-1
    409         */
    410354    }
    411355
     
    490434        //const Double_t STEPTHETA = 1.74533e-2; // aprox. 1 degree
    491435
    492         /* Mie (aerosol): */
     436        // Mie (aerosol):
    493437        for (Int_t j = 0; j < 90; j++)
    494438        {
     
    566510        InitAerosols(name2);
    567511    }
    568 /*
    569     Double_t GetOz(Double_t height, Double_t theta) const
    570     {
    571         // Distance between two points D = 1km /cos(theta)
    572         // Density along y within this km:   f =  (x[i+1]-x[i])/1km * dy
    573         // Integral of this density  f =  (x[i+1]-x[i])/1km * (y[i+1]-y[i])
    574         // f(h) = int [ (c1-c0)/1km*(h-h0)*dh + c0 ] dh
    575         //      = (c-co)*(h-h0)
    576 
    577         Double_t rc = 0;
    578         int i;
    579         for (i=0; i<49; i++)
    580             if (i>=2 && i+1<height/1e5)    // cm -> km
    581                 rc += oz_conc[i] * 1e5/cos(theta);
    582 
    583         rc -= oz_conc[2]*0.2*1e5/cos(theta);
    584         rc += oz_conc[i+1]*fmod(height/1e5,1)*1e5/cos(theta);
    585 
    586         return rc;
    587     }
    588     */
    589512
    590513    Double_t CalcOzoneAbsorption(Double_t h, Double_t wavelength, Double_t theta) const
     
    593516            return 1;
    594517
    595         //******* Ozone absorption *******
     518        // ******* Ozone absorption *******
    596519        if (h > 50.e5)
    597520            h = 50.e5;
     
    617540            return 1;
    618541
    619         //******* Mie (aerosol) *******
     542        // ******* Mie (aerosol) *******
    620543        if (h > 30.e5)
    621544            h = 30.e5;
     
    665588        const Double_t h = TMath::Sqrt(H*H + d*d + 2*H*z) - R();
    666589
    667         //**** Rayleigh scattering: *****
     590        // **** Rayleigh scattering: *****
    668591        const Double_t T_Ray = CalcTransmission(h, wavelength, sin2);
    669592        if (T_Ray<0)
    670593            return 0;
    671594
    672         //****** Ozone absorption: ******
     595        // ****** Ozone absorption: ******
    673596        const Double_t T_Oz  = CalcOzoneAbsorption(h, wavelength, theta);
    674597
    675         //******** Mie (aerosol) ********
     598        // ******** Mie (aerosol) ********
    676599        const Double_t T_Mie = CalcAerosolAbsorption(h, wavelength, theta);
    677600
     
    690613
    691614const Double_t MAtmosphere::oz_conc[51]={0.3556603E-02, 0.3264150E-02, 0.2933961E-02, 0.2499999E-02, 0.2264150E-02, 0.2207546E-02, 0.2160377E-02, 0.2226414E-02, 0.2283018E-02, 0.2811320E-02, 0.3499999E-02, 0.4603772E-02, 0.6207545E-02, 0.8452828E-02, 0.9528299E-02, 0.9905657E-02, 0.1028302E-01, 0.1113207E-01, 0.1216981E-01, 0.1424528E-01, 0.1641509E-01, 0.1839622E-01, 0.1971697E-01, 0.1981131E-01, 0.1933962E-01, 0.1801886E-01, 0.1632075E-01, 0.1405660E-01, 0.1226415E-01, 0.1066037E-01, 0.9028300E-02, 0.7933960E-02, 0.6830187E-02, 0.5820753E-02, 0.4830188E-02, 0.4311319E-02, 0.3613206E-02, 0.3018867E-02, 0.2528301E-02, 0.2169811E-02, 0.1858490E-02, 0.1518867E-02, 0.1188679E-02, 0.9301884E-03, 0.7443394E-03, 0.5764149E-03, 0.4462263E-03, 0.3528301E-03, 0.2792452E-03, 0.2226415E-03, 0.1858490E-03};
    692 
     615*/
    693616// ==========================================================================
    694617
  • trunk/Mars/msim/Makefile

    r19561 r19763  
    2929           MSimAbsorption.cc \
    3030           MSimPointingPos.cc \
    31            MClonesArray.cc
     31           MClonesArray.cc \
     32           MAtmosphere.cc
    3233
    3334############################################################
  • trunk/Mars/msim/SimLinkDef.h

    r19561 r19763  
    2020#pragma link C++ class MClonesArray-; // - needed as custom streamer is already implemented
    2121
     22#pragma link C++ class MAtmosphere+;
     23#pragma link C++ class MAtmRayleigh+;
     24
    2225#endif
Note: See TracChangeset for help on using the changeset viewer.