Changeset 668 in Sophya for trunk/SophyaLib


Ignore:
Timestamp:
Nov 29, 1999, 3:16:10 PM (26 years ago)
Author:
ansari
Message:

Ajout de classes deleguees PPersist et correction integration - Sophie 29/11/99

Location:
trunk/SophyaLib/SkyT
Files:
2 added
20 edited

Legend:

Unmodified
Added
Removed
  • trunk/SophyaLib/SkyT/blackbody.cc

    r607 r668  
    11//--------------------------------------------------------------------------
    22// File and Version Information:
    3 //      $Id: blackbody.cc,v 1.2 1999-11-20 21:00:47 ansari Exp $
     3//      $Id: blackbody.cc,v 1.3 1999-11-29 14:16:03 ansari Exp $
    44//
    55// Description:
     
    2424//----------------
    2525BlackBody::BlackBody(double temperature)
    26   : RadSpectra(0., 10000.)
     26  : RadSpectra(10., 10000.)
    2727{
    2828  _temperature = temperature;
     
    5757}
    5858
     59void
     60BlackBody::WriteSelf(POutPersist& s) 
     61{
     62  s.PutR8(this->getTemperature());
     63  s.PutR8(this->minFreq());
     64  s.PutR8(this->maxFreq());
     65}
     66
     67void
     68BlackBody::ReadSelf(PInPersist& s) 
     69{
     70  s.GetR8(_temperature);
     71  s.GetR8(_numin);
     72  s.GetR8(_numax);
     73  cout << " Temperature - minFreq - maxFreq " << endl;
     74  cout << _temperature << "-" << _numin << "-" << _numax << endl;
     75}
     76
     77
    5978void
    6079BlackBody::Print(ostream& os) const
  • trunk/SophyaLib/SkyT/blackbody.h

    r607 r668  
    22//--------------------------------------------------------------------------
    33// File and Version Information:
    4 //      $Id: blackbody.h,v 1.2 1999-11-20 21:00:47 ansari Exp $
     4//      $Id: blackbody.h,v 1.3 1999-11-29 14:16:03 ansari Exp $
    55//
    66// Description:
     
    3333  inline void setTemperature(double newtemp) { _temperature = newtemp; }
    3434
     35  virtual void ReadSelf(PInPersist& s);
     36  virtual void WriteSelf(POutPersist& s);
    3537  // Redefintion of the Print function
    3638  virtual void      Print(ostream& os)  const;
  • trunk/SophyaLib/SkyT/easyTest.cc

    r601 r668  
    44#include "specrespvector.h"
    55#include "tvector.h"
    6 // #include "szsource.h"
    76#include "squarefilt.h"
    87#include "trianglefilt.h"
     8
     9#include "iobjspecresp.cc"
     10
    911int
    1012main()
    1113{
     14//   PInPersist in("out");
     15//   SR_ReadSelf(in);
     16//   cout << " " << endl;
     17
     18    PInPersist in2("outTF");
     19    SR_ReadSelf(in2);
     20    cout << " " << endl;
     21
    1222  cout << "BlackBody!" << endl;
    13   BlackBody myBB;
    14   double freqmin =  10.;
    15   double freqmax = 100;
     23  BlackBody myBB(2.73);
     24  double freqmin =  230.;
     25  double freqmax = 500;
    1626  double logIF = myBB.logIntegratedFlux(freqmin,freqmax);
    1727  double IF    = myBB.integratedFlux(freqmin,freqmax);
     
    1929  cout << "nolog " << IF    << endl;
    2030  cout << "min et max " << myBB.minFreq() << " :: " << myBB.maxFreq() << endl;
    21   cout << "full integration no log  " << myBB.integratedFlux() << endl;
    22   cout << "full integration log     " << myBB.logIntegratedFlux() << endl;
     31  cout << "full integration no log  " << myBB.integratedFlux(freqmin,freqmax) << endl;
     32  cout << "full integration log     " << myBB.logIntegratedFlux(freqmin,freqmax) << endl;
     33  cout << "full integration no log nolimit " << myBB.integratedFlux() << endl;
     34  cout << "full integration log  nolimit  " << myBB.logIntegratedFlux() << endl;
    2335
    24   /*
    25   cout << "SZSource " << endl;
    26   SzSource mySZ(1);
    27   double logSZ = mySZ.logIntegratedFlux(freqmin,freqmax);
    28   double SZ    = mySZ.integratedFlux(freqmin,freqmax);
    29   cout << "log   " << logSZ << endl;
    30   cout << "nolog " << SZ    << endl;
    31   cout << "min et max " << mySZ.minFreq() << " :: " << mySZ.maxFreq() << endl;
    32   cout << "full integration no log  " << mySZ.integratedFlux() << endl;
    33   cout << "full integration log     " << mySZ.logIntegratedFlux() << endl;
    34   */
    3536  cout << "squareFilter " << endl;
    36   SquareFilter mySF(0,200);
     37  SquareFilter mySF(200,600);
    3738  double logSF = mySF.logIntegratedSpect(freqmin,freqmax);
    3839  double SF    = mySF.IntegratedSpect(freqmin,freqmax);
     
    4041  cout << "nolog " << SF    << endl;
    4142  cout << "min et max " << mySF.minFreq() << " :: " << mySF.maxFreq() << endl;
    42   cout << "full integration no log  " << mySF.IntegratedSpect() << endl;
    43   cout << "full integration log     " << mySF.logIntegratedSpect() << endl;
     43  cout << "full integration no log  " << mySF.IntegratedSpect(200,700) << endl;
     44  cout << "full integration log     " << mySF.logIntegratedSpect(200,700) << endl;
     45  cout << "full integration no log nolimit  " << mySF.IntegratedSpect() << endl;
     46  cout << "full integration log  nolimit   " << mySF.logIntegratedSpect() << endl;
     47
    4448
    4549  cout << "triangleFilter" << endl;
    46   TriangleFilter myTF(10,200,20,40);
     50  TriangleFilter myTF(200,500,120,40);
    4751  double logTF = myTF.logIntegratedSpect(10.,freqmax);
    4852  double TF    = myTF.IntegratedSpect(10.,freqmax);
     
    5963  for (int i=0; i<maxVal; i++)
    6064    {
    61       vecOfNu(i) = (double)i+30.;
     65      vecOfNu(i) = (double)i+230.;
    6266      vecOfFDeNu(i) = 1.; //*(double)i+1;
    6367      cout << "entry values  " <<  vecOfNu(i) << " " << vecOfFDeNu(i) << endl;
    6468    }
    65   freqmin = 10.;
    66   freqmax = 19.;
     69  freqmin = 200.;
     70  freqmax = 259.;
    6771  RadSpectraVec myRSV(vecOfNu, vecOfFDeNu);
    6872  double RSV    = myRSV.integratedFlux(freqmin,freqmax);
     
    8185  for (int i=0; i<SRVmaxVal; i++)
    8286    {
    83       vecOfNuRSV(i) = (double)i+30.;
     87      vecOfNuRSV(i) = (double)i+130.;
    8488      vecOfFDeNuRSV(i) = 10*(double)i+1;
    8589      //      cout << "entry values  " <<  vecOfNuRSV(i) << " " << vecOfFDeNuRSV(i) << endl;
     
    99103  cout << "...Testing filter and integrate !" << endl;
    100104
    101   cout << " BBSF nolog " << myBB.filteredIntegratedFlux(mySF,30.,100.) << endl;
    102   cout << " BBSF   log " << myBB.filteredLogIntFlux(mySF,30.,100.) << endl;
    103   cout << "full integration no log  " << myBB.integratedFlux(30.,100.) << endl;
    104   cout << "full integration log     " << myBB.logIntegratedFlux(30.,100.) << endl;
     105  cout << " BBSF nolog " << myBB.filteredIntegratedFlux(mySF,200.,400.) << endl;
     106  cout << " BBSF   log " << myBB.filteredLogIntFlux(mySF,200.,400.) << endl;
     107  cout << "full integration no log  " << myBB.integratedFlux(200.,400.) << endl;
     108  cout << "full integration log     " << myBB.logIntegratedFlux(200.,400.) << endl;
    105109  cout << "SF" << endl;
    106   cout << "full integration no log  " << mySF.IntegratedSpect(30.,100.) << endl;
    107   cout << "full integration log     " << mySF.logIntegratedSpect(30.,100.) << endl;
     110  cout << "full integration no log  " << mySF.IntegratedSpect(200.,400.) << endl;
     111  cout << "full integration log     " << mySF.logIntegratedSpect(200.,400.) << endl;
    108112
    109   cout << " BBTF nolog " << myBB.filteredIntegratedFlux(myTF,30.,100.) << endl;
    110   cout << " BBTF   log " << myBB.filteredLogIntFlux(myTF,30.,100.) << endl;
     113  cout << " BBTF nolog " << myBB.filteredIntegratedFlux(myTF,200.,400.) << endl;
     114  cout << " BBTF   log " << myBB.filteredLogIntFlux(myTF,200.,400.) << endl;
    111115  cout << "TF" << endl;
    112   cout << "full integration no log  " << myTF.IntegratedSpect(30.,100.) << endl;
    113   cout << "full integration log     " << myTF.logIntegratedSpect(30.,100.) << endl;
     116  cout << "full integration no log  " << myTF.IntegratedSpect(200.,400.) << endl;
     117  cout << "full integration log     " << myTF.logIntegratedSpect(200.,400.) << endl;
    114118
    115119  /*
     
    123127                           */
    124128  cout << "********" << endl;
    125   cout << " RSVSF nolog " << myRSV.filteredIntegratedFlux(mySF,30.,100.) << endl;
    126   cout << " RSVSF   log " << myRSV.filteredLogIntFlux(mySF,30.,100.) << endl;
    127   cout << "full integration no log  " << myRSV.integratedFlux(30.,100.) << endl;
    128   cout << "full integration log     " << myRSV.logIntegratedFlux(30.,100.) << endl;
     129  double min, max;
     130  min=232;
     131  max=235;
    129132
    130   cout << " RSVTF nolog " << myRSV.filteredIntegratedFlux(myTF,30.,100.) << endl;
    131   cout << " RSVTF   log " << myRSV.filteredLogIntFlux(myTF,30.,100.) << endl;
     133  cout << " RSVSF nolog " << myRSV.filteredIntegratedFlux(mySF,min,max) << endl;
     134  cout << " RSVSF   log " << myRSV.filteredLogIntFlux(mySF,min,max) << endl;
     135  cout << "full integration no log  " << myRSV.integratedFlux(230.,500.) << endl;
     136  cout << "full integration log     " << myRSV.logIntegratedFlux(230.,500.) << endl;
     137  cout << "full integration no log min max " << myRSV.integratedFlux(min,max) << endl;
     138  cout << "full integration log  min max   " << myRSV.logIntegratedFlux(min,max) << endl;
     139
     140  cout << " RSVTF nolog " << myRSV.filteredIntegratedFlux(myTF,230.,500.) << endl;
     141  cout << " RSVTF   log " << myRSV.filteredLogIntFlux(myTF,230.,500.) << endl;
     142 
     143//   cout << "New TESTS USING IOBJS!" << endl;
     144//   POutPersist out("out");
     145//   TriangleFilter* myTF2 = new TriangleFilter(10,200,20,40);
     146//   SR_WriteSelf(myTF2,out);
     147
     148//   POutPersist outV("outV");
     149//   cout << "check before anything" << vecOfNu.NElts()<< endl;
     150//   SpecRespVec* mySRV2 = new SpecRespVec(vecOfNu, vecOfFDeNu);
     151//   SR_WriteSelf(mySRV2,outV);
     152 
     153//   Vector myVec(10);
     154//   myVec.ReSize(10);
     155//   cout << myVec.NElts();
     156//   return 1;
     157
     158  cout << "read and write things in file...ppersist!" << endl;
     159  TriangleFilter myTF2(10,200,20,40);
     160  POutPersist outTF("outTF");
     161  myTF2.WriteSelf(outTF);
     162//   PInPersist inTF("outTF");
     163//   myTF2.ReadSelf(inTF);
    132164 
    133165
    134   return 1;
    135166}
  • trunk/SophyaLib/SkyT/gaussfilt.cc

    r610 r668  
    11//--------------------------------------------------------------------------
    22// File and Version Information:
    3 //      $Id: gaussfilt.cc,v 1.3 1999-11-21 23:25:45 ansari Exp $
     3//      $Id: gaussfilt.cc,v 1.4 1999-11-29 14:16:04 ansari Exp $
    44//
    55// Description:
     
    2222// Constructor --
    2323//----------------
     24GaussianFilter::GaussianFilter()
     25  : SpectralResponse()
     26{
     27  setParams(100, 10., 1.);
     28}
     29
    2430GaussianFilter::GaussianFilter(double nu0, double s, double a, double numin, double numax)
    2531  : SpectralResponse(numin, numax)
    2632{
    27   if (s < 1.e-19) s = 1.e-19;
    28   _s = s;
    29   _nu0 = nu0;
    30   _a = a;
     33  setParams(nu0, s, a);
    3134}
    3235
     
    6669}
    6770
     71
     72
     73void
     74GaussianFilter::setParams(double nu0, double s, double a)
     75{
     76  if (s < 1.e-19) s = 1.e-19;
     77  _s = s;
     78  _nu0 = nu0;
     79  _a = a;
     80}
     81
     82
     83
    6884void
    6985GaussianFilter::Print(ostream& os)  const
     
    7692
    7793}
     94
     95void
     96ObjFileIO<GaussianFilter>::WriteSelf(POutPersist& s) const
     97{
     98  if(dobj == NULL)
     99    {
     100      cout << " ObjFileIO<GaussianFilter>::WriteSelf:: dobj= null " << endl;
     101      return;
     102    }
     103  int_4 version, nothing;
     104  version = 1;
     105  nothing = 0;   // Reserved for future use
     106  s.PutI4(version);
     107  s.PutI4(nothing);
     108
     109  s.PutR8(dobj->minFreq());
     110  s.PutR8(dobj->maxFreq());
     111  s.PutR8(dobj->giveNorm());
     112  s.PutR8(dobj->giveNu0());
     113  s.PutR8(dobj->giveDNu());
     114}
     115
     116void
     117ObjFileIO<GaussianFilter>::ReadSelf(PInPersist& s) 
     118{
     119  int_4 version, nothing;
     120  version = 1;
     121  nothing = 0;   // Reserved for future use
     122  s.GetI4(version);
     123  s.GetI4(nothing);
     124
     125  if(dobj == NULL)
     126    {
     127      dobj= new GaussianFilter();
     128      ownobj= true;
     129    }
     130
     131  r_8 a, nu0, dnu, numin, numax;
     132  s.GetR8(numin);
     133  s.GetR8(numax);
     134  s.GetR8(a);
     135  s.GetR8(nu0);
     136  s.GetR8(dnu);
     137  dobj->setMinMaxFreq(numin, numax);
     138  dobj->setParams(nu0, dnu, a);
     139  //  cout << " Norm - Nu0 - DNu - minFreq - maxFreq " << endl;
     140  // cout << _a << "-" << _nu0  << "-" << _s << "-" << _numin << "-" << _numax << endl;
     141}
     142
     143
     144#ifdef __CXX_PRAGMA_TEMPLATES__
     145#pragma define_template ObjFileIO<GaussianFilter>
     146#endif
     147
     148#if defined(ANSI_TEMPLATES) || defined(GNU_TEMPLATES)
     149template class ObjFileIO<GaussianFilter>;
     150#endif
  • trunk/SophyaLib/SkyT/gaussfilt.h

    r610 r668  
    22//--------------------------------------------------------------------------
    33// File and Version Information:
    4 //      $Id: gaussfilt.h,v 1.3 1999-11-21 23:25:45 ansari Exp $
     4//      $Id: gaussfilt.h,v 1.4 1999-11-29 14:16:05 ansari Exp $
    55//
    66// Description:
     
    1818//----------------------
    1919#include "specresp.h"
     20#include "objfio.h"
    2021
    2122//------------------------------------
     
    2930// Spectral response in the form  A Exp(-((nu-nu0)/s)^2)
    3031
     32namespace SOPHYA {
     33
    3134class GaussianFilter:public SpectralResponse
    3235{
    3336public:
    3437  //Constructors
     38  GaussianFilter ();
    3539  GaussianFilter (double nu0, double s, double a=1., double numin=0., double numax= 9.e49);
    3640 
     
    4953  virtual void   Print(ostream& os)  const;
    5054
     55  virtual inline double giveNorm() const {return _a;};
     56  virtual inline double giveNu0() const {return _nu0;};
     57  virtual inline double giveDNu() const {return _s;};
     58  virtual void setParams(double nu0, double s, double a=1.);
     59 
    5160protected:
    5261  double _a, _s, _nu0;
     
    5463
    5564
     65  // ObjFileIO<SpecRespVec> pour les PPersist
     66  inline POutPersist& operator << (POutPersist& os, GaussianFilter & obj)
     67    { ObjFileIO<GaussianFilter> fio(&obj); fio.Write(os); return(os);}
     68 
     69  inline PInPersist& operator >> (PInPersist& os, GaussianFilter & obj)
     70    { ObjFileIO<GaussianFilter> fio(&obj); fio.Read(os); return(os);}
     71
     72};  // End of namespace
     73
    5674#endif
  • trunk/SophyaLib/SkyT/nupower.cc

    r610 r668  
    11//--------------------------------------------------------------------------
    22// File and Version Information:
    3 //      $Id: nupower.cc,v 1.3 1999-11-21 23:25:45 ansari Exp $
     3//      $Id: nupower.cc,v 1.4 1999-11-29 14:16:05 ansari Exp $
    44//
    55// Description:
     
    2424// Constructor --
    2525//----------------
     26PowerLawSpectra::PowerLawSpectra()
     27{
     28}
     29
    2630PowerLawSpectra::PowerLawSpectra(double a, double b, double nu0, double dnu, double numin, double numax)
    2731  : RadSpectra(numin, numax)
     
    4751}
    4852
     53
     54void
     55PowerLawSpectra::WriteSelf(POutPersist& s) 
     56{
     57  s.PutR8(this->giveNorm());
     58  s.PutR8(this->giveNu0());
     59  s.PutR8(this->giveDNu());
     60  s.PutR8(this->giveExp());
     61  s.PutR8(this->minFreq());
     62  s.PutR8(this->maxFreq());
     63}
     64
     65void
     66PowerLawSpectra::ReadSelf(PInPersist& s) 
     67{
     68  s.GetR8(_a);
     69  s.GetR8(_nu0);
     70  s.GetR8(_dnu);
     71  s.GetR8(_b);
     72  s.GetR8(_numin);
     73  s.GetR8(_numax);
     74  cout << " Norm - Nu0 - DNu - Exp - minFreq - maxFreq " << endl;
     75  cout << _a << "-" << _nu0  << "-" << _dnu << "-" << _b << "-" << _numin << "-" << _numax << endl;
     76}
     77
     78
    4979void
    5080PowerLawSpectra::Print(ostream& os) const
  • trunk/SophyaLib/SkyT/nupower.h

    r610 r668  
    22//--------------------------------------------------------------------------
    33// File and Version Information:
    4 //      $Id: nupower.h,v 1.3 1999-11-21 23:25:46 ansari Exp $
     4//      $Id: nupower.h,v 1.4 1999-11-29 14:16:05 ansari Exp $
    55//
    66// Description:
     
    2222public:   //Constructor
    2323 
     24  PowerLawSpectra();
    2425  PowerLawSpectra(double a, double b, double nu0, double dnu, double numin=0., double numax=9.e49);
    2526
     
    3031  // Redefintion of the Print function
    3132  virtual void      Print(ostream& os)  const;
     33 
     34  virtual inline double giveNorm() const {return _a;};
     35  virtual inline double giveNu0() const {return _nu0;};
     36  virtual inline double giveDNu() const {return _dnu;};
     37  virtual inline double giveExp() const {return _b;};
     38 
     39  virtual void WriteSelf(POutPersist& s) ;
     40  virtual void ReadSelf(PInPersist& s) ;
     41 
    3242
    3343protected:
  • trunk/SophyaLib/SkyT/radspec.cc

    r607 r668  
    11//--------------------------------------------------------------------------
    22// File and Version Information:
    3 //      $Id: radspec.cc,v 1.2 1999-11-20 21:00:50 ansari Exp $
     3//      $Id: radspec.cc,v 1.3 1999-11-29 14:16:06 ansari Exp $
    44//
    55// Description:
     
    104104RadSpectra::integratedFlux(double f1, double f2)  const
    105105{
    106     _raypourfinteg = const_cast<RadSpectra *>(this);
    107     TrpzInteg I(RadSpectra_fluxFunction , f1, f2); 
    108     double val = (double)I;
    109     _raypourfinteg = NULL;  // On ne peut pas faire ca avant la destruction de I
    110     return(val);       
     106//   cout << endl;
     107//   cout <<  this->minFreq() << " = " << this->maxFreq() << endl;
     108//   cout <<  f1 << " = " << f2 << endl;
     109  if(f1 < this->minFreq()) f1 = this->minFreq();
     110  if(f2 > this->maxFreq()) f2 = this->maxFreq();
     111  _raypourfinteg = const_cast<RadSpectra *>(this);
     112  TrpzInteg I(RadSpectra_fluxFunction , f1, f2); 
     113  double val = (double)I;
     114  _raypourfinteg = NULL;  // On ne peut pas faire ca avant la destruction de I
     115  return(val);       
    111116}
    112117double
    113118RadSpectra::integratedFlux()  const
    114119{
    115   return integratedFlux(_numin, _numax);
     120  return integratedFlux(this->minFreq(),this->maxFreq());
    116121}
    117122
     
    129134RadSpectra::logIntegratedFlux(double f1, double f2)  const
    130135{
     136  if(f1 < this->minFreq()) f1 = this->minFreq();
     137  if(f2 > this->maxFreq()) f2 = this->maxFreq();
     138
    131139  double f1Log = log10(f1);
    132140  double f2Log = log10(f2);
     
    161169  _raypourfinteg = const_cast<RadSpectra *>(this);
    162170  _filter = const_cast<SpectralResponse *>(&filter);
     171   if(f1 < this->minFreq()) f1 = this->minFreq();
     172   if(f2 > this->maxFreq()) f2 = this->maxFreq();
     173
    163174  TrpzInteg I(RadSpectra_filteredFlux,f1,f2);
    164175  double val = (double)I;
     
    185196  double nu = pow(10,tau);
    186197  double flux = _raypourfinteg->flux(nu)*nu;
    187   return(flux * _filter->transmission(nu));
     198  double result = flux * _filter->transmission(nu);
     199  return(result);
    188200}
    189201
     
    192204RadSpectra::filteredLogIntFlux(SpectralResponse const& filter, double f1, double f2) const
    193205{
    194 
    195 //   double f1Log = log10(f1);
    196 //   double f2Log = log10(f2);
    197 //   if(f1Log < -1.e99) f1Log = -1.e99;
    198 //   if(f2Log > 1.e99)  f2Log = 1.e99;
    199 //   _rayIntLog = const_cast<RadSpectra *>(this);
    200 //   TrpzInteg I(RadSpectra_logFluxFunction,f1Log,f2Log);
    201 //   double value = (double)I * log(10.);
    202 //   return(value);       
    203 //   _rayIntLog = NULL;
    204206 
    205207   _raypourfinteg = NULL;
    206208   _filter = NULL;
     209   if(f1 < this->minFreq()) f1 = this->minFreq();
     210   if(f2 > this->maxFreq()) f2 = this->maxFreq();
     211   
    207212   double f1Log = log10(f1);
    208213   double f2Log = log10(f2);
     
    226231
    227232
     233
    228234void
    229235RadSpectra::Print(ostream& os) const
  • trunk/SophyaLib/SkyT/radspec.h

    r607 r668  
    22//--------------------------------------------------------------------------
    33// File and Version Information:
    4 //      $Id: radspec.h,v 1.2 1999-11-20 21:00:50 ansari Exp $
     4//      $Id: radspec.h,v 1.3 1999-11-29 14:16:06 ansari Exp $
    55//
    66// Description:
     
    1818
    1919#include "specresp.h"
    20 
     20#include "objfio.h"
    2121//              ---------------------
    2222//              -- Class Interface --
     
    7676
    7777  virtual void      Print(ostream& os)  const;
     78  virtual void ReadSelf(PInPersist& s) = 0;
     79  virtual void WriteSelf(POutPersist& s) = 0;
    7880
    7981protected:
  • trunk/SophyaLib/SkyT/radspecvector.cc

    r610 r668  
    11//--------------------------------------------------------------------------
    22// File and Version Information:
    3 //      $Id: radspecvector.cc,v 1.3 1999-11-21 23:25:46 ansari Exp $
     3//      $Id: radspecvector.cc,v 1.4 1999-11-29 14:16:06 ansari Exp $
    44//
    55// Description:
     
    2626// Constructor --
    2727//----------------
     28RadSpectraVec::RadSpectraVec()
     29{
     30}
     31
    2832RadSpectraVec::RadSpectraVec(Vector const & nu, Vector const & fdenu, double numin, double numax)
    2933        : RadSpectra(numin, numax)
     
    3539  _numin = nu(0);
    3640  _numax = nu(nu.NElts()-1);
     41  _size = nu.NElts();
    3742  if(_vecOfNu.NElts() != _vecOfFDeNu.NElts()) cout << "vectors are not compatible" << exit;
    3843}
     
    7883}
    7984
     85void
     86RadSpectraVec::WriteSelf(POutPersist& s)
     87{
     88  s.PutI4(this->NbElts());
     89  for (int i=0; i< this->NbElts(); i++)
     90    {
     91      s.PutR8(this->getNuVec(i));
     92      s.PutR8(this->getFNuVec(i));
     93    }
     94  s.PutR8(this->minFreq());
     95  s.PutR8(this->maxFreq());
     96 
     97}
     98
     99void
     100RadSpectraVec::ReadSelf(PInPersist& s)
     101{
     102  s.GetI4(_size);
     103
     104  _vecOfNu.ReSize(_size);
     105  _vecOfFDeNu.ReSize(_size);
     106  for (int i=0; i< _size; i++)
     107    {
     108      s.GetR8(_vecOfNu(i));
     109      s.GetR8(_vecOfFDeNu(i));
     110    }
     111  s.GetR8(_numin);
     112  s.GetR8(_numax);
     113  cout << "minFreq - maxFreq"<< endl;
     114  cout <<    _numin<< "-" <<  _numax << endl;
     115}
     116
     117
    80118
    81119void
  • trunk/SophyaLib/SkyT/radspecvector.h

    r607 r668  
    3030public:
    3131  //Constructor
     32  RadSpectraVec ();
    3233  RadSpectraVec (Vector const & nu, Vector const & fdenu, double numin=0., double numax=9.e49);
    3334
     
    4748  inline Vector& getNuVec() { return _vecOfNu; }
    4849  inline Vector& getFNuVec() { return _vecOfFDeNu; }
     50  inline double getNuVec(int i) const { return _vecOfNu(i); }
     51  inline double getFNuVec(int i) const { return _vecOfFDeNu(i); }
     52  inline int NbElts() const { return _size;}
     53  virtual void ReadSelf(PInPersist& s);
     54  virtual void WriteSelf(POutPersist& s);
    4955
    5056  virtual void   Print(ostream& os)  const;
     
    5359  Vector _vecOfNu;
    5460  Vector _vecOfFDeNu;
    55  
     61  int _size;
    5662};
    5763
  • trunk/SophyaLib/SkyT/specresp.cc

    r607 r668  
    11//--------------------------------------------------------------------------
    22// File and Version Information:
    3 //      $Id: specresp.cc,v 1.2 1999-11-20 21:00:52 ansari Exp $
     3//      $Id: specresp.cc,v 1.3 1999-11-29 14:16:08 ansari Exp $
    44//
    55// Description:
     
    1919#include "specresp.h"
    2020#include "integ.h"
     21#include "tvector.h"
    2122
    2223//----------------
     
    6061}
    6162
     63 
     64// To change min-max frequency
     65void
     66SpectralResponse::setMinMaxFreq(double numin, double numax)
     67{
     68  _numin = numin;
     69  _numax = numax;
     70}
    6271 
    6372
     
    108117SpectralResponse::IntegratedSpect(double numin, double numax) const
    109118{
     119  if(numin < this->minFreq()) numin = this->minFreq();
     120  if(numax > this->maxFreq()) numax = this->maxFreq();
     121
     122 
    110123  _mySpecResp = const_cast<SpectralResponse *>(this);
    111   if(numin <= _numin) numin = _numin;
    112   if(numax >= _numax) numax = _numax;
    113124  TrpzInteg I(SpectralResponse_transmission , numin, numax); 
    114125  double val = (double)I;
     
    129140SpectralResponse::logIntegratedSpect(double numin, double numax) const
    130141{
    131   if(numin <= _numin) numin = _numin;
    132   if(numax >= _numax) numax = _numax;
     142  if(numin <= this->minFreq()) numin = this->minFreq();
     143  if(numax >= this->maxFreq()) numax = this->maxFreq();
    133144  if(numin == 0) numin = 1.e-99;
    134145  double f1Log = log10(numin);
  • trunk/SophyaLib/SkyT/specresp.h

    r607 r668  
    22//--------------------------------------------------------------------------
    33// File and Version Information:
    4 //      $Id: specresp.h,v 1.2 1999-11-20 21:00:52 ansari Exp $
     4//      $Id: specresp.h,v 1.3 1999-11-29 14:16:08 ansari Exp $
    55//
    66// Description:
     
    1414
    1515#include "machdefs.h"
     16#include "anydataobj.h"
    1617#include <iostream.h>
    17 
    1818//------------------------------------
    1919// Collaborating Class Declarations --
     
    2525
    2626// ***IMPORTANT*** All frequencies are expressed in GHz  (10^9 Hz)
     27namespace SOPHYA {
     28 
     29  class SpectralResponse : public AnyDataObj
     30  {
     31   
     32  public:
     33    //Constructor
     34    SpectralResponse(double numin=0., double numax=1.);
     35   
     36    // destructor
     37    virtual ~SpectralResponse();
     38   
     39    //
     40    //  Member Functions
     41    //
     42   
     43    //  The transmission() function is virtual:
     44    virtual double transmission(double nu) const =0 ;
     45   
     46    inline double operator() (double nu) const { return(transmission(nu)); }
     47   
     48    virtual void      Print(ostream& os)  const;
     49   
     50    virtual double minFreq() const;
     51    virtual double maxFreq() const;
     52    virtual double meanFreq() const;
     53    virtual double peakFreq() const;
     54    virtual double peakTransmission() const;
    2755
    28 class SpectralResponse
    29 {
     56    // For changing the min/max frequency
     57    virtual void   setMinMaxFreq(double numin, double numax);
    3058
    31 public:
    32   //Constructor
    33   SpectralResponse(double numin=0., double numax=1.);
    34 
    35   // destructor
    36   virtual ~SpectralResponse();
    37 
    38   //
    39   //  Member Functions
    40   //
    41 
    42   //  The transmission() function is virtual:
    43   virtual double transmission(double nu) const =0 ;
    44 
    45   inline double operator() (double nu) const { return(transmission(nu)); }
    46 
    47   virtual void      Print(ostream& os)  const;
    48 
    49   virtual double minFreq() const;
    50   virtual double maxFreq() const;
    51   virtual double meanFreq() const;
    52   virtual double peakFreq() const;
    53   virtual double peakTransmission() const;
    54   virtual double IntegratedSpect(double numin, double numax) const ;
    55   virtual double logIntegratedSpect(double numin, double numax) const ;
    56   virtual double IntegratedSpect() const ;
    57   virtual double logIntegratedSpect() const ;
    58 
    59 protected:
    60   double _numin;
    61   double _numax;
     59    virtual double IntegratedSpect(double numin, double numax) const ;
     60    virtual double logIntegratedSpect(double numin, double numax) const ;
     61    virtual double IntegratedSpect() const ;
     62    virtual double logIntegratedSpect() const ;
     63   
     64  protected:
     65    double _numin;
     66    double _numax;
     67  };
     68 
     69 
     70  // definition of the << operator
     71  inline ostream& operator << (ostream& s,  SpectralResponse const & sr)
     72    {  sr.Print(s);  return(s);  }
     73 
     74 
     75 
    6276};
    6377
    64 
    65 // definition of the << operator
    66 inline ostream& operator << (ostream& s,  SpectralResponse const & sr)
    67   {  sr.Print(s);  return(s);  }
     78#endif
    6879
    6980
    70 #endif
     81
     82
  • trunk/SophyaLib/SkyT/specrespvector.cc

    r610 r668  
    11//--------------------------------------------------------------------------
    22// File and Version Information:
    3 //      $Id: specrespvector.cc,v 1.3 1999-11-21 23:25:47 ansari Exp $
     3//      $Id: specrespvector.cc,v 1.4 1999-11-29 14:16:09 ansari Exp $
    44//
    55// Description:
     
    2222#include "specrespvector.h"
    2323#include "pexceptions.h"
    24 
    2524//----------------
    2625// Constructor --
    2726//----------------
     27SpecRespVec::SpecRespVec()
     28        : SpectralResponse()
     29{
     30}
     31
    2832SpecRespVec::SpecRespVec(Vector const & nu, Vector const & fdenu, double numin, double numax)
    2933        : SpectralResponse(numin, numax)
     
    3539  _numin = nu(0);
    3640  _numax = nu(nu.NElts()-1);
     41  _size = nu.NElts();
    3742  if(_vecOfNu.NElts() != _vecOfFDeNu.NElts()) cout << "vectors are not compatible" << exit;
    3843}
     
    9196
    9297}
     98
     99
     100void
     101ObjFileIO<SpecRespVec>::WriteSelf(POutPersist& s) const
     102{
     103  if(dobj == NULL)
     104    {
     105      cout << " ObjFileIO<SpecRespVec>::WriteSelf:: dobj= null " << endl;
     106      return;
     107    }
     108
     109  int_4 version, nothing;
     110  version = 1;
     111  nothing = 0;   // Reserved for future use
     112  s.PutI4(version);
     113  s.PutI4(nothing);
     114
     115  s.PutR8(dobj->minFreq());
     116  s.PutR8(dobj->maxFreq());
     117
     118  // TVector<T> has Persistence Manager
     119  s <<  dobj->getNuVec();
     120  s <<  dobj->getTNuVec();
     121}
     122
     123void
     124ObjFileIO<SpecRespVec>::ReadSelf(PInPersist& s)
     125{
     126  int_4 version, nothing;
     127  version = 1;
     128  nothing = 0;   // Reserved for future use
     129  s.GetI4(version);
     130  s.GetI4(nothing);
     131
     132  if(dobj == NULL)
     133    {
     134      Vector v1(10);
     135      Vector v2(10);
     136      dobj= new SpecRespVec();
     137      ownobj= true;
     138    }
     139 
     140  r_8 minf, maxf;
     141  s.GetR8(minf);
     142  s.GetR8(maxf);
     143  dobj->setMinMaxFreq(minf, maxf);
     144  // TVector<T> has Persistence Manager
     145  s >>  dobj->getNuVec();
     146  s >>  dobj->getTNuVec();
     147}
     148
     149
     150#ifdef __CXX_PRAGMA_TEMPLATES__
     151#pragma define_template ObjFileIO<SpecRespVec>
     152#endif
     153
     154#if defined(ANSI_TEMPLATES) || defined(GNU_TEMPLATES)
     155template class ObjFileIO<SpecRespVec>;
     156#endif
  • trunk/SophyaLib/SkyT/specrespvector.h

    r607 r668  
    22//--------------------------------------------------------------------------
    33// File and Version Information:
    4 //      $Id: specrespvector.h,v 1.2 1999-11-20 21:00:53 ansari Exp $
     4//      $Id: specrespvector.h,v 1.3 1999-11-29 14:16:09 ansari Exp $
    55//
    66// Description:
     
    1818#include "specresp.h"
    1919#include "tvector.h"
     20#include "objfio.h"
    2021
    2122//------------------------------------
     
    2930// ***IMPORTANT*** All frequencies are expressed in GHz  (10^9 Hz)
    3031
    31 class SpecRespVec :  public SpectralResponse
    32 {
     32namespace SOPHYA {
     33 
     34  class SpecRespVec :  public SpectralResponse
     35  {
    3336
    3437public:
    3538  //Constructor
     39  SpecRespVec();
    3640  SpecRespVec(Vector const & nu, Vector const & fdenu, double numin=0., double numax=1.);
    3741
     
    4751
    4852  // Acces to Nu and T(nu) vectors
    49   inline Vector& getNuVec() { return _vecOfNu; }
    50   inline Vector& getTNuVec() { return _vecOfFDeNu; }
    51 
     53  inline Vector&  getNuVec()  { return _vecOfNu; } ;
     54  inline Vector& getTNuVec()  { return _vecOfFDeNu; }
     55  inline double getNuVec(int i) const { return _vecOfNu(i); }
     56  inline double getTNuVec(int i) const { return _vecOfFDeNu(i); }
     57  inline int NbElts() const { return _size;}
     58 
    5259  virtual void      Print(ostream& os)  const;
    53 
    5460
    5561protected:
    5662  Vector _vecOfNu;
    5763  Vector _vecOfFDeNu;
     64  int _size;
    5865};
    5966
     67  // ObjFileIO<SpecRespVec> pour les PPersist
     68  inline POutPersist& operator << (POutPersist& os, SpecRespVec & obj)
     69    { ObjFileIO<SpecRespVec> fio(&obj); fio.Write(os); return(os);}
     70 
     71  inline PInPersist& operator >> (PInPersist& os, SpecRespVec & obj)
     72    { ObjFileIO<SpecRespVec> fio(&obj); fio.Read(os); return(os);}
    6073
     74};  // End of namespace
    6175#endif
  • trunk/SophyaLib/SkyT/squarefilt.cc

    r607 r668  
    11//--------------------------------------------------------------------------
    22// File and Version Information:
    3 //      $Id: squarefilt.cc,v 1.2 1999-11-20 21:00:53 ansari Exp $
     3//      $Id: squarefilt.cc,v 1.3 1999-11-29 14:16:09 ansari Exp $
    44//
    55// Description:
     
    2121// Constructor --
    2222//----------------
     23SquareFilter::SquareFilter()
     24  : SpectralResponse()
     25{
     26}
     27
    2328SquareFilter::SquareFilter(double numin, double numax)
    2429  : SpectralResponse(numin, numax)
     
    6065SquareFilter::peakTransmission() const
    6166{
    62 return _peakTransmission;
     67  return _peakTransmission;
    6368}
     69
     70void
     71SquareFilter::WriteSelf(POutPersist& s)
     72{
     73  s.PutR8(this->minFreq());
     74  s.PutR8(this->maxFreq());
     75}
     76
     77void
     78SquareFilter::ReadSelf(PInPersist& s)
     79{
     80  double minFreq, maxFreq;
     81  s.GetR8(_numin);
     82  s.GetR8(_numax);
     83  cout << "minFreq - maxFreq " <<  _numin << "-" << _numax  << endl;
     84}
  • trunk/SophyaLib/SkyT/squarefilt.h

    r607 r668  
    22//--------------------------------------------------------------------------
    33// File and Version Information:
    4 //      $Id: squarefilt.h,v 1.2 1999-11-20 21:00:54 ansari Exp $
     4//      $Id: squarefilt.h,v 1.3 1999-11-29 14:16:09 ansari Exp $
    55//
    66// Description:
     
    2929class SquareFilter:public SpectralResponse
    3030{
     31
    3132public:
    3233  //Constructors
     34  SquareFilter ();
    3335  SquareFilter (double numin, double numax);
    3436 
     
    4547  virtual double peakTransmission() const;
    4648 
     49  virtual void WriteSelf(POutPersist& s) ;
     50  virtual void ReadSelf(PInPersist& s) ;
     51 
     52 
     53
    4754protected:
    4855  double _peakTransmission;
  • trunk/SophyaLib/SkyT/tgrsr.cc

    r611 r668  
    11#include "machdefs.h"
    22#include <iostream.h>
     3#include <typeinfo>
    34#include <math.h>
    45
  • trunk/SophyaLib/SkyT/trianglefilt.cc

    r607 r668  
    11//--------------------------------------------------------------------------
    22// File and Version Information:
    3 //      $Id: trianglefilt.cc,v 1.2 1999-11-20 21:00:54 ansari Exp $
     3//      $Id: trianglefilt.cc,v 1.3 1999-11-29 14:16:10 ansari Exp $
    44//
    55// Description:
     
    2121// Constructor --
    2222//----------------
     23
     24TriangleFilter::TriangleFilter()
     25   : SpectralResponse()
     26{
     27}
    2328TriangleFilter::TriangleFilter(double numin, double numax,double nupeak, double valueatpeak)
    2429   : SpectralResponse(numin, numax)
     
    6166return _peakTransmission;
    6267}
     68
     69void
     70TriangleFilter::WriteSelf(POutPersist& s)
     71{
     72  s.PutR8(this->peakFreq());
     73  s.PutR8(this->peakTransmission());
     74  s.PutR8(this->minFreq());
     75  s.PutR8(this->maxFreq());
     76 
     77}
     78
     79void
     80TriangleFilter::ReadSelf(PInPersist& s)   
     81{
     82  //  double peakFreq, peakTransmission, minFreq,  maxFreq;
     83  s.GetR8(_nuPeak);
     84  s.GetR8(_peakTransmission);
     85  s.GetR8(_numin);
     86  s.GetR8(_numax);
     87  cout << "peakFreq - peakTransmission - minFreq - maxFreq " << endl;
     88  cout <<  _nuPeak << "-" <<  _peakTransmission<< "-" <<  _numin << "-" <<  _numax << endl;
     89
     90}
  • trunk/SophyaLib/SkyT/trianglefilt.h

    r607 r668  
    22//--------------------------------------------------------------------------
    33// File and Version Information:
    4 //      $Id: trianglefilt.h,v 1.2 1999-11-20 21:00:54 ansari Exp $
     4//      $Id: trianglefilt.h,v 1.3 1999-11-29 14:16:10 ansari Exp $
    55//
    66// Description:
     
    3131  //Constructors
    3232  TriangleFilter (double numin, double numax,double nupeak, double valueatpeak);
    33  
     33  TriangleFilter ();
    3434
    3535  // destructor
     
    4343  virtual double peakFreq() const;
    4444  virtual double peakTransmission() const;
     45  virtual void WriteSelf(POutPersist& s) ;
     46  virtual void ReadSelf(PInPersist& s)  ;
    4547
    4648protected:
Note: See TracChangeset for help on using the changeset viewer.