Changeset 1528 in Sophya for trunk/SophyaProg/PrgMap
- Timestamp:
- Jun 14, 2001, 5:16:20 PM (24 years ago)
- Location:
- trunk/SophyaProg/PrgMap
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaProg/PrgMap/cremskfrsph.cc
r1522 r1528 1 1 // Creation d'une sphere de masque a partir d'une sphere de valeurs 2 2 // cmv 13/6/01 3 // cremskfrsph -m 0.1 -v 1.,0. sph143k05_e.fits sphmskw.fits 4 // cremskfrsph -n -m -1.e-30. -M 1.e-30. -v 1.,0. sph143k05.fits sphmsk.fits 3 5 #include "machdefs.h" 4 6 #include <unistd.h> … … 17 19 <<" -m min : min value"<<endl 18 20 <<" -M max : max value"<<endl 19 <<" condition for filling masque is : min<=V<=max"<<endl 21 <<" condition for filling masque is : min<=sphere value<=max"<<endl 22 <<" (bounds are included)"<<endl 20 23 <<" -n : negate the condition"<<endl 21 24 <<" -v valmsk,inimsk:"<<endl … … 56 59 char * sphmsk = arg[optind+1]; 57 60 58 {59 61 cout<<"Sphere values : "<<sphval<<endl 60 62 <<"Sphere mask : "<<sphmsk<<endl … … 65 67 cout<<"Condition : "; 66 68 if(negate) cout<<"!"; 67 cout<<"( "<<vmin<<" <= V <= "<<vmax<<" )"<<endl; 68 } 69 cout<<"( "<<vmin<<" <= V <= "<<vmax<<" ) bounds are included"<<endl; 69 70 70 71 // Lecture de la sphere Healpix des valeurs -
trunk/SophyaProg/PrgMap/extrap2sph.cc
r1526 r1528 1 1 // Pour boucher les trous d'une sphere HEALPIX utilisant une autre sphere 2 2 // cmv 13/6/01 3 // extrap2sph -w sph143k05_e.fits sph143k05.fits sphred.fits sphout_2.fits 4 // extrap2sph -m -1.e-30 -M +1.e-30 sph143k05.fits sphred.fits sphout_22.fits 3 5 #include "machdefs.h" 4 6 #include <unistd.h> … … 14 16 void usage() 15 17 { 16 cout<<"extrap2sph [-w sphinw.fits - 0 nulval]"<<endl18 cout<<"extrap2sph [-w sphinw.fits -m valmin -M valmax]"<<endl 17 19 <<" sphin.fits sphred.fits sphout.fits"<<endl 18 20 <<" -w sphinw.fits : input sphere weight (def=NULL)"<<endl 19 <<" -0 nulval : value to identify empty pixel in sphin (def=0.)"<<endl 20 <<" (used if sphinw.fits==NULL)"<<endl 21 <<" sphin.fits : input sphere"<<endl 21 <<" -m minval : value to identify EMPTY pixel (def=-1.e30.)"<<endl 22 <<" -M maxval : value to identify EMPTY pixel (def=+1.e30)"<<endl 23 <<" condition for EMPTY pixel is (minval<val<maxval)"<<endl 24 <<" (bounds are excluded, used only if sphinw.fits==NULL)"<<endl 25 <<" sphin.fits : input sphere"<<endl 22 26 <<" sphred.fits : input reducted sphere"<<endl 23 27 <<" sphout.fits : output sphere"<<endl; … … 26 30 int main(int narg, char* arg[]) 27 31 { 28 double nulval=0.; 32 bool tstmin=false, tstmax=false; 33 double valmin=-1.e30, valmax=+1.e30; 29 34 char * fsphinw = NULL; 30 35 int c; 31 while((c = getopt(narg,arg,"h 0:w:")) != -1) {36 while((c = getopt(narg,arg,"hm:M:w:")) != -1) { 32 37 switch (c) { 33 case '0' : 34 sscanf(optarg,"%lf",&nulval); 38 case 'm' : 39 sscanf(optarg,"%lf",&valmin); 40 tstmin=true; 41 break; 42 case 'M' : 43 sscanf(optarg,"%lf",&valmax); 44 tstmax=true; 35 45 break; 36 46 case 'w' : … … 48 58 char * fsphout = arg[optind+2]; 49 59 50 cout<<"Sphere Input : "<<fsphin<<endl 51 <<"Weight Sphere Input : "<<fsphinw<<endl 52 <<"Reducted Sphere Input : "<<fsphred<<endl 53 <<"Sphere Output : "<<fsphout<<endl 54 <<"nulval : "<<nulval<<endl; 60 cout<<"Input Sphere : "<<fsphin<<endl 61 <<"Input Weight Sphere : "<<fsphinw<<endl 62 <<"Input Reducted Sphere : "<<fsphred<<endl 63 <<"Output Sphere : "<<fsphout<<endl; 64 if(!fsphinw) 65 cout<<"- test min("<<tstmin<<") : "<<valmin<<endl 66 <<" test max("<<tstmax<<") : "<<valmax<<endl 67 <<"Condition for EMPTY pixel is :\n ("<<valmin 68 <<" < sphere value < "<<valmax<<") bounds are excluded!"<<endl; 55 69 56 70 // Lecture des spheres … … 58 72 {FitsInFile sfits(fsphin); sfits >> sphin;} 59 73 int nlat = sphin.SizeIndex(); 60 cout<<"Opening Sphere Input:"<<endl74 cout<<"Opening Input Sphere :"<<endl 61 75 <<" Type of map : "<<sphin.TypeOfMap()<<endl 62 76 <<" Number of pixels : "<<sphin.NbPixels()<<endl … … 67 81 FitsInFile sfits(fsphinw); 68 82 sfits >> sphinw; 69 cout<<"Opening Weight Sphere Input:"<<endl83 cout<<"Opening Input Weight Sphere :"<<endl 70 84 <<" Type of map : "<<sphinw.TypeOfMap()<<endl 71 85 <<" Number of pixels : "<<sphinw.NbPixels()<<endl … … 79 93 SphereHEALPix<r_8> sphred; 80 94 {FitsInFile sfits(fsphred); sfits >> sphred;} 81 cout<<"Opening Reducted Sphere Input:"<<endl95 cout<<"Opening Input Reducted Sphere :"<<endl 82 96 <<" Type of map : "<<sphred.TypeOfMap()<<endl 83 97 <<" Number of pixels : "<<sphred.NbPixels()<<endl 84 98 <<" Nlat : "<<sphred.SizeIndex()<<endl; 85 99 86 // Creation de la sphere output87 cout<<"Creating Sphere for output"<<endl;88 SphereHEALPix<r_8> sphout(sphin,false);89 90 100 // Filling hole for Output Sphere 91 101 cout<<"...Filling hole for Output Sphere"<<endl; 92 uint_4 n=0; 93 for(int_4 i=0;i<sphout.NbPixels();i++) { 94 if(fsphinw) {if(sphinw(i)>0.) continue;} 95 else {if(sphout(i)!=nulval) continue;} 102 uint_4 n=0, n0=0; 103 for(int_4 i=0;i<sphin.NbPixels();i++) { 104 if(fsphinw) { 105 if(sphinw(i)>0.) continue; 106 } else { 107 // Not Filled pixels ]valmin,valmax[ 108 // Filled pixels ]-Infinity,valmin] or [valmax,+Infinity[ 109 if(tstmin && sphin(i)<=valmin) continue; 110 if(tstmax && sphin(i)>=valmax) continue; 111 } 96 112 double theta,phi; 97 sph out.PixThetaPhi(i,theta,phi);113 sphin.PixThetaPhi(i,theta,phi); 98 114 int_4 ir = sphred.PixIndexSph(theta,phi); 99 sph out(i) = sphred(ir);100 n++; 115 sphin(i) = sphred(ir); 116 n++; if(sphred(ir)!=0.) n0++; 101 117 } 102 cout<<" Number of filled pixels "<<n<<endl; 118 cout<<" Number of pixels filled " 119 <<n<<" (not null values "<<n0<<")"<<endl; 103 120 104 121 // Ecriture de la sphere … … 107 124 FitsOutFile sfits(fsphout); 108 125 cout<<"Writing Output Sphere Fits file"<<endl; 109 sfits<<sph out;126 sfits<<sphin; 110 127 } 111 128 -
trunk/SophyaProg/PrgMap/extrapsph.cc
r1526 r1528 1 1 // Pour boucher les trous d'une sphere HEALPIX en clusterisant dans une sphere 2 2 // plus petite cmv 13/6/01 3 // extrapsph -r 2 sph143k05.fits sph143k05_e.fits 4 // sphout.fits sphoutw.fits sphred.fits sphredw.fits 3 5 #include "machdefs.h" 4 6 #include <unistd.h> … … 17 19 <<" sphout.fits [sphout_w.fits" 18 20 <<" sphred.fits sphred_w.fits]"<<endl 19 <<" -r reduc : reduction factor for nlat in clustering must be 2^n (def=2)"<<endl20 <<" sphin.fits : input sphere"<<endl21 <<" sphin_w.fits : input sphere filling weight"<<endl22 <<" sphout.fits : output sphere"<<endl23 <<" sphout_w.fits 24 <<" sphred.fits : output reducted sphere"<<endl25 <<" sphred_w.fits 21 <<" -r reduc : reduction factor for clustering (must be 2^n, def=2)"<<endl 22 <<" sphin.fits : input sphere"<<endl 23 <<" sphin_w.fits : input sphere filling weight"<<endl 24 <<" sphout.fits : output sphere"<<endl 25 <<" sphout_w.fits : output sphere filling weight"<<endl 26 <<" sphred.fits : output reducted sphere"<<endl 27 <<" sphred_w.fits : output reducted sphere filling weight"<<endl; 26 28 } 27 29 … … 52 54 if(optind+5<narg) fsphredw = arg[optind+5]; 53 55 54 cout<<" Sphere Input: "<<fsphin<<endl55 <<" Weight Sphere Input: "<<fsphinw<<endl56 <<" Sphere Output: "<<fsphout<<endl57 <<" Weight Sphere Output: "<<fsphoutw<<endl58 <<" Reducted Sphere Output: "<<fsphred<<endl59 <<" Reducted Weight Sphere Output: "<<fsphredw<<endl56 cout<<"Input Sphere : "<<fsphin<<endl 57 <<"Input Weight Sphere : "<<fsphinw<<endl 58 <<"Output Sphere : "<<fsphout<<endl 59 <<"Output Weight Sphere : "<<fsphoutw<<endl 60 <<"Output Reducted Sphere : "<<fsphred<<endl 61 <<"Output Reducted Weight Sphere : "<<fsphredw<<endl 60 62 <<"Reduction : "<<red<<endl; 61 63 … … 65 67 int nlat = sphin.SizeIndex(); 66 68 int nlatr = nlat/red; 67 cout<<"Opening Sphere Input:"<<endl69 cout<<"Opening Input Sphere :"<<endl 68 70 <<" Type of map : "<<sphin.TypeOfMap()<<endl 69 71 <<" Number of pixels : "<<sphin.NbPixels()<<endl … … 72 74 SphereHEALPix<r_8> sphinw; 73 75 {FitsInFile sfits(fsphinw); sfits >> sphinw;} 74 cout<<"Opening Weight Sphere Input:"<<endl76 cout<<"Opening Input Weight Sphere :"<<endl 75 77 <<" Type of map : "<<sphinw.TypeOfMap()<<endl 76 78 <<" Number of pixels : "<<sphinw.NbPixels()<<endl … … 81 83 } 82 84 83 // Creation des spheres output84 cout<<"Creating Spheres for output"<<endl;85 SphereHEALPix<r_8> sphout(sphin,false);86 SphereHEALPix<r_8> sphoutw(sphinw,false);87 88 85 // Creation des spheres reduites 89 86 cout<<"Creating Reducted Spheres : nlatr = "<<nlatr<<endl; … … 92 89 SphereHEALPix<r_8> sphredw(nlatr); 93 90 sphredw.SetPixels(0.); 94 cout<<"Creating Reducted Sphere :"<<endl 95 <<" Number of pixels : "<<sphred.NbPixels()<<endl 91 cout<<" Number of pixels : "<<sphred.NbPixels()<<endl 96 92 <<" Nlat : "<<sphred.SizeIndex()<<endl; 97 93 98 94 // Filling reducted spheres 99 95 cout<<"...Filling Reducted Spheres"<<endl; 96 uint_4 n=0; 100 97 for(int_4 i=0;i<sphin.NbPixels();i++) { 101 98 if(sphinw(i)<=0.) continue; … … 105 102 sphred(ir) += sphin(i)*sphinw(i); 106 103 sphredw(ir) += sphinw(i); 104 n++; 107 105 } 106 cout<<" Input Sphere: Number of filled pixels "<<n<<endl; 108 107 cout<<"...Computing Reducted Spheres"<<endl; 109 uint_4n=0;108 n=0; 110 109 for(int_4 ir=0;ir<sphred.NbPixels();ir++) 111 110 if(sphredw(ir) > 0.) {sphred(ir) /= sphredw(ir); n++;} 112 cout<<" Number of filled pixels"<<n<<endl;111 cout<<" Reducted Sphere: Number of pixels filled "<<n<<endl; 113 112 114 113 // Filling hole for Output Spheres 115 114 cout<<"...Filling hole for Output Spheres"<<endl; 116 115 n=0; 117 for(int_4 i=0;i<sph out.NbPixels();i++) {118 if(sph outw(i)>0.) continue;116 for(int_4 i=0;i<sphin.NbPixels();i++) { 117 if(sphinw(i)>0.) continue; 119 118 double theta,phi; 120 sph out.PixThetaPhi(i,theta,phi);119 sphin.PixThetaPhi(i,theta,phi); 121 120 int_4 ir = sphred.PixIndexSph(theta,phi); 122 121 if(sphredw(ir)<=0.) continue; 123 sph out(i) = sphred(ir);124 sph outw(i) = -sphredw(ir);122 sphin(i) = sphred(ir); 123 sphinw(i) = -sphredw(ir); 125 124 n++; 126 125 } 127 cout<<" Number of filled pixels"<<n<<endl;126 cout<<" Output Sphere: Number of pixels filled "<<n<<endl; 128 127 129 128 // Ecriture des spheres … … 132 131 FitsOutFile sfits(fsphout); 133 132 cout<<"Writing Output Sphere Fits file"<<endl; 134 sfits<<sph out;133 sfits<<sphin; 135 134 } 136 135 if(fsphoutw) { … … 138 137 FitsOutFile sfits(fsphoutw); 139 138 cout<<"Writing Output Sphere Weight Fits file"<<endl; 140 sfits<<sph outw;139 sfits<<sphinw; 141 140 } 142 141 if(fsphred) {
Note:
See TracChangeset
for help on using the changeset viewer.