Changeset 1626 in Sophya for trunk/SophyaProg/PrgMap/msksphere.cc


Ignore:
Timestamp:
Aug 7, 2001, 6:20:32 PM (24 years ago)
Author:
cmv
Message:

Uniformisation des programmes + doc cmv 7/8/01

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/SophyaProg/PrgMap/msksphere.cc

    r1535 r1626  
    1111#include "fitsspherehealpix.h"
    1212
     13/*!
     14  \ingroup PrgMap
     15  \file msksphere.cc
     16  \brief \b msksphere: mask a sphere of datas with a mask sphere.
     17  \verbatim
     18csh> msksphere -h
     19msksphere [-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
    1333void usage();
    1434void usage()
    1535{
    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;
     36cout<<"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;
    2748}
    2849
     
    3051{
    3152double vmask=0.,vmin=-1.e30,vmax=1.e30;
    32 bool tstmin=false,tstmax=false;
     53bool tstmin=false,tstmax=false,negate=false;
     54string dum;
    3355int c;
    34 while((c = getopt(narg,arg,"hm:M:v:")) != -1) {
     56while((c = getopt(narg,arg,"hnm:M:v:")) != -1) {
    3557  switch (c) {
     58  case 'n' :
     59    negate = true;
     60    break;
    3661  case 'm' :
    3762    sscanf(optarg,"%lf",&vmin);
     
    5681char * sphout = arg[optind+2];
    5782
     83if(!tstmin && !tstmax) {tstmin=true; vmin=0.; negate=true;}
     84
     85if(negate) dum = ".NOT."; else dum="";
    5886cout<<"Sphere values : "<<sphval<<endl
    5987    <<"Sphere mask   : "<<sphmsk<<endl
    6088    <<"Sphere out    : "<<sphout<<endl
    61     <<"  ...min("<<tstmin<<") "<<vmin<<"  max("<<tstmax<<") "<<vmax<<endl
     89    <<"  ...min("<<tstmin<<") "<<vmin<<endl
     90    <<"     max("<<tstmax<<") "<<vmax<<endl
    6291    <<"  ...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;
    6594
    6695// Lecture de la sphere Healpix des valeurs
     
    88117uint_4 nmask = 0;
    89118for(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++;
    97126}
    98127cout<<"    .... Number of values masked   : "<<nmask<<endl;
     
    102131// Ecriture de la sphere Healpix sur fits
    103132{
    104 string dum = "rm -f "; dum += sphout; system(dum.c_str());
     133dum = "rm -f "; dum += sphout; system(dum.c_str());
    105134FitsOutFile sfits(sphout);
    106135cout<<"Writing Output Masked Sphere Fits file"<<endl;
Note: See TracChangeset for help on using the changeset viewer.