📄 snaphu_io.c
字号:
params->initmethod=MSTINIT; }else if(!strcmp(argv[i],"--mcf")){ params->initmethod=MCFINIT; }else if(!strcmp(argv[i],"--aa")){ if(i+2<argc){ StrNCopy(infiles->ampfile,argv[++i],MAXSTRLEN); StrNCopy(infiles->ampfile2,argv[++i],MAXSTRLEN); infiles->ampfileformat=FLOAT_DATA; params->amplitude=TRUE; }else{ noarg_exit=TRUE; } }else if(!strcmp(argv[i],"--AA")){ if(++i+1<argc){ StrNCopy(infiles->ampfile,argv[i++],MAXSTRLEN); StrNCopy(infiles->ampfile2,argv[i],MAXSTRLEN); infiles->ampfileformat=FLOAT_DATA; params->amplitude=FALSE; }else{ noarg_exit=TRUE; } }else if(!strcmp(argv[i],"--tile")){ if(++i+3<argc){ if(StringToLong(argv[i++],&(params->ntilerow)) || StringToLong(argv[i++],&(params->ntilecol)) || StringToLong(argv[i++],&(params->rowovrlp)) || StringToLong(argv[i],&(params->colovrlp))){ fprintf(sp0,"option %s requires four integer arguments\n", argv[i-4]); exit(ABNORMAL_EXIT); } }else{ noarg_exit=TRUE; } }else if(!strcmp(argv[i],"--piece")){ if(++i+3<argc){ if(StringToLong(argv[i++],&(params->piecefirstrow)) || StringToLong(argv[i++],&(params->piecefirstcol)) || StringToLong(argv[i++],&(params->piecenrow)) || StringToLong(argv[i],&(params->piecencol))){ fprintf(sp0,"option %s requires four integer arguments\n", argv[i-4]); exit(ABNORMAL_EXIT); } }else{ noarg_exit=TRUE; } }else if(!strcmp(argv[i],"--nproc")){ if(++i<argc){ if(StringToLong(argv[i],&(params->nthreads))){ fprintf(sp0,"option %s requires an integer arguemnt\n", argv[i-1]); exit(ABNORMAL_EXIT); } }else{ noarg_exit=TRUE; } }else if(!strcmp(argv[i],"--assemble")){ params->assembleonly=TRUE; if(++i<argc){ StrNCopy(params->tiledir,argv[i],MAXSTRLEN); }else{ noarg_exit=TRUE; } }else if(!strcmp(argv[i],"--copyright") || !strcmp(argv[i],"--info")){ fprintf(sp1,COPYRIGHT); exit(ABNORMAL_EXIT); }else if(!strcmp(argv[i],"--help")){ fprintf(sp1,OPTIONSHELPFULL); exit(ABNORMAL_EXIT); }else{ fprintf(sp0,"unrecognized option %s\n",argv[i]); exit(ABNORMAL_EXIT); } if(noarg_exit){ fprintf(sp0,"incorrect number of arguments for option %s\n", argv[i-1]); exit(ABNORMAL_EXIT); } } }else{ /* argument is not an option */ if(!strlen(infiles->infile)){ StrNCopy(infiles->infile,argv[i],MAXSTRLEN); }else if(*linelenptr==0){ if(StringToLong(argv[i],linelenptr) || *linelenptr<=0){ fprintf(sp0,"line length must be positive integer\n"); exit(ABNORMAL_EXIT); } }else{ fprintf(sp0,"multiple input files: %s and %s\n", infiles->infile,argv[i]); exit(ABNORMAL_EXIT); } } } /* end for loop over arguments */ /* check to make sure we have required arguments */ if(!strlen(infiles->infile) || !(*linelenptr)){ fprintf(sp0,"not enough input arguments. type %s -h for help\n", PROGRAMNAME); exit(ABNORMAL_EXIT); }} /* end of ProcessArgs *//* function: CheckParams() * ----------------------- * Checks all parameters to make sure they are valid. This is just a boring * function with lots of checks in it. */void CheckParams(infileT *infiles, outfileT *outfiles, long linelen, long nlines, paramT *params){ long ni, nj, n; FILE *fp; /* make sure output file is writable (try opening in append mode) */ /* file will be opened in write mode later, clobbering existing file */ if((fp=fopen(outfiles->outfile,"a"))==NULL){ fprintf(sp0,"file %s is not writable\n",outfiles->outfile); exit(ABNORMAL_EXIT); }else{ if(ftell(fp)){ fclose(fp); }else{ fclose(fp); remove(outfiles->outfile); } if(!strcmp(outfiles->outfile,infiles->infile) && !params->eval && !params->regrowconncomps){ fprintf(sp0,"WARNING: output will overwrite input\n"); } } /* make sure options aren't contradictory */ if(params->initonly && params->unwrapped){ fprintf(sp0,"cannot use initialize-only mode with unwrapped input\n"); exit(ABNORMAL_EXIT); } if(params->initonly && params->p>=0){ fprintf(sp0,"cannot use initialize-only mode with Lp costs\n"); exit(ABNORMAL_EXIT); } if(params->costmode==NOSTATCOSTS && !(params->initonly || params->p>=0)){ fprintf(sp0,"no-statistical-costs option can only be used in\n"); fprintf(sp0," initialize-only or Lp-norm modes\n"); exit(ABNORMAL_EXIT); } if(strlen(infiles->costinfile) && params->costmode==NOSTATCOSTS){ fprintf(sp0,"no-statistical-costs option cannot be given\n"); fprintf(sp0," if input cost file is specified\n"); exit(ABNORMAL_EXIT); } if(strlen(outfiles->costoutfile) && params->costmode==NOSTATCOSTS){ fprintf(sp0,"no-statistical-costs option cannot be given\n"); fprintf(sp0," if output cost file is specified\n"); exit(ABNORMAL_EXIT); } /* check geometry parameters */ if(params->earthradius<=0){ fprintf(sp0,"earth radius must be nonnegative\n"); exit(ABNORMAL_EXIT); } if(params->altitude){ if(params->altitude>0){ params->orbitradius=params->earthradius+params->altitude; }else{ fprintf(sp0,"platform altitude must be positive\n"); exit(ABNORMAL_EXIT); } }else if(params->orbitradius < params->earthradius){ fprintf(sp0,"platform orbit radius must be greater than earth radius\n"); exit(ABNORMAL_EXIT); } if(params->costmode==TOPO && params->baseline<0){ fprintf(sp0,"baseline length must be nonnegative\n"); exit(ABNORMAL_EXIT); } if(params->costmode==TOPO && params->baseline==0){ fprintf(sp0,"WARNING: zero baseline may give unpredictable results\n"); } if(params->ncorrlooks<=0){ fprintf(sp0,"number of looks ncorrlooks must be positive\n"); exit(ABNORMAL_EXIT); } if(params->nearrange<=0){ fprintf(sp0,"slant range parameter nearrange must be positive (meters)\n"); exit(ABNORMAL_EXIT); } if(params->dr<=0 || params->da<=0){ fprintf(sp0,"pixel spacings dr and da must be positive (meters)\n"); exit(ABNORMAL_EXIT); } /* dr and da after multilooking can be larger than rangeres, azres */ /* if(params->rangeres<=(params->dr) || params->azres<=(params->da)){ fprintf(sp0,"resolutions parameters must be larger than pixel spacings\n"); exit(ABNORMAL_EXIT); } */ if(params->lambda<=0){ fprintf(sp0,"wavelength lambda must be positive (meters)\n"); exit(ABNORMAL_EXIT); } /* check scattering model defaults */ if(params->kds<=0){ fprintf(sp0,"scattering model parameter kds must be positive\n"); exit(ABNORMAL_EXIT); } if(params->specularexp<=0){ fprintf(sp0,"scattering model parameter SPECULAREXP must be positive\n"); exit(ABNORMAL_EXIT); } if(params->dzrcritfactor<0){ fprintf(sp0,"dzrcritfactor must be nonnegative\n"); exit(ABNORMAL_EXIT); } if(params->laywidth<1){ fprintf(sp0,"layover window width laywidth must be positive\n"); exit(ABNORMAL_EXIT); } if(params->layminei<0){ fprintf(sp0,"layover minimum brightness must be nonnegative\n"); exit(ABNORMAL_EXIT); } if(params->sloperatiofactor<0){ fprintf(sp0,"slope ratio fudge factor must be nonnegative\n"); exit(ABNORMAL_EXIT); } if(params->sigsqei<=0){ fprintf(sp0,"intensity estimate variance must be positive\n"); exit(ABNORMAL_EXIT); } /* check decorrelation model defaults */ if(params->drho<=0){ fprintf(sp0,"correlation step size drho must be positive\n"); exit(ABNORMAL_EXIT); } if(params->rhosconst1<=0 || params->rhosconst2<=0){ fprintf(sp0,"parameters rhosconst1 and rhosconst2 must be positive\n"); exit(ABNORMAL_EXIT); } if(!strlen(infiles->corrfile) && (params->defaultcorr<0 || params->defaultcorr>1)){ fprintf(sp0,"default correlation must be between 0 and 1\n"); exit(ABNORMAL_EXIT); } if(params->rhominfactor<0){ fprintf(sp0,"parameter rhominfactor must be nonnegative\n"); exit(ABNORMAL_EXIT); } if(params->ncorrlooksaz<1 || params->ncorrlooksrange<1 || params->nlooksaz<1 || params->nlooksrange<1 || params->nlooksother<1){ fprintf(sp0,"numbers of looks must be positive integer\n"); exit(ABNORMAL_EXIT); } if(!strlen(infiles->corrfile)){ if(params->ncorrlooksaz<params->nlooksaz){ fprintf(sp0,"NCORRLOOKSAZ cannot be smaller than NLOOKSAZ\n"); fprintf(sp0," setting NCORRLOOKSAZ to equal NLOOKSAZ\n"); params->ncorrlooksaz=params->nlooksaz; } if(params->ncorrlooksrange<params->nlooksrange){ fprintf(sp0,"NCORRLOOKSRANGE cannot be smaller than NLOOKSRANGE\n"); fprintf(sp0," setting NCORRLOOKSRANGE to equal NLOOKSRANGE\n"); params->ncorrlooksrange=params->nlooksrange; } } /* check pdf model parameters */ if(params->azdzfactor<0){ fprintf(sp0,"parameter azdzfactor must be nonnegative\n"); exit(ABNORMAL_EXIT); } if(params->dzeifactor<0){ fprintf(sp0,"parameter dzeifactor must be nonnegative\n"); exit(ABNORMAL_EXIT); } if(params->dzeiweight<0 || params->dzeiweight>1.0){ fprintf(sp0,"parameter dzeiweight must be between 0 and 1\n"); exit(ABNORMAL_EXIT); } if(params->dzlayfactor<0){ fprintf(sp0,"parameter dzlayfactor must be nonnegative\n"); exit(ABNORMAL_EXIT); } if(params->layconst<=0){ fprintf(sp0,"parameter layconst must be positive\n"); exit(ABNORMAL_EXIT); } if(params->layfalloffconst<0){ fprintf(sp0,"parameter layfalloffconst must be nonnegative\n"); exit(ABNORMAL_EXIT); } if(params->sigsqshortmin<=0){ fprintf(sp0,"parameter sigsqshortmin must be positive\n"); exit(ABNORMAL_EXIT); } if(params->sigsqlayfactor<0){ fprintf(sp0,"parameter sigsqlayfactor must be nonnegative\n"); exit(ABNORMAL_EXIT); } /* check deformation mode parameters */ if(params->defoazdzfactor<0){ fprintf(sp0,"parameter defoazdzfactor must be nonnegative\n"); exit(ABNORMAL_EXIT); } if(params->defothreshfactor<0){ fprintf(sp0,"parameter defothreshfactor must be nonnegative\n"); exit(ABNORMAL_EXIT); } if(params->defomax<0){ fprintf(sp0,"parameter defomax must be nonnegative\n"); exit(ABNORMAL_EXIT); } if(params->sigsqcorr<0){ fprintf(sp0,"parameter sigsqcorr must be nonnegative\n"); exit(ABNORMAL_EXIT); } if(params->defolayconst<=0){ fprintf(sp0,"parameter defolayconst must be positive\n"); exit(ABNORMAL_EXIT); } /* check algorithm parameters */ /* be sure to check for things that will cause type overflow */ /* or floating point exception */ if((params->initmaxflow)<1 && (params->initmaxflow)!=AUTOCALCSTATMAX){ fprintf(sp0,"initialization maximum flow must be positive\n"); exit(ABNORMAL_EXIT); } if((params->arcmaxflowconst)<1){ fprintf(sp0,"arcmaxflowconst must be positive\n"); exit(ABNORMAL_EXIT); } if((params->maxflow)<1){ fprintf(sp0,"maxflow must be positive\n"); exit(ABNORMAL_EXIT); } if(params->krowei<=0 || params->kcolei<=0){ fprintf(sp0,"averaging window sizes krowei and kcolei must be positive\n"); exit(ABNORMAL_EXIT); } if(params->kperpdpsi<=0 || params->kpardpsi<=0){ fprintf(sp0, "averaging window sizes kperpdpsi and kpardpsi must be positive\n"); exit(ABNORMAL_EXIT); } if(params->threshold<=0){ fprintf(sp0,"numerical solver threshold must be positive\n"); exit(ABNORMAL_EXIT); } if(params->initdzr<=0){ fprintf(sp0,"initdzr must be positive\n"); exit(ABNORMAL_EXIT); } if(params->initdzstep<=0){ fprintf(sp0,"initdzstep must be positive\n"); exit(ABNORMAL_EXIT); } if(params->maxcost>POSSHORTRANGE || params->maxcost<=0){ fprintf(sp0,"maxcost must be positive and within range or short int\n"); exit(ABNORMAL_EXIT);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -