LCOV - code coverage report
Current view: top level - atmosphere/ATM/test - ATMDiscontinuityTest.cc (source / functions) Hit Total Coverage
Test: casacpp_coverage.info Lines: 4 38 10.5 %
Date: 2024-12-11 20:54:31 Functions: 1 1 100.0 %

          Line data    Source code
       1             : /*******************************************************************************
       2             :  * ALMA - Atacama Large Millimeter Array
       3             :  * (c) Instituto de Estructura de la Materia, 2011
       4             :  * (in the framework of the ALMA collaboration).
       5             :  * All rights reserved.
       6             :  * 
       7             :  * This library is free software; you can redistribute it and/or
       8             :  * modify it under the terms of the GNU Lesser General Public
       9             :  * License as published by the Free Software Foundation; either
      10             :  * version 2.1 of the License, or (at your option) any later version.
      11             :  * 
      12             :  * This library is distributed in the hope that it will be useful,
      13             :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      14             :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
      15             :  * Lesser General Public License for more details.
      16             :  * 
      17             :  * You should have received a copy of the GNU Lesser General Public
      18             :  * License along with this library; if not, write to the Free Software
      19             :  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
      20             :  *******************************************************************************/
      21             : 
      22             : #include <string>
      23             : #include <vector>
      24             : #include <iostream>
      25             : #include <fstream>
      26             : #include <stdlib.h>
      27             : 
      28             : 
      29             : #include <atmosphere/ATM/ATMPercent.h>
      30             : #include <atmosphere/ATM/ATMPressure.h>
      31             : #include <atmosphere/ATM/ATMNumberDensity.h>
      32             : #include <atmosphere/ATM/ATMMassDensity.h>
      33             : #include <atmosphere/ATM/ATMTemperature.h>
      34             : #include <atmosphere/ATM/ATMLength.h>
      35             : #include <atmosphere/ATM/ATMInverseLength.h>
      36             : #include <atmosphere/ATM/ATMOpacity.h>
      37             : #include <atmosphere/ATM/ATMAngle.h>
      38             : #include <atmosphere/ATM/ATMHumidity.h>
      39             : #include <atmosphere/ATM/ATMFrequency.h>
      40             : #include <atmosphere/ATM/ATMWaterVaporRadiometer.h>
      41             : #include <atmosphere/ATM/ATMWVRMeasurement.h>
      42             : #include <atmosphere/ATM/ATMProfile.h>
      43             : #include <atmosphere/ATM/ATMSpectralGrid.h>
      44             : #include <atmosphere/ATM/ATMRefractiveIndex.h>
      45             : #include <atmosphere/ATM/ATMRefractiveIndexProfile.h>
      46             : #include <atmosphere/ATM/ATMSkyStatus.h>
      47             : 
      48             : // using namespace telcal::atm;
      49             : using namespace atm;
      50             : using namespace std;
      51             : 
      52           1 : int main(int argc, char *argv[]) {
      53             :   
      54           1 :   if (argc<3) {
      55           1 :     cout<<"ATMDiscontinuityTest.cpp fminGhz fmaxGhz"<<endl;
      56           1 :     exit(0);
      57             :   }
      58             : 
      59             :   // Read arguments
      60           0 :   double freqmin = atof(argv[1]);
      61           0 :   double freqmax = atof(argv[2]);
      62             :   
      63           0 :   if (freqmin<50. || freqmax>1000. || freqmax<50. || freqmax>1000.) {
      64           0 :     cout<<"Error : freq value should be in the interval [50Ghz,1000Ghz]"<<endl;
      65           0 :     exit(0);
      66             :   }
      67             :    
      68             :   // Define spectralGrid
      69           0 :   unsigned int numchan=1000; 
      70           0 :   unsigned int refchan=500;  
      71             : 
      72           0 :   double freq = (freqmin+freqmax)/2.; 
      73           0 :   Frequency reffreq(freq,"GHz");
      74             : 
      75           0 :   double dfreq = (freqmax-freqmin)/double(numchan); 
      76             : 
      77           0 :   Frequency chansep(  dfreq,"GHz");
      78             :   //cout<<freqmin<<" "<<freqmax<<" "<<freq<<" chansep="<<dfreq<<endl;
      79             : 
      80           0 :   SpectralGrid band(numchan, refchan, reffreq, chansep);
      81             : 
      82             : 
      83             :   // Atmospheric profile
      84           0 :   unsigned int atmType = 1; // TROPICAL
      85           0 :   Temperature      T( 273.0,"K" );     // Ground temperature
      86           0 :   Pressure         P( 550.0,"mb");     // Ground Pressure
      87           0 :   Humidity         H(  20.0,"%" );     // Ground Relative Humidity (indication)
      88           0 :   Length         Alt(  5000,"m" );     // Altitude of the site 
      89           0 :   Length         WVL(   1.0,"km");     // Water vapor scale height
      90           0 :   double         TLR=  -6.5      ;     // Tropospheric lapse rate (must be in K/km)
      91           0 :   Length      topAtm(  48.0,"km");     // Upper atm. boundary for calculations
      92           0 :   Pressure     Pstep(   5.0,"mb");     // Primary pressure step (10.0 mb)
      93           0 :   double   PstepFact=         1.1;     // Pressure step ratio between two consecutive layers
      94             : 
      95           0 :   AtmProfile myProfile( Alt, P, T, TLR, H, WVL, Pstep, PstepFact,  topAtm, atmType );
      96             : 
      97           0 :   RefractiveIndexProfile abs_band(band, myProfile); 
      98           0 :   SkyStatus mySky_1band(abs_band);
      99           0 :   mySky_1band.setAirMass(1.0);
     100             : 
     101           0 :   FILE * fp = fopen("tsky.dat","w");
     102           0 :   for(unsigned int i=0; i<mySky_1band.getNumChan(0); i++){
     103           0 :     fprintf(fp, "%f %f\n",
     104           0 :             mySky_1band.getChanFreq(i).get("GHz"),
     105           0 :             mySky_1band.getTebbSky(i).get("K"));
     106             :   }
     107           0 :   fclose(fp);
     108             : 
     109           0 :   return 0;
     110           0 : }
     111             : 

Generated by: LCOV version 1.16