Changeset 1715 for trunk/src


Ignore:
Timestamp:
03/17/10 22:03:25 (15 years ago)
Author:
Max Voronkov
Message:

changed pressure to the mean sea level to match miriad, bugfix, C++ code is now exposed to python

Location:
trunk/src
Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/STAtmosphere.cpp

    r1713 r1715  
    6565 **/
    6666STAtmosphere::STAtmosphere(double wvScale, double maxAlt, size_t nLayers) :
    67    itsGndTemperature(288.), itsGndPressure(101325.), itsGndHumidity(0.5),
    68    itsLapseRate(0.0065), itsWVScale(wvScale), itsMaxAlt(maxAlt),
    6967   itsHeights(nLayers), itsTemperatures(nLayers),
    70    itsDryPressures(nLayers), itsVapourPressures(nLayers)
     68   itsDryPressures(nLayers), itsVapourPressures(nLayers),
     69   itsGndTemperature(288.), itsPressure(101325.), itsGndHumidity(0.5),
     70   itsLapseRate(0.0065), itsWVScale(wvScale), itsMaxAlt(maxAlt), itsObsHeight(200.)
    7171{
    7272  recomputeAtmosphereModel();
     
    7676 * Constructor with explicitly given parameters of the atmosphere
    7777 * @param[in] temperature air temperature at the observatory (K)
    78  * @param[in] pressure air pressure at the observatory (Pascals)
     78 * @param[in] pressure air pressure at the sea level (Pascals)
    7979 * @param[in] humidity air humidity at the observatory (fraction)
    8080 * @param[in] lapseRate temperature lapse rate (K/m), default is 0.0065 K/m to match MIRIAD and ISA
     
    8787STAtmosphere::STAtmosphere(double temperature, double pressure, double humidity, double lapseRate,
    8888               double wvScale, double maxAlt, size_t nLayers) :
    89    itsGndTemperature(temperature), itsGndPressure(pressure), itsGndHumidity(humidity),
    90    itsLapseRate(lapseRate), itsWVScale(wvScale), itsMaxAlt(maxAlt),
    9189   itsHeights(nLayers), itsTemperatures(nLayers),
    92    itsDryPressures(nLayers), itsVapourPressures(nLayers)
     90   itsDryPressures(nLayers), itsVapourPressures(nLayers),
     91   itsGndTemperature(temperature), itsPressure(pressure), itsGndHumidity(humidity),
     92   itsLapseRate(lapseRate), itsWVScale(wvScale), itsMaxAlt(maxAlt), itsObsHeight(200.)
    9393{
    9494  recomputeAtmosphereModel();
     
    9898 * Set the new weather station data, recompute the model
    9999 * @param[in] temperature air temperature at the observatory (K)
    100  * @param[in] pressure air pressure at the observatory (Pascals)
     100 * @param[in] pressure air pressure at the sea level (Pascals)
    101101 * @param[in] humidity air humidity at the observatory (fraction)
    102102 **/
     
    104104{
    105105  itsGndTemperature = temperature;
    106   itsGndPressure = pressure;
     106  itsPressure = pressure;
    107107  itsGndHumidity = humidity;
    108108  recomputeAtmosphereModel();
     
    110110
    111111/**
     112 * Set the elevation of the observatory (height above mean sea level)
     113 * By default, 200m is assumed.
     114 * @param[in] elev elevation in metres
     115 **/
     116void STAtmosphere::setObservatoryElevation(double elev)
     117{
     118  itsObsHeight = elev;
     119  recomputeAtmosphereModel(); 
     120}
     121
     122
     123/**
    112124 * Build the atmosphere model based on exponential fall-off, ideal gas and hydrostatic
    113125 * equilibrium. The model parameters are taken from the data members of this class.
     
    116128{
    117129  AlwaysAssert(itsGndTemperature > 0, AipsError);
    118   AlwaysAssert(itsGndPressure > 0., AipsError);
     130  AlwaysAssert(itsPressure > 0., AipsError);
    119131  AlwaysAssert((itsGndHumidity >= 0.) && (itsGndHumidity<=1.), AipsError);
    120132  AlwaysAssert(itsMaxAlt > 0., AipsError);
     
    126138  // free-fall acceleration
    127139  const double g = 9.81;
     140 
    128141  const double wvGndSaturationPressure = wvSaturationPressure(itsGndTemperature);
     142  const double gndPressure = itsPressure*exp(-M*g/(QC::R.get().getValue()*itsGndTemperature)*
     143                   (itsObsHeight+0.5*itsLapseRate*itsObsHeight*itsObsHeight/itsGndTemperature));
    129144  for (size_t layer = 0; layer < nLayers(); ++layer) {
    130145       const double height = double(layer)*heightStep;
    131146       itsHeights[layer] = height;
    132147       itsTemperatures[layer] = itsGndTemperature/(1.+itsLapseRate*height/itsGndTemperature);
    133        const double pressure = itsGndPressure * exp(-M*g/(QC::R.get().getValue()*itsGndTemperature)*
     148       const double pressure = gndPressure * exp(-M*g/(QC::R.get().getValue()*itsGndTemperature)*
    134149                   (height+0.5*itsLapseRate*height*height/itsGndTemperature));
    135150       itsVapourPressures[layer] = casa::min(itsGndHumidity*exp(-height/itsWVScale)*wvGndSaturationPressure,
    136151                                             wvSaturationPressure(itsTemperatures[layer]));
    137152       itsDryPressures[layer] = pressure - itsVapourPressures[layer];                                     
     153       std::cout<<"layer="<<layer<<": H="<<itsHeights[layer]<<" T="<<itsTemperatures[layer]<<
     154           " Pvap="<<itsVapourPressures[layer]<<" Pdry="<<itsDryPressures[layer]<<endl;
    138155  }
    139156}
     
    166183double STAtmosphere::wvSaturationPressure(double temperature)
    167184{
    168   if (temperature > 215.) {
     185  if (temperature <= 215.) {
    169186      return 0.;
    170187  }
  • trunk/src/STAtmosphere.h

    r1713 r1715  
    110110
    111111  /**
     112   * Set the elevation of the observatory (height above mean sea level)
     113   * By default, 200m is assumed.
     114   * @param[in] elev elevation in metres
     115   **/
     116  void setObservatoryElevation(double elev);
     117
     118  /**
    112119   * Calculate zenith opacity at the given frequency. This is a simplified version
    113120   * of the routine implemented in MIRIAD, which calculates just zenith opacity and
     
    136143   * @return zenith opacity (nepers, i.e. dimensionless)
    137144   **/
    138    double opacity(double freq, double el) const;
     145  double opacity(double freq, double el) const;
    139146
    140147  /**
     
    226233  double itsGndTemperature;
    227234 
    228   // ground level pressure (Pascals)
    229   double itsGndPressure;
     235  // sea level pressure (Pascals)
     236  double itsPressure;
    230237 
    231238  // ground level humidity (fraction)
     
    240247  // altitude of the highest layer of the model (m)
    241248  double itsMaxAlt;
     249 
     250  // observatory elevation (m)
     251  double itsObsHeight;
    242252};
    243253
  • trunk/src/python_asap.cpp

    r1598 r1715  
    7676  asap::python::python_Logger();
    7777  asap::python::python_STCoordinate();
     78  asap::python::python_STAtmosphere();
    7879
    7980#ifndef HAVE_LIBPYRAP
  • trunk/src/python_asap.h

    r1598 r1715  
    4848    void python_Logger();
    4949    void python_STCoordinate();
     50    void python_STAtmosphere();
    5051
    5152  } // python
Note: See TracChangeset for help on using the changeset viewer.