Beispiel #1
0
local void setparams()
{
    input = getparam("in");
    ncol = nemoinpi(getparam("xcol"),col,MAXCOL);
    if (ncol < 0) error("parsing error col=%s",getparam("col"));
    
    nmax = nemo_file_lines(input,getiparam("nmax"));
    if (nmax<1) error("Problem reading from %s",input);

    instr = stropen (input,"r");
}
Beispiel #2
0
FunctionTable *ft_open(string fname, int mode, int xcol, int ycol)
{
    FunctionTable *ftp;
    stream instr;
    real *coldat[2];   /* 2, for X and Y columns */
    int n, colnr[2];

    ftp = (FunctionTable *) allocate(sizeof(FunctionTable));
    ftp->name = scopy(fname);
    ftp->mode  = mode;
    
    n = nemo_file_lines(fname,MAXLINES);  /* initial guess for number of points */
    if (n < 1) {
        warning("ft_open: No data can be read from %s",fname);
        return NULL;
    }
    /* allocate a bit conservatively */
    coldat[0] = ftp->x = (real *) allocate(n * sizeof(real));
    coldat[1] = ftp->y = (real *) allocate(n * sizeof(real));
    colnr[0] = xcol;
    colnr[1] = ycol;

    instr = stropen(fname,"r");
    ftp->n = get_atable(instr, 2, colnr, coldat, n);
    strclose(instr);
    
    if (ftp->n < 0) {
    	ftp->n = -ftp->n;
    	warning("Could only read %d data from file",ftp->n);
    }

    if (ftp->n < 1) {
        warning("ft_open: no data has been read from %s",fname);
        return NULL;
    }
    if (mode == FUNTAB_SPLINE) {
        ftp->coeff = (real *) allocate(3*ftp->n*sizeof(real));
        spline(ftp->coeff, ftp->x, ftp->y, ftp->n);        
    } else if (mode == FUNTAB_LINEAR) {
        ftp->coeff = NULL;
    } else {
        error("ft_open: wrong mode (%d)",mode);
    }

    ftp->errors = 0;

    return ftp;
}
Beispiel #3
0
setparams()
{
    string inname = getparam("in");
    nmax = nemo_file_lines(inname,getiparam("nmax"));
    if (nmax<0) error("Error opening %s",inname);
    if (nmax==0) error("No data?");
    instr = stropen (inname,"r");

    if (hasvalue("out"))
        outstr=stropen(getparam("out"),"w");
    else
        outstr=NULL;

    nxcol = nemoinpi(getparam("xcol"),xcolnr,MAXCOL);
    if (nxcol<0) error("Illegal xcol= nxcol=%d",nxcol);
    nycol = nemoinpi(getparam("ycol"),ycolnr,MAXCOL);
    if (nycol<0) error("Illegal ycol= nycol=%d",nycol);

    if (hasvalue("dxcol"))
        dxcolnr = getiparam("dxcol");
    else
        dxcolnr = 0;

    if (hasvalue("dycol"))
        dycolnr = getiparam("dycol");
    else
        dycolnr = 0;

    if (hasvalue("xrange"))
        setrange(xrange,getparam("xrange"));
    else {
        xrange[0] = -HUGE;
        xrange[1] = HUGE;
    } 
    
    method = getparam("fit");
    nsigma = getdparam("nsigma");
    order = getiparam("order");
    if (order<0) error("order=%d of %s cannot be negative",order,method);
    Qtab = getbparam("tab");

    mpfit_mode = getiparam("mpfit");
}
Beispiel #4
0
string *line_open_file(string fname) {
  stream istr;
  char *cp, line[MAX_LINELEN];
  int i, n;
  string *lines;

  n = nemo_file_lines(fname,0);
  lines = (string *) allocate((n+1)*sizeof(string));

  istr = stropen(fname,"r");
  for (i=0; i<n; i++) {
    if (fgets(line,MAX_LINELEN,istr) == NULL) error("short file");
    strip_newline(line);
    lines[i] = strdup(line);
  }
  lines[n] = 0;
  strclose(istr);
  return lines;
}
Beispiel #5
0
nemo_main()
{
  int i, j, nxcol, colnr[MAXCOL], nmax, npt;
  real xmin, xmax, *coldat[MAXCOL];
  string input;
  stream instr;

  input = getparam("in");                             /* input table filename */
  nmax = nemo_file_lines(input,getiparam("nmax"));             /* count lines */
  dprintf(0,"Allocated %d lines for table\n",nmax);

  nxcol = nemoinpi(getparam("xcol"),colnr,MAXCOL);   /* colum numbers to read */
  if (nxcol < 1) error("Error parsing xcol=%s",getparam("xcol"));

  dprintf(0,"Reading %d column(s): ",nxcol);
  for (j=0; j<nxcol; j++) {          /* loop allocating space for each column */
    dprintf(0," %d",colnr[j]);
    coldat[j] = (real *) allocate(sizeof(real)*nmax);
  }
  dprintf(0,"\n");

  instr = stropen(input,"r");                                    /* open file */
  npt = get_atable(instr,nxcol,colnr,coldat,nmax);                /* get data */
  if (npt < 0) {
    npt = -npt;
    warning("Could only read first set of %d data",npt);
  }
  dprintf(0,"Found %d lines in table\n",npt);
  
  xmin = xmax =  coldat[0][0];          /* set the min/max to the first data */
  for (j=0; j<nxcol; j++) {                        /*  loop over all columns */
    for (i=0; i<npt; i++) {                      /* and loop over all points */
      xmax=MAX(coldat[j][i],xmax);
      xmin=MIN(coldat[j][i],xmin);
    }
  }
  dprintf(0,"MinMax in the data: %g %g\n",xmin,xmax);
}
Beispiel #6
0
void nemo_main(void){
   int i,numwritten=0,nummissed=0;
   int numimages=0;
   stream fp_in,fp,fp2;
   string *sp,logic;
   int count,n;
   int edge_dist;             /* exclude sources this many pixels from the edge */
   string inFile;             /* name of input file */
   char line[MAX_LINELEN];    /* a line of text from the inFile */
   int racol,deccol,maxcol;   /* column numbers for ra/dec in file */
   double ra,dec;             /* the values of ra/dec for a given line */
   int nentries;              /* number of valid entries, used for progress tracking */

   inFile    = getparam("in");
   edge_dist = getiparam("edge");
   logic     = getparam("logic");

   sp = burststring(getparam("col"),", \n");
   n  = xstrlen(sp,sizeof(string)) - 1;
   if (n != 2) error("You must specify ra,dec columns for col keyword!");
   racol = natoi(sp[0]) - 1;
   deccol = natoi(sp[1]) - 1;
   freestrings(sp);
   if (racol >= deccol)
      maxcol = racol;
   else
      maxcol = deccol;


   sp = burststring(getparam("fits"),", \n");
   n  = xstrlen(sp,sizeof(string))-1;
   for (i=0; i<n; i++){
      ini_mask(sp[i],i);
      numimages++;
   }
   freestrings(sp);
   
   sp = burststring(getparam("out"),", \n");
   n  = xstrlen(sp,sizeof(string))-1;
   if (n == 1){
      fp  = stropen(sp[0],"w");
      fp2 = stropen("/dev/null","w!");
   } else if (n == 2){
      fp  = stropen(sp[0],"w");
      fp2 = stropen(sp[1],"w");
   }else
      error("You must give one or two output files!\n");
   freestrings(sp);

   nentries = nemo_file_lines(inFile,0);
   progress_init("overlap percent complete:",nentries);
   nentries = 0;
   
   fp_in = stropen(inFile,"r");
   while (fgets(line,MAX_LINELEN,fp_in)){
      progress_update(nentries);
      if (line[0] != '#'){
         nentries += 1;
         sp = burststring(line," \t\n");
         n  = xstrlen(sp,sizeof(string)) - 2; /* zero based */
         if (n < maxcol)
            error("Insufficient columns on line!");
         ra  = natof(sp[racol]);
         dec = natof(sp[deccol]);
         freestrings(sp);
         count = 0;
         for (i=0; i< numimages; i++)
            count+= is_edge(ra,dec,edge_dist,i);
         if(streq(logic,"or") && (count<numimages)){
            fprintf(fp,line);
            numwritten++;
         }
         else if(streq(logic,"and") && (count==0) && (numimages > 0)){
            fprintf(fp,line);
            numwritten++;
         }
         else {
            fprintf(fp2,line);
            nummissed++;
         }
      }
   }
   strclose(fp_in);
   strclose(fp);
   strclose(fp2);
   progress_finish();

   printf("Sources outside regions: %d\n",nummissed);
   printf("Sources inside regions: %d\n",numwritten);
   printf("Number of images: %d\n",numimages);
}
Beispiel #7
0
nemo_main()
{
  stream istr;
  float fval;
  double dval;
  int i, k, l, n, n2, iw, i1, i2, lineno, ival;
  string *sp, *idf0, *pars;
  char *cp, *cp1, line[MAX_LINELEN];
  bool Qline = getbparam("lineno");
  bool Qshow_idf;
  bool Qtype = getbparam("checktype");
  bool Qreport = getbparam("report");
  int argc, nidf, nidf2, nw, nopen, nrow;
  IDF *idf;
  string *argv, *av, *w;
  cstring *csp, *csn;
  
  if (hasvalue("idf")) {
    n = nemo_file_lines(getparam("idf"),0);
    dprintf(1,"%s : nlines=%d\n",getparam("idf"),n);
    idf0 = (string *) allocate((n+1)*sizeof(string));
    istr = stropen(getparam("idf"),"r");
    for (i=0; i<n; i++) {
      if (fgets(line,MAX_LINELEN,istr) == NULL) error("short file");
      strip_newline(line);
      idf0[i] = strdup(line);
    }
    idf0[n] = 0;
    strclose(istr);
  } else {
    warning("Testing IDF");
    idf0 = testidf;
  }

  /* report, and pre-parse and count the true IDF's */

  dprintf(1,"report IDF\n");
  Qshow_idf = !hasvalue("out");
  nidf = 0;
  for (sp = idf0, lineno=0; *sp; sp++) {
    if (*sp[0] == '#') continue;
    lineno++;
    if (Qshow_idf) {
      if (Qline)
	printf("%d: %s\n",lineno,*sp);	
      else
	printf("%s\n",*sp);	
    }
    w = burststring(*sp," \t");
    nw = xstrlen(w,sizeof(string))-1;
    for (i=0; i<nw; i++) {
      if (*w[i] == '#') break;
      cp = strchr(w[i],':');
      if (cp==NULL) error("Missing : on %s",w[i]);
      nidf++;
    }
  } 
  dprintf(0,"Found %d IDF_parameters in %d lines in idf file\n",nidf,lineno);

  /* now fully parse IDF */

  idf = (IDF *) allocate(nidf*sizeof(IDF));
  nidf2 = 0;
  nopen = 0;
  nrow = 0;
  for (sp = idf0; *sp; sp++) {
    if (*sp[0] == '#') continue;
    nrow++;
    if (nopen) error("Cannot handle any parameters after an open ended array");
    w = burststring(*sp," \t");
    nw = xstrlen(w,sizeof(string))-1;
    for (i=0; i<nw; i++) {
      if (*w[i] == '#') break;
      cp = strchr(w[i],':');
      if (cp==NULL) error("Missing : on %s",w[i]);
      *cp++ = 0;
      /* now w[i] points to type; cp to keyword, possibly with a [] */
      idf[nidf2].type = strdup(w[i]);
      idf[nidf2].key  = strdup(cp);
      idf[nidf2].row  = nrow;
      idf[nidf2].col  = i+1;
      cp1 = strchr(cp,'[');
      if (cp1) {
	*cp1++ = 0;
	idf[nidf2].key  = strdup(cp);
	if (*cp1 == ']') {
	  if (nopen) error("Cannot handle more than one open ended array");
	  idf[nidf2].nvals = 0;
	  nopen++;
	} else
	  error("fixed dimensioned arrays not allowed yet : %s",cp);
      } else {
	idf[nidf2].key   = strdup(cp);
	idf[nidf2].nvals = -1;
      }
      nidf2++;
    }
  }
  if (nidf2 != nidf) error("nidf2=%d != nidf=%d\n",nidf2,nidf);


  /* report the full IDF */

  if (Q) {
      for (i=0; i<nidf; i++) {
      dprintf(1,"###: [%d,%d] %s %s\n", idf[i].row, idf[i].col, idf[i].type, idf[i].key);
    }
  }

  if (hasvalue("par")) {
    pars = line_open_file(getparam("par"));
    n2 = xstrlen(pars,sizeof(string))-1;
    dprintf(0,"Found %d lines in par file\n",n2);
    if (Q)
      if (n2 != lineno) warning("par file not same as idf");

    for (l=0, i=0; l<n2; l++) {    /* loop over all lines :   l counts lines, i counts idf's */
      /*  idf[i] is the current IDF */
      /*  pars[l] is the current line */
      /*  idf[i].row should match the current line */


      /* a comment spans (by definition) the whole line */
      if (i<nidf && streq(idf[i].type,IDF_COMMENT)) {
	  idf[i].out = strdup(pars[l]);
	  idf[i].cout.val = strdup(pars[l]);
	  idf[i].cout.nxt = 0;
	  i++;
	  continue;
      } 
      /* for now any types are not comments, and so treated same way */
      w = burststring(pars[l]," \t");
      nw = xstrlen(w,sizeof(string))-1;

#if 1
      /* just do it, no checking */
      for (iw=0; iw<nw; iw++) {
	if (*w[iw] == '#') break;
	if (i < nidf) {
	  idf[i].out = strdup(w[iw]);
	  idf[i].cout.val = strdup(w[iw]);
	  idf[i].cout.nxt = 0;
	} else {
	  if (nopen==0) error("Too many values, and no open ended array");

	  csn = (cstring *) allocate(sizeof(cstring));
	  csn->val = strdup(w[iw]);
	  csn->nxt = 0;

	  csp = &idf[nidf-1].cout;
	  while (csp->nxt)
	    csp = csp->nxt;
	  csp->nxt = csn;
	}
	i++;
      }
      if (Q) {
	if (i==nidf) {
	  warning("end of idf %d %d",l,n2);
	  if (l<n2-1) warning("not exhausting lines in par file");
	}
      }
#else
      /* messy double checking */
      for (i1=i; i<nidf && idf[i1].row==idf[i].row; i1++) {
	dprintf(0,"i=%d i1=%d row=%d row1=%d\n",i,i1,idf[i].row,idf[i1].row);
      }
      n2 = i1-i;
      if (nw != n2) error("nw=%d != n2=%d i=%d l=%d (%s)",nw,n2,i,l,pars[l]);
      for (i1=i, iw=0; i<nidf && idf[i1].row==idf[i].row; i1++, iw++) {
	idf[i1].out = strdup(w[iw]);
      }
#endif
    }

    if (Q) {
      for (i=0; i<nidf; i++) {
	printf("###: [%d,%d] %-3s %-10s = %s\n", idf[i].row, idf[i].col, idf[i].type, idf[i].key, idf[i].out);
      }
    }
  }

  /* report the command line tail after the -- */

  dprintf(1,"getargv\n");
  argv = getargv(&argc);
  dprintf(1,"  argc=%d\n",argc);
  if (argc>0) {
    argv++; /* skip the -- */
    if (Qtype) warning("Type checking not implemented yet");
    for (av = argv; *av; av++) {
      if (Q) printf("arg: %s\n",*av);
      cp = strchr(*av,'=');
      if (cp) {
	*cp++ = 0;
	for (i=0; i<nidf; i++) {
	  if (streq(*av,idf[i].key)) {
	    dprintf(1,"Patching key=%s with val=%s\n",*av,cp);
	    if (idf[i].nvals < 0) {
	      idf[i].out      = strdup(cp);
	      idf[i].cout.val = strdup(cp);
	      idf[i].cout.nxt = 0;
	    } else {
	      w = burststring(cp," ,");
	      nw = xstrlen(w,sizeof(string))-1;
	      idf[i].out      = strdup(w[0]);
	      idf[i].cout.val = strdup(cp);
	      idf[i].cout.nxt = 0;
	      csn = &idf[i].cout;
	      for (iw=0; iw<nw; iw++) {
		csn->val = strdup(w[iw]);
		if (iw<nw-1) {
  		  csn->nxt = (cstring *) allocate(sizeof(cstring));
		  csn = csn->nxt;
		} else
		  csn->nxt = 0;
	      }
	    }
	    break;
	  }
	}
	if (i==nidf) error("%d: key=%s not registered in IDF",i,*av);
      } else {
	error("cannot handle arugments yet that are not key=val");
      }
    }
  }

  if (Q) {
    for (i=0; i<nidf; i++) {
      printf(">>>: [%d,%d] %-3s %-10s = %s\n", idf[i].row, idf[i].col, idf[i].type, idf[i].key, idf[i].out);
    }
  }
  
  if (hasvalue("out")) {
    istr = stropen(getparam("out"),"w");
    for (i=0; i<nidf; i++) {
      if (i>0 && idf[i].row != idf[i-1].row) 
	fprintf(istr,"\n");
      if (idf[i].col > 1) fprintf(istr," ");
      if (streq(idf[i].type,"qs") && idf[i].out[0] != '\'')
	fprintf(istr,"'%s'",idf[i].out);
      else
	fprintf(istr,"%s",idf[i].out);

    }
    fprintf(istr,"\n");
    if (nopen) {
      csp = idf[nidf-1].cout.nxt;
      while (csp) {
	fprintf(istr,"%s\n",csp->val);	
	csp = csp->nxt;
      }
    }
    strclose(istr);
  }

  if (Qreport) {
    for (i=0; i<nidf; i++) {
      printf("%s=%s\n",idf[i].key,idf[i].out);
    }
  }

}
Beispiel #8
0
void nemo_main()
{
  int colnr[2];
  real *coldat[2], *xdat, *ydat, xmin, xmax, ymin, ymax;
  real *udat, *vdat, umin, umax, vmin, vmax;
  real x, y1, y2, dx, xscale, yscale, xQmin, xQmax;
  real tbb,sum,sum0;
  stream instr, tabstr;
  int i, n, ns, nmax;
  real *sdat, *spdat;
  string spectrum, filter = filtername(getparam("filter"));
  bool Qnorm = getbparam("normalize");
  bool Qmin = hasvalue("xmin");
  bool Qmax = hasvalue("xmax");
  bool Qtab = hasvalue("out");
  
  nmax = nemo_file_lines(filter,MAXLINES);
  xdat = coldat[0] = (real *) allocate(nmax*sizeof(real));
  ydat = coldat[1] = (real *) allocate(nmax*sizeof(real));
  colnr[0] = 1;  /* wavelenght in angstrom */
  colnr[1] = 2;  /* normalized filter response [0,1] */
  instr = stropen(filter,"r");
  n = get_atable(instr,2,colnr,coldat,nmax);
  strclose(instr);

  if (Qtab) tabstr = stropen(getparam("out"),"w");
  
  for(i=0; i<n; i++) {
    dprintf(2,"%g %g\n",xdat[i],ydat[i]);
    if (i==0) {
      xmin = xmax = xdat[0];
      ymin = ymax = ydat[0];
    } else {
      if (xdat[i] <= xdat[i-1]) 
	error("Filter %s must be sorted in wavelength",filter);
      xmax = MAX(xmax,xdat[i]);
      ymax = MAX(ymax,ydat[i]);
      xmin = MIN(xmin,xdat[i]);
      ymin = MIN(ymin,ydat[i]);
    }
  }
  dprintf(1,"Filter wavelength range: %g : %g\n",xmin,xmax);
  dprintf(1,"Filter response range: %g : %g\n",ymin,ymax);
  if (ydat[0]   != 0) warning("lower edge filter response not 0: %g",ydat[0]);
  if (ydat[n-1] != 0) warning("upper edge filter response not 0: %g",ydat[n-1]);
  dx = getdparam("step");
  if ((xmax-xmin)/100 < dx) {
    warning("Integration step %g in Angstrom too large, resetting to %g",
	    dx, (xmax-xmin)/100);
    dx = (xmax-xmin)/100;
  }
  
  /* setup a spline interpolation table into the filter */
  sdat = (real *) allocate(sizeof(real)*n*3);
  spline(sdat,xdat,ydat,n);

  if (Qmin) {                  /* override any min/max rules ? */
    xQmin = getdparam("xmin");
    if (xQmin > xmin) warning("xmin=%g greater than minimum in filter (%g)",xQmin,xmin);
  }
  if (Qmax) {
    xQmax = getdparam("xmax");
    if (xQmax < xmax) warning("xmax=%g less than maximum in filter (%g)",xQmax,xmax);
  }

  if (hasvalue("tbb")) {                /* using a Planck curve */
    tbb = getdparam("tbb");
    if (Qmin) xmin = xQmin;
    if (Qmax) xmax = xQmax;

    sum = sum0 = 0;
    for (x = xmin; x <= xmax; x += dx) {
      y1 = seval(x,xdat,ydat,sdat,n);    /* filter */
      y2 = planck(x,tbb);
      dprintf(3,"%g %g %g\n",x,y1,y2);
      if (Qtab) fprintf(tabstr,"%g %g\n",x,MAX(DATAMIN,y1*y2));
      sum += y1*y2;
      sum0 += y1;
    }
    if (Qnorm)
      sum /= sum0;
    else
      sum *= dx;
    if (Qtab)
      dprintf(0,"%g %g %g\n",tbb,sum,-2.5*log10(sum));
    else
      printf("%g %g %g\n",tbb,sum,-2.5*log10(sum));

  } else if (hasvalue("spectrum")) {

    warning("spectrum= is a new feature");
    spectrum = getparam("spectrum");
    nmax = nemo_file_lines(spectrum,MAXLINES);
    udat = coldat[0] = (real *) allocate(nmax*sizeof(real));
    vdat = coldat[1] = (real *) allocate(nmax*sizeof(real));
    colnr[0] = getiparam("xcol");
    colnr[1] = getiparam("ycol");
    instr = stropen(spectrum,"r");
    ns = get_atable(instr,2,colnr,coldat,nmax);
    strclose(instr);

    xscale = getdparam("xscale");
    yscale = getdparam("yscale");

    for(i=0; i<ns; i++) {
      dprintf(2,"%g %g\n",udat[i],vdat[i]);
      udat[i] *= xscale;
      vdat[i] *= yscale;
      if (i==0) {
	umin = umax = udat[0];
	vmin = vmax = vdat[0];
      } else {
	if (udat[i] <= udat[i-1])
	  error("Spectrum %s must be sorted in wavelength",spectrum);
	umax = MAX(umax,udat[i]);
	vmax = MAX(vmax,vdat[i]);
	umin = MIN(umin,udat[i]);
	vmin = MIN(vmin,vdat[i]);
      }
    }
    dprintf(1,"Spectrum wavelength range: %g : %g\n",umin,umax);
    dprintf(1,"Spectrum response range: %g : %g\n",vmin,vmax);

    if (umax < xmin || umin >xmax)
      error("Spectrum and filter do not overlap");

    /* setup a spline interpolation table into the spectrum */
    spdat = (real *) allocate(sizeof(real)*n*3);
    spline(spdat,udat,vdat,ns);

    sum = sum0 = 0;
    if (Qmin) xmin = xQmin;
    if (Qmax) xmax = xQmax;
    for (x = xmin; x <= xmax; x += dx) {
      y1 = seval(x,xdat,ydat,sdat,n);    /* filter */
      if (umin < x && x <umax)
	y2 = seval(x,udat,vdat,spdat,ns);  /* spectrum */
      else
	y2 = 0.0;
      dprintf(3,"%g %g %g\n",x,y1,y2);
      if (Qtab) fprintf(tabstr,"%g %g\n",x,MAX(DATAMIN,y1*y2));
      sum += y1*y2;
      sum0 += y1;
    }
    if (Qnorm)
      sum /= sum0;
    else
      sum *= dx;
    if (Qtab)
      dprintf(0,"0   %g %g\n",sum,-2.5*log10(sum));
    else
      printf("0   %g %g\n",sum,-2.5*log10(sum));

  } else
    warning("Either spectrum= or tbb= must be used");
}
Beispiel #9
0
local void setparams()
{
    input = getparam("in");
    ncol = nemoinpi(getparam("xcol"),col,MAXCOL);
    if (ncol < 0) error("parsing error col=%s",getparam("col"));
    if (hasvalue("out")) outstr=stropen(getparam("out"),"w");
    else outstr = NULL;

    nsteps = nemoinpd(getparam("bins"),bins,MAXHIST+1) - 1;
    if (nsteps == 0) {
      Qbin = FALSE;
      Qmin = hasvalue("xmin");
      Qmax = hasvalue("xmax");
      nsteps=getiparam("bins");
      if (nsteps > MAXHIST) 
        error("bins=%d too large; MAXHIST=%d",nsteps,MAXHIST);
      if (Qmin) xrange[0] = getdparam("xmin");
      if (Qmax) xrange[1] = getdparam("xmax");
      if (Qmin && Qmax && xrange[0] >= xrange[1]) error("Need xmin < xmax");
    } else if (nsteps > 0) {
      Qbin = TRUE;
      Qmin = TRUE;
      Qmax = TRUE;
      xrange[0] = hasvalue("xmin") ?  getdparam("xmin") : bins[0];
      xrange[1] = hasvalue("xmax") ?  getdparam("xmax") : bins[nsteps];
      warning("new mode: manual bins=%s",getparam("bins"));
    } else
      error("no proper usage for bins=%s",getparam("bins"));
    Qauto = (!Qmin || !Qmax) ;
    Qmad = getbparam("mad");

    maxcount=getiparam("maxcount");
    headline = getparam("headline");
    ylog=getbparam("ylog");
    xlab=getparam("xlab");
    ylab=getparam("ylab");
    Qgauss = getbparam("gauss");
    Qresid = getbparam("residual");
    Qtab = getbparam("tab");
    Qcumul = getbparam("cumul");
    if (Qcumul) {
        Qgauss=Qresid=FALSE;
        ylog=FALSE;
    }
    Qmedian = getbparam("median");
    Qtorben = getbparam("torben");
    if (Qtorben) Qmedian=FALSE;
    Qrobust = getbparam("robust");
    if (ylog && streq(ylab,"N")) ylab = scopy("log(N)");
    Qdual = getbparam("dual");

    nmax = nemo_file_lines(input,getiparam("nmax"));
    if (nmax<1) error("Problem reading from %s",input);

    nxcoord = nemoinpr(getparam("xcoord"),xcoord,MAXCOORD);

    nsigma = getdparam("nsigma");
    mysort = getsort(getparam("sort"));
    scale = getrparam("scale");
    if (scale != 1.0) {
      int n1=strlen(xlab);
      string s2 = getparam("scale");
      int n2=strlen(s2);
      xlab2 = (string) allocate(n1+n2+20);
      sprintf(xlab2,"%s [scale *%s]",xlab,s2);
      xlab = xlab2;
    }
    instr = stropen (input,"r");
}