Changeset 1626 in Sophya for trunk/SophyaProg/PrgMap/msksphere.cc
- Timestamp:
- Aug 7, 2001, 6:20:32 PM (24 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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.