LCOV - code coverage report
Current view: top level - components/ComponentModels - FluxStdsQS2.cc (source / functions) Hit Total Coverage
Test: casacpp_coverage.info Lines: 28 217 12.9 %
Date: 2024-10-12 00:35:29 Functions: 2 9 22.2 %

          Line data    Source code
       1             : //# FluxStdsQS2.cc: Definition of the flux standards some of which may varies in time
       2             : //# depend on time.
       3             : //# Copyright (C) 2013
       4             : //# Associated Universities, Inc. Washington DC, USA.
       5             : //#
       6             : //# This library is free software; you can redistribute it and/or modify it
       7             : //# under the terms of the GNU Library General Public License as published by
       8             : //# the Free Software Foundation; either version 2 of the License, or (at your
       9             : //# option) any later version.
      10             : //#
      11             : //# This library is distributed in the hope that it will be useful, but WITHOUT
      12             : //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
      13             : //# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
      14             : //# License for more details.
      15             : //#
      16             : //# You should have received a copy of the GNU Library General Public License
      17             : //# along with this library; if not, write to the Free Software Foundation,
      18             : //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
      19             : //#
      20             : //# Correspondence concerning AIPS++ should be addressed as follows:
      21             : //#        Internet email: casa-feedback@nrao.edu.
      22             : //#        Postal address: AIPS++ Project Office
      23             : //#                        National Radio Astronomy Observatory
      24             : //#                        520 Edgemont Road
      25             : //#                        Charlottesville, VA 22903-2475 USA
      26             : //#
      27             : 
      28             : #include <components/ComponentModels/FluxStdsQS2.h>
      29             : #include <components/ComponentModels/FluxStdSrcs.h>
      30             : #include <casacore/casa/OS/Path.h>
      31             : #include <casacore/casa/System/Aipsrc.h>
      32             : #include <casatools/Config/State.h>
      33             : 
      34             : //#include <casa/Logging/LogIO.h>
      35             : 
      36             : using namespace casacore;
      37             : namespace casa { //# NAMESPACE CASA - BEGIN
      38             : namespace NSTDS { //# NAMESPACE NSTDS - BEGIN
      39             : // Each of these c'tors defines the polynomial coefficients for the
      40             : // log10(fluxDensity) = polynomial(log10(frequency)) calculations
      41             : // and optionally additional coefficients for estimating the flux density
      42             : // uncertainties. 
      43             : //
      44             : // fill_coeffs() with two RigidVectors uses the first one for the flux density
      45             : // coefficients and second one for the uncertainty coefficients, starting at
      46             : // order 0.  If the second RigidVector is omitted no uncertainty will be
      47             : // estimated.
      48             : 
      49             : 
      50           0 : Bool FluxStdBaars::setSourceCoeffs()
      51             : {
      52           0 :   Bool found = true;
      53             :   
      54           0 :   setFreqUnit("MHz");
      55           0 :   FSS::Source srcEnum = FCVQS::getSrcEnum();
      56             :   
      57           0 :   if(srcEnum == FSS::THREEC286)
      58           0 :     fill_coeffs(RVF3(1.480, 0.292, -0.124), RVF3(0.018, 0.006, 0.001));
      59           0 :   else if(srcEnum == FSS::THREEC48)
      60           0 :     fill_coeffs(RVF3(2.345, 0.071, -0.138), RVF3(0.03, 0.001, 0.001));
      61           0 :   else if(srcEnum == FSS::THREEC147)
      62           0 :     fill_coeffs(RVF3(1.766, 0.447, -0.184), RVF3(0.017, 0.006, 0.001));
      63           0 :   else if(srcEnum == FSS::THREEC138)
      64           0 :     fill_coeffs(RVF3(2.009, -0.07176, -0.0862)); // No error specified
      65           0 :   else if(srcEnum == FSS::NINETEEN34M638)
      66           0 :     fill_coeffs(RVF4(-23.839, 19.569, -4.8168, 0.35836)); // No error specified
      67           0 :   else if(srcEnum == FSS::THREEC295)
      68           0 :     fill_coeffs(RVF3(1.485, 0.759, -0.255), RVF3(0.013, 0.009, 0.001));
      69             :   else
      70           0 :     found = false;
      71           0 :   return found;
      72             : }
      73             : 
      74           0 : Bool FluxStdPerley90::setSourceCoeffs()
      75             : {
      76           0 :   Bool found = true;
      77             :   
      78           0 :   setFreqUnit("MHz");
      79           0 :   FSS::Source srcEnum = FCVQS::getSrcEnum();
      80             : 
      81           0 :   if(srcEnum == FSS::THREEC286)
      82           0 :     fill_coeffs(RVF3(1.35899, 0.3599, -0.13338));
      83           0 :   else if(srcEnum == FSS::THREEC48)
      84           0 :     fill_coeffs(RVF3(2.0868, 0.20889, -0.15498));
      85           0 :   else if(srcEnum == FSS::THREEC147)
      86           0 :     fill_coeffs(RVF3(1.92641, 0.36072, -0.17389));
      87           0 :   else if(srcEnum == FSS::THREEC138)
      88           0 :     fill_coeffs(RVF3(2.009, -0.07176, -0.0862));
      89           0 :   else if(srcEnum == FSS::NINETEEN34M638)
      90           0 :     fill_coeffs(RVF4(-30.7667, 26.4908, -7.0977, 0.605334));
      91           0 :   else if(srcEnum == FSS::THREEC295)
      92           0 :     fill_coeffs(RVF3(1.485, 0.759, -0.255));
      93             :   else
      94           0 :     found = false;
      95           0 :   return found;
      96             : }
      97             : 
      98           0 : Bool FluxStdPerleyTaylor95::setSourceCoeffs()
      99             : {
     100           0 :   Bool found = true;
     101             :   
     102           0 :   setFreqUnit("MHz");
     103           0 :   FSS::Source srcEnum = FCVQS::getSrcEnum();
     104             : 
     105           0 :   if(srcEnum == FSS::THREEC286)
     106           0 :     fill_coeffs(RVF4(0.50344, 1.05026, -0.31666, 0.01602));
     107           0 :   else if(srcEnum == FSS::THREEC48)
     108           0 :     fill_coeffs(RVF4(1.16801, 1.07526, -0.42254, 0.02699));
     109           0 :   else if(srcEnum == FSS::THREEC147)
     110           0 :     fill_coeffs(RVF4(0.05702, 2.09340, -0.7076, 0.05477));
     111           0 :   else if(srcEnum == FSS::THREEC138)
     112           0 :     fill_coeffs(RVF4(1.97498, -0.23918, 0.01333, -0.01389));
     113           0 :   else if(srcEnum == FSS::NINETEEN34M638)
     114           0 :     fill_coeffs(RVF4(-30.7667, 26.4908, -7.0977, 0.605334));
     115           0 :   else if(srcEnum == FSS::THREEC295)
     116           0 :     fill_coeffs(RVF4(1.28872, 0.94172, -0.31113, 0.00569));
     117             :   else
     118           0 :     found = false;
     119           0 :   return found;
     120             : }
     121             : 
     122           5 : Bool FluxStdPerleyTaylor99::setSourceCoeffs()
     123             : {
     124           5 :   Bool found = true;
     125             :   
     126           5 :   setFreqUnit("GHz");
     127           5 :   FSS::Source srcEnum = FCVQS::getSrcEnum();
     128             : 
     129             :   //LogIO os(LogOrigin("FluxStdPerleyTaylor99", "setSourceCoeffs", WHERE));
     130             :   // os << LogIO::NORMAL
     131             :   //    << "srcEnum before fill_coeffs() = " << srcEnum
     132             :   //    << LogIO::POST;
     133             : 
     134           5 :   if(srcEnum == FSS::THREEC286)
     135           5 :     fill_coeffs(RVF4(1.23734, -0.43276, -0.14223, 0.00345));
     136           0 :   else if(srcEnum == FSS::THREEC48)
     137           0 :     fill_coeffs(RVF4(1.31752, -0.74090, -0.16708, 0.01525));
     138           0 :   else if(srcEnum == FSS::THREEC147)
     139           0 :     fill_coeffs(RVF4(1.44856, -0.67252, -0.21124, 0.04077));
     140           0 :   else if(srcEnum == FSS::THREEC138)
     141           0 :     fill_coeffs(RVF4(1.00761, -0.55629, -0.11134, -0.0146));
     142           0 :   else if(srcEnum == FSS::NINETEEN34M638){
     143             :     // The broken polynomial is smooth enough to be 1st-order differentiable.
     144             :     //
     145             :     // The coefficients have been shifted to use GHz instead of MHz.
     146           0 :     fill_lohi_coeffs(RVF4(1.170418, 0.248618, -1.649694, 0.605334),  // Low
     147           0 :                      MFrequency(Quantity(10.0, "GHz")),              // break
     148           0 :                      RVF4(-2.5739, 10.0707, -10.0595, 2.9372));      // High
     149             :   }
     150           0 :   else if(srcEnum == FSS::THREEC295)
     151           0 :     fill_coeffs(RVF4(1.46744, -0.7735, -0.25912, 0.00752));
     152             :   else
     153           0 :     found = false;
     154           5 :   return found;
     155             : }
     156             : 
     157           0 : Bool FluxStdPerleyButler2010::setSourceCoeffs()
     158             : {
     159           0 :   Bool found = true;
     160             :   
     161           0 :   setFreqUnit("GHz");
     162           0 :   FSS::Source srcEnum = FCVQS::getSrcEnum();
     163             : 
     164           0 :   if(srcEnum == FSS::THREEC286)
     165           0 :     fill_coeffs(RVF4(1.2361, -0.4127, -0.1864, 0.0294));
     166           0 :   else if(srcEnum == FSS::THREEC48)
     167           0 :     fill_coeffs(RVF4(1.3197, -0.7253, -0.2023, 0.0540));
     168           0 :   else if(srcEnum == FSS::THREEC147)
     169           0 :     fill_coeffs(RVF4(1.4428, -0.6300, -0.3142, 0.1032));
     170           0 :   else if(srcEnum == FSS::THREEC138)
     171           0 :     fill_coeffs(RVF4(1.0053, -0.4384, -0.1855, 0.0511));
     172           0 :   else if(srcEnum == FSS::NINETEEN34M638){
     173             :     // The broken polynomial is smooth enough to be 1st-order differentiable.
     174             :     //
     175             :     // The coefficients have been shifted to use GHz instead of MHz.
     176           0 :     fill_lohi_coeffs(RVF4(1.170418, 0.248618, -1.649694, 0.605334),  // Low
     177           0 :                      MFrequency(Quantity(10.0, "GHz")),              // break
     178           0 :                      RVF4(-2.5739, 10.0707, -10.0595, 2.9372));      // High
     179             :   }
     180           0 :   else if(srcEnum == FSS::THREEC295)
     181           0 :     fill_coeffs(RVF4(1.4605, -0.7043, -0.3951, 0.0815));
     182           0 :   else if(srcEnum == FSS::THREEC196)
     183           0 :     fill_coeffs(RVF4(1.2753, -0.7971, -0.2255, 0.0380));
     184             :   else
     185           0 :     found = false;
     186           0 :   return found;
     187             : }
     188             : 
     189             : // If more sources are added in future, turn this into table based one
     190           0 : Bool FluxStdStevensReynolds2016::setSourceCoeffs()
     191             : {
     192           0 :   Bool found = true;
     193             : 
     194           0 :   setFreqUnit("GHz");
     195           0 :   FSS::Source srcEnum = FCVQS::getSrcEnum();
     196             : 
     197           0 :   if(srcEnum == FSS::NINETEEN34M638){
     198             :     // New high frequency parameters as of May 1, 2016,
     199             :     //  from Partridge et al (2016), ApJ 821,1
     200             :     //
     201             :     // The coefficients have been shifted to use GHz instead of MHz.
     202           0 :     fill_lohi_coeffs(RVF4(1.170418, 0.248618, -1.649694, 0.605334),  // Low
     203           0 :                      MFrequency(Quantity(11.1496, "GHz")),           // break
     204           0 :                      RVF2(1.7581, -1.3763));      // High
     205             :   }
     206             :   else
     207           0 :     found = false;
     208           0 :   return found;
     209             : }
     210             : 
     211           0 : Bool FluxStdPerleyButler2013::setSourceCoeffs()
     212             : {
     213           0 :   Bool found = true;
     214           0 :   Bool timevar = true;
     215           0 :   setFreqUnit("GHz");
     216           0 :   FSS::Source srcEnum = FCVQS::getSrcEnum();
     217           0 :   String stddatapath;
     218           0 :   String stdTabName("PerleyButler2013Coeffs");
     219             :   
     220           0 :   String resolvepath = casatools::get_state( ).resolve("nrao/VLA/standards/"+stdTabName);
     221           0 :   if (resolvepath != "nrao/VLA/standards/"+stdTabName) {
     222           0 :       stddatapath = resolvepath;
     223             :   }
     224             :   else {
     225           0 :       stddatapath = "./"+stdTabName;
     226             :   }
     227           0 :   if (!Table::isReadable(stddatapath)) {
     228           0 :       ostringstream oss;
     229           0 :       oss << "The coefficient data for Perley-Butler 2013," <<  stdTabName
     230           0 :           << " is not found in the current directory or in datapath/measurespath.";
     231           0 :       throw(AipsError(String(oss)));
     232           0 :   }
     233             :   //cerr<<"use stddatapath="<<stddatapath<<endl;
     234           0 :   LogIO os(LogOrigin("FluxStdPerleyButler2013", "setSourceCoeffs", WHERE));
     235             :    os << LogIO::NORMAL2
     236             :       << "Use the coefficent data table: " << stddatapath
     237           0 :       << LogIO::POST;
     238             : 
     239             :  
     240           0 :   Path stdTablePath(stddatapath);
     241             :   //cerr<<"stddatapath="<<stddatapath<<endl;
     242           0 :   FCVQS::readQSCoeffsTable(stdTablePath);
     243           0 :   if (srcEnum != FSS::THREEC286 && 
     244           0 :       srcEnum != FSS::THREEC123 &&
     245           0 :       srcEnum != FSS::THREEC295 &&
     246           0 :       srcEnum != FSS::THREEC196 &&
     247           0 :       srcEnum != FSS::THREEC48 &&
     248           0 :       srcEnum != FSS::THREEC138 &&
     249             :       srcEnum != FSS::THREEC147) 
     250           0 :     found=false;
     251             : 
     252             :   // check if considered as non-variable
     253           0 :   if (srcEnum == FSS::THREEC286 ||
     254           0 :       srcEnum == FSS::THREEC123 ||
     255           0 :       srcEnum == FSS::THREEC295 ||
     256             :       srcEnum == FSS::THREEC196) {
     257             :     // no need to do this now, will be filled with nepoch=1 in FluxCalcVQS::()
     258             :     //uInt row=0;
     259             :     //FluxCalcVQS::setSourceCoeffsfromVec(row);     
     260             :     //RigidVector<Vector<Float>, 2> coeffs=FluxCalcVQS::getCurrentCoeffs(); 
     261             :     //fill_coeffs(RVF4(coeffs(0)), RVF4(coeffs(1)) );
     262           0 :     timevar=false;
     263             :   }
     264           0 :   FCVQS::isTimeVar(timevar);
     265             : 
     266           0 :   return found;
     267           0 : }
     268             : 
     269           0 : Bool FluxStdScaifeHeald2012::setSourceCoeffs()
     270             : {
     271           0 :   Bool found = true;
     272             : 
     273           0 :   setFreqUnit( "GHz" );
     274           0 :   FSS::Source srcEnum = FCVQS::getSrcEnum();
     275             :   //FCQS::Source srcEnum = getSrcEnum();
     276             : 
     277           0 :   String stddatapath;
     278           0 :   String stdTabName("ScaifeHeald2012Coeffs");
     279             : 
     280           0 :   String resolvepath = casatools::get_state( ).resolve("nrao/VLA/standards/"+stdTabName);
     281           0 :   if (resolvepath != "nrao/VLA/standards/"+stdTabName) {
     282           0 :       stddatapath = resolvepath;
     283             :   }
     284             :   else {
     285           0 :       stddatapath = "./"+stdTabName;
     286             :   }
     287           0 :   if (!Table::isReadable(stddatapath)) {
     288           0 :       ostringstream oss;
     289           0 :       oss << "The coefficient data for Scaife-Heald 2012," <<  stdTabName
     290           0 :           << " is not found in the current directory or in datapath/measurespath.";
     291           0 :       throw(AipsError(String(oss)));
     292           0 :   }
     293             :   //cerr<<"use stddatapath="<<stddatapath<<endl;
     294           0 :   LogIO os(LogOrigin("FluxStdScaifeHeald2012", "setSourceCoeffs", WHERE));
     295             :    os << LogIO::NORMAL2
     296             :       << "Use the coefficent data table: " << stddatapath
     297           0 :       << LogIO::POST;
     298             : 
     299             : 
     300           0 :   Path stdTablePath(stddatapath);
     301             :   //cerr<<"stddatapath="<<stddatapath<<endl;
     302           0 :   FCVQS::readQSCoeffsTable(stdTablePath);
     303           0 :   if (srcEnum != FSS::THREEC48 && 
     304           0 :       srcEnum != FSS::THREEC147 &&
     305           0 :       srcEnum != FSS::THREEC196 &&
     306           0 :       srcEnum != FSS::THREEC286 &&
     307           0 :       srcEnum != FSS::THREEC295 &&
     308             :       srcEnum != FSS::THREEC380) 
     309           0 :     found=false;
     310             : /****
     311             :   // Needed before the coeffs. are stored in an external table
     312             :   //if ( srcEnum == FCQS::THREEC48 )
     313             :   if ( srcEnum == FSS::THREEC48 )
     314             :     fill_coeffs( RVF4( 64.768, -0.387, -0.420,  0.181 ),
     315             :                  RVF4(  1.761,  0.039,  0.031,  0.060 ) );
     316             :   //else if ( srcEnum == FCQS::THREEC147 )
     317             :   else if ( srcEnum == FSS::THREEC147 )
     318             :     fill_coeffs( RVF4( 66.738, -0.022, -1.012,  0.549 ),
     319             :                  RVF4(  2.490,  0.030,  0.167,  0.170 ) );
     320             :   //else if ( srcEnum == FCQS::THREEC196 )
     321             :   else if ( srcEnum == FSS::THREEC196 )
     322             :     fill_coeffs( RVF3( 83.084, -0.699, -0.110 ),
     323             :                  RVF3(  1.862,  0.014,  0.024 ) );
     324             :   //else if ( srcEnum == FCQS::THREEC286 )
     325             :   else if ( srcEnum == FSS::THREEC286 )
     326             :     fill_coeffs( RVF4( 27.477, -0.158,  0.032, -0.180 ),
     327             :                  RVF4(  0.746,  0.033,  0.043,  0.052 ) );
     328             :   //else if ( srcEnum == FCQS::THREEC295 )
     329             :   else if ( srcEnum == FSS::THREEC295 )
     330             :     fill_coeffs( RVF5( 97.763, -0.582, -0.298,  0.583, -0.363 ),
     331             :                  RVF5(  2.787,  0.045,  0.085,  0.116,  0.137 ) );
     332             :   //else if ( srcEnum == FCQS::THREEC380 )
     333             :   else if ( srcEnum == FSS::THREEC380 )
     334             :     fill_coeffs( RVF2( 77.352, -0.767 ),
     335             :                  RVF2(  1.164,  0.013 ) );
     336             :   else
     337             :     found = false;
     338             :   cerr<<"FluxStdSaifeHeald2012::setSourceCoeffs() ok?"<<found<<endl;
     339             : ****/
     340           0 :   FCVQS::isTimeVar(false);
     341             : 
     342           0 :   return found;
     343           0 : }
     344             : 
     345          32 : Bool FluxStdPerleyButler2017::setSourceCoeffs()
     346             : {
     347          32 :   Bool found = true;
     348          32 :   Bool timevar = false;
     349          32 :   setFreqUnit("GHz");
     350          32 :   FSS::Source srcEnum = FCVQS::getSrcEnum();
     351          32 :   String stddatapath;
     352          32 :   String stdTabName("PerleyButler2017Coeffs");
     353             : 
     354          64 :   String resolvepath = casatools::get_state( ).resolve("nrao/VLA/standards/"+stdTabName);
     355          32 :   if (resolvepath != "nrao/VLA/standards/"+stdTabName) {
     356          32 :       stddatapath = resolvepath;
     357             :   }
     358             :   else {
     359           0 :       stddatapath = "./"+stdTabName;
     360             :   }
     361          32 :   if (!Table::isReadable(stddatapath)) {
     362           0 :       ostringstream oss;
     363           0 :       oss << "The coefficient data for Perley-Butler 2017, " <<  stdTabName
     364           0 :           << " is not found in the current directory or in datapath/measurespath.";
     365           0 :       throw(AipsError(String(oss)));
     366           0 :   }
     367          64 :   LogIO os(LogOrigin("FluxStdPerleyButler2017", "setSourceCoeffs", WHERE));
     368             :    os << LogIO::NORMAL2
     369             :       << "Use the coefficent data table: " << stddatapath
     370          32 :       << LogIO::POST;
     371             : 
     372             : 
     373          32 :   Path stdTablePath(stddatapath);
     374             :   //cerr<<"stddatapath="<<stddatapath<<endl;
     375          32 :   FCVQS::readQSCoeffsTable(stdTablePath);
     376          32 :   if (srcEnum != FSS::THREEC286 &&
     377           0 :       srcEnum != FSS::THREEC123 &&
     378           0 :       srcEnum != FSS::THREEC295 &&
     379           0 :       srcEnum != FSS::THREEC196 &&
     380           0 :       srcEnum != FSS::THREEC48 &&
     381           0 :       srcEnum != FSS::THREEC138 &&
     382           0 :       srcEnum != FSS::THREEC147 &&
     383           0 :       srcEnum != FSS::J0133 &&
     384           0 :       srcEnum != FSS::FORNAXA &&
     385           0 :       srcEnum != FSS::J0444 &&
     386           0 :       srcEnum != FSS::PICTORA &&
     387           0 :       srcEnum != FSS::TAURUSA &&
     388           0 :       srcEnum != FSS::HYDRAA &&
     389           0 :       srcEnum != FSS::VIRGOA &&
     390           0 :       srcEnum != FSS::HERCULESA &&
     391           0 :       srcEnum != FSS::THREEC353 &&
     392           0 :       srcEnum != FSS::THREEC380 &&
     393           0 :       srcEnum != FSS::CYGNUSA &&
     394           0 :       srcEnum != FSS::THREEC444 &&
     395             :       srcEnum != FSS::CASSIOPEIAA)
     396           0 :     found=false;
     397             :   // all PB2017 source models are treated as non-variable
     398             :   // check if considered as variable
     399          32 :   if (srcEnum == FSS::THREEC48 || 
     400          32 :       srcEnum == FSS::THREEC138 ||
     401             :       srcEnum == FSS::THREEC147) { 
     402           0 :     timevar=true;
     403             :   }
     404          32 :   FCVQS::isTimeVar(timevar);
     405          32 :   return found;
     406          32 : }
     407             : 
     408             : } //# NAMESPACE NSTD - END 
     409             : } //# NAMESPACE CASA - END

Generated by: LCOV version 1.16