Changeset 931 in Sophya for trunk/SophyaProg/PMixer
- Timestamp:
- Apr 14, 2000, 3:37:06 PM (25 years ago)
- Location:
- trunk/SophyaProg/PMixer
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaProg/PMixer/skymixer.cc
r928 r931 1 #include "machdefs.h" 2 #include <stdlib.h> 3 #include <stdio.h> 4 5 #include <iostream.h> 6 #include <math.h> 7 8 #include <string> 9 #include <vector> 10 11 #include "timing.h" 12 #include "sambainit.h" 13 #include "pexceptions.h" 14 #include "datacards.h" 15 #include "fitsioserver.h" 16 17 #include "spherehealpix.h" 18 #include "fiospherehealpix.h" 19 #include "fitsspherehealpix.h" 20 #include "radspecvector.h" 21 #include "blackbody.h" 22 #include "derivblackbody.h" 23 #include "nupower.h" 24 25 #include "squarefilt.h" 26 #include "trianglefilt.h" 27 #include "specrespvector.h" 28 #include "gaussfilt.h" 1 #include "pmixer.h" 29 2 30 3 /*! 31 \defgroup PMixer PMixer module32 This module contains programs which:33 <UL>34 <LI> add several sky components, taking into account their35 radiation spectra and convoluting them with a given filter36 response : skymixer37 <LI> create a map with point source : extractRS38 <LI> generate sky components, radiation spectra and spectral39 response (small generator of maps) : tgsky and tgrsr40 </UL>41 A detailed description may be found at:42 */4 * \defgroup PMixer PMixer module 5 * This module contains programs which: 6 * <UL> 7 * <LI> add several sky components, taking into account their 8 * radiation spectra and convoluting them with a given filter 9 * response : skymixer 10 * <LI> create a map with point source : extractRS 11 * <LI> generate sky components, radiation spectra and spectral 12 * response (small generator of maps) : tgsky and tgrsr 13 * </UL> 14 * A detailed description may be found at: 15 */ 43 16 /*! 44 17 * \ingroup PMixer … … 48 21 *radiation spectra and convoluting them with a given filter 49 22 *response 50 */23 */ 51 24 52 25 // ----------------------------------------------------------------- … … 59 32 void SpectralResponse2Nt(SpectralResponse& sr, POutPersist & so, string name); 60 33 61 //62 // treating maps63 //---------------------------------------------------------64 template <class T> void MeanSig(NDataBlock<T> const & dbl, double& gmoy, double& gsig);65 template <class T> void Sph2Sph(PixelMap<T>& in, PixelMap<T>& out);66 //67 34 // to add different sky components and corresponding tools 68 35 //---------------------------------------------------------- … … 710 677 } 711 678 712 /* Nouvelle-Fonction */ 713 714 template <class T> 715 void Sph2Sph(PixelMap<T>& in, PixelMap<T>& out) 716 // Cette fonction remplit la sphere out a partir de la sphere in 717 // Les spheres peuvent etre de type et de pixelisations differentes 718 { 719 int kin,kout; 720 double teta,phi; 721 722 int* cnt = new int[out.NbPixels()+1]; 723 for(kout=0; kout<out.NbPixels(); kout++) 724 { cnt[kout] = 0; out(kout) = 0.; } 725 726 for(kin=0; kin<in.NbPixels(); kin++) { 727 in.PixThetaPhi(kin, teta, phi); 728 kout = out.PixIndexSph(teta, phi); 729 out(kout) += in(kin); 730 731 cnt[kout] ++; 732 733 } 734 735 double moy, sig, dcn; 736 moy = 0.; sig = 0.; 737 for(kout=0; kout<out.NbPixels(); kout++) { 738 dcn = cnt[kout]; moy += dcn; sig += (dcn*dcn); 739 if (cnt[kout] > 0) out(kout) /= dcn; 740 else { 741 out.PixThetaPhi(kout, teta, phi); 742 int pixel = in.PixIndexSph(teta,phi); 743 out(kout) = in.PixVal(pixel); 744 } 745 } 746 747 moy /= out.NbPixels(); 748 sig = sig/out.NbPixels() - moy*moy; 749 if (sig >= 0.) sig = sqrt(sig); 750 751 delete[] cnt; 752 753 if(printlev>2) 754 { 755 printf("Sph2Sph_Info NbPix In= %d Out= %d CntMoy,Sig= %g %g\n", 756 in.NbPixels(), out.NbPixels(), moy, sig); 757 PrtTim("End of Sph2Sph() "); 758 } 759 } 760 761 762 763 /* Nouvelle-Fonction */ 764 template <class T> 765 void MeanSig(NDataBlock<T> const & dbl, double& gmoy, double& gsig) 766 767 { 768 gmoy=0.; 769 gsig = 0.; 770 double valok; 771 for(int k=0; k<(int)dbl.Size(); k++) { 772 valok = dbl(k); 773 gmoy += valok; gsig += valok*valok; 774 } 775 gmoy /= (double)dbl.Size(); 776 gsig = gsig/(double)dbl.Size() - gmoy*gmoy; 777 if (gsig >= 0.) gsig = sqrt(gsig); 778 } 679 680 681 682 683 /* Nouvelle-Fonction */ 779 684 780 685 /* Nouvelle-Fonction */ -
trunk/SophyaProg/PMixer/tgsky.cc
r928 r931 1 #include "machdefs.h" 2 #include <iostream.h> 3 #include <math.h> 1 #include "pmixer.h" 2 #include "mapoperation.h" 4 3 5 #include "sambainit.h"6 #include "spherehealpix.h"7 #include "fiospherehealpix.h"8 #include "fitsioserver.h"9 #include "nbrandom.h"10 #include "bruit.h"11 #include "timing.h"12 4 /*! \ingroup PMixer 13 \file tgsky.cc5 * \file tgsky.cc 14 6 * \brief \b PROGRAM \b tgsky <BR> 15 7 * \l Program which generates different types of random skies 16 8 */ 9 // ------------- Main program -------------- 17 10 18 // Test program to generate different type of random skies19 template <class T>20 void MeanSig(PixelMap<T> const & map, double& gmoy, double& gsig);21 22 // ------------- Main program --------------23 11 int main(int narg, char* arg[]) 24 12 { … … 102 90 103 91 // Computing mean and sigma on the sphere 104 MeanSig(sph , gmoy, gsig);92 MeanSig(sph.DataBlock(), gmoy, gsig); 105 93 cout << "SphereHEALPix<float> Mean= " << gmoy << " Sigma = " << gsig << endl; 106 94 PrtTim("End of Mean-Sig "); … … 126 114 } 127 115 128 /* Nouvelle-Methode */129 template <class T>130 void MeanSig(PixelMap<T> const & map, double& gmoy, double& gsig)131 132 {133 gmoy=0.;134 gsig = 0.;135 double valok;136 for(int k=0; k<map.NbPixels(); k++) {137 valok = map(k);138 gmoy += valok; gsig += valok*valok;139 }140 gmoy /= (double)map.NbPixels();141 gsig = gsig/(double)map.NbPixels() - gmoy*gmoy;142 if (gsig >= 0.) gsig = sqrt(gsig);143 }
Note:
See TracChangeset
for help on using the changeset viewer.