LCOV - code coverage report
Current view: top level - atmosphere/ATM - ATMRefractiveIndexProfile.cc (source / functions) Hit Total Coverage
Test: casacpp_coverage.info Lines: 518 990 52.3 %
Date: 2024-10-29 13:38:20 Functions: 58 136 42.6 %

          Line data    Source code
       1             : /*******************************************************************************
       2             :  * ALMA - Atacama Large Millimiter Array
       3             :  * (c) Instituto de Estructura de la Materia, 2009
       4             :  *
       5             :  * This library is free software; you can redistribute it and/or
       6             :  * modify it under the terms of the GNU Lesser General Public
       7             :  * License as published by the Free Software Foundation; either
       8             :  * version 2.1 of the License, or (at your option) any later version.
       9             :  *
      10             :  * This library is distributed in the hope that it will be useful,
      11             :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      12             :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      13             :  * Lesser General Public License for more details.
      14             :  *
      15             :  * You should have received a copy of the GNU Lesser General Public
      16             :  * License along with this library; if not, write to the Free Software
      17             :  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
      18             :  *
      19             :  * "@(#) $Id: ATMRefractiveIndexProfile.cpp Exp $"
      20             :  *
      21             :  * who       when      what
      22             :  * --------  --------  ----------------------------------------------
      23             :  * pardo     24/03/09  created
      24             :  */
      25             : 
      26             : #include "ATMRefractiveIndexProfile.h"
      27             : 
      28             : #include <iostream>
      29             : #include <math.h>
      30             : #include <string>
      31             : #include <vector>
      32             : 
      33             : 
      34             : 
      35             : ATM_NAMESPACE_BEGIN
      36             : 
      37             : // Constructors
      38             : 
      39           2 : RefractiveIndexProfile::RefractiveIndexProfile(const Frequency &freq,
      40           2 :                                                const AtmProfile &atmProfile) :
      41           2 :   AtmProfile(atmProfile), SpectralGrid(freq)
      42             : {
      43           2 :   mkRefractiveIndexProfile();
      44           2 : }
      45             : 
      46           3 : RefractiveIndexProfile::RefractiveIndexProfile(const SpectralGrid &spectralGrid,
      47           3 :                                                const AtmProfile &atmProfile) :
      48           3 :   AtmProfile(atmProfile), SpectralGrid(spectralGrid)
      49             : {
      50           3 :   mkRefractiveIndexProfile();
      51           3 : }
      52             : 
      53           3 : RefractiveIndexProfile::RefractiveIndexProfile(const RefractiveIndexProfile & a) : AtmProfile(a), SpectralGrid(a)
      54             : {
      55             :   //   std::cout<<"Enter RefractiveIndexProfile copy constructor version Fri May 20 00:59:47 CEST 2005"<<endl;
      56             : 
      57             :   // level AtmProfile
      58             : 
      59             :   // type_ = a.type_;
      60             :   // prLimit_ = a.prLimit_;
      61             :   /*
      62             :    v_hx_.reserve(a.v_hx_.size());
      63             :    v_px_.reserve(a.v_px_.size());
      64             :    v_tx_.reserve(a.v_tx_.size());
      65             :    for(unsigned int n=0; n<a.v_hx_.size(); n++){
      66             :    v_hx_.push_back(a.v_hx_[n]);
      67             :    v_px_.push_back(a.v_px_[n]);
      68             :    v_tx_.push_back(a.v_tx_[n]);
      69             :    }
      70             :    */
      71             : 
      72           3 :   typeAtm_ = a.typeAtm_;
      73           3 :   groundTemperature_ = a.groundTemperature_;
      74           3 :   tropoLapseRate_ = a.tropoLapseRate_;
      75           3 :   groundPressure_ = a.groundPressure_;
      76           3 :   relativeHumidity_ = a.relativeHumidity_;
      77           3 :   wvScaleHeight_ = a.wvScaleHeight_;
      78           3 :   pressureStep_ = a.pressureStep_;
      79           3 :   pressureStepFactor_ = a.pressureStepFactor_;
      80           3 :   altitude_ = a.altitude_;
      81           3 :   topAtmProfile_ = a.topAtmProfile_;
      82           3 :   numLayer_ = a.numLayer_;
      83           3 :   newBasicParam_ = a.newBasicParam_;
      84             : 
      85             :   // copy thresholds
      86           3 :   altitudeThreshold_ = a.altitudeThreshold_;
      87           3 :   groundPressureThreshold_ = a.groundPressureThreshold_;
      88           3 :   groundTemperatureThreshold_ = a.groundTemperatureThreshold_;
      89           3 :   tropoLapseRateThreshold_ = a.tropoLapseRateThreshold_;
      90           3 :   relativeHumidityThreshold_ = a.relativeHumidityThreshold_;
      91           3 :   wvScaleHeightThreshold_ = a.wvScaleHeightThreshold_;
      92             : 
      93           3 :   v_layerThickness_.reserve(numLayer_);
      94           3 :   v_layerTemperature_.reserve(numLayer_);
      95           3 :   v_layerWaterVapor_.reserve(numLayer_);
      96           3 :   v_layerCO_.reserve(numLayer_);
      97           3 :   v_layerO3_.reserve(numLayer_);
      98           3 :   v_layerN2O_.reserve(numLayer_);
      99           3 :   v_layerNO2_.reserve(numLayer_);
     100           3 :   v_layerSO2_.reserve(numLayer_);
     101             : 
     102             : 
     103          83 :   for(unsigned int n = 0; n < numLayer_; n++) {
     104          80 :     v_layerThickness_.push_back(a.v_layerThickness_[n]);
     105          80 :     v_layerTemperature_.push_back(a.v_layerTemperature_[n]);
     106             :     //cout << "n=" << n << std::endl;
     107          80 :     v_layerWaterVapor_.push_back(a.v_layerWaterVapor_[n]);
     108          80 :     v_layerPressure_.push_back(a.v_layerPressure_[n]);
     109          80 :     v_layerCO_.push_back(a.v_layerCO_[n]);
     110          80 :     v_layerO3_.push_back(a.v_layerO3_[n]);
     111          80 :     v_layerN2O_.push_back(a.v_layerN2O_[n]);
     112          80 :     v_layerNO2_.push_back(a.v_layerNO2_[n]);
     113          80 :     v_layerSO2_.push_back(a.v_layerSO2_[n]);
     114             :   }
     115             : 
     116             :   // level Spectral Grid
     117           3 :   freqUnits_ = a.freqUnits_;
     118           3 :   v_chanFreq_ = a.v_chanFreq_;
     119             : 
     120           3 :   v_numChan_ = a.v_numChan_;
     121           3 :   v_refChan_ = a.v_refChan_;
     122           3 :   v_refFreq_ = a.v_refFreq_;
     123           3 :   v_chanSep_ = a.v_chanSep_;
     124           3 :   v_maxFreq_ = a.v_maxFreq_;
     125           3 :   v_minFreq_ = a.v_minFreq_;
     126           3 :   v_intermediateFrequency_ = a.v_intermediateFrequency_;
     127           3 :   v_loFreq_ = a.v_loFreq_;
     128             : 
     129           3 :   v_sidebandSide_ = a.v_sidebandSide_;
     130           3 :   v_sidebandType_ = a.v_sidebandType_;
     131             : 
     132           3 :   vv_assocSpwId_ = a.vv_assocSpwId_;
     133           3 :   vv_assocNature_ = a.vv_assocNature_;
     134             : 
     135           3 :   v_transfertId_ = a.v_transfertId_;
     136             : 
     137             :   // level Absorption Profile
     138           3 :   vv_N_H2OLinesPtr_.reserve(a.v_chanFreq_.size());
     139           3 :   vv_N_H2OContPtr_.reserve(a.v_chanFreq_.size());
     140           3 :   vv_N_O2LinesPtr_.reserve(a.v_chanFreq_.size());
     141           3 :   vv_N_DryContPtr_.reserve(a.v_chanFreq_.size());
     142           3 :   vv_N_O3LinesPtr_.reserve(a.v_chanFreq_.size());
     143           3 :   vv_N_COLinesPtr_.reserve(a.v_chanFreq_.size());
     144           3 :   vv_N_N2OLinesPtr_.reserve(a.v_chanFreq_.size());
     145           3 :   vv_N_NO2LinesPtr_.reserve(a.v_chanFreq_.size());
     146           3 :   vv_N_SO2LinesPtr_.reserve(a.v_chanFreq_.size());
     147             : 
     148             :   std::vector<std::complex<double> >* v_N_H2OLinesPtr;
     149             :   std::vector<std::complex<double> >* v_N_H2OContPtr;
     150             :   std::vector<std::complex<double> >* v_N_O2LinesPtr;
     151             :   std::vector<std::complex<double> >* v_N_DryContPtr;
     152             :   std::vector<std::complex<double> >* v_N_O3LinesPtr;
     153             :   std::vector<std::complex<double> >* v_N_COLinesPtr;
     154             :   std::vector<std::complex<double> >* v_N_N2OLinesPtr;
     155             :   std::vector<std::complex<double> >* v_N_NO2LinesPtr;
     156             :   std::vector<std::complex<double> >* v_N_SO2LinesPtr;
     157             : 
     158          29 :   for(unsigned int nc = 0; nc < v_chanFreq_.size(); nc++) {
     159             : 
     160          26 :     v_N_H2OLinesPtr = new std::vector<std::complex<double> > ;
     161          26 :     v_N_H2OLinesPtr->reserve(numLayer_);
     162          26 :     v_N_H2OContPtr = new std::vector<std::complex<double> > ;
     163          26 :     v_N_H2OContPtr->reserve(numLayer_);
     164          26 :     v_N_O2LinesPtr = new std::vector<std::complex<double> > ;
     165          26 :     v_N_O2LinesPtr->reserve(numLayer_);
     166          26 :     v_N_DryContPtr = new std::vector<std::complex<double> > ;
     167          26 :     v_N_DryContPtr->reserve(numLayer_);
     168          26 :     v_N_O3LinesPtr = new std::vector<std::complex<double> > ;
     169          26 :     v_N_O3LinesPtr->reserve(numLayer_);
     170          26 :     v_N_COLinesPtr = new std::vector<std::complex<double> > ;
     171          26 :     v_N_COLinesPtr->reserve(numLayer_);
     172          26 :     v_N_N2OLinesPtr = new std::vector<std::complex<double> > ;
     173          26 :     v_N_N2OLinesPtr->reserve(numLayer_);
     174          26 :     v_N_NO2LinesPtr = new std::vector<std::complex<double> > ;
     175          26 :     v_N_NO2LinesPtr->reserve(numLayer_);
     176          26 :     v_N_SO2LinesPtr = new std::vector<std::complex<double> > ;
     177          26 :     v_N_SO2LinesPtr->reserve(numLayer_);
     178             : 
     179         606 :     for(unsigned int n = 0; n < numLayer_; n++) {
     180             : 
     181             :       // std::cout << "numLayer_=" << nc << " " << n << std::endl; // COMMENTED OUT BY JUAN MAY/16/2005
     182             : 
     183         580 :       v_N_H2OLinesPtr->push_back(a.vv_N_H2OLinesPtr_[nc]->at(n));
     184         580 :       v_N_H2OContPtr->push_back(a.vv_N_H2OContPtr_[nc]->at(n));
     185         580 :       v_N_O2LinesPtr->push_back(a.vv_N_O2LinesPtr_[nc]->at(n));
     186         580 :       v_N_DryContPtr->push_back(a.vv_N_DryContPtr_[nc]->at(n));
     187         580 :       v_N_O3LinesPtr->push_back(a.vv_N_O3LinesPtr_[nc]->at(n));
     188         580 :       v_N_COLinesPtr->push_back(a.vv_N_COLinesPtr_[nc]->at(n));
     189         580 :       v_N_N2OLinesPtr->push_back(a.vv_N_N2OLinesPtr_[nc]->at(n));
     190         580 :       v_N_NO2LinesPtr->push_back(a.vv_N_NO2LinesPtr_[nc]->at(n));
     191         580 :       v_N_SO2LinesPtr->push_back(a.vv_N_SO2LinesPtr_[nc]->at(n));
     192             : 
     193             :     }
     194             : 
     195          26 :     vv_N_H2OLinesPtr_.push_back(v_N_H2OLinesPtr);
     196          26 :     vv_N_H2OContPtr_.push_back(v_N_H2OContPtr);
     197          26 :     vv_N_O2LinesPtr_.push_back(v_N_O2LinesPtr);
     198          26 :     vv_N_DryContPtr_.push_back(v_N_DryContPtr);
     199          26 :     vv_N_O3LinesPtr_.push_back(v_N_O3LinesPtr);
     200          26 :     vv_N_COLinesPtr_.push_back(v_N_COLinesPtr);
     201          26 :     vv_N_N2OLinesPtr_.push_back(v_N_N2OLinesPtr);
     202          26 :     vv_N_NO2LinesPtr_.push_back(v_N_NO2LinesPtr);
     203          26 :     vv_N_SO2LinesPtr_.push_back(v_N_SO2LinesPtr);
     204             : 
     205             :   }
     206             : 
     207           3 : }
     208             : 
     209           0 : RefractiveIndexProfile::RefractiveIndexProfile()
     210             : {
     211           0 : }
     212             : 
     213           8 : RefractiveIndexProfile::~RefractiveIndexProfile()
     214             : {
     215           8 :   rmRefractiveIndexProfile();
     216           8 : }
     217             : 
     218         128 : void RefractiveIndexProfile::rmRefractiveIndexProfile()
     219             : {
     220             :   // for every frequency channel delete the pointer to the absorption profile
     221        2631 :   for(unsigned int nc = 0; nc < v_chanFreq_.size(); nc++) {
     222        2503 :     delete vv_N_H2OLinesPtr_[nc];
     223        2503 :     delete vv_N_H2OContPtr_[nc];
     224        2503 :     delete vv_N_O2LinesPtr_[nc];
     225        2503 :     delete vv_N_DryContPtr_[nc];
     226        2503 :     delete vv_N_O3LinesPtr_[nc];
     227        2503 :     delete vv_N_COLinesPtr_[nc];
     228        2503 :     delete vv_N_N2OLinesPtr_[nc];
     229        2503 :     delete vv_N_NO2LinesPtr_[nc];
     230        2503 :     delete vv_N_SO2LinesPtr_[nc];
     231             :   }
     232         128 : }
     233             : 
     234         120 : bool RefractiveIndexProfile::updateRefractiveIndexProfile(const Length &altitude,
     235             :                                                           const Pressure &groundPressure,
     236             :                                                           const Temperature &groundTemperature,
     237             :                                                           double tropoLapseRate,
     238             :                                                           const Humidity &relativeHumidity,
     239             :                                                           const Length &wvScaleHeight)
     240             : {
     241             : 
     242         120 :   bool updated = false;
     243         120 :   bool mkNewAtmProfile = updateAtmProfile(altitude,
     244             :                                           groundPressure,
     245             :                                           groundTemperature,
     246             :                                           tropoLapseRate,
     247             :                                           relativeHumidity,
     248             :                                           wvScaleHeight);
     249         120 :   unsigned int numLayer = getNumLayer();
     250             : 
     251         120 :   if(vv_N_H2OLinesPtr_.size() < v_chanFreq_.size()) {
     252           0 :     mkNewAtmProfile = true;
     253           0 :     std::cout << " RefractiveIndexProfile: number of spectral windows has increased"
     254           0 :         << std::endl;
     255             :   }
     256         120 :   if(mkNewAtmProfile) {
     257         120 :     if(numLayer) {
     258         120 :       mkRefractiveIndexProfile();
     259         120 :       updated = true;
     260             :     } else {
     261           0 :       std::cout << " RefractiveIndexProfile: ERROR:  getNumLayer() returns 0"
     262           0 :           << std::endl;
     263             :     }
     264             :   }
     265         120 :   return updated;
     266             : }
     267             : 
     268             : // NB: this interface is required because the sub-class .... overrides this method.
     269           0 : bool RefractiveIndexProfile::setBasicAtmosphericParameters(const Length &altitude,
     270             :                                                            const Pressure &groundPressure,
     271             :                                                            const Temperature &groundTemperature,
     272             :                                                            double tropoLapseRate,
     273             :                                                            const Humidity &relativeHumidity,
     274             :                                                            const Length &wvScaleHeight)
     275             : {
     276           0 :   bool updated = updateRefractiveIndexProfile(altitude,
     277             :                                               groundPressure,
     278             :                                               groundTemperature,
     279             :                                               tropoLapseRate,
     280             :                                               relativeHumidity,
     281             :                                               wvScaleHeight);
     282           0 :   return updated;
     283             : }
     284             : 
     285         125 : void RefractiveIndexProfile::mkRefractiveIndexProfile()
     286             : {
     287             : 
     288             :   //    static const double abun_18o=0.0020439;
     289             :   //    static const double abun_17o=0.0003750;
     290             :   //    static const double abun_D=0.000298444;
     291             :   //    static const double o2_mixing_ratio=0.2092;
     292             :   //    static const double mmol_h2o=18.005059688;  //   20*0.0020439+19*(0.0003750+2*0.000298444)+18*(1-0.0020439-0.0003750-2*0.000298444)
     293             : 
     294             :   // static bool first = true;   // [-Wunused_but_set_variable]
     295             : 
     296             :   double abun_O3, abun_CO, abun_N2O, abun_NO2, abun_SO2;
     297             :   double wvt, wv;
     298             :   // double t; // [-Wunused_but_set_variable]
     299             :   double nu;
     300             :   // double nu2, nu_pi; // [-Wunused_but_set_variable]
     301             :   // double width;
     302             :   // unsigned int npoints;
     303         125 :   RefractiveIndex atm;
     304             :   //    double sumAbsO3Lines1, sumAbsCOLines1, sumAbsN2OLines1, sumAbsNO2Lines1, sumAbsSO2Lines1;
     305             : 
     306             : 
     307             :   //TODO we will have to put numLayer_ and v_chanFreq_.size() const
     308             :   //we do not want to resize! ==> pas de setter pour SpectralGrid
     309             : 
     310             :   //cout << "vv_N_H2OLinesPtr_.size()=" << vv_N_H2OLinesPtr_.size() << std::endl;
     311         125 :   if(vv_N_H2OLinesPtr_.size() == 0) { // first time
     312           5 :     vv_N_H2OLinesPtr_.reserve(v_chanFreq_.size());
     313           5 :     vv_N_H2OContPtr_.reserve(v_chanFreq_.size());
     314           5 :     vv_N_O2LinesPtr_.reserve(v_chanFreq_.size());
     315           5 :     vv_N_DryContPtr_.reserve(v_chanFreq_.size());
     316           5 :     vv_N_O3LinesPtr_.reserve(v_chanFreq_.size());
     317           5 :     vv_N_COLinesPtr_.reserve(v_chanFreq_.size());
     318           5 :     vv_N_N2OLinesPtr_.reserve(v_chanFreq_.size());
     319           5 :     vv_N_NO2LinesPtr_.reserve(v_chanFreq_.size());
     320           5 :     vv_N_SO2LinesPtr_.reserve(v_chanFreq_.size());
     321             :   } else {
     322         120 :     if(vv_N_H2OLinesPtr_.size() == v_chanFreq_.size()) // there are new basic param
     323         120 :     rmRefractiveIndexProfile(); // delete all the layer profiles for all the frequencies
     324             :   }
     325             : 
     326             :   std::vector<std::complex<double> >* v_N_H2OLinesPtr;
     327             :   std::vector<std::complex<double> >* v_N_H2OContPtr;
     328             :   std::vector<std::complex<double> >* v_N_O2LinesPtr;
     329             :   std::vector<std::complex<double> >* v_N_DryContPtr;
     330             :   std::vector<std::complex<double> >* v_N_O3LinesPtr;
     331             :   std::vector<std::complex<double> >* v_N_COLinesPtr;
     332             :   std::vector<std::complex<double> >* v_N_N2OLinesPtr;
     333             :   std::vector<std::complex<double> >* v_N_NO2LinesPtr;
     334             :   std::vector<std::complex<double> >* v_N_SO2LinesPtr;
     335             : 
     336             :   // std::cout << "v_chanFreq_.size()=" << v_chanFreq_.size() << std::endl;
     337             :   // std::cout << "numLayer_=" << numLayer_ << std::endl;
     338             :   // std::cout << "v_chanFreq_[0]=" << v_chanFreq_[0] << std::endl;
     339             :   // check if new spectral windows have been added
     340             :   unsigned int ncmin;
     341             :   /*  std::cout << "vv_N_H2OLinesPtr_.size()="<<vv_N_H2OLinesPtr_.size()<<endl; */
     342         125 :   ncmin = vv_N_H2OLinesPtr_.size(); // will be > 0 if spectral window(s) have been added
     343         125 :   if(newBasicParam_) ncmin = 0;
     344             : 
     345             :   //    std::cout << "ncmin=" << ncmin << std::endl;
     346             : 
     347        2602 :   for(unsigned int nc = ncmin; nc < v_chanFreq_.size(); nc++) {
     348             : 
     349        2477 :     v_N_H2OLinesPtr = new std::vector<std::complex<double> > ;
     350        2477 :     v_N_H2OContPtr = new std::vector<std::complex<double> > ;
     351        2477 :     v_N_O2LinesPtr = new std::vector<std::complex<double> > ;
     352        2477 :     v_N_DryContPtr = new std::vector<std::complex<double> > ;
     353        2477 :     v_N_O3LinesPtr = new std::vector<std::complex<double> > ;
     354        2477 :     v_N_COLinesPtr = new std::vector<std::complex<double> > ;
     355        2477 :     v_N_N2OLinesPtr = new std::vector<std::complex<double> > ;
     356        2477 :     v_N_NO2LinesPtr = new std::vector<std::complex<double> > ;
     357        2477 :     v_N_SO2LinesPtr = new std::vector<std::complex<double> > ;
     358        2477 :     v_N_H2OLinesPtr->reserve(numLayer_);
     359        2477 :     v_N_H2OContPtr->reserve(numLayer_);
     360        2477 :     v_N_O2LinesPtr->reserve(numLayer_);
     361        2477 :     v_N_DryContPtr->reserve(numLayer_);
     362        2477 :     v_N_O3LinesPtr->reserve(numLayer_);
     363        2477 :     v_N_COLinesPtr->reserve(numLayer_);
     364        2477 :     v_N_N2OLinesPtr->reserve(numLayer_);
     365        2477 :     v_N_NO2LinesPtr->reserve(numLayer_);
     366        2477 :     v_N_SO2LinesPtr->reserve(numLayer_);
     367             : 
     368        2477 :     nu = 1.0E-9 * v_chanFreq_[nc]; // ATM uses GHz units
     369             : 
     370             :     // std::cout << "freq. points =" << v_chanFreq_.size() << std::endl;
     371             : 
     372             :     /*       TO BE IMPLEMENTED IN NEXT RELEASE
     373             : 
     374             :     if (v_chanFreq_.size()>1){
     375             :       if(nc==0){
     376             :         width = fabs(v_chanFreq_[nc+1]-v_chanFreq_[nc])*1e-9;       // width en GHz para ATM
     377             :         npoints=(unsigned int)round(width*100);                     // One point every 10 MHz
     378             :       }else{
     379             :         if(nc==v_chanFreq_.size()-1){
     380             :           width = fabs(v_chanFreq_[nc]-v_chanFreq_[nc-1])*1e-9;     // width en GHz para ATM
     381             :           npoints=(unsigned int)round(width*100);                   // One point every 10 MHz
     382             :         }else{
     383             :           width = fabs((v_chanFreq_[nc+1]-v_chanFreq_[nc-1])/2.0)*1e-9;    // width en GHz para ATM
     384             :           npoints=(unsigned int)round(width*100);                          // One point every 10 MHz
     385             :         }
     386             :       }
     387             :     }else{
     388             :       width = 0.001;      // default width = 1 MHz = 0.001 GHz
     389             :       npoints=1;
     390             :     }
     391             : 
     392             :     if(npoints==0){npoints=1;}
     393             : 
     394             :     */
     395             : 
     396             : 
     397             : 
     398             :     // std::cout << "nc =" << nc << " nu=" << nu << " width=" << width << " GHz    npoints=" << npoints << std::endl;
     399             : 
     400             :     // nu2 = nu * nu;      // [-Wunused_but_set_variable]
     401             :     // nu_pi = nu / M_PI;    // [-Wunused_but_set_variable]
     402             : 
     403       52387 :     for(unsigned int j = 0; j < numLayer_; j++) {
     404             : 
     405       49910 :       wv = v_layerWaterVapor_[j] * 1000.0; // se multiplica por 10**3 por cuestión de unidades en las rutinas fortran.
     406       49910 :       wvt = wv * v_layerTemperature_[j] / 217.0; // v_layerWaterVapor_[j] está en kg/m**3
     407             :       // t = v_layerTemperature_[j] / 300.0;    // [-Wunused_but_set_variable]
     408             : 
     409             : 
     410             :       // std::cout <<"ATMRefractiveIndexProfile: " << v_layerTemperature_[j] << " K " << v_layerPressure_[j] << " mb "  << nu << " GHz " << std::endl;
     411             :       // std::cout <<"ATMRefractiveIndexProfile: O2" <<  atm.getRefractivity_o2(v_layerTemperature_[j],v_layerPressure_[j],wvt,nu) << std::endl;
     412             :       // std::cout << "ATMRefractiveIndexProfile: O2" << atm.getRefractivity_o2(v_layerTemperature_[j],v_layerPressure_[j],wvt,nu,width,npoints) << std::endl;
     413             :       // std::cout << "ATMRefractiveIndexProfile: H2O" << atm.getRefractivity_h2o(v_layerTemperature_[j],v_layerPressure_[j],wvt,nu) << std::endl;
     414             :       // std::cout << "ATMRefractiveIndexProfile: H2O" << atm.getRefractivity_h2o(v_layerTemperature_[j],v_layerPressure_[j],wvt,nu,width,npoints) << std::endl;
     415             :       // std::cout <<"ATMRefractiveIndexProfile: O3" <<  atm.getRefractivity_o3(v_layerTemperature_[j],v_layerPressure_[j],nu,v_layerO3_[j]) << std::endl;
     416             :       // std::cout << "ATMRefractiveIndexProfile: O3" << atm.getRefractivity_o3(v_layerTemperature_[j],v_layerPressure_[j],nu,width,npoints,v_layerO3_[j]) << std::endl;
     417             :       // std::cout <<"ATMRefractiveIndexProfile: CO" <<  atm.getSpecificRefractivity_co(v_layerTemperature_[j],v_layerPressure_[j],nu) << std::endl;
     418             :       // std::cout << "ATMRefractiveIndexProfile: CO" << atm.getSpecificRefractivity_co(v_layerTemperature_[j],v_layerPressure_[j],nu,width,npoints) << std::endl;
     419             : 
     420       49910 :       v_N_O2LinesPtr->push_back(atm.getRefractivity_o2(v_layerTemperature_[j],
     421       49910 :                                                        v_layerPressure_[j],
     422             :                                                        wvt,
     423             :                                                        nu));     // ,width,npoints)); TO BE IMPLEMENTED IN NEXT RELEASE
     424             : 
     425             :       std::complex<double> cont_h2o =
     426       49910 :         atm.getSpecificRefractivity_cnth2o(v_layerTemperature_[j],
     427       49910 :                                            v_layerPressure_[j],
     428             :                                            wvt,
     429             :                                            nu);                   // ,width,npoints); TO BE IMPLEMENTED IN NEXT RELEASE
     430             :       std::complex<double> cont_dry =
     431       49910 :           atm.getSpecificRefractivity_cntdry(v_layerTemperature_[j],
     432       49910 :                                              v_layerPressure_[j],
     433             :                                              wvt,
     434             :                                              nu);                  // ,width,npoints); TO BE IMPLEMENTED IN NEXT RELEASE
     435             : 
     436       49910 :       v_N_H2OContPtr->push_back(cont_h2o);
     437       49910 :       v_N_DryContPtr->push_back(cont_dry);
     438             : 
     439       49910 :       if(v_layerWaterVapor_[j] > 0) {
     440             : 
     441       49910 :         v_N_H2OLinesPtr->push_back(atm.getRefractivity_h2o(v_layerTemperature_[j],
     442       49910 :                                                            v_layerPressure_[j],
     443             :                                                            wvt,
     444             :                                                            nu)); // ,width,npoints)); TO BE IMPLEMENTED IN NEXT RELEASE
     445             :       } else {
     446           0 :         v_N_H2OLinesPtr->push_back(0.0);
     447             :       }
     448             : 
     449             :       //        if(v_layerO3_[j]<0.0||j==10){cout << "v_layerO3_[" << j << "]=" << v_layerO3_[j] << std::endl;}
     450             : 
     451       49910 :       if(v_layerO3_[j] > 0) {
     452             : 
     453       49910 :         abun_O3 = v_layerO3_[j] * 1E-6;
     454       49910 :         v_N_O3LinesPtr->push_back(atm.getRefractivity_o3(v_layerTemperature_[j],
     455       49910 :                                                          v_layerPressure_[j],
     456             :                                                          nu,      // width,npoints, TO BE IMPLEMENTED IN NEXT RELEASE
     457             :                                                          abun_O3 * 1e6));
     458             :       } else {
     459           0 :         v_N_O3LinesPtr->push_back(0.0);
     460             :       }
     461             : 
     462       49910 :       if(v_layerCO_[j] > 0) {
     463       49910 :         abun_CO = v_layerCO_[j] * 1E-6; // in cm^-3
     464       99820 :         v_N_COLinesPtr->push_back(atm.getSpecificRefractivity_co(v_layerTemperature_[j],
     465       49910 :                                                                  v_layerPressure_[j],
     466             :                                                                  nu)            // ,width,npoints) TO BE IMPLEMENTED IN NEXT RELEASE
     467      149730 :                                   * abun_CO * 1e6); // m^2 * m^-3 = m^-1
     468             :         } else {
     469           0 :         v_N_COLinesPtr->push_back(0.0);
     470             :       }
     471             : 
     472       49910 :       if(v_layerN2O_[j] > 0) {
     473       49910 :         abun_N2O = v_layerN2O_[j] * 1E-6;
     474       99820 :         v_N_N2OLinesPtr->push_back(atm.getSpecificRefractivity_n2o(v_layerTemperature_[j],
     475       49910 :                                                                    v_layerPressure_[j],
     476             :                                                                    nu)             // ,width,npoints) TO BE IMPLEMENTED IN NEXT RELEASE
     477      149730 :                                    * abun_N2O * 1e6); // m^2 * m^-3 = m^-1
     478             :         } else {
     479           0 :         v_N_N2OLinesPtr->push_back(0.0);
     480             :       }
     481             : 
     482       49910 :       if(v_layerNO2_[j] > 0) {
     483       49910 :         abun_NO2 = v_layerNO2_[j] * 1E-6;
     484       99820 :         v_N_NO2LinesPtr->push_back(atm.getSpecificRefractivity_no2(v_layerTemperature_[j],
     485       49910 :                                                                    v_layerPressure_[j],
     486             :                                                                    nu)             // ,width,npoints) TO BE IMPLEMENTED IN NEXT RELEASE
     487      149730 :                                    * abun_NO2 * 1e6); // m^2 * m^-3 = m^-1
     488             :       } else {
     489           0 :         v_N_NO2LinesPtr->push_back(0.0);
     490             :       }
     491             : 
     492       49910 :       if(v_layerSO2_[j] > 0) {
     493       49910 :         abun_SO2 = v_layerSO2_[j] * 1E-6;
     494       99820 :         v_N_SO2LinesPtr->push_back(atm.getSpecificRefractivity_so2(v_layerTemperature_[j],
     495       49910 :                                                                    v_layerPressure_[j],
     496             :                                                                    nu)            // ,width,npoints) TO BE IMPLEMENTED IN NEXT RELEASE
     497      149730 :                                    * abun_SO2 * 1e6); // m^2 * m^-3 = m^-1
     498             :       } else {
     499           0 :         v_N_SO2LinesPtr->push_back(0.0);
     500             :       }
     501             :     }
     502             : 
     503             :     // if(vv_N_H2OLinesPtr_.size() == 0) first = true;  // [-Wunused_but_set_variable]
     504             : 
     505        2477 :     if(vv_N_H2OLinesPtr_.size() < v_chanFreq_.size()) {
     506          77 :       vv_N_H2OLinesPtr_.push_back(v_N_H2OLinesPtr);
     507          77 :       vv_N_H2OContPtr_.push_back(v_N_H2OContPtr);
     508          77 :       vv_N_O2LinesPtr_.push_back(v_N_O2LinesPtr);
     509          77 :       vv_N_DryContPtr_.push_back(v_N_DryContPtr);
     510          77 :       vv_N_O3LinesPtr_.push_back(v_N_O3LinesPtr);
     511          77 :       vv_N_COLinesPtr_.push_back(v_N_COLinesPtr);
     512          77 :       vv_N_N2OLinesPtr_.push_back(v_N_N2OLinesPtr);
     513          77 :       vv_N_NO2LinesPtr_.push_back(v_N_NO2LinesPtr);
     514          77 :       vv_N_SO2LinesPtr_.push_back(v_N_SO2LinesPtr);
     515             :     } else {
     516        2400 :       vv_N_H2OLinesPtr_[nc] = v_N_H2OLinesPtr;
     517        2400 :       vv_N_H2OContPtr_[nc] = v_N_H2OContPtr;
     518        2400 :       vv_N_O2LinesPtr_[nc] = v_N_O2LinesPtr;
     519        2400 :       vv_N_DryContPtr_[nc] = v_N_DryContPtr;
     520        2400 :       vv_N_O3LinesPtr_[nc] = v_N_O3LinesPtr;
     521        2400 :       vv_N_COLinesPtr_[nc] = v_N_COLinesPtr;
     522        2400 :       vv_N_N2OLinesPtr_[nc] = v_N_N2OLinesPtr;
     523        2400 :       vv_N_NO2LinesPtr_[nc] = v_N_NO2LinesPtr;
     524        2400 :       vv_N_SO2LinesPtr_[nc] = v_N_SO2LinesPtr;
     525             :     }
     526             : 
     527             :   }
     528             : 
     529         125 :   newBasicParam_ = false;
     530             :   // first = false;  // [-Wunused_but_set_variable]
     531         125 : }
     532             : 
     533             : 
     534           0 : Opacity RefractiveIndexProfile::getDryOpacityUpTo(unsigned int nc, Length refalti)
     535             : {
     536           0 :   unsigned int ires; unsigned int numlayerold; Length alti;  double fractionLast;
     537           0 :   Opacity opacityout0; Opacity opacityout1; Opacity zeroOp(0.0,Opacity::UnitNeper);
     538             : 
     539           0 :   if(refalti.get(Length::UnitKiloMeter) <= altitude_.get(Length::UnitKiloMeter)) {
     540           0 :     return zeroOp;
     541             :   }else{
     542           0 :       fractionLast = 1.0; numlayerold = numLayer_;
     543           0 :       opacityout0=getDryOpacity(nc); ires=numlayerold-1; alti=altitude_;
     544           0 :       for(unsigned int i=0; i<numLayer_; i++){
     545           0 :         if(alti.get(Length::UnitKiloMeter) < refalti.get(Length::UnitKiloMeter) &&  (alti.get(Length::UnitKiloMeter)+v_layerThickness_[i]/1000.0) >= refalti.get(Length::UnitKiloMeter))
     546           0 :           { ires=i; fractionLast = (refalti.get(Length::UnitMeter)-alti.get(Length::UnitMeter))/v_layerThickness_[i]; }
     547           0 :         alti = alti + Length(v_layerThickness_[i],Length::UnitMeter);
     548             :       }
     549           0 :       numLayer_ = ires;
     550           0 :       opacityout0=getDryOpacity(nc);
     551           0 :       numLayer_ = ires+1;
     552           0 :       opacityout1=getDryOpacity(nc);
     553           0 :       numLayer_ = numlayerold;
     554           0 :       return opacityout0+(opacityout1-opacityout0)*fractionLast;
     555             :   }
     556           0 : }
     557          12 : Opacity RefractiveIndexProfile::getDryOpacity(unsigned int nc)
     558             : {
     559          12 :   if(!chanIndexIsValid(nc)) return Opacity(-999.0);
     560          12 :   double kv = 0;
     561         372 :   for(unsigned int j = 0; j < numLayer_; j++) {
     562         720 :     kv = kv + imag(vv_N_O2LinesPtr_[nc]->at(j) + vv_N_DryContPtr_[nc]->at(j)
     563         720 :                    + vv_N_O3LinesPtr_[nc]->at(j)  + vv_N_COLinesPtr_[nc]->at(j)
     564         720 :                    + vv_N_N2OLinesPtr_[nc]->at(j) + vv_N_NO2LinesPtr_[nc]->at(j)
     565        1080 :                    + vv_N_SO2LinesPtr_[nc]->at(j)) * v_layerThickness_[j];
     566             :   }
     567          12 :   return Opacity(kv);
     568             : }
     569             : 
     570             : 
     571           0 : Opacity RefractiveIndexProfile::getAverageDryOpacity(unsigned int spwid)
     572             : {
     573           0 :   if(!spwidAndIndexAreValid(spwid, 0)) return Opacity(-999.0);
     574           0 :   Opacity totalaverage;
     575           0 :   totalaverage = Opacity(0.0, Opacity::UnitNeper);
     576           0 :   for(unsigned int nc = 0; nc < getNumChan(spwid); nc++) {
     577           0 :     totalaverage = totalaverage + getDryOpacity(spwid, nc);
     578             :   }
     579           0 :   totalaverage = totalaverage / getNumChan(spwid);
     580           0 :   return totalaverage;
     581           0 : }
     582             : 
     583           0 : Opacity RefractiveIndexProfile::getAverageO2LinesOpacity(unsigned int spwid)
     584             : {
     585           0 :   if(!spwidAndIndexAreValid(spwid, 0)) return Opacity(-999.0);
     586           0 :   Opacity totalaverage;
     587           0 :   totalaverage = Opacity(0.0, Opacity::UnitNeper);
     588           0 :   for(unsigned int nc = 0; nc < getNumChan(spwid); nc++) {
     589           0 :     totalaverage = totalaverage + getO2LinesOpacity(spwid, nc);
     590             :   }
     591           0 :   totalaverage = totalaverage / getNumChan(spwid);
     592           0 :   return totalaverage;
     593           0 : }
     594             : 
     595           0 : Opacity RefractiveIndexProfile::getAverageO3LinesOpacity(unsigned int spwid)
     596             : {
     597           0 :   if(!spwidAndIndexAreValid(spwid, 0)) return Opacity(-999.0);
     598           0 :   Opacity totalaverage;
     599           0 :   totalaverage = Opacity(0.0, Opacity::UnitNeper);
     600           0 :   for(unsigned int nc = 0; nc < getNumChan(spwid); nc++) {
     601             :     /*      std::cout << " Freq = " << getChanFreq(spwid,nc).get(Frequency::UnitGigaHertz)
     602             :      << " O3 opacity = " << getO3LinesOpacity(spwid,nc).get(Opacity::UnitNeper)
     603             :      << " O3 pathlength = " << getO3LinesPathLength(spwid,nc).get(Length::Microns)
     604             :      << " O2 opacity = " << getO2LinesOpacity(spwid,nc).get(Opacity::UnitNeper)
     605             :      << " O2 pathlength = " << getO2LinesPathLength(spwid,nc).get(Length::Microns)
     606             :      << std::endl; */
     607           0 :     totalaverage = totalaverage + getO3LinesOpacity(spwid, nc);
     608             :   }
     609           0 :   totalaverage = totalaverage / getNumChan(spwid);
     610           0 :   return totalaverage;
     611           0 : }
     612             : 
     613           0 : Opacity RefractiveIndexProfile::getAverageN2OLinesOpacity(unsigned int spwid)
     614             : {
     615           0 :   if(!spwidAndIndexAreValid(spwid, 0)) return Opacity(-999.0);
     616           0 :   Opacity totalaverage;
     617           0 :   totalaverage = Opacity(0.0, Opacity::UnitNeper);
     618           0 :   for(unsigned int nc = 0; nc < getNumChan(spwid); nc++) {
     619           0 :     totalaverage = totalaverage + getN2OLinesOpacity(spwid, nc);
     620             :   }
     621           0 :   totalaverage = totalaverage / getNumChan(spwid);
     622           0 :   return totalaverage;
     623           0 : }
     624             : 
     625           0 : Opacity RefractiveIndexProfile::getAverageNO2LinesOpacity(unsigned int spwid)
     626             : {
     627           0 :   if(!spwidAndIndexAreValid(spwid, 0)) return Opacity(-999.0);
     628           0 :   Opacity totalaverage;
     629           0 :   totalaverage = Opacity(0.0, Opacity::UnitNeper);
     630           0 :   for(unsigned int nc = 0; nc < getNumChan(spwid); nc++) {
     631           0 :     totalaverage = totalaverage + getNO2LinesOpacity(spwid, nc);
     632             :   }
     633           0 :   totalaverage = totalaverage / getNumChan(spwid);
     634           0 :   return totalaverage;
     635           0 : }
     636             : 
     637           0 : Opacity RefractiveIndexProfile::getAverageSO2LinesOpacity(unsigned int spwid)
     638             : {
     639           0 :   if(!spwidAndIndexAreValid(spwid, 0)) return Opacity(-999.0);
     640           0 :   Opacity totalaverage;
     641           0 :   totalaverage = Opacity(0.0, Opacity::UnitNeper);
     642           0 :   for(unsigned int nc = 0; nc < getNumChan(spwid); nc++) {
     643           0 :     totalaverage = totalaverage + getSO2LinesOpacity(spwid, nc);
     644             :   }
     645           0 :   totalaverage = totalaverage / getNumChan(spwid);
     646           0 :   return totalaverage;
     647           0 : }
     648             : 
     649             : 
     650             : 
     651             : 
     652           0 : Opacity RefractiveIndexProfile::getAverageCOLinesOpacity(unsigned int spwid)
     653             : {
     654           0 :   if(!spwidAndIndexAreValid(spwid, 0)) return Opacity(-999.0);
     655           0 :   Opacity totalaverage;
     656           0 :   totalaverage = Opacity(0.0, Opacity::UnitNeper);
     657           0 :   for(unsigned int nc = 0; nc < getNumChan(spwid); nc++) {
     658           0 :     totalaverage = totalaverage + getCOLinesOpacity(spwid, nc);
     659             :   }
     660           0 :   totalaverage = totalaverage / getNumChan(spwid);
     661           0 :   return totalaverage;
     662           0 : }
     663             : 
     664           0 : Opacity RefractiveIndexProfile::getAverageDryContOpacity(unsigned int spwid)
     665             : {
     666           0 :   if(!spwidAndIndexAreValid(spwid, 0)) return Opacity(-999.0);
     667           0 :   Opacity totalaverage;
     668           0 :   totalaverage = Opacity(0.0, Opacity::UnitNeper);
     669           0 :   for(unsigned int nc = 0; nc < getNumChan(spwid); nc++) {
     670           0 :     totalaverage = totalaverage + getDryContOpacity(spwid, nc);
     671             :   }
     672           0 :   totalaverage = totalaverage / getNumChan(spwid);
     673           0 :   return totalaverage;
     674           0 : }
     675             : 
     676           1 : Opacity RefractiveIndexProfile::getDryContOpacity()
     677             : {
     678           1 :   return getDryContOpacity(0);
     679             : }
     680             : 
     681           1 : Opacity RefractiveIndexProfile::getDryContOpacity(unsigned int nc)
     682             : {
     683           1 :   if(!chanIndexIsValid(nc)) return Opacity(-999.0);
     684           1 :   double kv = 0;
     685          31 :   for(unsigned int j = 0; j < numLayer_; j++) {
     686          30 :     kv = kv + imag(vv_N_DryContPtr_[nc]->at(j)) * v_layerThickness_[j];
     687             :   }
     688           1 :   return Opacity(kv);
     689             : }
     690             : 
     691           0 : Opacity RefractiveIndexProfile::getDryContOpacity(unsigned int spwid,
     692             :                                                   unsigned int nc)
     693             : {
     694           0 :   if(!spwidAndIndexAreValid(spwid, nc)) return Opacity(-999.0);
     695           0 :   return getDryContOpacity(v_transfertId_[spwid] + nc);
     696             : }
     697             : 
     698           1 : Opacity RefractiveIndexProfile::getO2LinesOpacity()
     699             : {
     700           1 :   return getO2LinesOpacity(0);
     701             : }
     702             : 
     703           1 : Opacity RefractiveIndexProfile::getO2LinesOpacity(unsigned int nc)
     704             : {
     705           1 :   if(!chanIndexIsValid(nc)) return Opacity(-999.0);
     706           1 :   double kv = 0;
     707          31 :   for(unsigned int j = 0; j < numLayer_; j++) {
     708          30 :     kv = kv + imag(vv_N_O2LinesPtr_[nc]->at(j)) * v_layerThickness_[j];
     709             :   }
     710           1 :   return Opacity(kv);
     711             : }
     712             : 
     713           0 : Opacity RefractiveIndexProfile::getO2LinesOpacity(unsigned int spwid,
     714             :                                                   unsigned int nc)
     715             : {
     716           0 :   if(!spwidAndIndexAreValid(spwid, nc)) return Opacity(-999.0);
     717           0 :   return getO2LinesOpacity(v_transfertId_[spwid] + nc);
     718             : }
     719             : 
     720           1 : Opacity RefractiveIndexProfile::getCOLinesOpacity()
     721             : {
     722           1 :   return getCOLinesOpacity(0);
     723             : }
     724             : 
     725           1 : Opacity RefractiveIndexProfile::getCOLinesOpacity(unsigned int nc)
     726             : {
     727           1 :   if(!chanIndexIsValid(nc)) return Opacity(-999.0);
     728           1 :   double kv = 0;
     729          31 :   for(unsigned int j = 0; j < numLayer_; j++) {
     730          30 :     kv = kv + imag(vv_N_COLinesPtr_[nc]->at(j)) * v_layerThickness_[j];
     731             :   }
     732           1 :   return Opacity(kv);
     733             : }
     734             : 
     735           0 : Opacity RefractiveIndexProfile::getCOLinesOpacity(unsigned int spwid,
     736             :                                                   unsigned int nc)
     737             : {
     738           0 :   if(!spwidAndIndexAreValid(spwid, nc)) return Opacity(-999.0);
     739           0 :   return getCOLinesOpacity(v_transfertId_[spwid] + nc);
     740             : }
     741             : 
     742           1 : Opacity RefractiveIndexProfile::getN2OLinesOpacity()
     743             : {
     744           1 :   return getN2OLinesOpacity(0);
     745             : }
     746             : 
     747           0 : Opacity RefractiveIndexProfile::getNO2LinesOpacity()
     748             : {
     749           0 :   return getNO2LinesOpacity(0);
     750             : }
     751             : 
     752           0 : Opacity RefractiveIndexProfile::getSO2LinesOpacity()
     753             : {
     754           0 :   return getSO2LinesOpacity(0);
     755             : }
     756             : 
     757           1 : Opacity RefractiveIndexProfile::getN2OLinesOpacity(unsigned int nc)
     758             : {
     759           1 :   if(!chanIndexIsValid(nc)) return Opacity(-999.0);
     760           1 :   double kv = 0;
     761          31 :   for(unsigned int j = 0; j < numLayer_; j++) {
     762          30 :     kv = kv + imag(vv_N_N2OLinesPtr_[nc]->at(j)) * v_layerThickness_[j];
     763             :   }
     764           1 :   return Opacity(kv);
     765             : }
     766             : 
     767           0 : Opacity RefractiveIndexProfile::getN2OLinesOpacity(unsigned int spwid,
     768             :                                                    unsigned int nc)
     769             : {
     770           0 :   if(!spwidAndIndexAreValid(spwid, nc)) return Opacity(-999.0);
     771           0 :   return getN2OLinesOpacity(v_transfertId_[spwid] + nc);
     772             : }
     773             : 
     774           0 : Opacity RefractiveIndexProfile::getNO2LinesOpacity(unsigned int nc)
     775             : {
     776           0 :   if(!chanIndexIsValid(nc)) return Opacity(-999.0);
     777           0 :   double kv = 0;
     778           0 :   for(unsigned int j = 0; j < numLayer_; j++) {
     779           0 :     kv = kv + imag(vv_N_NO2LinesPtr_[nc]->at(j)) * v_layerThickness_[j];
     780             :   }
     781           0 :   return Opacity(kv);
     782             : }
     783             : 
     784           0 : Opacity RefractiveIndexProfile::getNO2LinesOpacity(unsigned int spwid,
     785             :                                                    unsigned int nc)
     786             : {
     787           0 :   if(!spwidAndIndexAreValid(spwid, nc)) return Opacity(-999.0);
     788           0 :   return getNO2LinesOpacity(v_transfertId_[spwid] + nc);
     789             : }
     790             : 
     791             : 
     792           0 : Opacity RefractiveIndexProfile::getSO2LinesOpacity(unsigned int nc)
     793             : {
     794           0 :   if(!chanIndexIsValid(nc)) return Opacity(-999.0);
     795           0 :   double kv = 0;
     796           0 :   for(unsigned int j = 0; j < numLayer_; j++) {
     797           0 :     kv = kv + imag(vv_N_SO2LinesPtr_[nc]->at(j)) * v_layerThickness_[j];
     798             :   }
     799           0 :   return Opacity(kv);
     800             : }
     801             : 
     802           0 : Opacity RefractiveIndexProfile::getSO2LinesOpacity(unsigned int spwid,
     803             :                                                    unsigned int nc)
     804             : {
     805           0 :   if(!spwidAndIndexAreValid(spwid, nc)) return Opacity(-999.0);
     806           0 :   return getSO2LinesOpacity(v_transfertId_[spwid] + nc);
     807             : }
     808             : 
     809             : 
     810           1 : Opacity RefractiveIndexProfile::getO3LinesOpacity()
     811             : {
     812           1 :   return getO3LinesOpacity(0);
     813             : }
     814             : 
     815           1 : Opacity RefractiveIndexProfile::getO3LinesOpacity(unsigned int nc)
     816             : {
     817           1 :   if(!chanIndexIsValid(nc)) return Opacity(-999.0);
     818           1 :   double kv = 0;
     819          31 :   for(unsigned int j = 0; j < numLayer_; j++) {
     820          30 :     kv = kv + imag(vv_N_O3LinesPtr_[nc]->at(j)) * v_layerThickness_[j];
     821             :   }
     822           1 :   return Opacity(kv);
     823             : }
     824             : 
     825           0 : Opacity RefractiveIndexProfile::getO3LinesOpacity(unsigned int spwid,
     826             :                                                   unsigned int nc)
     827             : {
     828           0 :   if(!spwidAndIndexAreValid(spwid, nc)) return Opacity(-999.0);
     829           0 :   return getO3LinesOpacity(v_transfertId_[spwid] + nc);
     830             : }
     831             : 
     832           1 : Opacity RefractiveIndexProfile::getWetOpacity(const Length &integratedwatercolumn)
     833             : {
     834             : //   std::cout << "1 integratedwatercolumn.get()="  << integratedwatercolumn.get() << std::endl;
     835             : //   std::cout << "2 getGroundWH2O().get()="   << getGroundWH2O().get() << std::endl;
     836             : //   std::cout << "3 getWetOpacity()="  << std::endl;
     837             : //   std::cout << "4 " << std::endl;
     838           2 :   return getWetOpacity(getGroundWH2O(),0)*(integratedwatercolumn.get()/getGroundWH2O().get());
     839             : 
     840             :   // 2010_SEP02: return getWetOpacity(integratedwatercolumn,0)*(integratedwatercolumn.get()/getGroundWH2O().get());
     841             : }
     842             : 
     843           1 : Opacity RefractiveIndexProfile::getWetOpacity(const Length &integratedwatercolumn,
     844             :                                               unsigned int nc)
     845             : {
     846           1 :   if(!chanIndexIsValid(nc)) return Opacity(-999.0);
     847           1 :   double kv = 0;
     848             :   /*  std::cout<<"nc="<<nc<<endl; */
     849          31 :   for(unsigned int j = 0; j < numLayer_; j++) {
     850          30 :     kv = kv + imag(vv_N_H2OLinesPtr_[nc]->at(j) + vv_N_H2OContPtr_[nc]->at(j))
     851          30 :         * v_layerThickness_[j];
     852             : 
     853             :   }
     854           2 :   return Opacity(kv*(integratedwatercolumn.get()/getGroundWH2O().get()));
     855             : }
     856             : 
     857           0 : Opacity RefractiveIndexProfile::getWetOpacity(const Length & integratedwatercolumn,
     858             :                                               unsigned int spwid,
     859             :                                               unsigned int nc)
     860             : {
     861           0 :   if(!spwidAndIndexAreValid(spwid, nc)) return Opacity(-999.0);
     862           0 :   return getWetOpacity(integratedwatercolumn,v_transfertId_[spwid] + nc);
     863             : }
     864             : 
     865           0 : Opacity RefractiveIndexProfile::getAverageWetOpacity(const Length &integratedwatercolumn,
     866             :                                                      unsigned int spwid)
     867             : {
     868           0 :   if(!spwidAndIndexAreValid(spwid, 0)) return Opacity(-999.0);
     869           0 :   Opacity totalaverage;
     870           0 :   totalaverage = Opacity(0.0, Opacity::UnitNeper);
     871           0 :   for(unsigned int nc = 0; nc < getNumChan(spwid); nc++) {
     872           0 :     totalaverage = totalaverage + getWetOpacity(integratedwatercolumn, spwid, nc);
     873             :   }
     874           0 :   totalaverage = totalaverage / getNumChan(spwid);
     875           0 :   return totalaverage;
     876           0 : }
     877             : 
     878           1 : Opacity RefractiveIndexProfile::getH2OLinesOpacity(const Length &integratedwatercolumn)
     879             : {
     880           1 :   return getH2OLinesOpacity(integratedwatercolumn,0);
     881             : }
     882             : 
     883           1 : Opacity RefractiveIndexProfile::getH2OLinesOpacity(const Length &integratedwatercolumn,
     884             :                                                    unsigned int nc)
     885             : {
     886           1 :   if(!chanIndexIsValid(nc)) return Opacity(-999.0);
     887           1 :   double kv = 0;
     888          31 :   for(unsigned int j = 0; j < numLayer_; j++) {
     889             :     /*    std::cout <<"j="<<j<<" abs H2O Lines ="<<vv_N_H2OLinesPtr_[nc]->at(j) <<endl; */
     890          30 :     kv = kv + imag(vv_N_H2OLinesPtr_[nc]->at(j)) * v_layerThickness_[j];
     891             :   }
     892           2 :   return Opacity(kv*(integratedwatercolumn.get()/getGroundWH2O().get()));
     893             : }
     894             : 
     895           0 : Opacity RefractiveIndexProfile::getH2OLinesOpacity(const Length &integratedwatercolumn,
     896             :                                                    unsigned int spwid,
     897             :                                                    unsigned int nc)
     898             : {
     899           0 :   if(!spwidAndIndexAreValid(spwid, nc)) return Opacity(-999.0);
     900           0 :   return getH2OLinesOpacity(integratedwatercolumn,v_transfertId_[spwid] + nc);
     901             : }
     902             : 
     903           0 : Opacity RefractiveIndexProfile::getAverageH2OLinesOpacity(const Length &integratedwatercolumn,
     904             :                                                           unsigned int spwid)
     905             : {
     906           0 :   if(!spwidAndIndexAreValid(spwid, 0)) return Opacity(-999.0);
     907           0 :   Opacity totalaverage;
     908           0 :   totalaverage = Opacity(0.0, Opacity::UnitNeper);
     909           0 :   for(unsigned int nc = 0; nc < getNumChan(spwid); nc++) {
     910           0 :     totalaverage = totalaverage + getH2OLinesOpacity(integratedwatercolumn,spwid, nc);
     911             :   }
     912           0 :   totalaverage = totalaverage / getNumChan(spwid);
     913           0 :   return totalaverage;
     914           0 : }
     915             : 
     916             : 
     917           1 : Opacity RefractiveIndexProfile::getH2OContOpacity(const Length &integratedwatercolumn)
     918             : {
     919           1 :   return getH2OContOpacity(integratedwatercolumn,0);
     920             : }
     921             : 
     922             : 
     923           1 : Opacity RefractiveIndexProfile::getH2OContOpacity(const Length &integratedwatercolumn,
     924             :                                                   unsigned int nc)
     925             : {
     926           1 :   if(!chanIndexIsValid(nc)) return Opacity(-999.0);
     927           1 :   double kv = 0;
     928          31 :   for(unsigned int j = 0; j < numLayer_; j++) {
     929          30 :     kv = kv + imag(vv_N_H2OContPtr_[nc]->at(j)) * v_layerThickness_[j];
     930             :   }
     931           2 :   return Opacity(kv*(integratedwatercolumn.get()/getGroundWH2O().get()));
     932             : }
     933             : 
     934             : 
     935           0 : Opacity RefractiveIndexProfile::getH2OContOpacity(const Length &integratedwatercolumn,
     936             :                                                   unsigned int spwid,
     937             :                                                   unsigned int nc)
     938             : {
     939           0 :   if(!spwidAndIndexAreValid(spwid, nc)) return Opacity(-999.0);
     940           0 :   return getH2OContOpacity(integratedwatercolumn,v_transfertId_[spwid] + nc);
     941             : }
     942             : 
     943             : 
     944             : 
     945           0 : Opacity RefractiveIndexProfile::getAverageH2OContOpacity(const Length &integratedwatercolumn,
     946             :                                                          unsigned int spwid)
     947             : {
     948           0 :   if(!spwidAndIndexAreValid(spwid, 0)) return Opacity(-999.0);
     949           0 :   Opacity totalaverage;
     950           0 :   totalaverage = Opacity(0.0, Opacity::UnitNeper);
     951           0 :   for(unsigned int nc = 0; nc < getNumChan(spwid); nc++) {
     952           0 :     totalaverage = totalaverage + getH2OContOpacity(integratedwatercolumn,spwid, nc);
     953             :   }
     954           0 :   totalaverage = totalaverage / getNumChan(spwid);
     955           0 :   return totalaverage;
     956           0 : }
     957             : 
     958           0 : Angle RefractiveIndexProfile::getDispersiveH2OPhaseDelay(const Length &integratedwatercolumn)
     959             : {
     960           0 :   return getDispersiveH2OPhaseDelay(integratedwatercolumn,0);
     961             : }
     962             : 
     963           2 : Length RefractiveIndexProfile::getDispersiveH2OPathLength(const Length &integratedwatercolumn)
     964             : {
     965           2 :   return getDispersiveH2OPathLength(integratedwatercolumn,0);
     966             : }
     967             : 
     968           2 : Angle RefractiveIndexProfile::getDispersiveH2OPhaseDelay(const Length &integratedwatercolumn,
     969             :                                                          unsigned int nc)
     970             : {
     971           2 :   if(!chanIndexIsValid(nc)) {
     972           0 :     return Angle(-999.0, Angle::UnitDegree);
     973             :   }
     974           2 :   double kv = 0;
     975          62 :   for(unsigned int j = 0; j < numLayer_; j++) {
     976          60 :     kv = kv + real(vv_N_H2OLinesPtr_[nc]->at(j)) * v_layerThickness_[j];
     977             :   }
     978           2 :   Angle aa(kv*(integratedwatercolumn.get()/getGroundWH2O().get())* 57.29578, Angle::UnitDegree);
     979           2 :   return aa;
     980           2 : }
     981             : 
     982           2 : Length RefractiveIndexProfile::getDispersiveH2OPathLength(const Length &integratedwatercolumn,
     983             :                                                           unsigned int nc)
     984             : {
     985           2 :   if(!chanIndexIsValid(nc)) {
     986           0 :     return Length(-999.0, Length::UnitMeter);
     987             :   }
     988           2 :   double wavelength = 299792458.0 / v_chanFreq_[nc]; // in m
     989           2 :   Length ll((wavelength / 360.0) * getDispersiveH2OPhaseDelay(integratedwatercolumn,nc).get(Angle::UnitDegree),
     990           2 :             Length::UnitMeter);
     991           2 :   return ll;
     992           2 : }
     993             : 
     994           0 : Angle RefractiveIndexProfile::getDispersiveH2OPhaseDelay(const Length &integratedwatercolumn,
     995             :                                                          unsigned int spwid,
     996             :                                                          unsigned int nc)
     997             : {
     998           0 :   if(!spwidAndIndexAreValid(spwid, nc)) {
     999           0 :     return Angle(-999.0, Angle::UnitDegree);
    1000             :   }
    1001           0 :   return getDispersiveH2OPhaseDelay(integratedwatercolumn,v_transfertId_[spwid] + nc);
    1002             : }
    1003             : 
    1004           0 : Angle RefractiveIndexProfile::getAverageDispersiveH2OPhaseDelay(const Length &integratedwatercolumn,
    1005             :                                                                 unsigned int spwid)
    1006             : {
    1007           0 :   if(!spwidAndIndexAreValid(spwid, 0)) {
    1008           0 :     return Angle(-999.0, Angle::UnitDegree);
    1009             :   }
    1010           0 :   double av = 0.0;
    1011           0 :   for(unsigned int i = 0; i < getNumChan(spwid); i++) {
    1012           0 :     av = av + getDispersiveH2OPhaseDelay(integratedwatercolumn,v_transfertId_[spwid] + i).get(Angle::UnitDegree);
    1013             :   }
    1014           0 :   av = av / getNumChan(spwid);
    1015           0 :   Angle average(av, Angle::UnitDegree);
    1016           0 :   return average;
    1017           0 : }
    1018             : 
    1019           0 : Length RefractiveIndexProfile::getDispersiveH2OPathLength(const Length &integratedwatercolumn,
    1020             :                                                           unsigned int spwid,
    1021             :                                                           unsigned int nc)
    1022             : {
    1023           0 :   if(!spwidAndIndexAreValid(spwid, nc)) {
    1024           0 :     return Length(-999.0, Length::UnitMeter);
    1025             :   }
    1026           0 :   return getDispersiveH2OPathLength(integratedwatercolumn,v_transfertId_[spwid] + nc);
    1027             : }
    1028             : 
    1029           0 : Length RefractiveIndexProfile::getAverageDispersiveH2OPathLength(const Length &integratedwatercolumn,
    1030             :                                                                  unsigned int spwid)
    1031             : {
    1032           0 :   if(!spwidAndIndexAreValid(spwid, 0)) {
    1033           0 :     return Length(-999.0, Length::UnitMeter);
    1034             :   }
    1035           0 :   double av = 0.0;
    1036           0 :   for(unsigned int i = 0; i < getNumChan(spwid); i++) {
    1037           0 :     av = av + getDispersiveH2OPathLength(integratedwatercolumn,v_transfertId_[spwid] + i).get(Length::UnitMilliMeter);
    1038             :   }
    1039           0 :   av = av / getNumChan(spwid);
    1040           0 :   Length average(av, Length::UnitMilliMeter);
    1041           0 :   return average;
    1042           0 : }
    1043             : 
    1044           0 : Angle RefractiveIndexProfile::getNonDispersiveDryPhaseDelay()
    1045             : {
    1046           0 :   return getNonDispersiveDryPhaseDelay(0);
    1047             : }
    1048             : 
    1049           1 : Length RefractiveIndexProfile::getNonDispersiveDryPathLength()
    1050             : {
    1051           1 :   return getNonDispersiveDryPathLength(0);
    1052             : }
    1053             : 
    1054           0 : Angle RefractiveIndexProfile::getDispersiveDryPhaseDelay()
    1055             : {
    1056           0 :   return getDispersiveDryPhaseDelay(0);
    1057             : }
    1058             : 
    1059           0 : Length RefractiveIndexProfile::getDispersiveDryPathLength()
    1060             : {
    1061           0 :   return getDispersiveDryPathLength(0);
    1062             : }
    1063             : 
    1064        4801 : Angle RefractiveIndexProfile::getNonDispersiveDryPhaseDelay(unsigned int nc)
    1065             : {
    1066        4801 :   if(!chanIndexIsValid(nc)) {
    1067           0 :     return Angle(-999.0, Angle::UnitDegree);
    1068             :   }
    1069        4801 :   double kv = 0;
    1070      100431 :   for(unsigned int j = 0; j < numLayer_; j++) {
    1071       95630 :     kv = kv + real(vv_N_DryContPtr_[nc]->at(j)) * v_layerThickness_[j];
    1072             :   }
    1073        4801 :   Angle aa(kv * 57.29578, Angle::UnitDegree);
    1074        4801 :   return aa;
    1075        4801 : }
    1076             : 
    1077           0 : Angle RefractiveIndexProfile::getDispersiveDryPhaseDelay(unsigned int nc)
    1078             : {
    1079             :   //    std::cout << "getO2LinesPhaseDelay(" << nc << ")=" << getO2LinesPhaseDelay(nc).get(Angle::UnitDegree)  << std::endl;
    1080             :   // std::cout << "getO3LinesPhaseDelay(" << nc << ")=" << getO3LinesPhaseDelay(nc).get(Angle::UnitDegree) << std::endl;
    1081             :   //    std::cout << "getN2OLinesPhaseDelay(" << nc << ")=" << getN2OLinesPhaseDelay(nc).get(Angle::UnitDegree) << std::endl;
    1082             :   //    std::cout << "getNO2LinesPhaseDelay(" << nc << ")=" << getNO2LinesPhaseDelay(nc).get(Angle::UnitDegree) << std::endl;
    1083             :   //    std::cout << "getSO2LinesPhaseDelay(" << nc << ")=" << getSO2LinesPhaseDelay(nc).get(Angle::UnitDegree) << std::endl;
    1084             :   //    std::cout << "getCOLinesPhaseDelay(" << nc << ")=" << getCOLinesPhaseDelay(nc).get(Angle::UnitDegree) << std::endl;
    1085           0 :   return getO2LinesPhaseDelay(nc) + getO3LinesPhaseDelay(nc)
    1086           0 :       + getN2OLinesPhaseDelay(nc) + getCOLinesPhaseDelay(nc)
    1087           0 :       + getNO2LinesPhaseDelay(nc) + getSO2LinesPhaseDelay(nc);
    1088             : }
    1089             : 
    1090        4801 : Length RefractiveIndexProfile::getNonDispersiveDryPathLength(unsigned int nc)
    1091             : {
    1092        4801 :   if(!chanIndexIsValid(nc)) {
    1093           0 :     return Length(-999.0, Length::UnitMeter);
    1094             :   }
    1095        4801 :   double wavelength = 299792458.0 / v_chanFreq_[nc]; // in m
    1096             :   Length
    1097        4801 :       ll((wavelength / 360.0) * getNonDispersiveDryPhaseDelay(nc).get(Angle::UnitDegree),
    1098        4801 :          Length::UnitMeter);
    1099        4801 :   return ll;
    1100        4801 : }
    1101             : 
    1102           0 : Angle RefractiveIndexProfile::getNonDispersiveDryPhaseDelay(unsigned int spwid,
    1103             :                                                             unsigned int nc)
    1104             : {
    1105           0 :   if(!spwidAndIndexAreValid(spwid, nc)) {
    1106           0 :     return Angle(-999.0, Angle::UnitDegree);
    1107             :   }
    1108           0 :   return getNonDispersiveDryPhaseDelay(v_transfertId_[spwid] + nc);
    1109             : }
    1110             : 
    1111           0 : Length RefractiveIndexProfile::getDispersiveDryPathLength(unsigned int nc)
    1112             : {
    1113           0 :   if(!chanIndexIsValid(nc)) {
    1114           0 :     return Length(-999.0, Length::UnitMeter);
    1115             :   }
    1116           0 :   double wavelength = 299792458.0 / v_chanFreq_[nc]; // in m
    1117           0 :   Length ll((wavelength / 360.0) * getDispersiveDryPhaseDelay(nc).get(Angle::UnitDegree),
    1118           0 :             Length::UnitMeter);
    1119           0 :   return ll;
    1120           0 : }
    1121             : 
    1122           0 : Angle RefractiveIndexProfile::getDispersiveDryPhaseDelay(unsigned int spwid,
    1123             :                                                          unsigned int nc)
    1124             : {
    1125           0 :   if(!spwidAndIndexAreValid(spwid, nc)) {
    1126           0 :     return Angle(-999.0, Angle::UnitDegree);
    1127             :   }
    1128           0 :   return getDispersiveDryPhaseDelay(v_transfertId_[spwid] + nc);
    1129             : }
    1130             : 
    1131           0 : Angle RefractiveIndexProfile::getAverageNonDispersiveDryPhaseDelay(unsigned int spwid)
    1132             : {
    1133           0 :   if(!spwidAndIndexAreValid(spwid, 0)) {
    1134           0 :     return Angle(-999.0, Angle::UnitDegree);
    1135             :   }
    1136           0 :   double av = 0.0;
    1137           0 :   for(unsigned int i = 0; i < getNumChan(spwid); i++) {
    1138           0 :     av = av
    1139           0 :         + getNonDispersiveDryPhaseDelay(v_transfertId_[spwid] + i).get(Angle::UnitDegree);
    1140             :   }
    1141           0 :   av = av / getNumChan(spwid);
    1142           0 :   Angle average(av, Angle::UnitDegree);
    1143           0 :   return average;
    1144           0 : }
    1145             : 
    1146           0 : Angle RefractiveIndexProfile::getAverageDispersiveDryPhaseDelay(unsigned int spwid)
    1147             : {
    1148           0 :   if(!spwidAndIndexAreValid(spwid, 0)) {
    1149           0 :     return Angle(-999.0, Angle::UnitDegree);
    1150             :   }
    1151           0 :   double av = 0.0;
    1152           0 :   for(unsigned int i = 0; i < getNumChan(spwid); i++) {
    1153           0 :     av = av + getDispersiveDryPhaseDelay(v_transfertId_[spwid] + i).get(Angle::UnitDegree);
    1154             :   }
    1155           0 :   av = av / getNumChan(spwid);
    1156           0 :   Angle average(av, Angle::UnitDegree);
    1157           0 :   return average;
    1158           0 : }
    1159             : 
    1160           0 : Length RefractiveIndexProfile::getNonDispersiveDryPathLength(unsigned int spwid,
    1161             :                                                              unsigned int nc)
    1162             : {
    1163           0 :   if(!spwidAndIndexAreValid(spwid, nc)) {
    1164           0 :     return Length(-999.0, Length::UnitMeter);
    1165             :   }
    1166           0 :   return getNonDispersiveDryPathLength(v_transfertId_[spwid] + nc);
    1167             : }
    1168             : 
    1169           0 : Length RefractiveIndexProfile::getDispersiveDryPathLength(unsigned int spwid,
    1170             :                                                           unsigned int nc)
    1171             : {
    1172           0 :   if(!spwidAndIndexAreValid(spwid, nc)) {
    1173           0 :     return Length(-999.0, Length::UnitMeter);
    1174             :   }
    1175           0 :   return getDispersiveDryPathLength(v_transfertId_[spwid] + nc);
    1176             : }
    1177             : 
    1178         240 : Length RefractiveIndexProfile::getAverageNonDispersiveDryPathLength(unsigned int spwid)
    1179             : {
    1180         240 :   if(!spwidAndIndexAreValid(spwid, 0)) {
    1181           0 :     return Length(-999.0, Length::UnitMeter);
    1182             :   }
    1183         240 :   double av = 0.0;
    1184        5040 :   for(unsigned int i = 0; i < getNumChan(spwid); i++) {
    1185        4800 :     av = av
    1186        4800 :         + getNonDispersiveDryPathLength(v_transfertId_[spwid] + i).get(Length::UnitMilliMeter);
    1187             :   }
    1188         240 :   av = av / getNumChan(spwid);
    1189         240 :   Length average(av, Length::UnitMilliMeter);
    1190         240 :   return average;
    1191         240 : }
    1192             : 
    1193           0 : Length RefractiveIndexProfile::getAverageDispersiveDryPathLength(unsigned int spwid)
    1194             : {
    1195           0 :   if(!spwidAndIndexAreValid(spwid, 0)) {
    1196           0 :     return Length(-999.0, Length::UnitMeter);
    1197             :   }
    1198           0 :   double av = 0.0;
    1199           0 :   for(unsigned int i = 0; i < getNumChan(spwid); i++) {
    1200           0 :     av = av + getDispersiveDryPathLength(v_transfertId_[spwid] + i).get(Length::UnitMilliMeter);
    1201             :   }
    1202             : 
    1203           0 :   av = av / getNumChan(spwid);
    1204           0 :   Length average(av, Length::UnitMilliMeter);
    1205           0 :   return average;
    1206           0 : }
    1207             : 
    1208           0 : Angle RefractiveIndexProfile::getO2LinesPhaseDelay()
    1209             : {
    1210           0 :   return getO2LinesPhaseDelay(0);
    1211             : }
    1212             : 
    1213           1 : Length RefractiveIndexProfile::getO2LinesPathLength()
    1214             : {
    1215           1 :   return getO2LinesPathLength(0);
    1216             : }
    1217             : 
    1218        4801 : Angle RefractiveIndexProfile::getO2LinesPhaseDelay(unsigned int nc)
    1219             : {
    1220        4801 :   if(!chanIndexIsValid(nc)) {
    1221           0 :     return Angle(-999.0, Angle::UnitDegree);
    1222             :   }
    1223        4801 :   double kv = 0;
    1224      100431 :   for(unsigned int j = 0; j < numLayer_; j++) {
    1225       95630 :     kv = kv + real(vv_N_O2LinesPtr_[nc]->at(j)) * v_layerThickness_[j];
    1226             :   }
    1227        4801 :   Angle aa(kv * 57.29578, Angle::UnitDegree);
    1228        4801 :   return aa;
    1229        4801 : }
    1230             : 
    1231        4801 : Length RefractiveIndexProfile::getO2LinesPathLength(unsigned int nc)
    1232             : {
    1233        4801 :   if(!chanIndexIsValid(nc)) {
    1234           0 :     return Length(-999.0, Length::UnitMeter);
    1235             :   }
    1236        4801 :   double wavelength = 299792458.0 / v_chanFreq_[nc]; // in m
    1237        4801 :   Length ll((wavelength / 360.0) * getO2LinesPhaseDelay(nc).get(Angle::UnitDegree), Length::UnitMeter);
    1238        4801 :   return ll;
    1239        4801 : }
    1240             : 
    1241           0 : Angle RefractiveIndexProfile::getO2LinesPhaseDelay(unsigned int spwid,
    1242             :                                                    unsigned int nc)
    1243             : {
    1244           0 :   if(!spwidAndIndexAreValid(spwid, nc)) {
    1245           0 :     return Angle(-999.0, Angle::UnitDegree);
    1246             :   }
    1247           0 :   return getO2LinesPhaseDelay(v_transfertId_[spwid] + nc);
    1248             : }
    1249             : 
    1250           0 : Angle RefractiveIndexProfile::getAverageO2LinesPhaseDelay(unsigned int spwid)
    1251             : {
    1252           0 :   if(!spwidAndIndexAreValid(spwid, 0)) {
    1253           0 :     return Angle(-999.0, Angle::UnitDegree);
    1254             :   }
    1255           0 :   double av = 0.0;
    1256           0 :   for(unsigned int i = 0; i < getNumChan(spwid); i++) {
    1257           0 :     av = av + getO2LinesPhaseDelay(v_transfertId_[spwid] + i).get(Angle::UnitDegree);
    1258             :   }
    1259           0 :   av = av / getNumChan(spwid);
    1260           0 :   Angle average(av, Angle::UnitDegree);
    1261           0 :   return average;
    1262           0 : }
    1263             : 
    1264           0 : Length RefractiveIndexProfile::getO2LinesPathLength(unsigned int spwid,
    1265             :                                                     unsigned int nc)
    1266             : {
    1267           0 :   if(!spwidAndIndexAreValid(spwid, nc)) {
    1268           0 :     return Length(-999.0, Length::UnitMeter);
    1269             :   }
    1270           0 :   return getO2LinesPathLength(v_transfertId_[spwid] + nc);
    1271             : }
    1272             : 
    1273         240 : Length RefractiveIndexProfile::getAverageO2LinesPathLength(unsigned int spwid)
    1274             : {
    1275         240 :   if(!spwidAndIndexAreValid(spwid, 0)) {
    1276           0 :     return Length(-999.0, Length::UnitMeter);
    1277             :   }
    1278         240 :   double av = 0.0;
    1279        5040 :   for(unsigned int i = 0; i < getNumChan(spwid); i++) {
    1280        4800 :     av = av + getO2LinesPathLength(v_transfertId_[spwid] + i).get(Length::UnitMilliMeter);
    1281             :   }
    1282         240 :   av = av / getNumChan(spwid);
    1283         240 :   Length average(av, Length::UnitMilliMeter);
    1284         240 :   return average;
    1285         240 : }
    1286             : 
    1287           0 : Angle RefractiveIndexProfile::getO3LinesPhaseDelay()
    1288             : {
    1289           0 :   return getO3LinesPhaseDelay(0);
    1290             : }
    1291             : 
    1292           1 : Length RefractiveIndexProfile::getO3LinesPathLength()
    1293             : {
    1294           1 :   return getO3LinesPathLength(0);
    1295             : }
    1296             : 
    1297        4801 : Angle RefractiveIndexProfile::getO3LinesPhaseDelay(unsigned int nc)
    1298             : {
    1299        4801 :   if(!chanIndexIsValid(nc)) {
    1300           0 :     return Angle(-999.0, Angle::UnitDegree);
    1301             :   }
    1302        4801 :   double kv = 0;
    1303             : 
    1304             :   //    if(nc=66){cout << "vv_N_O3LinesPtr_" << ".size()=" << vv_N_O3LinesPtr_.size() << std::endl;}
    1305             : 
    1306      100431 :   for(unsigned int j = 0; j < numLayer_; j++) {
    1307             :     /* if(nc=66){
    1308             :      std::cout << "j=" << j << " vv_N_O3LinesPtr_[" << nc << "]->at(" << j << ")="  << vv_N_O3LinesPtr_[nc]->at(j) << std::endl;
    1309             :      } */
    1310       95630 :     kv = kv + real(vv_N_O3LinesPtr_[nc]->at(j)) * v_layerThickness_[j];
    1311             :   }
    1312        4801 :   Angle aa(kv * 57.29578, Angle::UnitDegree);
    1313        4801 :   return aa;
    1314        4801 : }
    1315             : 
    1316        4801 : Length RefractiveIndexProfile::getO3LinesPathLength(unsigned int nc)
    1317             : {
    1318        4801 :   if(!chanIndexIsValid(nc)) {
    1319           0 :     return Length(-999.0, Length::UnitMeter);
    1320             :   }
    1321        4801 :   double wavelength = 299792458.0 / v_chanFreq_[nc]; // in m
    1322        4801 :   Length ll((wavelength / 360.0) * getO3LinesPhaseDelay(nc).get(Angle::UnitDegree), Length::UnitMeter);
    1323        4801 :   return ll;
    1324        4801 : }
    1325             : 
    1326           0 : Angle RefractiveIndexProfile::getO3LinesPhaseDelay(unsigned int spwid,
    1327             :                                                    unsigned int nc)
    1328             : {
    1329           0 :   if(!spwidAndIndexAreValid(spwid, nc)) {
    1330           0 :     return Angle(-999.0, Angle::UnitDegree);
    1331             :   }
    1332           0 :   return getO3LinesPhaseDelay(v_transfertId_[spwid] + nc);
    1333             : }
    1334             : 
    1335           0 : Angle RefractiveIndexProfile::getAverageO3LinesPhaseDelay(unsigned int spwid)
    1336             : {
    1337           0 :   if(!spwidAndIndexAreValid(spwid, 0)) {
    1338           0 :     return Angle(-999.0, Angle::UnitDegree);
    1339             :   }
    1340           0 :   double av = 0.0;
    1341           0 :   for(unsigned int i = 0; i < getNumChan(spwid); i++) {
    1342           0 :     av = av + getO3LinesPhaseDelay(v_transfertId_[spwid] + i).get(Angle::UnitDegree);
    1343             :   }
    1344           0 :   av = av / getNumChan(spwid);
    1345           0 :   Angle average(av, Angle::UnitDegree);
    1346           0 :   return average;
    1347           0 : }
    1348             : 
    1349           0 : Length RefractiveIndexProfile::getO3LinesPathLength(unsigned int spwid,
    1350             :                                                     unsigned int nc)
    1351             : {
    1352           0 :   if(!spwidAndIndexAreValid(spwid, nc)) {
    1353           0 :     return Length(-999.0, Length::UnitMeter);
    1354             :   }
    1355           0 :   return getO3LinesPathLength(v_transfertId_[spwid] + nc);
    1356             : }
    1357             : 
    1358         240 : Length RefractiveIndexProfile::getAverageO3LinesPathLength(unsigned int spwid)
    1359             : {
    1360         240 :   if(!spwidAndIndexAreValid(spwid, 0)) {
    1361           0 :     return Length(-999.0, Length::UnitMeter);
    1362             :   }
    1363         240 :   double av = 0.0;
    1364        5040 :   for(unsigned int i = 0; i < getNumChan(spwid); i++) {
    1365        4800 :     av = av + getO3LinesPathLength(v_transfertId_[spwid] + i).get(Length::UnitMilliMeter);
    1366             :   }
    1367         240 :   av = av / getNumChan(spwid);
    1368         240 :   Length average(av, Length::UnitMilliMeter);
    1369         240 :   return average;
    1370         240 : }
    1371             : 
    1372           0 : Angle RefractiveIndexProfile::getCOLinesPhaseDelay()
    1373             : {
    1374           0 :   return getCOLinesPhaseDelay(0);
    1375             : }
    1376             : 
    1377           1 : Length RefractiveIndexProfile::getCOLinesPathLength()
    1378             : {
    1379           1 :   return getCOLinesPathLength(0);
    1380             : }
    1381             : 
    1382        4801 : Angle RefractiveIndexProfile::getCOLinesPhaseDelay(unsigned int nc)
    1383             : {
    1384        4801 :   if(!chanIndexIsValid(nc)) {
    1385           0 :     return Angle(-999.0, Angle::UnitDegree);
    1386             :   }
    1387        4801 :   double kv = 0;
    1388      100431 :   for(unsigned int j = 0; j < numLayer_; j++) {
    1389       95630 :     kv = kv + real(vv_N_COLinesPtr_[nc]->at(j)) * v_layerThickness_[j];
    1390             :   }
    1391        4801 :   Angle aa(kv * 57.29578, Angle::UnitDegree);
    1392        4801 :   return aa;
    1393        4801 : }
    1394             : 
    1395        4801 : Length RefractiveIndexProfile::getCOLinesPathLength(unsigned int nc)
    1396             : {
    1397        4801 :   if(!chanIndexIsValid(nc)) {
    1398           0 :     return Length(-999.0, Length::UnitMeter);
    1399             :   }
    1400        4801 :   double wavelength = 299792458.0 / v_chanFreq_[nc]; // in m
    1401        4801 :   Length ll((wavelength / 360.0) * getCOLinesPhaseDelay(nc).get(Angle::UnitDegree), Length::UnitMeter);
    1402        4801 :   return ll;
    1403        4801 : }
    1404             : 
    1405           0 : Angle RefractiveIndexProfile::getCOLinesPhaseDelay(unsigned int spwid,
    1406             :                                                    unsigned int nc)
    1407             : {
    1408           0 :   if(!spwidAndIndexAreValid(spwid, nc)) {
    1409           0 :     return Angle(-999.0, Angle::UnitDegree);
    1410             :   }
    1411           0 :   return getCOLinesPhaseDelay(v_transfertId_[spwid] + nc);
    1412             : }
    1413             : 
    1414           0 : Angle RefractiveIndexProfile::getAverageCOLinesPhaseDelay(unsigned int spwid)
    1415             : {
    1416           0 :   if(!spwidAndIndexAreValid(spwid, 0)) {
    1417           0 :     return Angle(-999.0, Angle::UnitDegree);
    1418             :   }
    1419           0 :   double av = 0.0;
    1420           0 :   for(unsigned int i = 0; i < getNumChan(spwid); i++) {
    1421           0 :     av = av + getCOLinesPhaseDelay(v_transfertId_[spwid] + i).get(Angle::UnitDegree);
    1422             :   }
    1423           0 :   av = av / getNumChan(spwid);
    1424           0 :   Angle average(av, Angle::UnitDegree);
    1425           0 :   return average;
    1426           0 : }
    1427             : 
    1428           0 : Length RefractiveIndexProfile::getCOLinesPathLength(unsigned int spwid,
    1429             :                                                     unsigned int nc)
    1430             : {
    1431           0 :   if(!spwidAndIndexAreValid(spwid, nc)) {
    1432           0 :     return Length(-999.0, Length::UnitMeter);
    1433             :   }
    1434           0 :   return getCOLinesPathLength(v_transfertId_[spwid] + nc);
    1435             : }
    1436             : 
    1437         240 : Length RefractiveIndexProfile::getAverageCOLinesPathLength(unsigned int spwid)
    1438             : {
    1439         240 :   if(!spwidAndIndexAreValid(spwid, 0)) {
    1440           0 :     return Length(-999.0, Length::UnitMeter);
    1441             :   }
    1442         240 :   double av = 0.0;
    1443        5040 :   for(unsigned int i = 0; i < getNumChan(spwid); i++) {
    1444        4800 :     av = av + getCOLinesPathLength(v_transfertId_[spwid] + i).get(Length::UnitMilliMeter);
    1445             :   }
    1446         240 :   av = av / getNumChan(spwid);
    1447         240 :   Length average(av, Length::UnitMilliMeter);
    1448         240 :   return average;
    1449         240 : }
    1450             : 
    1451           0 : Angle RefractiveIndexProfile::getN2OLinesPhaseDelay()
    1452             : {
    1453           0 :   return getN2OLinesPhaseDelay(0);
    1454             : }
    1455             : 
    1456           1 : Length RefractiveIndexProfile::getN2OLinesPathLength()
    1457             : {
    1458           1 :   return getN2OLinesPathLength(0);
    1459             : }
    1460             : 
    1461        4801 : Angle RefractiveIndexProfile::getN2OLinesPhaseDelay(unsigned int nc)
    1462             : {
    1463        4801 :   if(!chanIndexIsValid(nc)) {
    1464           0 :     return Angle(-999.0, Angle::UnitDegree);
    1465             :   }
    1466        4801 :   double kv = 0;
    1467      100431 :   for(unsigned int j = 0; j < numLayer_; j++) {
    1468       95630 :     kv = kv + real(vv_N_N2OLinesPtr_[nc]->at(j)) * v_layerThickness_[j];
    1469             :   }
    1470        4801 :   Angle aa(kv * 57.29578, Angle::UnitDegree);
    1471        4801 :   return aa;
    1472        4801 : }
    1473             : 
    1474        4801 : Length RefractiveIndexProfile::getN2OLinesPathLength(unsigned int nc)
    1475             : {
    1476        4801 :   if(!chanIndexIsValid(nc)) {
    1477           0 :     return Length(-999.0, Length::UnitMeter);
    1478             :   }
    1479        4801 :   double wavelength = 299792458.0 / v_chanFreq_[nc]; // in m
    1480        4801 :   Length ll((wavelength / 360.0) * getN2OLinesPhaseDelay(nc).get(Angle::UnitDegree), Length::UnitMeter);
    1481        4801 :   return ll;
    1482        4801 : }
    1483             : 
    1484           0 : Angle RefractiveIndexProfile::getN2OLinesPhaseDelay(unsigned int spwid,
    1485             :                                                     unsigned int nc)
    1486             : {
    1487           0 :   if(!spwidAndIndexAreValid(spwid, nc)) {
    1488           0 :     return Angle(-999.0, Angle::UnitDegree);
    1489             :   }
    1490           0 :   return getN2OLinesPhaseDelay(v_transfertId_[spwid] + nc);
    1491             : }
    1492             : 
    1493           0 : Angle RefractiveIndexProfile::getAverageN2OLinesPhaseDelay(unsigned int spwid)
    1494             : {
    1495           0 :   if(!spwidAndIndexAreValid(spwid, 0)) {
    1496           0 :     return Angle(-999.0, Angle::UnitDegree);
    1497             :   }
    1498           0 :   double av = 0.0;
    1499           0 :   for(unsigned int i = 0; i < getNumChan(spwid); i++) {
    1500           0 :     av = av + getN2OLinesPhaseDelay(v_transfertId_[spwid] + i).get(Angle::UnitDegree);
    1501             :   }
    1502           0 :   av = av / getNumChan(spwid);
    1503           0 :   Angle average(av, Angle::UnitDegree);
    1504           0 :   return average;
    1505           0 : }
    1506             : 
    1507           0 : Length RefractiveIndexProfile::getN2OLinesPathLength(unsigned int spwid,
    1508             :                                                      unsigned int nc)
    1509             : {
    1510           0 :   if(!spwidAndIndexAreValid(spwid, nc)) {
    1511           0 :     return Length(-999.0, Length::UnitMeter);
    1512             :   }
    1513           0 :   return getN2OLinesPathLength(v_transfertId_[spwid] + nc);
    1514             : }
    1515             : 
    1516         240 : Length RefractiveIndexProfile::getAverageN2OLinesPathLength(unsigned int spwid)
    1517             : {
    1518         240 :   if(!spwidAndIndexAreValid(spwid, 0)) {
    1519           0 :     return Length(-999.0, Length::UnitMeter);
    1520             :   }
    1521         240 :   double av = 0.0;
    1522        5040 :   for(unsigned int i = 0; i < getNumChan(spwid); i++) {
    1523        4800 :     av = av + getN2OLinesPathLength(v_transfertId_[spwid] + i).get(Length::UnitMilliMeter);
    1524             :   }
    1525         240 :   av = av / getNumChan(spwid);
    1526         240 :   Length average(av, Length::UnitMilliMeter);
    1527         240 :   return average;
    1528         240 : }
    1529             : 
    1530             : 
    1531             : 
    1532             : 
    1533             : 
    1534             : 
    1535           0 : Angle RefractiveIndexProfile::getNO2LinesPhaseDelay()
    1536             : {
    1537           0 :   return getNO2LinesPhaseDelay(0);
    1538             : }
    1539             : 
    1540           0 : Length RefractiveIndexProfile::getNO2LinesPathLength()
    1541             : {
    1542           0 :   return getNO2LinesPathLength(0);
    1543             : }
    1544             : 
    1545        4800 : Angle RefractiveIndexProfile::getNO2LinesPhaseDelay(unsigned int nc)
    1546             : {
    1547        4800 :   if(!chanIndexIsValid(nc)) {
    1548           0 :     return Angle(-999.0, Angle::UnitDegree);
    1549             :   }
    1550        4800 :   double kv = 0;
    1551      100400 :   for(unsigned int j = 0; j < numLayer_; j++) {
    1552       95600 :     kv = kv + real(vv_N_NO2LinesPtr_[nc]->at(j)) * v_layerThickness_[j];
    1553             :   }
    1554        4800 :   Angle aa(kv * 57.29578, Angle::UnitDegree);
    1555        4800 :   return aa;
    1556        4800 : }
    1557             : 
    1558        4800 : Length RefractiveIndexProfile::getNO2LinesPathLength(unsigned int nc)
    1559             : {
    1560        4800 :   if(!chanIndexIsValid(nc)) {
    1561           0 :     return Length(-999.0, Length::UnitMeter);
    1562             :   }
    1563        4800 :   double wavelength = 299792458.0 / v_chanFreq_[nc]; // in m
    1564        4800 :   Length ll((wavelength / 360.0) * getNO2LinesPhaseDelay(nc).get(Angle::UnitDegree), Length::UnitMeter);
    1565        4800 :   return ll;
    1566        4800 : }
    1567             : 
    1568           0 : Angle RefractiveIndexProfile::getNO2LinesPhaseDelay(unsigned int spwid,
    1569             :                                                     unsigned int nc)
    1570             : {
    1571           0 :   if(!spwidAndIndexAreValid(spwid, nc)) {
    1572           0 :     return Angle(-999.0, Angle::UnitDegree);
    1573             :   }
    1574           0 :   return getNO2LinesPhaseDelay(v_transfertId_[spwid] + nc);
    1575             : }
    1576             : 
    1577           0 : Angle RefractiveIndexProfile::getAverageNO2LinesPhaseDelay(unsigned int spwid)
    1578             : {
    1579           0 :   if(!spwidAndIndexAreValid(spwid, 0)) {
    1580           0 :     return Angle(-999.0, Angle::UnitDegree);
    1581             :   }
    1582           0 :   double av = 0.0;
    1583           0 :   for(unsigned int i = 0; i < getNumChan(spwid); i++) {
    1584           0 :     av = av + getNO2LinesPhaseDelay(v_transfertId_[spwid] + i).get(Angle::UnitDegree);
    1585             :   }
    1586           0 :   av = av / getNumChan(spwid);
    1587           0 :   Angle average(av, Angle::UnitDegree);
    1588           0 :   return average;
    1589           0 : }
    1590             : 
    1591           0 : Length RefractiveIndexProfile::getNO2LinesPathLength(unsigned int spwid,
    1592             :                                                      unsigned int nc)
    1593             : {
    1594           0 :   if(!spwidAndIndexAreValid(spwid, nc)) {
    1595           0 :     return Length(-999.0, Length::UnitMeter);
    1596             :   }
    1597           0 :   return getNO2LinesPathLength(v_transfertId_[spwid] + nc);
    1598             : }
    1599             : 
    1600         240 : Length RefractiveIndexProfile::getAverageNO2LinesPathLength(unsigned int spwid)
    1601             : {
    1602         240 :   if(!spwidAndIndexAreValid(spwid, 0)) {
    1603           0 :     return Length(-999.0, Length::UnitMeter);
    1604             :   }
    1605         240 :   double av = 0.0;
    1606        5040 :   for(unsigned int i = 0; i < getNumChan(spwid); i++) {
    1607        4800 :     av = av + getNO2LinesPathLength(v_transfertId_[spwid] + i).get(Length::UnitMilliMeter);
    1608             :   }
    1609         240 :   av = av / getNumChan(spwid);
    1610         240 :   Length average(av, Length::UnitMilliMeter);
    1611         240 :   return average;
    1612         240 : }
    1613             : 
    1614             : 
    1615             : 
    1616             : 
    1617             : 
    1618             : 
    1619             : 
    1620             : 
    1621           0 : Angle RefractiveIndexProfile::getSO2LinesPhaseDelay()
    1622             : {
    1623           0 :   return getSO2LinesPhaseDelay(0);
    1624             : }
    1625             : 
    1626           0 : Length RefractiveIndexProfile::getSO2LinesPathLength()
    1627             : {
    1628           0 :   return getSO2LinesPathLength(0);
    1629             : }
    1630             : 
    1631        4800 : Angle RefractiveIndexProfile::getSO2LinesPhaseDelay(unsigned int nc)
    1632             : {
    1633        4800 :   if(!chanIndexIsValid(nc)) {
    1634           0 :     return Angle(-999.0, Angle::UnitDegree);
    1635             :   }
    1636        4800 :   double kv = 0;
    1637      100400 :   for(unsigned int j = 0; j < numLayer_; j++) {
    1638       95600 :     kv = kv + real(vv_N_SO2LinesPtr_[nc]->at(j)) * v_layerThickness_[j];
    1639             :   }
    1640        4800 :   Angle aa(kv * 57.29578, Angle::UnitDegree);
    1641        4800 :   return aa;
    1642        4800 : }
    1643             : 
    1644        4800 : Length RefractiveIndexProfile::getSO2LinesPathLength(unsigned int nc)
    1645             : {
    1646        4800 :   if(!chanIndexIsValid(nc)) {
    1647           0 :     return Length(-999.0, Length::UnitMeter);
    1648             :   }
    1649        4800 :   double wavelength = 299792458.0 / v_chanFreq_[nc]; // in m
    1650        4800 :   Length ll((wavelength / 360.0) * getSO2LinesPhaseDelay(nc).get(Angle::UnitDegree), Length::UnitMeter);
    1651        4800 :   return ll;
    1652        4800 : }
    1653             : 
    1654           0 : Angle RefractiveIndexProfile::getSO2LinesPhaseDelay(unsigned int spwid,
    1655             :                                                     unsigned int nc)
    1656             : {
    1657           0 :   if(!spwidAndIndexAreValid(spwid, nc)) {
    1658           0 :     return Angle(-999.0, Angle::UnitDegree);
    1659             :   }
    1660           0 :   return getSO2LinesPhaseDelay(v_transfertId_[spwid] + nc);
    1661             : }
    1662             : 
    1663           0 : Angle RefractiveIndexProfile::getAverageSO2LinesPhaseDelay(unsigned int spwid)
    1664             : {
    1665           0 :   if(!spwidAndIndexAreValid(spwid, 0)) {
    1666           0 :     return Angle(-999.0, Angle::UnitDegree);
    1667             :   }
    1668           0 :   double av = 0.0;
    1669           0 :   for(unsigned int i = 0; i < getNumChan(spwid); i++) {
    1670           0 :     av = av + getSO2LinesPhaseDelay(v_transfertId_[spwid] + i).get(Angle::UnitDegree);
    1671             :   }
    1672           0 :   av = av / getNumChan(spwid);
    1673           0 :   Angle average(av, Angle::UnitDegree);
    1674           0 :   return average;
    1675           0 : }
    1676             : 
    1677           0 : Length RefractiveIndexProfile::getSO2LinesPathLength(unsigned int spwid,
    1678             :                                                      unsigned int nc)
    1679             : {
    1680           0 :   if(!spwidAndIndexAreValid(spwid, nc)) {
    1681           0 :     return Length(-999.0, Length::UnitMeter);
    1682             :   }
    1683           0 :   return getSO2LinesPathLength(v_transfertId_[spwid] + nc);
    1684             : }
    1685             : 
    1686         240 : Length RefractiveIndexProfile::getAverageSO2LinesPathLength(unsigned int spwid)
    1687             : {
    1688         240 :   if(!spwidAndIndexAreValid(spwid, 0)) {
    1689           0 :     return Length(-999.0, Length::UnitMeter);
    1690             :   }
    1691         240 :   double av = 0.0;
    1692        5040 :   for(unsigned int i = 0; i < getNumChan(spwid); i++) {
    1693        4800 :     av = av + getSO2LinesPathLength(v_transfertId_[spwid] + i).get(Length::UnitMilliMeter);
    1694             :   }
    1695         240 :   av = av / getNumChan(spwid);
    1696         240 :   Length average(av, Length::UnitMilliMeter);
    1697         240 :   return average;
    1698         240 : }
    1699             : 
    1700             : 
    1701           0 : Angle RefractiveIndexProfile::getNonDispersiveH2OPhaseDelay(const Length &integratedwatercolumn)
    1702             : {
    1703           0 :   return getNonDispersiveH2OPhaseDelay(integratedwatercolumn,0);
    1704             : }
    1705             : 
    1706           2 : Length RefractiveIndexProfile::getNonDispersiveH2OPathLength(const Length &integratedwatercolumn)
    1707             : {
    1708           2 :   return getNonDispersiveH2OPathLength(integratedwatercolumn,0);
    1709             : }
    1710             : 
    1711           2 : Angle RefractiveIndexProfile::getNonDispersiveH2OPhaseDelay(const Length &integratedwatercolumn,
    1712             :                                                             unsigned int nc)
    1713             : {
    1714           2 :   double kv = 0;
    1715           2 :   if(!chanIndexIsValid(nc)) {
    1716           0 :     return Angle(-999.0, Angle::UnitDegree);
    1717             :   }
    1718          62 :   for(unsigned int j = 0; j < numLayer_; j++) {
    1719          60 :     kv = kv + real(vv_N_H2OContPtr_[nc]->at(j)) * v_layerThickness_[j];
    1720             :   }
    1721           2 :   Angle aa(kv*(integratedwatercolumn.get()/getGroundWH2O().get())* 57.29578, Angle::UnitDegree);
    1722           2 :   return aa;
    1723           2 : }
    1724             : 
    1725           2 : Length RefractiveIndexProfile::getNonDispersiveH2OPathLength(const Length &integratedwatercolumn,
    1726             :                                                              unsigned int nc)
    1727             : {
    1728           2 :   if(!chanIndexIsValid(nc)) {
    1729           0 :     return Length(-999.0, Length::UnitMeter);
    1730             :   }
    1731           2 :   double wavelength = 299792458.0 / v_chanFreq_[nc]; // in m
    1732           2 :   Length ll((wavelength / 360.0) * getNonDispersiveH2OPhaseDelay(integratedwatercolumn,nc).get(Angle::UnitDegree),Length::UnitMeter);
    1733           2 :   return ll;
    1734           2 : }
    1735             : 
    1736           0 : Angle RefractiveIndexProfile::getNonDispersiveH2OPhaseDelay(const Length &integratedwatercolumn,
    1737             :                                                             unsigned int spwid,
    1738             :                                                             unsigned int nc)
    1739             : {
    1740           0 :   if(!spwidAndIndexAreValid(spwid, nc)) {
    1741           0 :     return Angle(-999.0, Angle::UnitDegree);
    1742             :   }
    1743           0 :   return getNonDispersiveH2OPhaseDelay(integratedwatercolumn,v_transfertId_[spwid] + nc);
    1744             : }
    1745             : 
    1746           0 : Angle RefractiveIndexProfile::getAverageNonDispersiveH2OPhaseDelay(const Length &integratedwatercolumn,
    1747             :                                                                    unsigned int spwid)
    1748             : {
    1749           0 :   if(!spwidAndIndexAreValid(spwid, 0)) {
    1750           0 :     return Angle(-999.0, Angle::UnitDegree);
    1751             :   }
    1752           0 :   double av = 0.0;
    1753           0 :   for(unsigned int i = 0; i < getNumChan(spwid); i++) {
    1754           0 :     av = av
    1755           0 :         + getNonDispersiveH2OPhaseDelay(v_transfertId_[spwid] + i).get(Angle::UnitDegree);
    1756             :   }
    1757           0 :   av = av / getNumChan(spwid);
    1758           0 :   Angle average(av*(integratedwatercolumn.get()/getGroundWH2O().get()), Angle::UnitDegree);
    1759           0 :   return average;
    1760           0 : }
    1761             : 
    1762           0 : Length RefractiveIndexProfile::getNonDispersiveH2OPathLength(const Length &integratedwatercolumn,
    1763             :                                                              unsigned int spwid,
    1764             :                                                              unsigned int nc)
    1765             : {
    1766           0 :   if(!spwidAndIndexAreValid(spwid, nc)) {
    1767           0 :     return Length(-999.0);
    1768             :   }
    1769           0 :   return getNonDispersiveH2OPathLength(integratedwatercolumn,v_transfertId_[spwid] + nc);
    1770             : }
    1771             : 
    1772           0 : Length RefractiveIndexProfile::getAverageNonDispersiveH2OPathLength(const Length &integratedwatercolumn,
    1773             :                                                                     unsigned int spwid)
    1774             : {
    1775           0 :   if(!spwidAndIndexAreValid(spwid, 0)) {
    1776           0 :     return Length(-999.0);
    1777             :   }
    1778           0 :   double av = 0.0;
    1779           0 :   for(unsigned int i = 0; i < getNumChan(spwid); i++) {
    1780           0 :     av = av
    1781           0 :       + getNonDispersiveH2OPathLength(integratedwatercolumn,v_transfertId_[spwid] + i).get(Length::UnitMeter);
    1782             :   }
    1783           0 :   av = av / getNumChan(spwid);
    1784           0 :   Length average(av, Length::UnitMeter);
    1785           0 :   return average;
    1786           0 : }
    1787             : 
    1788             : // NB: the function chanIndexIsValid will be overrided by ....
    1789       88634 : bool RefractiveIndexProfile::chanIndexIsValid(unsigned int nc)
    1790             : {
    1791       88634 :   if(nc < vv_N_H2OLinesPtr_.size()) return true;
    1792           0 :   if(nc < v_chanFreq_.size()) {
    1793             :     std::cout
    1794           0 :         << " RefractiveIndexProfile: Requested index in a new spectral window ==> update profile"
    1795           0 :         << std::endl;
    1796           0 :     mkRefractiveIndexProfile();
    1797             :     // std::cout << "...and we return" << std::endl;
    1798           0 :     return true;
    1799             :   }
    1800           0 :   std::cout << " RefractiveIndexProfile: ERROR: Invalid channel frequency index"
    1801           0 :       << std::endl;
    1802           0 :   return false;
    1803             : }
    1804             : 
    1805             : // NB: the function spwidAndIndexAreValid will be overrided by ...
    1806        2174 : bool RefractiveIndexProfile::spwidAndIndexAreValid(unsigned int spwid,
    1807             :                                                    unsigned int idx)
    1808             : {
    1809             : 
    1810        2174 :   if(spwid > getNumSpectralWindow() - 1) {
    1811             :     std::cout
    1812           0 :         << " RefractiveIndexProfile: ERROR: spectral window identifier out of range "
    1813           0 :         << std::endl;
    1814           0 :     return false;
    1815             :   }
    1816        2174 :   if(idx > getNumChan(spwid) - 1) {
    1817           0 :     std::cout << " RefractiveIndexProfile: ERROR: channel index out of range "
    1818           0 :         << std::endl;
    1819           0 :     return false;
    1820             :   }
    1821        2174 :   unsigned int nc = v_transfertId_[spwid] + idx;
    1822        2174 :   bool valid = chanIndexIsValid(nc);
    1823        2174 :   return valid;
    1824             : }
    1825             : 
    1826           0 : void RefractiveIndexProfile::updateNewSpectralWindows()
    1827             : {
    1828           0 :   mkRefractiveIndexProfile();
    1829           0 : }
    1830             : 
    1831             : ATM_NAMESPACE_END

Generated by: LCOV version 1.16