Changeset 724 in Sophya for trunk/SophyaLib


Ignore:
Timestamp:
Feb 21, 2000, 12:23:25 PM (26 years ago)
Author:
ansari
Message:

nouvelle gestion des thetaslices

Location:
trunk/SophyaLib/Samba
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/SophyaLib/Samba/spheregorski.cc

    r701 r724  
    211211  InitNul();
    212212  Pixelize(m);
     213  SetThetaSlices();
    213214}
    214215//++
     
    268269  InitNul();
    269270  Pixelize(m);
     271  SetThetaSlices();
    270272}
    271273
     
    322324//++
    323325template<class T>
    324 int_4 SphereGorski<T>::NbThetaSlices() const
     326uint_4 SphereGorski<T>::NbThetaSlices() const
    325327
    326328//    Return number of slices in theta direction on the  sphere
    327329//--
    328330{
    329   return int(4*nSide_-1);
     331  uint_4 nbslices = uint_4(4*nSide_-1);
     332  if (nSide_<=0)
     333    {
     334      nbslices = 0;
     335      throw PException(" sphere not pixelized, NbSlice=0 ");
     336    }
     337  return nbslices;
    330338}
    331339
     
    352360    }
    353361
    354   int_4 iring= 0;
    355   int_4 lring  = 0;
    356   if(index < nSide_-1)
    357     {
    358       iring= 2*index*(index+1);
    359       lring= 4*(index+1);
    360     }
    361   else if(index < 3*nSide_)
    362     {
    363       iring= 2*nSide_*(2*index-nSide_+1);
    364       lring= 4*nSide_;
    365     }
    366   else
    367     {
    368       int_4 nc= 4*nSide_-1-index;
    369       iring = nPix_-2*nc*(nc+1);
    370       lring = 4*nc;
    371     }
     362
     363  int_4 iring= sliceBeginIndex_(index);
     364  int_4 lring  =  sliceLenght_(index);
     365
    372366
    373367  phi.ReSize(lring);
     
    382376    }
    383377  theta= TH;
     378}
     379//++
     380//++
     381
     382template<class T>
     383void SphereGorski<T>::GetThetaSlice(int_4 sliceIndex,double& theta, double& phi0, TVector<int>& pixelIndices,TVector<T>& value) const
     384
     385//    For a theta-slice with index 'sliceIndex', return :
     386//
     387//    the corresponding "theta"
     388//    the corresponding "phi" for first pixel of the slice
     389//
     390//    a vector containing the indices of the pixels of the slice
     391//    (equally distributed in phi)
     392//
     393//    a vector containing the corresponding values of pixels
     394//
     395//--
     396{
     397
     398  if (sliceIndex<0 || sliceIndex >= NbThetaSlices())
     399    {
     400      // THROW(out_of_range("SphereGorski::PIxVal Pixel index out of range"));
     401      cout << " SphereGorski::GetThetaSlice : Pixel index out of range" <<endl;
     402      THROW(rangeCheckErr);
     403    }
     404
     405  int_4 iring= sliceBeginIndex_(sliceIndex);
     406  int_4 lring  =  sliceLenght_(sliceIndex);
     407  pixelIndices.ReSize(lring);
     408  value.ReSize(lring);
     409  for(int_4 kk = 0; kk < lring;kk++)
     410    {
     411      pixelIndices(kk)= kk+iring;
     412      value(kk)= PixVal(kk+iring);
     413    }
     414  PixThetaPhi(iring, theta, phi0);
     415}
     416//++
     417template<class T>
     418void SphereGorski<T>::SetThetaSlices() 
     419
     420//--
     421{
     422  sliceBeginIndex_.ReSize(4*nSide_-1);
     423  sliceLenght_.ReSize(4*nSide_-1);
     424  for (int sliceIndex=0; sliceIndex<  nSide_-1; sliceIndex++)
     425    {
     426      sliceBeginIndex_(sliceIndex)  = 2*sliceIndex*(sliceIndex+1);
     427      sliceLenght_(sliceIndex) = 4*(sliceIndex+1);
     428    }
     429  for (int sliceIndex= nSide_-1; sliceIndex<  3*nSide_; sliceIndex++)
     430    {
     431      sliceBeginIndex_(sliceIndex)  = 2*nSide_*(2*sliceIndex-nSide_+1);
     432      sliceLenght_(sliceIndex) = 4*nSide_;
     433    }
     434  for (int sliceIndex= 3*nSide_; sliceIndex< 4*nSide_-1; sliceIndex++)
     435    {
     436      int_4 nc= 4*nSide_-1-sliceIndex;
     437      sliceBeginIndex_(sliceIndex)  = nPix_-2*nc*(nc+1);
     438      sliceLenght_(sliceIndex) = 4*nc;
     439    }
    384440}
    385441
     
    11791235  dobj->setParameters(nSide,nPix, Omega);
    11801236
    1181 // On lit le DataBlock;
     1237// On lit les DataBlocks;
    11821238  FIO_NDataBlock<T> fio_nd(&dobj->pixels_);
    11831239  fio_nd.Read(is);
     1240  FIO_NDataBlock<int> fio_ndi1(&dobj->sliceBeginIndex_);
     1241  fio_ndi1.Read(is);
     1242  FIO_NDataBlock<int> fio_ndi2(&dobj->sliceLenght_);
     1243  fio_ndi2.Read(is);
    11841244}
    11851245
     
    12161276  os.PutI4(nPix);
    12171277  os.PutR8(dobj->PixSolAngle());
    1218 // On ecrit le dataBlock
     1278// On ecrit les dataBlocks
    12191279  FIO_NDataBlock<T> fio_nd(&dobj->pixels_);
    12201280  fio_nd.Write(os);
     1281  FIO_NDataBlock<int> fio_ndi1(&dobj->sliceBeginIndex_);
     1282  fio_ndi1.Write(os);
     1283  FIO_NDataBlock<int> fio_ndi2(&dobj->sliceLenght_);
     1284  fio_ndi2.Write(os);
    12211285}
    12221286
  • trunk/SophyaLib/Samba/spheregorski.h

    r708 r724  
    7474virtual ~SphereGorski();
    7575
     76/*! Setting blockdata to temporary (see ndatablock documentation) */
     77inline virtual void SetTemp(bool temp=false) const {pixels_.SetTemp(temp);};
    7678// ------------------ Definition of PixelMap abstract methods
    7779
     
    8789/* Nombre de tranches en theta */
    8890/*!    Return number of slices in theta direction on the  sphere */
    89 int_4 NbThetaSlices() const;
     91uint_4 NbThetaSlices() const;
    9092/*!   For a theta-slice with index 'index', return :
    9193
     
    9799*/
    98100void GetThetaSlice(int_4 index,double& theta,TVector<double>& phi,TVector<T>& value) const;
     101/*!   For a theta-slice with index 'index', return :
     102
     103   the corresponding "theta"
     104
     105   the corresponding "phi" for first pixel of the slice
     106
     107    a vector containing indices of the pixels of the slice
     108
     109   (equally distributed in phi)
     110
     111    a vector containing the corresponding values of pixels
     112*/
     113 void GetThetaSlice(int_4 sliceIndex,double& theta, double& phi0, TVector<int>& pixelIndices,TVector<T>& value) const ;
    99114
    100115/* Return true if teta,phi in map  */
     
    184199// ------------- méthodes internes ----------------------
    185200void InitNul();
     201 void SetThetaSlices();
    186202
    187203int_4  nest2ring(int_4 nside,int_4 ipnest) const;
     
    200216
    201217// ------------- variables internes -----------------------
     218
    202219int_4 nSide_;
    203220int_4 nPix_;
     
    205222
    206223NDataBlock<T> pixels_;
     224NDataBlock<int> sliceBeginIndex_;
     225 NDataBlock<int> sliceLenght_;
    207226
    208227};
Note: See TracChangeset for help on using the changeset viewer.