Changeset 1626 in Sophya for trunk/SophyaProg
- Timestamp:
- Aug 7, 2001, 6:20:32 PM (24 years ago)
- Location:
- trunk/SophyaProg/PrgMap
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaProg/PrgMap/cl2map.cc
r1607 r1626 13 13 #include "fitsspherehealpix.h" 14 14 #include "fitstarray.h" 15 16 /*! 17 \defgroup PrgMap PrgMap module 18 This module contains simple programs to perform various tasks 19 on spherical maps. 20 */ 15 21 16 22 /*! -
trunk/SophyaProg/PrgMap/cremskfrsph.cc
r1535 r1626 13 13 #include "fitsspherehealpix.h" 14 14 15 /*! 16 \ingroup PrgMap 17 \file cremskfrsph.cc 18 \brief \b cremskfrsph: Create a masked sphere from a sphere of datas 19 \verbatim 20 csh> cremskfrsph -h 21 cremskfrsph [-n -m min -M max -v valmsk,inimsk] sphval.fits sphmask.fits 22 -m min : min value 23 -M max : max value 24 condition for filling masque is: min<=sphere_value<=max 25 (fill mask with valmsk) (bounds are included) 26 -n : negate the condition 27 (switch to: sphere_value<min || max<sphere_value) 28 -v valmsk,inimsk: 29 valmsk: value to be put into mask if ok (def=1.) 30 inimsk: initialisation value for the mask (def=0.) 31 \endverbatim 32 */ 33 15 34 void usage(); 16 35 void usage() … … 19 38 <<" -m min : min value"<<endl 20 39 <<" -M max : max value"<<endl 21 <<" condition for filling masque is : min<=spherevalue<=max"<<endl22 <<" 40 <<" condition for filling masque is: min<=sphere_value<=max"<<endl 41 <<" (fill mask with valmsk) (bounds are included)"<<endl 23 42 <<" -n : negate the condition"<<endl 43 <<" (switch to: sphere_value<min || max<sphere_value)"<<endl 24 44 <<" -v valmsk,inimsk:"<<endl 25 45 <<" valmsk: value to be put into mask if ok (def=1.)"<<endl … … 32 52 double vmin=-1.e30,vmax=1.e30,vmask=1.,vmaskini=0.; 33 53 bool tstmin=false,tstmax=false,negate=false; 54 string dum; 34 55 int c; 35 56 while((c = getopt(narg,arg,"hnm:M:v:")) != -1) { … … 59 80 char * sphmsk = arg[optind+1]; 60 81 82 if(negate) dum = ".NOT."; else dum = ""; 61 83 cout<<"Sphere values : "<<sphval<<endl 62 84 <<"Sphere mask : "<<sphmsk<<endl 63 <<" ...min("<<tstmin<<") "<<vmin<<" max("<<tstmax<<") "<<vmax<<endl 85 <<" ...min("<<tstmin<<") "<<vmin<<endl 86 <<" max("<<tstmax<<") "<<vmax<<endl 64 87 <<" ...negate "<<negate<<endl 65 88 <<" ...mask set value "<<vmask<<endl 66 <<" mask init value "<<vmaskini<<endl; 67 cout<<"Condition : "; 68 if(negate) cout<<"!"; 69 cout<<"( "<<vmin<<" <= V <= "<<vmax<<" ) bounds are included"<<endl; 89 <<" mask init value "<<vmaskini<<endl 90 <<"Condition on data to set the mask: " 91 <<dum<<"( "<<vmin<<" <= V <= "<<vmax<<" )"<<endl; 70 92 71 93 // Lecture de la sphere Healpix des valeurs 72 SphereHEALPix<r_8> sph; 94 SphereHEALPix<r_8> sph; 73 95 FitsInFile sfits(sphval); 74 96 sfits >> sph; … … 87 109 for(int_4 i=0;i<sph.NbPixels();i++) { 88 110 sphm(i) = vmaskini; 89 r_8 v = sph(i); 90 bool intoint = true; 91 if(tstmin && v<vmin) intoint=false; 92 if(tstmax && v>vmax) intoint=false; 93 // [vmin , vmax] 94 // intoint : false [ true ] false (si tstmin && tstmax) 95 // intoint : false [ true (si tstmin && !tstmax) 96 // intoint : true ] false (si !tstmin && tstmax) 97 if(negate && intoint) continue; 98 else if(!negate && !intoint) continue; 111 112 bool skp = (tstmin || tstmax) ? negate : false; 113 if((tstmin && sph(i)<vmin) || (tstmax && sph(i)>vmax)) skp = !negate; 114 if(skp) continue; // Do nothing 115 99 116 sphm(i) = vmask; 100 117 nmask++; … … 106 123 // Ecriture de la sphere Healpix sur fits 107 124 { 108 stringdum = "rm -f "; dum += sphmsk; system(dum.c_str());125 dum = "rm -f "; dum += sphmsk; system(dum.c_str()); 109 126 FitsOutFile swfits(sphmsk); 110 127 cout<<"Writing Mask Sphere Fits file"<<endl; -
trunk/SophyaProg/PrgMap/extrap2sph.cc
r1528 r1626 1 // Pour boucher les trous d'une sphere HEALPIX utilisant une autre sphere 1 // Pour boucher les trous d'une sphere HEALPIX en utilisant 2 // une autre sphere HEALPIX 2 3 // cmv 13/6/01 3 4 // extrap2sph -w sph143k05_e.fits sph143k05.fits sphred.fits sphout_2.fits … … 13 14 #include "fitsspherehealpix.h" 14 15 16 /*! 17 \ingroup PrgMap 18 \file extrap2sph.cc 19 \brief \b extrap2sph: Fill holes in a sphere of datas by using 20 an other sphere of datas. 21 A mask to define the place to be tested in the sphere might be given. 22 \verbatim 23 csh> extrap2sph -h 24 extrap2sph [-m valmin -M valmax -r rvalmin -R rvalmax] 25 [-w sphinw.fits] sphin.fits sphred.fits sphout.fits 26 -w sphinw.fits : input sphere weight, if sphinw_value<=0. (def=NULL) 27 if sphinw_value<=0. pixel has not to be filled 28 -m minval : min value to identify EMPTY pixel of sphin (def=no_test) 29 -M maxval : max value to identify EMPTY pixel of sphin (def=no_test) 30 condition for EMPTY pixel is (minval<=val<=maxval) 31 -n : negate the previous condition, condition for EMPTY pixel 32 becomes: (val<minval || maxval<val) 33 -r rminval : min value to identify GOOD pixel of sphred (def=no_test) 34 -R rmaxval : max value to identify GOOD pixel of sphred (def=no_test) 35 condition for GOOD pixel is (minval<=val<=maxval) 36 -n : negate the previous condition, condition for GOOD pixel 37 becomes: (val<minval || maxval<val) 38 sphin.fits : input sphere 39 sphred.fits : input reducted sphere 40 sphout.fits : output sphere 41 \endverbatim 42 */ 43 15 44 void usage(); 16 45 void usage() 17 46 { 18 cout<<"extrap2sph [-w sphinw.fits -m valmin -M valmax]"<<endl 19 <<" sphin.fits sphred.fits sphout.fits"<<endl 20 <<" -w sphinw.fits : input sphere weight (def=NULL)"<<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 47 cout<<"extrap2sph [-m valmin -M valmax -r rvalmin -R rvalmax]"<<endl 48 <<" [-w sphinw.fits] sphin.fits sphred.fits sphout.fits"<<endl 49 <<" -w sphinw.fits : input sphere weight, if sphinw_value<=0. (def=NULL)"<<endl 50 <<" if sphinw_value<=0. pixel has not to be filled"<<endl 51 <<" -m minval : min value to identify EMPTY pixel of sphin (def=no_test)"<<endl 52 <<" -M maxval : max value to identify EMPTY pixel of sphin (def=no_test)"<<endl 53 <<" condition for EMPTY pixel is (minval<=val<=maxval)"<<endl 54 <<" -n : negate the previous condition, condition for EMPTY pixel"<<endl 55 <<" becomes: (val<minval || maxval<val)"<<endl 56 <<" -r rminval : min value to identify GOOD pixel of sphred (def=no_test)"<<endl 57 <<" -R rmaxval : max value to identify GOOD pixel of sphred (def=no_test)"<<endl 58 <<" condition for GOOD pixel is (minval<=val<=maxval)"<<endl 59 <<" -n : negate the previous condition, condition for GOOD pixel"<<endl 60 <<" becomes: (val<minval || maxval<val)"<<endl 25 61 <<" sphin.fits : input sphere"<<endl 26 62 <<" sphred.fits : input reducted sphere"<<endl … … 30 66 int main(int narg, char* arg[]) 31 67 { 32 bool tstmin=false, tstmax=false; 33 double valmin=-1.e30, valmax=+1.e30; 68 bool tstmin=false, tstmax=false, neg=false; 69 bool rtstmin=false, rtstmax=false, rneg=false; 70 double valmin=0., valmax=0., rvalmin=0., rvalmax=0.; 34 71 char * fsphinw = NULL; 72 string dum; 35 73 int c; 36 while((c = getopt(narg,arg,"h m:M:w:")) != -1) {74 while((c = getopt(narg,arg,"hnNm:M:r:R:w:")) != -1) { 37 75 switch (c) { 76 case 'n' : 77 neg = true; 78 break; 79 case 'N' : 80 rneg = true; 81 break; 38 82 case 'm' : 39 83 sscanf(optarg,"%lf",&valmin); … … 43 87 sscanf(optarg,"%lf",&valmax); 44 88 tstmax=true; 89 break; 90 case 'r' : 91 sscanf(optarg,"%lf",&rvalmin); 92 rtstmin=true; 93 break; 94 case 'R' : 95 sscanf(optarg,"%lf",&rvalmax); 96 rtstmax=true; 45 97 break; 46 98 case 'w' : … … 54 106 55 107 if(optind+2>=narg) {usage(); exit(1);} 56 char * fsphin 108 char * fsphin = arg[optind]; 57 109 char * fsphred = arg[optind+1]; 58 char * fsphout 110 char * fsphout = arg[optind+2]; 59 111 60 112 cout<<"Input Sphere : "<<fsphin<<endl … … 62 114 <<"Input Reducted Sphere : "<<fsphred<<endl 63 115 <<"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; 116 if(neg) dum = ".NOT."; else dum=""; 117 cout<<"- Sphere - test min("<<tstmin<<") : "<<valmin<<endl 118 <<" test max("<<tstmax<<") : "<<valmax<<endl 119 <<" negate("<<neg<<")"<<endl 120 <<" - Condition for EMPTY pixel in Sphere is :"<<endl 121 <<" "<<dum<<"( "<<valmin<<" <= V <= "<<valmax<<" )"<<endl; 122 if(rneg) dum = ".NOT."; else dum=""; 123 cout<<"- Reducted Sphere - test min("<<rtstmin<<") : "<<rvalmin<<endl 124 <<" test max("<<rtstmax<<") : "<<rvalmax<<endl 125 <<" negate("<<rneg<<")"<<endl 126 <<" - Condition for GOOD pixel in Reducted Sphere is :"<<endl 127 <<" "<<dum<<"( "<<rvalmin<<" <= V <= "<<rvalmax<<" )"<<endl; 69 128 70 129 // Lecture des spheres … … 102 161 uint_4 n=0, n0=0; 103 162 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 } 163 bool skp; 164 if(fsphinw) if(sphinw(i)<=0.) continue; // Pixel out of acceptance! 165 166 // Test if pixel of Sphere has to be extrapolated 167 skp = (tstmin || tstmax) ? neg : false; 168 if((tstmin && sphin(i)<valmin) || (tstmax && sphin(i)>valmax)) skp = !neg; 169 if(skp) continue; // Do nothing 170 112 171 double theta,phi; 113 172 sphin.PixThetaPhi(i,theta,phi); 114 173 int_4 ir = sphred.PixIndexSph(theta,phi); 174 175 // Test if pixel of Reducted Sphere is good 176 skp = (rtstmin || rtstmax) ? rneg : false; 177 if((rtstmin && sphred(i)<rvalmin) || (rtstmax && sphred(i)>rvalmax)) skp = !rneg; 178 if(skp) continue; // Do nothing 179 115 180 sphin(i) = sphred(ir); 116 181 n++; if(sphred(ir)!=0.) n0++; … … 121 186 // Ecriture de la sphere 122 187 { 123 stringdum = "rm -f "; dum += fsphout; system(dum.c_str());188 dum = "rm -f "; dum += fsphout; system(dum.c_str()); 124 189 FitsOutFile sfits(fsphout); 125 190 cout<<"Writing Output Sphere Fits file"<<endl; -
trunk/SophyaProg/PrgMap/extrapsph.cc
r1545 r1626 1 // Pour boucher les trous d'une sphere HEALPIX en clusterisant dans une sphere 2 // plus petite cmv 13/6/01 1 // Pour boucher les trous d'une sphere HEALPIX en la clusterisant 2 // dans une sphere plus petite puis en la re-extrapolant. 3 // cmv 13/6/01 3 4 // extrapsph -r 2 sph143k05.fits sph143k05_e.fits 4 5 // sphout.fits sphoutw.fits sphred.fits sphredw.fits … … 13 14 #include "fitsspherehealpix.h" 14 15 16 /*! 17 \ingroup PrgMap 18 \file extrapsph.cc 19 \brief \b extrapsph: Fill holes in a sphere of datas by reducing 20 it size and re-extrapolating. 21 \verbatim 22 csh> extrapsph -h 23 extrapsph [-r reduc_factor] sphin.fits sphinw.fits 24 sphout.fits [sphout_w.fits sphred.fits sphred_w.fits] 25 -r reduc : reduction factor for clustering (must be 2^n, def=2) 26 sphin.fits : input sphere 27 sphin_w.fits : input sphere filling weight 28 sphout.fits : output sphere 29 sphout_w.fits : output sphere filling weight 30 sphred.fits : output reducted sphere 31 sphred_w.fits : output reducted sphere filling weight 32 \endverbatim 33 */ 34 15 35 void usage(); 16 36 void usage() 17 37 { 18 cout<<"extrapsph [-r reduc ] sphin.fits sphinw.fits"<<endl19 <<" 38 cout<<"extrapsph [-r reduc_factor] sphin.fits sphinw.fits"<<endl 39 <<" sphout.fits [sphout_w.fits" 20 40 <<" sphred.fits sphred_w.fits]"<<endl 21 41 <<" -r reduc : reduction factor for clustering (must be 2^n, def=2)"<<endl … … 31 51 { 32 52 int red=2; 53 string dum; 33 54 int c; 34 55 while((c = getopt(narg,arg,"hr:")) != -1) { … … 122 143 if(sphredw(ir)<=0.) continue; 123 144 sphin(i) = sphred(ir); 145 // On passe en negatif les pixels qui ont ete extrapoles 124 146 sphinw(i) = -sphredw(ir); 125 147 n++; … … 129 151 // Ecriture des spheres 130 152 { 131 stringdum = "rm -f "; dum += fsphout; system(dum.c_str());153 dum = "rm -f "; dum += fsphout; system(dum.c_str()); 132 154 FitsOutFile sfits(fsphout); 133 155 cout<<"Writing Output Sphere Fits file"<<endl; … … 135 157 } 136 158 if(fsphoutw) { 137 stringdum = "rm -f "; dum += fsphoutw; system(dum.c_str());159 dum = "rm -f "; dum += fsphoutw; system(dum.c_str()); 138 160 FitsOutFile sfits(fsphoutw); 139 161 cout<<"Writing Output Sphere Weight Fits file"<<endl; … … 141 163 } 142 164 if(fsphred) { 143 stringdum = "rm -f "; dum += fsphred; system(dum.c_str());165 dum = "rm -f "; dum += fsphred; system(dum.c_str()); 144 166 FitsOutFile sfits(fsphred); 145 167 cout<<"Writing Reducted Sphere Fits file"<<endl; … … 147 169 } 148 170 if(fsphredw) { 149 stringdum = "rm -f "; dum += fsphredw; system(dum.c_str());171 dum = "rm -f "; dum += fsphredw; system(dum.c_str()); 150 172 FitsOutFile sfits(fsphredw); 151 173 cout<<"Writing Reducted Sphere Weight Fits file"<<endl; -
trunk/SophyaProg/PrgMap/msksphere.cc
r1535 r1626 11 11 #include "fitsspherehealpix.h" 12 12 13 /*! 14 \ingroup PrgMap 15 \file msksphere.cc 16 \brief \b msksphere: mask a sphere of datas with a mask sphere. 17 \verbatim 18 csh> msksphere -h 19 msksphere [-m min -M max -v valmsk] sphval.fits sphmask.fits sphout.fits 20 sphval.fits : inpout sphere of datas where the pixels have to be masked 21 sphmask.fits : inpout masked sphere used to mask pixels 22 sphout.fits : output masked sphere of datas 23 -m min : min mask_sphere_value for MASKING the sphere pixel 24 -M max : max mask_sphere_value for MASKING the sphere pixel 25 condition for MASKING sphere pixel is (min<=mask_sphere_value<=max) 26 -n : negate the previous condition, condition for MASKING sphere pixel 27 becomes: (mask_sphere_value<minval || maxval<mask_sphere_value) 28 Default (no -m and -M): mask pixel if mask_sphere_value<0. 29 -v valmsk : set sphere value for masked pixels (def=0.) 30 \endverbatim 31 */ 32 13 33 void usage(); 14 34 void usage() 15 35 { 16 cout<<"msksphere [-m min -M max -v valmsk]"<<endl 17 <<" sphval.fits sphmask.fits sphout.fits"<<endl 18 <<" -m min : min value"<<endl 19 <<" -M max : max value"<<endl 20 <<" condition for masking is :"<<endl 21 <<" mask_sphere_value <= min"<<endl 22 <<" OR"<<endl 23 <<" mask_sphere_value >= max"<<endl 24 <<" (bounds are included)"<<endl 25 <<" Default is mask_sphere_value <=0. (no -m and -M)"<<endl 26 <<" -v valmsk : set value for masked pixels (def=0.)"<<endl; 36 cout<<"msksphere [-m min -M max -v valmsk]" 37 <<" sphval.fits sphmask.fits sphout.fits"<<endl 38 <<" sphval.fits : inpout sphere of datas where the pixels have to be masked"<<endl 39 <<" sphmask.fits : inpout masked sphere used to mask pixels"<<endl 40 <<" sphout.fits : output masked sphere of datas"<<endl 41 <<" -m min : min mask_sphere_value for MASKING the sphere pixel"<<endl 42 <<" -M max : max mask_sphere_value for MASKING the sphere pixel"<<endl 43 <<" condition for MASKING sphere pixel is (min<=mask_sphere_value<=max)"<<endl 44 <<" -n : negate the previous condition, condition for MASKING sphere pixel"<<endl 45 <<" becomes: (mask_sphere_value<minval || maxval<mask_sphere_value)"<<endl 46 <<" Default (no -m and -M): mask pixel if mask_sphere_value<0."<<endl 47 <<" -v valmsk : set sphere value for masked pixels (def=0.)"<<endl; 27 48 } 28 49 … … 30 51 { 31 52 double vmask=0.,vmin=-1.e30,vmax=1.e30; 32 bool tstmin=false,tstmax=false; 53 bool tstmin=false,tstmax=false,negate=false; 54 string dum; 33 55 int c; 34 while((c = getopt(narg,arg,"h m:M:v:")) != -1) {56 while((c = getopt(narg,arg,"hnm:M:v:")) != -1) { 35 57 switch (c) { 58 case 'n' : 59 negate = true; 60 break; 36 61 case 'm' : 37 62 sscanf(optarg,"%lf",&vmin); … … 56 81 char * sphout = arg[optind+2]; 57 82 83 if(!tstmin && !tstmax) {tstmin=true; vmin=0.; negate=true;} 84 85 if(negate) dum = ".NOT."; else dum=""; 58 86 cout<<"Sphere values : "<<sphval<<endl 59 87 <<"Sphere mask : "<<sphmsk<<endl 60 88 <<"Sphere out : "<<sphout<<endl 61 <<" ...min("<<tstmin<<") "<<vmin<<" max("<<tstmax<<") "<<vmax<<endl 89 <<" ...min("<<tstmin<<") "<<vmin<<endl 90 <<" max("<<tstmax<<") "<<vmax<<endl 62 91 <<" ...mask set value "<<vmask<<endl 63 <<" Condition for masking pixel is : "64 <<" ( Vmsk <= "<<vmin<<" OR Vmsk >= "<<vmax<<" ) bounds are included"<<endl;92 <<" Condition for masking pixel is :"<<endl 93 <<" "<<dum<<"( "<<vmin<<" <= V <= "<<vmax<<" )"<<endl; 65 94 66 95 // Lecture de la sphere Healpix des valeurs … … 88 117 uint_4 nmask = 0; 89 118 for(int_4 i=0;i<sph.NbPixels();i++) { 90 r_8 v = msph(i); 91 bool masked=false;92 if( tstmin && v<=vmin) {sph(i) = vmask; masked = true;}93 if( tstmax && v>=vmax) {sph(i) = vmask; masked = true;}94 if(!tstmin && !tstmax && v<=0.) 95 {sph(i) = vmask; masked = true;}96 if(masked)nmask++;119 120 bool skp = (tstmin || tstmax) ? negate : false; 121 if((tstmin && msph(i)<vmin) || (tstmax && msph(i)>vmax)) skp = !negate; 122 if(skp) continue; // Do nothing 123 124 sph(i) = vmask; 125 nmask++; 97 126 } 98 127 cout<<" .... Number of values masked : "<<nmask<<endl; … … 102 131 // Ecriture de la sphere Healpix sur fits 103 132 { 104 stringdum = "rm -f "; dum += sphout; system(dum.c_str());133 dum = "rm -f "; dum += sphout; system(dum.c_str()); 105 134 FitsOutFile sfits(sphout); 106 135 cout<<"Writing Output Masked Sphere Fits file"<<endl;
Note:
See TracChangeset
for help on using the changeset viewer.