Changeset 1626 in Sophya for trunk/SophyaProg/PrgMap/extrap2sph.cc
- Timestamp:
- Aug 7, 2001, 6:20:32 PM (24 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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;
Note:
See TracChangeset
for help on using the changeset viewer.