⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 snaphu_io.c

📁 phase unwrapping algorithm for SAR interferometry
💻 C
📖 第 1 页 / 共 5 页
字号:
  }  if(params->costscale<=0){    fprintf(sp0,"cost scale factor costscale must be positive\n");    exit(ABNORMAL_EXIT);  }  if(params->p<0 && params->p!=PROBCOSTP){    fprintf(sp0,"Lp-norm parameter p should be nonnegative\n");    exit(ABNORMAL_EXIT);  }  if((params->costmode==TOPO && params->maxflow*params->nshortcycle)     >POSSHORTRANGE){    fprintf(sp0,"maxflow exceeds range of short int for given nshortcycle\n");    exit(ABNORMAL_EXIT);  }  if(params->costmode==DEFO && ceil(params->defomax*params->nshortcycle)     >POSSHORTRANGE){    fprintf(sp0,"defomax exceeds range of short int for given nshortcycle\n");    exit(ABNORMAL_EXIT);  }  if(params->maxnewnodeconst<=0 || params->maxnewnodeconst>1){    fprintf(sp0,"maxnewnodeconst must be between 0 and 1\n");    exit(ABNORMAL_EXIT);  }  if(params->sourcemode>1 || params->sourcemode<-1){    fprintf(sp0,"sourcemode must be -1, 0, or 1\n");    exit(ABNORMAL_EXIT);  }  if(infiles->infileformat!=FLOAT_DATA || strlen(infiles->magfile)){    params->havemagnitude=TRUE;  }else{    params->havemagnitude=FALSE;  }  if(params->maxnflowcycles==USEMAXCYCLEFRACTION){    params->maxnflowcycles=LRound(params->maxcyclefraction				   *nlines/(double )params->ntilerow				   *linelen/(double )params->ntilecol);  }  if(params->initmaxflow==AUTOCALCSTATMAX      && !(params->ntilerow==1 && params->ntilecol==1)){    fprintf(sp0,"initial maximum flow cannot be calculated automatically in "	    "tile mode\n");    exit(ABNORMAL_EXIT);  }#ifdef NO_CS2  if(params->initmethod==MCFINIT && !params->unwrapped){    fprintf(sp0,"program not compiled with cs2 MCF solver module\n");    exit(ABNORMAL_EXIT);  }    #endif    /* tile parameters */  if(params->ntilerow<1 || params->ntilecol<1){    fprintf(sp0,"numbers of tile rows and columns must be positive\n");    exit(ABNORMAL_EXIT);  }  if(params->rowovrlp<0 || params->colovrlp<0){    fprintf(sp0,"tile overlaps must be nonnegative\n");    exit(ABNORMAL_EXIT);  }  if(params->ntilerow>1 || params->ntilecol>1){    ni=ceil((nlines+(params->ntilerow-1)*params->rowovrlp)	    /(double )params->ntilerow);    nj=ceil((linelen+(params->ntilecol-1)*params->colovrlp)	    /(double )params->ntilecol);    if(params->p>=0){      fprintf(sp0,"tile mode not enabled for Lp costs\n");      exit(ABNORMAL_EXIT);    }    if(params->ntilerow+params->rowovrlp > nlines        || params->ntilecol+params->colovrlp > linelen       || params->ntilerow*params->ntilerow > nlines       || params->ntilecol*params->ntilecol > linelen){      fprintf(sp0,"tiles too small or overlap too large for given input\n");      exit(ABNORMAL_EXIT);    }    if(params->minregionsize        > ((nlines-(params->ntilerow-1)*(ni-params->rowovrlp))	  *(linelen-(params->ntilecol-1)*(nj-params->colovrlp)))){      fprintf(sp0,"minimum region size too large for given tile parameters\n");      exit(ABNORMAL_EXIT);    }    if(TMPTILEOUTFORMAT!=ALT_LINE_DATA && TMPTILEOUTFORMAT!=FLOAT_DATA){      fprintf(sp0,"unsupported TMPTILEOUTFORMAT value in complied binary\n");      exit(ABNORMAL_EXIT);    }    if(TMPTILEOUTFORMAT==FLOAT_DATA && outfiles->outfileformat!=FLOAT_DATA){      fprintf(sp0,"precompiled tile format precludes given output format\n");      exit(ABNORMAL_EXIT);    }    if(params->scndryarcflowmax<1){      fprintf(sp0,"parameter scndryarcflowmax too small\n");      exit(ABNORMAL_EXIT);    }    if(params->initonly){      fprintf(sp0,	      "initialize-only mode and tile mode are mutually exclusive\n");      exit(ABNORMAL_EXIT);    }    if(strlen(outfiles->conncompfile)){      fprintf(sp0,	      "connected components output not yet supported for tile mode\n");      exit(ABNORMAL_EXIT);    }    if(params->assembleonly){      n=strlen(params->tiledir);      while(--n>0 && params->tiledir[n]=='/'){	params->tiledir[n]='\0';      }      if(!strlen(params->tiledir)){	fprintf(sp0,"tile directory name cannot have zero length\n");	exit(ABNORMAL_EXIT);      }      if(!strcmp(params->tiledir,"/")){	StrNCopy(params->tiledir,"",MAXSTRLEN);      }    }    if(params->piecefirstrow!=DEF_PIECEFIRSTROW        || params->piecefirstcol!=DEF_PIECEFIRSTCOL       || params->piecenrow!=DEF_PIECENROW       || params->piecencol!=DEF_PIECENCOL){      fprintf(sp0,"piece-only mode cannot be used with multiple tiles\n");      exit(ABNORMAL_EXIT);    }  }else{    if(params->assembleonly){      fprintf(sp0,"assemble-only mode can only be used with multiple tiles\n");      exit(ABNORMAL_EXIT);    }    if(params->nthreads>1){      fprintf(sp0,"only one tile--disregarding multiprocessor option\n");    }    if(params->rowovrlp || params->colovrlp){      fprintf(sp0,"only one tile--disregarding tile overlap values\n");    }    params->piecefirstrow--;                   /* index from 0 instead of 1 */    params->piecefirstcol--;                   /* index from 0 instead of 1 */    if(!params->piecenrow){      params->piecenrow=nlines;    }    if(!params->piecencol){      params->piecencol=linelen;    }    if(params->piecefirstrow<0 || params->piecefirstcol<0        || params->piecenrow<1 || params->piecencol<1       || params->piecefirstrow+params->piecenrow>nlines       || params->piecefirstcol+params->piecencol>linelen){      fprintf(sp0,"illegal values for piece of interferogram to unwrap\n");      exit(ABNORMAL_EXIT);    }  }  if(params->nthreads<1){    fprintf(sp0,"number of processors must be at least one\n");    exit(ABNORMAL_EXIT);  }else if(params->nthreads>MAXTHREADS){    fprintf(sp0,"number of processors exceeds precomplied limit of %d\n",	    MAXTHREADS);    exit(ABNORMAL_EXIT);  }  /* connected component parameters */  if(params->regrowconncomps){    if(!strlen(outfiles->conncompfile)){      fprintf(sp0,"no connected component output file specified\n");      exit(ABNORMAL_EXIT);    }          params->unwrapped=TRUE;  }  if(params->minconncompfrac<0 || params->minconncompfrac>1){    fprintf(sp0,"illegal value for minimum connected component fraction\n");    exit(ABNORMAL_EXIT);  }  if(params->maxncomps<=0){    fprintf(sp0,"illegal value for maximum number of  connected components\n");    exit(ABNORMAL_EXIT);  }  if(strlen(outfiles->conncompfile)){    if(params->initonly){      fprintf(sp0,"WARNING: connected component mask cannot be generated "	      "in initialize-only mode\n         mask will not be output\n");      StrNCopy(outfiles->conncompfile,"",MAXSTRLEN);    }    if(params->costmode==NOSTATCOSTS){      fprintf(sp0,"WARNING: connected component mask cannot be generated "	      "without statistical costs\n         mask will not be output\n");      StrNCopy(outfiles->conncompfile,"",MAXSTRLEN);    }  }  /* set global pointers to functions for calculating and evaluating costs */  if(params->p<0){    if(params->costmode==TOPO){      CalcCost=CalcCostTopo;      EvalCost=EvalCostTopo;    }else if(params->costmode==DEFO){      CalcCost=CalcCostDefo;      EvalCost=EvalCostDefo;    }else if(params->costmode==SMOOTH){      CalcCost=CalcCostSmooth;      EvalCost=EvalCostSmooth;    }  }else{    if(params->p==0){      CalcCost=CalcCostL0;      EvalCost=EvalCostL0;    }else if(params->p==1){      CalcCost=CalcCostL1;      EvalCost=EvalCostL1;    }else if(params->p==2){      CalcCost=CalcCostL2;      EvalCost=EvalCostL2;    }else{      CalcCost=CalcCostLP;      EvalCost=EvalCostLP;    }  }}/* function: ReadConfigFile() * -------------------------- * Read in parameter values from a file, overriding existing parameters. */void ReadConfigFile(char *conffile, infileT *infiles, outfileT *outfiles,		    long *linelenptr, paramT *params){    long nlines, nparams, nfields;  FILE *fp;  char buf[MAXLINELEN];  char str1[MAXLINELEN], str2[MAXLINELEN];  char *ptr;  signed char badparam;  /* open input config file */  if(strlen(conffile)){    if((fp=fopen(conffile,"r"))==NULL){      /* abort if we were given a non-zero length name that is unreadable */      fprintf(sp0,"unable to read configuration file %s\n",conffile);      exit(ABNORMAL_EXIT);    }  }else{        /* if we were given a zero-length name, just ignore it and go on */    return;  }  /* read each line and convert the first two fields */  nlines=0;  nparams=0;  badparam=FALSE;  while(TRUE){    /* read a line from the file and store it in buffer buf */    buf[0]='\0';    ptr=fgets(buf,MAXLINELEN,fp);    /* break when we read EOF without reading any text */    if(ptr==NULL && !strlen(buf)){      break;    }    nlines++;    /* make sure we got the whole line */    if(strlen(buf)>=MAXLINELEN-1){      fprintf(sp0,"line %ld in file %s exceeds maximum line length\n",	      nlines,conffile);      exit(ABNORMAL_EXIT);    }          /* read the first two fields */    /* (str1, str2 same size as buf, so can't overflow them */    nfields=sscanf(buf,"%s %s",str1,str2);    /* if only one field is read, and it is not a comment, we have an error */    if(nfields==1 && isalnum(str1[0])){      fprintf(sp0,"unrecognized configuration parameter '%s' (%s:%ld)\n",	      str1,conffile,nlines);      exit(ABNORMAL_EXIT);    }    /* if we have (at least) two non-comment fields */    if(nfields==2 && isalnum(str1[0])){      /* do the conversions */      nparams++;      if(!strcmp(str1,"INFILE")){	StrNCopy(infiles->infile,str2,MAXSTRLEN);      }else if(!strcmp(str1,"OUTFILE")){	StrNCopy(outfiles->outfile,str2,MAXSTRLEN);      }else if(!strcmp(str1,"WEIGHTFILE")){	StrNCopy(infiles->weightfile,str2,MAXSTRLEN);      }else if(!strcmp(str1,"AMPFILE") || !strcmp(str1,"AMPFILE1")){	if(strlen(infiles->ampfile2) && !params->amplitude){	  fprintf(sp0,"cannot specify both amplitude and power\n");	  exit(ABNORMAL_EXIT);	}	StrNCopy(infiles->ampfile,str2,MAXSTRLEN);      }else if(!strcmp(str1,"AMPFILE2")){	if(strlen(infiles->ampfile) && !params->amplitude){	  fprintf(sp0,"cannot specify both amplitude and power\n");	  exit(ABNORMAL_EXIT);	}	StrNCopy(infiles->ampfile2,str2,MAXSTRLEN);	infiles->ampfileformat=FLOAT_DATA;      }else if(!strcmp(str1,"PWRFILE") || !strcmp(str1,"PWRFILE1")){	if(strlen(infiles->ampfile2) && params->amplitude){	  fprintf(sp0,"cannot specify both amplitude and power\n");	  exit(ABNORMAL_EXIT);	}		StrNCopy(infiles->ampfile,str2,MAXSTRLEN);	params->amplitude=FALSE;      }else if(!strcmp(str1,"PWRFILE2")){	if(strlen(infiles->ampfile) && params->amplitude){	  fprintf(sp0,"cannot specify both amplitude and power\n");	  exit(ABNORMAL_EXIT);	}		StrNCopy(infiles->ampfile2,str2,MAXSTRLEN);	params->amplitude=FALSE;	infiles->ampfileformat=FLOAT_DATA;      }else if(!strcmp(str1,"MAGFILE")){	StrNCopy(infiles->magfile,str2,MAXSTRLEN);      }else if(!strcmp(str1,"CORRFILE")){	StrNCopy(infiles->corrfile,str2,MAXSTRLEN);      }else if(!strcmp(str1,"ESTIMATEFILE")){	StrNCopy(infiles->estfile,str2,MAXSTRLEN);      }else if(!strcmp(str1,"LINELENGTH") || !strcmp(str1,"LINELEN")){	badparam=StringToLong(str2,linelenptr);      }else if(!strcmp(str1,"STATCOSTMODE")){	if(!strcmp(str2,"TOPO")){	  params->costmode=TOPO;	}else if(!strcmp(str2,"DEFO")){	  params->costmode=DEFO;	}else if(!strcmp(str2,"SMOOTH")){	  params->costmode=SMOOTH;	}else if(!strcmp(str2,"NOSTATCOSTS")){	  params->costmode=NOSTATCOSTS;	}else{	  badparam=TRUE;	}      }else if(!strcmp(str1,"INITONLY")){	badparam=SetBooleanSignedChar(&(params->initonly),str2);      }else if(!strcmp(str1,"UNWRAPPED_IN")){	badparam=SetBooleanSignedChar(&(params->unwrapped),str2);      }else if(!strcmp(str1,"DEBUG") || !strcmp(str1,"DUMPALL")){	badparam=SetBooleanSignedChar(&(params->dumpall),str2);      }else if(!strcmp(str1,"VERBOSE")){	badparam=SetBooleanSignedChar(&(params->verbose),str2);      }else if(!strcmp(str1,"INITMETHOD")){	if(!strcmp(str2,"MST") || !strcmp(str2,"mst")){	  params->initmethod=MSTINIT;	}else if(!strcmp(str2,"MCF") || !strcmp(str2,"mcf") 		 || !strcmp(str2,"CS2") || !strcmp(str2,"cs2")){	  params->initmethod=MCFINIT;	}else{	  badparam=TRUE;	}      }else if(!strcmp(str1,"ORBITRADIUS")){	if(!(badparam=StringToDouble(str2,&(params->orbitradius)))){	  params->altitude=0;	}      }else if(!strcmp(str1,"ALTITUDE")){	if(!(badparam=StringToDouble(str2,&(params->altitude)))){	  params->orbitradius=0;	}      }else if(!strcmp(str1,"EARTHRADIUS")){	badparam=StringToDouble(str2,&(params->earthradius));      }else if(!strcmp(str1,"BPERP")){	badparam=StringToDouble(str2,&(params->bperp));      }else if(!strcmp(str1,"TRANSMITMODE")){	if(!strcmp(str2,"PINGPONG") || !strcmp(str2,"REPEATPASS")){	  params->transmitmode=PINGPONG;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -