Changeset 1713 for trunk


Ignore:
Timestamp:
03/17/10 18:01:27 (15 years ago)
Author:
Max Voronkov
Message:

added method to calculate opacity including refraction effects + methods to work on a vector of frequencies

Location:
trunk/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/STAtmosphere.cpp

    r1712 r1713  
    383383}
    384384
     385/**
     386 * Calculate zenith opacity for the range of frequencies. Same as zenithOpacity, but
     387 * for a vector of frequencies.
     388 * @param[in] freqs vector of frequencies in Hz
     389 * @return vector of zenith opacities, one value per frequency (nepers, i.e. dimensionless)
     390 **/
     391std::vector<double> STAtmosphere::zenithOpacities(const std::vector<double> &freqs) const
     392{
     393  std::vector<double> result(freqs.size());
     394  for (size_t ch = 0; ch<freqs.size(); ++ch) {
     395       result[ch] = zenithOpacity(freqs[ch]);
     396  }
     397  return result;
     398}
     399
     400/**
     401 * Calculate opacity at the given frequency and elevation. This is a simplified
     402 * version of the routine implemented in MIRIAD, which calculates just the opacity and
     403 * nothing else. In contract to zenithOpacity, this method takes into account refraction
     404 * and is more accurate than if one assumes 1/sin(el) factor.
     405 * @param[in] freq frequency of interest in Hz
     406 * @param[in] el elevation in radians
     407 * @return zenith opacity (nepers, i.e. dimensionless)
     408 **/
     409double STAtmosphere::opacity(double freq, double el) const
     410{
     411  // essentially a numerical integration with the Trapezium method
     412  double tau = 0.;
     413  const double sineEl = sin(el);
     414  for (int layer = int(nLayers()) - 1; layer>=0; --layer) {
     415       double dH = 0.;
     416       if (layer == 0) {
     417           dH = 0.5*(itsHeights[1]-itsHeights[0]);
     418       } else if (layer + 1 == int(nLayers())) {
     419           dH = 0.5*(itsHeights[nLayers()-1]-itsHeights[nLayers()-2]);
     420       } else {
     421           dH = 0.5*(itsHeights[layer+1]-itsHeights[layer-1]);
     422       }
     423       // total complex refractivity
     424       const std::complex<double> n = dryRefractivity(freq,itsTemperatures[layer],itsDryPressures[layer],
     425                                                      itsVapourPressures[layer]) +
     426                                      vapourRefractivity(freq,itsTemperatures[layer],itsDryPressures[layer],
     427                                                      itsVapourPressures[layer]);
     428       // real and imaginary part of the total complex refractivity scaled appropriately
     429       const double nImag = 1e-6*std::imag(n);
     430       const double nReal = 1. + 1e-6*std::real(n);
     431       // length increment
     432       const double dL = dH*nReal/sqrt(nReal*nReal+sineEl*sineEl-1.);
     433       tau += dL*4.*casa::C::pi/QC::c.get().getValue()*freq*nImag;
     434  }
     435  return tau; 
     436}
     437
     438/**
     439 * Calculate opacities for the range of frequencies at the given elevation. Same as
     440 * opacity, but for a vector of frequencies.
     441 * @param[in] freqs vector of frequencies in Hz
     442 * @param[in] el elevation in radians
     443 * @return vector of opacities, one value per frequency (nepers, i.e. dimensionless)
     444 **/
     445std::vector<double> STAtmosphere::opacities(const std::vector<double> &freqs, double el) const
     446{
     447  std::vector<double> result(freqs.size());
     448  for (size_t ch = 0; ch<freqs.size(); ++ch) {
     449       result[ch] = opacity(freqs[ch],el);
     450  }
     451  return result;
     452}
     453
  • trunk/src/STAtmosphere.h

    r1712 r1713  
    119119  double zenithOpacity(double freq) const;
    120120
     121  /**
     122   * Calculate zenith opacity for the range of frequencies. Same as zenithOpacity, but
     123   * for a vector of frequencies.
     124   * @param[in] freqs vector of frequencies in Hz
     125   * @return vector of zenith opacities, one value per frequency (nepers, i.e. dimensionless)
     126   **/
     127  std::vector<double> zenithOpacities(const std::vector<double> &freqs) const;
     128 
     129  /**
     130   * Calculate opacity at the given frequency and elevation. This is a simplified
     131   * version of the routine implemented in MIRIAD, which calculates just the opacity and
     132   * nothing else. In contract to zenithOpacity, this method takes into account refraction
     133   * and is more accurate than if one assumes 1/sin(el) factor.
     134   * @param[in] freq frequency of interest in Hz
     135   * @param[in] el elevation in radians
     136   * @return zenith opacity (nepers, i.e. dimensionless)
     137   **/
     138   double opacity(double freq, double el) const;
     139
     140  /**
     141   * Calculate opacities for the range of frequencies at the given elevation. Same as
     142   * opacity, but for a vector of frequencies.
     143   * @param[in] freqs vector of frequencies in Hz
     144   * @param[in] el elevation in radians
     145   * @return vector of opacities, one value per frequency (nepers, i.e. dimensionless)
     146   **/
     147  std::vector<double> opacities(const std::vector<double> &freqs, double el) const;
     148         
    121149protected:
    122150  /**
Note: See TracChangeset for help on using the changeset viewer.