コード例 #1
0
ファイル: AspUtil.C プロジェクト: timburrow/ovj3
int AspUtil::getParSize(string parName) {
   const char *cname = parName.c_str();
   vInfo  info;
   if (!(P_getVarInfo(CURRENT,cname,&info)) ) return info.size; 
   else if (!(P_getVarInfo(GLOBAL,cname,&info)) ) return info.size; 
   else return 0; 
}
コード例 #2
0
ファイル: dfww.c プロジェクト: timburrow/ovj3
static int setspecmaxmin()
/********************/
{
    vInfo  info;
    double cutoff;

    specmax = mnumypnts - 3;
    specmin = mnumypnts - 3;
    if (P_getVarInfo(CURRENT,"cutoff",&info))
        return(COMPLETE);
    if (info.active == ACT_OFF)
        return(COMPLETE);
    P_getreal(CURRENT,"cutoff",&cutoff,1);
    if (cutoff < 2.0)
        cutoff = 2.0;
    if (info.size == 2)
    {
        specmax = (int) (dispcalib * cutoff);
        P_getreal(CURRENT,"cutoff",&cutoff,2);
        if (cutoff < 0.0)
            cutoff = 0.0;
        specmin = (int) (dispcalib * cutoff);
    }
    else if (info.size == 1)
    {
        specmax = (int) (dispcalib * cutoff);
        specmin = (int) (dispcalib * cutoff);
    }
    if (specmax > mnumypnts - 3)
        specmax = mnumypnts - 3;
    if (specmin < 0)
        specmin = 0;
    return(COMPLETE);
}
コード例 #3
0
ファイル: dpf.c プロジェクト: DanIverson/OpenVnmrJ
static int check_int(int *number)
/********************/
{
  vInfo  info;
  char   intmod[9];
  int    res;
  
  *number = ((P_getVarInfo(CURRENT,"liamp",&info)) ? 0 : info.size);
  if ( (res=P_getstring(CURRENT,"intmod",intmod,1,8)) )
  { P_err(res,"intmod",":"); ABORT; }
  return(!(strcmp(intmod,INT_FULL))); 
}
コード例 #4
0
ファイル: treefuncs.c プロジェクト: timburrow/ovj3
/*------------------------------------------------------------------------------
|
|	parmult(tree,name)
|
|	This function returns the multiplier of a real parameter
+----------------------------------------------------------------------------*/
double parmult(int tree, const char *name)
{
   int             ret;
   vInfo           varinfo;	/* variable information structure */

   if ( (ret = P_getVarInfo(tree, name, &varinfo)) )
   {
      text_error("parmult(): cannot find variable %s", name);
      if (bgflag)
	 P_err(ret, name, ": ");
      return (-1.0);
   }
   return( (varinfo.subtype == ST_PULSE) ? 1e-6 : 1.0);
}
コード例 #5
0
ファイル: treefuncs.c プロジェクト: timburrow/ovj3
/*------------------------------------------------------------------------------
|
|	whattype(tree,name)
|
|	This function returns the address of a real value of a variable based on
+----------------------------------------------------------------------------*/
int whattype(int tree, const char *name)
{
   int             ret;
   vInfo           varinfo;	/* variable information structure */
   char            mess[MAXSTR];

   if ( (ret = P_getVarInfo(tree, name, &varinfo)) )
   {
      sprintf(mess, "Cannot find the variable: %s", name);
      text_error(mess);
      if (bgflag)
	 P_err(ret, name, ": ");
      return (-1);
   }
   return (varinfo.basicType);
}
コード例 #6
0
ファイル: bootup.c プロジェクト: timburrow/ovj3
int jcurwin_jexp(int expnum, int oldexpnum )
{
    int index, get1, get2, retval=1;
    double dval;
    vInfo info; /* int VnmrJViewId */
    char path[MAXSTR];
    struct stat     stat_blk;

    (void) oldexpnum;
    if (mode_of_vnmr==AUTOMATION) /* || (mode_of_vnmr==BACKGROUND) */ 
      return(retval);

    if (expnum > 0)
    {
      sprintf(path, "%s/lock_%d.primary", userdir, expnum);
      if (stat( path, &stat_blk ) != 0) return(retval);

      get1 = P_getVarInfo(GLOBAL, "jcurwin", &info);
      get2 = P_getreal(GLOBAL, "jviewports", &dval, 1);
/* read number of viewports from jviewports[1] */
      if (get1==0 && get2==0)
      {
	get2 = (int) (dval + 0.5);
	if ((get2 > 0) && (get2 <= info.size))
	{
	  for (index=0; index<get2; index++)
	  {
	    P_getreal(GLOBAL, "jcurwin", &dval, index+1);
	    if (expnum == (int)dval)
	    {
	      char mstr[MAXPATH];
/*	      sprintf(mstr, "viewport %d", index+1);
	      writelineToVnmrJ("vnmrjcmd",mstr);
	      sprintf(mstr, "vplayout use %d", index+1);
	      writelineToVnmrJ("vnmrjcmd",mstr);
*/
	      P_getstring(GLOBAL, "jviewportlabel", mstr, index+1, MAXPATH);
	      Winfoprintf("Cannot join workspace exp%d - in use by %s viewport.\n",expnum,mstr);
	      retval = 0;
	      break;
	    }
	  }
	}
      }
    }
    return(retval);
}
コード例 #7
0
ファイル: bootup.c プロジェクト: timburrow/ovj3
void jcurwin_setexp(char *estring, int oldexpnum )
{
    int expnum;

    expnum = atoi(estring);
    if ((expnum < 0) || (expnum > MAXEXPS))
    {
      Werrprintf("jexp: value of jcurwin=%s out-of-range",estring);
      return;
    }
    if (P_setreal(GLOBAL,"jcurwin",(double)(expnum),VnmrJViewId) != 0)
    {
      Werrprintf("WARNING: jexp could not set parameter jcurwin");
    }
    else
    {
/* see jAutoSendIfGlobal( "jcurwin" ); */
      char mstr[MAXSTR];
      double dval;
      int i;
      vInfo info;
      sprintf(mstr,"jcurwin[%d]=%d",VnmrJViewId,expnum);
      writelineToVnmrJ("pglo",mstr);
/* check all other jcurwin values */
      if (oldexpnum > -1)
      {
        if (P_getVarInfo(GLOBAL, "jcurwin", &info)==0)
        {
	  if (info.size > VnmrJViewId)
	  {
	    for (i=VnmrJViewId; i<info.size; i++)
	    {
	      P_getreal(GLOBAL, "jcurwin", &dval, i+1);
/* if match, set to oldexpnum - see unlockAllExp() in locksys.c */
	      if ((int)(dval+0.1) == expnum)
	      {
		P_setreal(GLOBAL, "jcurwin", (double)(oldexpnum), i+1);
	        sprintf(mstr,"jcurwin[%d]=%d", i+1, oldexpnum);
	        writelineToVnmrJ("pglo",mstr);
	      }
	    }
	  }
        }
      }
    }
}
コード例 #8
0
ファイル: treefuncs.c プロジェクト: timburrow/ovj3
/*------------------------------------------------------------------------------
|
|	maxminlimit(tree,name)
|
|	This function returns the max & min limit of the real variable based
|				Author: Greg Brissey  8-18-95
+----------------------------------------------------------------------------*/
int par_maxminstep(int tree, const char *name, double *maxv, double *minv, double *stepv)
{
   int             ret,pindex;
   vInfo           varinfo;	/* variable information structure */
   char            mess[MAXSTR];

   if ( (ret = P_getVarInfo(tree, name, &varinfo)) )
   {
      sprintf(mess, "Cannot find the variable: %s", name);
      text_error(mess);
      if (bgflag)
	 P_err(ret, name, ": ");
      return (-1);
   }
   if (varinfo.basicType != ST_REAL)
   {
      sprintf(mess, "The variable '%s' is not a type 'REAL'", name);
      text_error(mess);
   }
   if (varinfo.prot & P_MMS)
   {
      pindex = (int) (varinfo.minVal+0.1);
      if (P_getreal( SYSTEMGLOBAL, "parmin", minv, pindex ))
         *minv = -1.0e+30;
      pindex = (int) (varinfo.maxVal+0.1);
      if (P_getreal( SYSTEMGLOBAL, "parmax", maxv, pindex ))
         *maxv = 1.0e+30;
      pindex = (int) (varinfo.step+0.1);
      if (P_getreal( SYSTEMGLOBAL, "parstep", stepv, pindex ))
            *stepv = 0.0;
   }
   else
   {
       *maxv = varinfo.maxVal;
       *minv = varinfo.minVal;
       *stepv = varinfo.step;
   }
   return (0);
}
コード例 #9
0
ファイル: active.c プロジェクト: timburrow/ovj3
/* ---------------------------------------------------------------
|  var_active(varname,tree);
|
|  Purpose:
|	This module determines if the variable passed is active or not.
|	This is determined by looking at the variable information
|	 structure "_vInfo".
|	if a real variable the info.active is check.
|	if a string then it's value is checked for 'unused' value.
|       Returns 1 if active, 0 if not, and -1 if error.
|
|				Author Greg Brissey  5/13/86
+------------------------------------------------------------------*/
int var_active(char *varname, int tree)
{
    char	strval[20];
    int		ret;
    vInfo	varinfo;		/* variable information structure */

    if (bgflag)
	fprintf(stderr,"active(): Variable: %s, Tree: %d \n",varname,tree);
    if ( (ret = P_getVarInfo(tree,varname,&varinfo)) )
    {
	if (bgflag)
           fprintf(stderr,"Cannot find the variable: %s",varname);
	return(-1);
    }
    if (bgflag)
	fprintf(stderr,"active(): vInfo.basicType = %d \n",varinfo.basicType);
    if (varinfo.basicType != T_STRING)
    {
    	if (bgflag)
	    fprintf(stderr,"active(): vInfo.active = %d \n",varinfo.active);
    	if (varinfo.active == ACT_ON)
	    return(1);
    	else
	    return(0);
    }
    else  /* --- variable is string check is value for 'undef' --- */
    {
	P_getstring(tree,varname,strval,1,10);
	/*getparm(varname,"string",tree,&strval[0],10);*/
	if (bgflag)
	    fprintf(stderr,"active(): Value of String variable: '%s'\n",strval);
    	if ((strncmp(strval,"unused",6) == 0) || 
	    (strncmp(strval,"Unused",6) == 0) )
	    return(0);
    	else
	    return(1);
    }
}
コード例 #10
0
ファイル: cps.c プロジェクト: timburrow/ovj3
/*-----------------------------------------------------------------
|       getmaxval()/1
|       Gets the maximum value of an arrayed or list real parameter.
+------------------------------------------------------------------*/
int getmaxval(const char *parname )
{
    int      size,r,i,tmpval,maxval;
    double   dval;
    vInfo    varinfo;

    if ( (r = P_getVarInfo(CURRENT, parname, &varinfo)) ) {
        abort_message("getmaxval: could not find the parameter \"%s\"\n",parname);
    }
    if ((int)varinfo.basicType != 1) {
        abort_message("getmaxval: \"%s\" is not an array of reals.\n",parname);
    }

    size = (int)varinfo.size;
    maxval = 0;
    for (i=0; i<size; i++) {
        if ( P_getreal(CURRENT,parname,&dval,i+1) ) {
	    abort_message("getmaxval: problem getting array element %d.\n",i+1);
	}
	tmpval = (int)(dval+0.5);
	if (tmpval > maxval)	maxval = tmpval;
    }
    return(maxval);
}
コード例 #11
0
ファイル: ddph.c プロジェクト: timburrow/ovj3
int wrspec_find_epscale(float *epscale, int proctype, int elem1_num, int elem2_num )
{
	float		*epsdelay, deps1, deps2;
	double		 eps_tmp;
	vInfo		 info;
	int		 i;

        (void) proctype;
/*	if (proctype == 6) { *epscale = 0.0; else do below; } */
/*	calc scale from eps */
/*	note only valid for proctype == 2 || proctype == 4 || proctype == 5 */
	*epscale = 0.0;	/* *epscale=0 translates to no scaling - see wrspec_output */
	if ( P_getVarInfo(CURRENT, "d3", &info) ) {
		*epscale = 0.0; 
	}
        else {  
		epsdelay=(float *)malloc((info.size) * sizeof(float));
		for( i=0; i< (int) info.size; i++ ) {
                        P_getreal(CURRENT, "d3", &eps_tmp, i+1);
                        epsdelay[i] = (float) eps_tmp; 
			}
		*epscale = 1.0;
		deps1 = epsdelay[(elem1_num - 1) % info.size]; 
		deps2 = epsdelay[(elem2_num - 1) % info.size]; 
		deps1 = deps2 - deps1;
		deps2 = deps1;
		if ( deps2 < 0 ) { deps2 = -deps2; }
		if ( deps2 < NEW_AMP_TOL ) { *epscale = 0.0; }
		else { *epscale = 1.0/(360.0 * deps1); }		/* true value */
		free((char *) epsdelay);
		}
	EPRINT1(1, "  wrspec: *epscale %f\n", *epscale ); 
/*	if (*epscale < 0.0) { *epscale = -1.0 * *epscale; } */

	return(0);
}
コード例 #12
0
ファイル: dpf.c プロジェクト: DanIverson/OpenVnmrJ
static int getlines(int noneg)
/*******************/
{
  vInfo  info;
  double freq;
  double amp;
  double tmpfrq;
  int    tmppos;
  int    r;
  int    index;
  int    count=0;

  if ( (r=P_getVarInfo(CURRENT,"llfrq",&info)) )
  { P_err(r,"llfrq",":");   return ERROR; }
  if (info.size >= 1)
  {
    if ((linefrq = (double *)
                   allocateWithId(sizeof(double)*(info.size + 1),"dpf"))==0)
    { Werrprintf("cannot allocate buffer space");
      return(0);
    }
    if ((lineamp = (double *)
                   allocateWithId(sizeof(double)*(info.size + 1),"dpf"))==0)
    { Werrprintf("cannot allocate buffer space");
      release(linefrq);
      return(0);
    }
    if ((linepos = (int *)
                   allocateWithId(sizeof(int)*(info.size + 1),"dpf"))==0)
    { Werrprintf("cannot allocate buffer space");
      release(linefrq);
      release(lineamp);
      return(0);
    }
    if (debug1)
      Wscrprintf("line      freq       amp       position\n");
    for (index = 1; index <= info.size; index++)
    {
      if ( (r=P_getreal(CURRENT,"llfrq",&freq,index)) )
      { P_err(r,"llfrq",":");   return ERROR; }
      tmpfrq = freq - rflrfp;
      tmppos = dfpnt  + dnpnt  * (wp  - tmpfrq  + sp ) / wp;
      if ( (r=P_getreal(CURRENT,"llamp",&amp,index)) )
      { P_err(r,"llamp",":");   return ERROR; }
      if (tmppos > dfpnt && tmppos < dfpnt+dnpnt && (amp >= 0 || !noneg))
      {
	count++;
        linefrq[count] = tmpfrq;
        linepos[count] = tmppos;
        if (amp < 0.0)
          amp = 0.0;
        lineamp[count] = amp * scale;
        if (debug1)
          Wscrprintf("%d   %g   %g   %d\n",
                  count,linefrq[count],lineamp[count],linepos[count]);
      }
    }
    return(count);
  }
  else
    return(0); 
}
コード例 #13
0
ファイル: fiddle.c プロジェクト: timburrow/ovj3
/*---------------------------------------
|    				        |
|    i_fiddle()    			|
|          				|
+--------------------------------------*/
static int i_fiddle(int argc, char *argv[])
{
	short status_mask;
	int  i,j;
	double v,np;
	vInfo info;
	int  flag;
	FILE *satfile;

	int	intcount;

	char	nohilbert[] 		= "nohilbert";		/* These are to */
	char	noextrap[] 		= "noextrap";		/* define the */
	char	verbos[] 		= "verbose";		/* strings used */
	char	fittedbaseline[] 	= "fittedbaseline";	/* for the 	*/
	char	stop1[] 		= "stop1";		/* fiddle 	*/
	char	stop2[] 		= "stop2";		/* command line	*/
	char	stop3[] 		= "stop3";
	char	stop4[] 		= "stop4";
	char	displaycf[] 		= "displaycf";
	char	nodc[] 			= "nodc";
	char	inver[] 		= "invert";
	char	satellites[] 		= "satellites";
	char	writefid[]		= "writefid";
	char	normalise[]		= "normalise";
	char	alternate[]		= "alternate";
	char	noaph[]			= "noaph";
	char	readcf[]		= "readcf";
	char	writecf[]		= "writecf";


	readcfflg=writecfflg=corfunc=noift=noftflag=invert=solvent=FALSE;
	dccorr=baseline=verbose=numsats=FALSE;
	apod=udifffg=difffg=firstfg=secondfg=nosub=FALSE;
	stopflag=0;
	halffg=hilbert=makereffg=ldcflag=extrap=aphflg=TRUE;
	altfg=flag2d=writefg=oflag=quantflag=FALSE;

	intcount=0;
	print=0;
	startno= -1;
	finishno=startno+1;
	stepno=1;
	sw1=0.0;
	rfl1=0.0;

	disp_status("IN");
	if ((P_getreal(PROCESSED, "ni", &v, 1) == 0&&(v>1.0))||
	    (P_getreal(PROCESSED, "ni2", &v, 1) == 0&&(v>1.0)) )
	{
		if (verbose) Wscrprintf("2D data\n");
		if 
(P_getreal(CURRENT,"sw1",&sw1,1)||P_getreal(CURRENT,"rfl1",&rfl1,1))
		{
			Werrprintf("Error accessing parameters\n");
			return(ERROR);
		}
	}


	if ((int)strlen(argv[0])>(int)6)
	{
		if (argv[0][6] == 'd')
		{
			Wscrprintf("Calculating FIDDLE'd difference between spectra n and n-1.\nds(1) for corrected 1st spectrum, ds(n) for difference.\n");
			difffg=TRUE;
			firstfg=TRUE;
		}
		if (argv[0][6] == 'u')
		{
			Wscrprintf("Calculating FIDDLE'd difference between spectra n and 1.\nds(1) for corrected 1st spectrum, ds(n) for difference \n");
			udifffg=TRUE;
			difffg=TRUE;
			firstfg=TRUE;
		}
		if (argv[0][6] == '2')
		{
			Wscrprintf("2D FIDDLE processing\n");
			flag2d=TRUE;
			quantflag=TRUE;
			extrap=FALSE;
			if (argv[0][8] == 'd')
			{
				Wscrprintf("... taking the difference between alternate fids\n");
				firstfg=TRUE;
				difffg=TRUE;
			}
		}
	}


	if (argc>1)		/* This is to check for the options used */
	{
		for (i=1;i<argc;i++)
		{
			if (atoi(argv[i])>0)
			{
				intcount++;
				if (intcount==1)
				{
					startno=atoi(argv[i])-1; 
					finishno=startno+1; 
					stepno=1;
				}
				if (intcount==2)
				{
					finishno=atoi(argv[i]); 
					stepno=1;
				}
				if (intcount==3)
				{
					stepno=atoi(argv[i]);
				}
			}
			else	if (equal(argv[i],nohilbert))
			{
				if (verbose) Wscrprintf("Not using Hilbert algorithm \n");
				hilbert=FALSE; 
				extrap=TRUE;
			}
			else if (equal(argv[i],noextrap))
			{
				if (verbose) Wscrprintf("Not using extrapolation of dispersion mode reference signal \n");
				extrap=FALSE;
			}
			else if (equal(argv[i],verbos))
			{
				verbose=TRUE;
				Wscrprintf("Verbose: displaying information during FIDDLE.\n");
			}
			else if (equal(argv[i],fittedbaseline))
			{
				if (verbose) Wscrprintf("Fitted baseline used.\n");
				baseline=TRUE;
			}
			else if (equal(argv[i],stop1))
			{
				if (verbose) Wscrprintf("Display experimental reference fid.\n");
				stopflag=1; 
				noftflag=TRUE;
			}
			else if (equal(argv[i],stop2))
			{
				if (verbose) Wscrprintf("Display correction function.\n");
				stopflag=2; 
				noftflag=TRUE;
			}
			else if (equal(argv[i],stop3))
			{
				if (verbose) Wscrprintf("Display ideal reference fid.\n");
				stopflag=3; 
				noftflag=TRUE;
			}
			else if (equal(argv[i],stop4))
			{
				if (verbose) Wscrprintf("Display first corrected fid.\n");
				stopflag=4;
			}
			else if (equal(argv[i],alternate))
			{
				if (verbose) Wscrprintf("Alternating phases of increments for hypercomplex 2D\n");
				altfg=TRUE;
			}
			else if (equal(argv[i],displaycf))
			{
				if (verbose) Wscrprintf("Display correction function in place of corrected spectrum\n");
				corfunc=TRUE; 
				noftflag=TRUE;
			}
			else if (equal(argv[i],nodc))
			{
				if (verbose) Wscrprintf("No dc correction of reference region \n");
				ldcflag=FALSE;
			}
			else if (equal(argv[i],inver))
			{
				if (verbose) Wscrprintf("Corrected difference spectrum will be inverted \n");
				invert=TRUE;
			}
			else if (equal(argv[i],satellites))
			{
				if (verbose) Wscrprintf("Satellites will be included in the ideal reference \n");
				numsats=TRUE;
				i++;
				if ((argc-1)<i)
				{
					Werrprintf("Satellite filename not specified");
					return(ERROR);
				}
				sprintf(satname,"/vnmr/satellites/%s",argv[i]);
				if (verbose) Wscrprintf("Satellite file name is %s \n",argv[i]);
			}
			else if (equal(argv[i],writefid))
			{
				if (verbose) Wscrprintf("Corrected fid will be written to disk \n");
				writefg=TRUE;
				i++;
				if ((argc-1)<i)
				{
					Werrprintf("Destination filename not specified\n");
					return(ERROR);
				}
				strcpy(writename,argv[i]);
				if (argv[i][0]!='/')
				{
					pathptr = get_cwd();
					strcpy(writename,pathptr);
					strcat(writename,"/");
					strcat(writename,argv[i]);
				}
				if
				(((int) 										
	(strlen(writename))<5)||(strcmp(&writename[strlen(writename)-4],".fid")))
				    strcat(writename,".fid");
				sprintf(sysstr,"mkdir %s",writename);
				if(system(sysstr))
				{
					sprintf(sysstr,"cd %s",writename);
					if(system(sysstr))
					{
						Werrprintf("System error: %s",sysstr);
						return(ERROR);
					}
				}
				Wscrprintf("Writing corrected fid out; destination file: %s\n",writename);
			}
			else if (equal(argv[i],writecf))
			{
				if (verbose) Wscrprintf("Correction function will be written to disk \n");
				writecfflg=TRUE;
				i++;
				if ((argc-1)<i)
				{
					Werrprintf("Destination filename not specified\n");
					return(ERROR);
				}
				strcpy(writecfname,argv[i]);
				if (argv[i][0]!='/')
				{
					pathptr = get_cwd();
					strcpy(writecfname,pathptr);
					strcat(writecfname,"/");
					strcat(writecfname,argv[i]);
				}
				if
				(((int) 										
	(strlen(writecfname))<5)||(strcmp(&writecfname[strlen(writecfname)-4],
				    ".fid")))
				    strcat(writecfname,".fid");
				sprintf(sysstr,"mkdir %s",writecfname);
				if(system(sysstr))
				{
					sprintf(sysstr,"cd %s",writecfname);
					if(system(sysstr))
					{
						Werrprintf("System error: %s",sysstr);
						return(ERROR);
					}
				}
				Wscrprintf("Writing correction function out; destination file: %s\n",writecfname);
			}
			else if (equal(argv[i],readcf))
			{
				if (verbose) Wscrprintf("Correction function will be read from disk \n");
				readcfflg=TRUE;
				i++;
				if ((argc-1)<i)
				{
					Werrprintf("Source filename not specified\n");
					return(ERROR);
				}
				strcpy(readcfname,argv[i]);
				if (argv[i][0]!='/')
				{
					pathptr = get_cwd();
					strcpy(readcfname,pathptr);
					strcat(readcfname,"/");
					strcat(readcfname,argv[i]);
				}
				if
				(((int) 										
	(strlen(readcfname))<5)||(strcmp(&readcfname[strlen(readcfname)-4],
				    ".fid")))
				   strcat(readcfname,".fid");
				sprintf(sysstr,"cd %s",readcfname);
				if(system(sysstr))
				{
					Werrprintf("System error: %s",sysstr);
					return(ERROR);
				}

				Wscrprintf("Reading correction function in; source file: %s\n",readcfname);
			}
			else if (equal(argv[i],noaph))
			{
				if (verbose) Wscrprintf("Reference region(s) will not be automatically phased\n");

				aphflg=FALSE;
			}
			else if (equal(argv[i],normalise))
			{
				if (verbose) Wscrprintf("Corrected spectra will be normalised to 1st spectrum\n");

				quantflag=TRUE;
			}

			else {
				Werrprintf("Option %s was not recognised ",argv[i]);
			}
		}
	}

	if (verbose&&numsats) printf("%s\n",satname);
	if (noift&&!stopflag) stopflag=2;
	if (stopflag==4&&!difffg) stopflag=3;
	if (difffg) finishno++;

	D_allrelease();


	/* get parameters */
	if  (
	    P_getreal(PROCESSED,"fn",&fn,1)||
	    P_getreal(CURRENT,"ct",&ct,1)||
	    P_getreal(CURRENT,"sw",&sw,1)||
	    P_getreal(CURRENT,"cr",&cr,1)||
	    P_getreal(CURRENT,"delta",&delta,1)||
	    P_getreal(CURRENT,"rfl",&rfl,1)||
	    P_getreal(CURRENT,"rfp",&rfp,1)||
	    P_getreal(CURRENT,"rp",&rp,1)||
	    P_getreal(CURRENT,"lp",&lp,1)||
	    P_getreal(PROCESSED,"sfrq",&sfrq,1)||
	    P_getreal(PROCESSED,"np",&np,1)
	    )
	{
		Werrprintf("Error accessing parameters\n");
		return(ERROR);
	}

	if (ct==0)
	{
		ct=1;
		Werrprintf("ct was zero; assumed to be 1\n");
	}
	if (verbose)
		Wscrprintf("sw %lf, cr %lf, delta %lf, rfl %lf, rfp %lf, rp %lf, lp %lf\n",
		    sw,cr,delta,rfl,rfp,rp,lp);
	if ((cr<rfp)||(cr-delta>rfp))
	{
		Werrprintf("Please place cursors either side of reference and try again\n");
		return(ERROR);
	}
	if (!aphflg)
	{
		if (flag2d)
		{
			if (P_getreal(CURRENT,"phinc",&rpinc,1))
			{
				/*  parameter phinc not created, so set phase increment to zero	*/
				rpinc=0.0;
			}
			if (P_getreal(CURRENT,"rp2nd",&rp2nd,1))
			{
				rp2nd=rp;
			}
		}
	}

	npi= (int)np;

	np0 = (int)fn;
	fn0 = np0;    /* ! */
	if (hilbert&&((int)np>fn0/2))
	{
		if (verbose) Wscrprintf("np = %f ",np);
		if (verbose) Wscrprintf("fn = %f\n",fn);
		Werrprintf("Data should be zerofilled so that fn>=2*np for hilbert transform");
		npi=(int) fn0/2;
	}
	if (hilbert) np0w=np0/2; 
	else np0w=np0;

	/* calculate rest of params */
	hzpp=sw/np0*2;
	refpos=2*(int)((sw-rfl)/hzpp);
	refposfr=((sw-rfl)/hzpp)-0.5*(double)refpos;
	leftpos=refpos-2*(int)((cr-rfp)/hzpp);
	rightpos=leftpos+2*(int)(delta/hzpp);
	if (verbose) Wscrprintf(" refposfr %g, hzpp %g, left %d, ref %d, right %d\n",
	    refposfr,hzpp,leftpos,refpos,rightpos);

	/* read satellite file if used */
	if (numsats)
	{
		if ((satfile=fopen(satname,"r"))==NULL)
		{
			Werrprintf("Error opening satellite file\n");
			return(ERROR);
		}
		numsats=0;
		while(fscanf(satfile,"%f %f %f\n",&satpos[numsats],
		    &satint[numsats],&satish[numsats])!=EOF)
		{
			if (verbose) printf("%f %f %f\n",
			    satpos[numsats],satint[numsats],satish[numsats]);
			numsats++;
		}
		fclose(satfile);
	}

	/* access & check the file containing the original spectrum */
	if ( (r = D_gethead(D_DATAFILE, &fidhead)) )
	{
		if (r == D_NOTOPEN)
		{
			if (verbose) Wscrprintf("Original Spectrum had to be re-opened \n");
			strcpy(path, curexpdir);
			strcat(path, "/datdir/data");
			r = D_open(D_DATAFILE, path, &fidhead); /* open the file */
		}

		if (r)
		{
			D_error(r);
			return(ERROR);
		}
	}
	status_mask = (S_DATA|S_SPEC|S_FLOAT|S_COMPLEX);
	if ( (fidhead.status & status_mask) != status_mask )
	{
		Werrprintf("No spectrum in file: use ft before fiddle. fidhead.status = %d", fidhead.status);
		return(ERROR);
	}
	if (np0 != fidhead.np)
	{
		Werrprintf("Size of data inconsistent, np0 = %d, head.np = %d",
		    np0, fidhead.np);
		return(ERROR);
	}

	if(writefg) getfidblockheadforwrite();
	if(writecfflg) getfidblockheadforcf();

	/* Set PHASFILE status to !S_DATA - this is required to
	 force a recalculation of the display from the new data
	 in DATAFILE (in the ds routine, see proc2d.c)   */
	if ( (r=D_gethead(D_PHASFILE,&phasehead)) )
	{
		if (r==D_NOTOPEN)
		{
			Wscrprintf("phas NOTOPEN\n");
			strcpy(path,curexpdir);
			strcat(path,"/datdir/phasefile");
			r=D_open(D_PHASFILE,path,&phasehead);
		}
		if (r)
		{
			D_error(r);
			return(ERROR);
		}
	}
	phasehead.status=0;
	if ( (r=D_updatehead(D_PHASFILE,&phasehead)) )
	{
		D_error(r);
		Wscrprintf("PHAS updatehead\n");
		return(ERROR);
	}

	/* allocate memory for the temp buffers & weight func. */
	if ( (data1=(float *)malloc(sizeof(float)*fn0))==0
	    ||(data2=(float *)malloc(sizeof(float)*fn0))==0
	    ||(data3=(float *)malloc(sizeof(float)*fn0))==0
	    ||(wtfunc=(float *)malloc(sizeof(float)*np0/2))==0)
	{
		Werrprintf("could not allocate memory\n");
		difffg=FALSE;
		freall(TRUE);
	}
	if (difffg)
	{
		if ((data4=(float *)malloc(sizeof(float)*fn0))==0)
		{
			Werrprintf("could not allocate memory\n");
			freall(TRUE);
		}
	}
	if (writefg||writecfflg||readcfflg)
	{
		if ((intbuf=(int *)malloc(sizeof(float)*fn0))==0)
		{
			Werrprintf("could not allocate memory\n");
			freall(TRUE);
		}
	}
	if(readcfflg) setupreadcf();

	/* setup weighting function for ideal fid */
	if (init_wt1(&wtp,S_NP))
	{
		Wscrprintf("ERROR: init_wt1(S_NP)\n");
		freall(TRUE);
	}
	if (init_wt2(&wtp,wtfunc,np0/2,FALSE,S_NP,1.0,FALSE))
	{
		Wscrprintf("ERROR: init_wt2()\n");
		freall(TRUE);
	}

	/* setup for solvent rd */
	if (solvent)
	{
		if (P_getVarInfo(CURRENT,"lifrq",&info))
		{
			Werrprintf("Error accessing resets");
			freall(TRUE);
		}
		numresets=(int)info.size;
		if (numresets<=1)
		{
			Werrprintf("Please provide some integral resets");
			freall(TRUE);
		}
		if ((resets=(double *)malloc(sizeof(double)*(numresets+4)))==0
		    ||(spy=(double *)malloc(sizeof(double)*(numresets+4)))==0
		    ||(spx=(int *)malloc(sizeof(int)*(numresets+4)))==0
		    ||(spg=(double *)malloc(sizeof(double)*(numresets+4)))==0 )
		{
			Werrprintf("error allocating memory");
			freall(TRUE);
		}
		i=1;
		flag=0;
		for (j=1;j<numresets;j++)
		{
			if (P_getreal(CURRENT,"lifrq",&resets[i],j))
			{
				Werrprintf("Error accessing lifrq(%d)\n",i);
				freall(TRUE);
			}
			if (resets[i]<(rfl-rfp+cr)&&flag==0)
			{
				resets[i+1]=resets[i];
				resets[i]=rfl-rfp+cr;
				flag=1;
				i++;
			}
			if (resets[i]<rfl&&flag==1)
			{
				resets[i+1]=resets[i];
				resets[i]=rfl;
				flag=2;
				i++;
			}
			if (resets[i]<(rfl-rfp+cr-delta)&&flag==2)
			{
				resets[i+1]=resets[i];
				resets[i]=rfl-rfp+cr-delta;
				flag=3;
				i++;
			}
			/*
				if (resets[i]>(rfl-rfp+cr-delta)&&flag==TRUE)
					i--;
			*/
			if (resets[i]==resets[i-1])
				i--;
			i++;
		}
		resets[0]=sw;
		numresets=i;
		resets[numresets]=hzpp;
	}

	disp_status(" ");
	return(COMPLETE);
}
コード例 #14
0
ファイル: init2d.c プロジェクト: timburrow/ovj3
/* frqdimname;	frequency dimension  */
static int getspecparms(int dis_setup, int frqdimname)
{
  char		aig[5],
		dmg[5],
		dmg1[5];
  int		dim0,dim1;
  int		r;
  double	x0;

// min, max sw values
  double minval, maxval;
  if(P_getmin(PROCESSED, "sw", &minval) ) minval = 200.0;
  if(P_getmax(PROCESSED, "sw", &maxval) ) maxval = 200.0;

  dim0 = FN0_DIM;
  dim1 = FN1_DIM;
  if (d2flag)
  {
     if (frqdimname == S_NP)
     {
        if (datahead.status & S_SPEC)
        {
           Werrprintf("Data file must first be re-initialized with FID data\n");
           return(ERROR);
        }

        d2flag = FALSE;
        dim0 = FN0_DIM;
        dim1 = FN0_DIM;
     }
     else
     {
        if (ndflag == FOUR_D)
        {
           if (frqdimname & S_NP)
           {
              dim0 = FN0_DIM;
              if (frqdimname & S_NI)
                 dim1 = FN1_DIM;
              else if (frqdimname & S_NI2)
                 dim1 = FN2_DIM;
              else
                 dim1 = FN3_DIM;
           }
           else if (frqdimname & S_NI)
           {
              dim0 = FN1_DIM;
              if (frqdimname & S_NI2)
                 dim1 = FN2_DIM;
              else
                 dim1 = FN3_DIM;
           }
           else
           {
              dim0 = FN2_DIM;
              dim1 = FN3_DIM;
           }
        }
        else if (frqdimname & S_NP)
        {
           dim0 = FN0_DIM;
           dim1 = ( (frqdimname & S_NI2) ? FN2_DIM : FN1_DIM );
        }
        else if ( (~frqdimname) & S_NF )
        {
           dim0 = FN2_DIM;
           dim1 = FN1_DIM;
        }
        else
        {   
           Werrprintf("Invalid name for 2nd dimension\n");
           return(ERROR);
        }
     }
  }

/************************************************
*  Set the normalization, processing mode, and  *
*  display flags for either 1D or 2D data.      *
************************************************/

  if ( (r = P_getstring(CURRENT, "aig", aig, 1, 4)) )
  {
     if ( expdir_to_expnum(curexpdir) > 0 )
        P_err(r, "aig", ":");
     return(ERROR);
  }

  if ( (r = P_getstring(CURRENT, "dmg", dmg, 1, 4)) )
  {
     P_err(r, "dmg", ":");
     return(ERROR);
  }

  normflag = (aig[0] == 'n');
  dophase = doabsval = dopower = dophaseangle = dodbm = FALSE;
  dof1phase = dof1absval = dof1power = dof1phaseangle = FALSE;

  dophase = ((dmg[0] == 'p') && (dmg[1] == 'h'));
  if (!dophase)
  {
     doabsval = ((dmg[0] == 'a') && (dmg[1] == 'v'));
     if (!doabsval)
     {
        dopower = ((dmg[0] == 'p') && (dmg[1] == 'w'));
        if (!dopower)
        {
           dophaseangle = ((dmg[0] == 'p') && (dmg[1] == 'a'));
           if (!dophaseangle)
           {
        	   dodbm = ((dmg[0] == 'd') && (dmg[1] == 'b'));
        	   if (!dodbm)
        	   {
        	      Werrprintf("Invalid display mode for 1D spectral data");
        	      return(ERROR);
        	   }
           }
        } 
     } 
  }

  if (d2flag)
  {
     r = P_getstring(CURRENT, "dmg1", dmg1, 1, 5);
     if (!r)
     {
        r = ( (strcmp(dmg1, "ph1") != 0) && (strcmp(dmg1, "av1") != 0) &&
		  (strcmp(dmg1, "pwr1") != 0) );
     }

     if (r)
     { /* default to "dmg" */
        if ( (r = P_getstring(CURRENT, "dmg", dmg1, 1, 4)) )
        {
           P_err(r, "dmg", ":");
           disp_status("        ");
           return(ERROR);
        }
     }

     dof1phase = ((dmg1[0] == 'p') && (dmg1[1] == 'h'));
     if (!dof1phase) 
     {
        dof1absval = ((dmg1[0] == 'a') && (dmg1[1] == 'v')); 
        if (!dof1absval)
        { 
           dof1power = ((dmg1[0] == 'p') && (dmg1[1] == 'w')); 
           if (!dof1power)
           {
              dof1phaseangle = ((dmg1[0] == 'p') && (dmg1[1] == 'a')); 
              if (!dof1phaseangle)
              {
                 Werrprintf("Invalid F1 display mode for 2D spectral data");
                 return(ERROR); 
              }
           } 
        } 
     }
  }

  if (dis_setup)
  {
/************************************
*  Get current display parameters.  *
************************************/
     P_getreal(CURRENT,"vs",&vs,1);
     P_getreal(CURRENT,"vsproj",&vsproj,1);
     P_getreal(CURRENT,"vs2d",&vs2d,1);
     C_GETPAR("is", &is);
     C_GETPAR("io", &io);
     C_GETPAR("th", &th);
     C_GETPAR("vp", &vp);
     C_GETPAR("vo", &vo);
     C_GETPAR("ho", &ho);
     C_GETPAR("lvl", &lvl);
     C_GETPAR("tlt", &tlt);
  }

  if (d2flag)
  {

/*******************************************************
*  Check whether the datafile contains FID's, half-    *
*  transformed spectra, or fully transformed spectra.  *
*******************************************************/

     if ( (~datahead.status) & S_SECND)
     { /* not fully transformed 2D spectrum */
        dim1 = ( (datahead.status & S_NI2) ? SW2_DIM : SW1_DIM );
        if ( (~datahead.status) & S_SPEC)
           dim0 = SW0_DIM;
     }
  }
  else
  {
     dim0 = FN0_DIM;
     dim1 = FN1_DIM;
  }

  if (d2flag && revflag)
  {
     set_spec_display(HORIZ,dim1,VERT,dim0);
     set_display_label(HORIZ,revchar,VERT,normchar);
     set_spec_proc(HORIZ,dim1,REVDIR, VERT,dim0,NORMDIR);
  }
  else
  {
     set_spec_display(HORIZ,dim0,VERT,dim1);
     set_display_label(HORIZ,normchar,VERT,revchar);
     set_spec_proc(HORIZ,dim0,NORMDIR, VERT,dim1,REVDIR);
  }
  get_sfrq(HORIZ,&sfrq);
  get_sfrq(VERT,&sfrq1);
  get_cursor_pars(HORIZ,&cr,&delta);
  get_phase_pars(HORIZ,&rp,&lp);
  get_ref_pars(HORIZ,&sw,&rflrfp,&fn);
  if(sw<=0 || sw>maxval) {
	Winfoprintf("Error sw out of bounds %f: 0 to %f",sw,maxval);
	return(ERROR);
  }
  get_scale_axis(HORIZ,&axisHoriz);
  get_scale_axis(VERT,&axisVert);
  {
     double axis_scl;
     int    reversed;

     get_scale_pars(HORIZ,&sp,&wp,&axis_scl,&reversed);
     if (get_axis_freq(HORIZ))
       set_sp_wp(&sp, &wp, sw, fn/2, rflrfp);
     else
       set_sf_wf(&sp, &wp, sw, fn/2);
     UpdateVal(HORIZ,WP_NAME,wp,NOSHOW);
     UpdateVal(HORIZ,SP_NAME,sp,NOSHOW);
  }

  if (d2flag)
  {
     get_phase_pars(VERT,&rp1,&lp1);
     get_ref_pars(VERT,&sw1,&rflrfp1,&fn1);
     if(dim1==FN1_DIM && (sw1<=0 || sw1>maxval)) {
	Winfoprintf("Error sw1 out of bounds %f: 0 to %f",sw1,maxval);
	return(ERROR);
  }
     {
        double axis_scl;
        int    reversed;

        get_scale_pars(VERT,&sp1,&wp1,&axis_scl,&reversed);
        if (get_axis_freq(VERT))
           set_sp_wp(&sp1, &wp1, sw1, fn1/2, rflrfp1);
        else
           set_sf_wf(&sp1, &wp1, sw1, fn1/2);
        UpdateVal(VERT,WP_NAME,wp1,NOSHOW);
        UpdateVal(VERT,SP_NAME,sp1,NOSHOW);
     }
     x0 = 1.0;
     if ( get_axis_freq(HORIZ) && get_axis_freq(VERT) )
     {
        if (((axisHoriz == 'c') || (axisHoriz == 'm') || (axisHoriz == 'u'))
         && ((axisVert == 'c') || (axisVert == 'm') || (axisVert == 'u')))
        {
	   if (axisHoriz == 'c') x0 =  1.0;
	   if (axisHoriz == 'm') x0 = 10.0;
	   if (axisHoriz == 'u') x0 = 1e4;
	   if (axisVert == 'c') x0 /= 1.0;
	   if (axisVert == 'm') x0 /= 10.0;
	   if (axisVert == 'u') x0 /= 1e4;
        }
     }
     aspect_ratio = (wp*sfrq1)/(x0*wp1*sfrq);
  }
  else
  {
     fn1 = fn;
     sw1 = 0.0;
     rflrfp1 = 0.0;
     aspect_ratio = 100.0;
  }
  normInt = 0;
  insval = 1.0;
  if (!P_getreal(CURRENT, "ins", &insval, 1))
  {
     vInfo  info;
     double tmp;

     if (!P_getreal(CURRENT, "insref", &tmp, 1))
     {
        P_getVarInfo(CURRENT,"insref",&info);
        if (!info.active)
           normInt = 1;
        else if (tmp > 0.0)
           insval /= tmp;
     }
  }
  if (insval <= 0.0)
     insval = 1.0;
  if (!normInt)
     insval /= (double) fn;

  normInt2 = 0;
  ins2val = 1.0;
  if (!P_getreal(CURRENT, "ins2", &ins2val, 1))
  {
     vInfo  info;
     double tmp;

     if (!P_getreal(CURRENT, "ins2ref", &tmp, 1))
     {
        P_getVarInfo(CURRENT,"ins2ref",&info);
        if (!info.active)
           normInt2 = 1;
        else if (tmp > 0.0)
           ins2val /= tmp;
     }
  }
  if (ins2val <= 0.0)
     ins2val = 1.0;
  if (!normInt2)
     ins2val /= ((double)fn * (double)fn1);

  return(COMPLETE);
}
コード例 #15
0
ファイル: vdialog.c プロジェクト: timburrow/ovj3
static void
dialog_sync_func(int cmd, int argc, char **argv)
{
	int	r, this_expnum, cpid;
	int	gfd;
	double  dval;
	char	*retStr;
	DLIST   *dlist;
	vInfo   info;
	int	ret, tree;
        char    dstr[256];

	if (debug > 1)
	  fprintf(stderr, " dialog_sync_func: cmd= %d  argc= %d\n", cmd, argc);
	cpid = atoi(argv[3]);
	if (debug > 1)
	  fprintf(stderr, " dialog command: %d, pid %d\n", cmd, cpid);
	dlist = dialog_list;
	gfd = -1;
	while (dlist != NULL)
	{
	    if (dlist->pid == cpid)
	    {
		gfd = dlist->fout;
		break;
	    }
	    dlist = dlist->next;
	}
	if (dlist == NULL || gfd < 0)
	{
	    if (debug > 1)
	       fprintf(stderr, " dialog_sync_func: could not find process\n");
	    return;
	}
	if (debug > 1)
	  fprintf(stderr, " execute command: %d, pid %d\n", cmd, cpid);
	switch (cmd) {
	  case  PWD:
		retStr = get_cwd();
             	write(gfd, retStr, strlen(retStr));
		break;
	  case  EXPDIR:
             	write(gfd, curexpdir, strlen(curexpdir));
		break;
	  case  GEXIT:
		dlist->used = 0;
		close_fd(dlist);
		dlist->pid = -1;
		break;
	  case  GOK: /* verify console is available */
		this_expnum = expdir_to_expnum( curexpdir );
  		r = is_exp_active( this_expnum );
		sprintf(data, "%d  \n", r);
             	write(gfd, data, strlen(data));
		break;
	  case  GQUERY:
		if (argc < 5)
		{
		    strcpy(data, "0  \n");
                    write(gfd, data, strlen(data));
		    return;
		}
		retStr = NULL;
                if (strstr(argv[4], "macro_value") != NULL)
                {
                    retStr = modify_show_str(argv[4], dstr);
                }
                if (retStr == NULL)
                    retStr = argv[4];

		queryFlag = 0;
		sprintf(data, "if (%s) then dialog('SYNCFUNC', %d, %d, '1') else dialog('SYNCFUNC', %d, %d, '0') endif\n", retStr, GTEST,cpid, GTEST, cpid);
		execString(data);
		if (queryFlag == 0)
                {
                    strcpy(data, "0  \n");
                    write(gfd, data, strlen(data));
                }
		break;
	  case  GTEST:
		if (argc < 5)
		    return;
		queryFlag = 1;
		if (debug > 1)
	  	    fprintf(stderr, " write to dialog: '%s'\n", argv[4]);
		sprintf(data, "%s   \n", argv[4]);
             	write(gfd, data, strlen(data));
		break;
	  case  VEXEC:
		if (argc < 5)
		    return;
		execString(argv[4]);
		break;
	  case  VGET:
		sprintf(data, "    \n");
		if (argc < 5)
		{
             	    write(gfd, data, strlen(data));
		    return;
		}
		tree = CURRENT;
		if ( (ret = P_getVarInfo(tree, argv[4], &info)) )
		{
		    tree = GLOBAL;
		    ret = P_getVarInfo(tree, argv[4], &info);
		}
		if (ret != 0)
		{
             	    write(gfd, data, strlen(data));
		    return;
		}
		if (info.basicType == T_STRING)
		{
		    P_getstring(tree,argv[4],data,1,1023);
		    if (strlen(data) < 4)
			strcat (data, "    \n");
		}
		else
		{
		    dval = 0.0;
		    P_getreal(tree,argv[4],&dval,1);
		    sprintf(data, "%g\n", dval);
		}
             	write(gfd, data, strlen(data));
		break;
	}
}
コード例 #16
0
ファイル: df2d.c プロジェクト: timburrow/OpenVnmrJ
/*-----------------------------------------------
|                                               |
|               get_one_fid()/3                 |
|                                               |
|    This function returns a pointer to the     |
|    requested FID in a 1D, arrayed, or 2D      |
|    experiment.                                |
|                                               |
+----------------------------------------------*/
float *get_one_fid(int curfid, int *np, dpointers *c_block, int dcflag)
{
  char          filepath[MAXPATHL],
                dcrmv[4];
  int           res,
                lastfid,
                force_getfid,
                headok;
  float         *fidptr;
  int           cftemp;
  int           cttemp;
  double        tmp;
  vInfo         info;
  ftparInfo	ftpar;
  dfilehead	fidhead,
		phasehead;
 
 
  force_getfid = (*np < 0);
  if (force_getfid)
     *np = -(*np);
  acqflag = FALSE;
  ftpar.np0 = *np;
  ftpar.fn0 = *np;
  ftpar.hypercomplex = FALSE;	/* ==> will not work for hypercomplex
				   2D interferograms */
  D_allrelease();
 
  if ( (res = D_gethead(D_PHASFILE, &phasehead)) )
  {
     if (res == D_NOTOPEN)
     {
        if ( (res = D_getfilepath(D_PHASFILE, filepath, curexpdir)) )
        {
           D_error(res);
           return(NULL);
        }

        res = D_open(D_PHASFILE, filepath, &phasehead); /* open the file */
     }
 
     if (res)
     {
        if ( new_phasefile(&phasehead, 0, 0, 0, 0, 0, ftpar.hypercomplex) )
           return(NULL);
     }
  }
 
  cftemp = 1;
  if (!P_getreal(CURRENT, "cf", &tmp, 1))
  {
     if (!P_getVarInfo(CURRENT, "cf", &info))
     {
        if (info.active)
           cftemp = (int) tmp;
     }
  }
  cttemp = 0;
  if (!P_getreal(PROCESSED, "ct", &tmp, 1))
     cttemp = (int) (tmp + 0.5);

  ls_ph_fid("lsfid", &(ftpar.lsfid0), "phfid", &(ftpar.phfid0), "lsfrq",
		&(ftpar.lsfrq0));
  headok = ( (phasehead.status == (S_DATA|S_FLOAT|S_COMPLEX)) &&
            (phasehead.ntraces == 1) && (phasehead.np == ftpar.np0) );
 
  if (headok)
  { /* if phase file does contain fid data, open the file */
     res = D_getbuf(D_PHASFILE, phasehead.nblocks, curfid, c_block);
 
     if (!res)
     {
        if ( (c_block->head->status == (S_DATA|S_FLOAT|S_COMPLEX)) &&
             (c_block->head->rpval == (float) (ftpar.phfid0)) &&
             (c_block->head->lpval == (float) (ftpar.lsfid0/2)) &&
             (c_block->head->lvl   == (float) (cftemp)) &&
             (c_block->head->tlt   == (float) (cttemp)) &&
             !force_getfid )
        {
           long_event();
           return((float *)c_block->data);
        }
     }
  }
 
/********************************************
*  If phasefile does not contain FID data,  *
*  open phasefile with the data handler.    *
********************************************/

  ftpar.zeroflag = FALSE;
  ftpar.arraydim = dim1count();
  lastfid = ftpar.arraydim;
  ftpar.fn0 = ftpar.np0;
  if ( i_fid(&fidhead, &ftpar) )   /* open fid file with data handler */
     return(NULL);
  if (ftpar.fn0 != ftpar.np0)
     headok = 0;

  *np = ftpar.np0;
  ftpar.fn0 = ftpar.np0;
 
  if (!headok)
  {
     if (new_phasefile(&phasehead, 0, ftpar.arraydim, 2*ftpar.np0, 1,
                    (S_DATA|S_FLOAT|S_COMPLEX), ftpar.hypercomplex))
     {
        return(NULL);
     }
  }
 
  if ( (res = D_allocbuf(D_PHASFILE, curfid, c_block)) )
  {
     D_error(res);
     return(NULL);
  }
 
  fidptr = (float *)c_block->data;
 
  /*******************************************
  *   provision for baseline offset removal  *
  *   using numbers reported by noise check  *
  *******************************************/

  ftpar.offset_flag = FALSE;
  if (!P_getstring(CURRENT,"dcrmv",dcrmv,1,4))
  {
    if (dcrmv[0] == 'y')
    {
      ftpar.offset_flag = TRUE;
    }
  }
  ftpar.t2dc = dcflag;
     
  if ( getfid(curfid, fidptr, &ftpar, &fidhead, &lastfid) ||
        (lastfid <= curfid) )
  {
     return(NULL);
  }
 
  if (ftpar.lsfid0 > 0)
     zerofill(fidptr + ftpar.np0 - ftpar.lsfid0, ftpar.lsfid0);
 
  D_close(D_USERFILE);
  setheader(c_block, (S_DATA|S_FLOAT|S_COMPLEX), NP_PHMODE, curfid,
                ftpar.hypercomplex);
  c_block->head->rpval = (float) (ftpar.phfid0);
  c_block->head->lpval = (float) (ftpar.lsfid0/2);
  c_block->head->lvl   = (float) (ftpar.cf);
  c_block->head->tlt   = (float) (ftpar.dspar.ctcount);
 
  if ( ftpar.cf != cftemp)
  {  /* cf is misset or inactive - just set it = 1 */
     Werrprintf("cf = %d is inconsistent with data",cftemp);
     P_setreal(CURRENT,  "cf", 1.0, 0);
     P_setreal(PROCESSED,"cf", 1.0, 0);
  }
  if ( (res = D_markupdated(D_PHASFILE, curfid)) )
  {
     D_error(res);
     return(NULL);
  }
 
  return(fidptr);
}
コード例 #17
0
ファイル: bootup.c プロジェクト: timburrow/ovj3
void setGlobalPars()
{
    char addr[MAXPATH];
    vInfo info;
    int e;

    e=P_setstring(GLOBAL,"userdir",userdir,0);
    if (e==-2)
    {	P_creatvar(GLOBAL,"userdir",ST_STRING);
	P_setlimits(GLOBAL,"userdir",(double)MAXPATH,0.0,0.0);
	P_setstring(GLOBAL,"userdir",userdir,0);
	P_setprot(GLOBAL,"userdir",0);
    }
    e=P_setstring(GLOBAL,"curexp",curexpdir,0);
    if (e==-2)
    {	P_creatvar(GLOBAL,"curexp",ST_STRING);
	P_setlimits(GLOBAL,"curexp",(double)MAXPATH,0.0,0.0);
	P_setstring(GLOBAL,"curexp",curexpdir,0);
	P_setprot(GLOBAL,"curexp",0);
    }
#ifdef VNMRJ
    jcurwin_setGlobalPars();
#endif 
    e=P_setstring(GLOBAL,"systemdir",systemdir,0);
    if (e==-2)
    {	P_creatvar(GLOBAL,"systemdir",ST_STRING);
	P_setlimits(GLOBAL,"systemdir",(double)MAXPATH,0.0,0.0);
	P_setstring(GLOBAL,"systemdir",systemdir,0);
	P_setprot(GLOBAL,"systemdir",0);
    }
    e=P_setstring(GLOBAL,"auto",(mode_of_vnmr == AUTOMATION) ? "y" : "n",0);
    if (e==-2)
    {	P_creatvar(GLOBAL,"auto",ST_STRING);
	P_setlimits(GLOBAL,"auto",(double)STR64,0.0,0.0);
	P_setstring(GLOBAL,"auto",(mode_of_vnmr == AUTOMATION) ? "y" : "n",0);
	P_setprot(GLOBAL,"auto",7);  /* do not allow any user change */
        P_Esetstring(GLOBAL,"auto","n",1);
        P_Esetstring(GLOBAL,"auto","y",2);
    }
    if (mode_of_vnmr == AUTOMATION)
    {
       getAutoDir(addr, MAXPATH);
       e=P_setstring(GLOBAL,"autodir",addr,0);
    }
    else
    {
       e=P_getstring(GLOBAL,"autodir",addr,1,MAXPATH);
    }
    if (e==-2)
    {	P_creatvar(GLOBAL,"autodir",ST_STRING);
	P_setlimits(GLOBAL,"autodir",(double)MAXPATH,0.0,0.0);
        if (mode_of_vnmr == AUTOMATION)
	   P_setstring(GLOBAL,"autodir",addr,0);
	P_setprot(GLOBAL,"autodir",3);
    }
    GET_VNMR_ADDR(addr);
    e=P_setstring(GLOBAL,"vnmraddr",addr,0);
    if (e==-2)
    {	P_creatvar(GLOBAL,"vnmraddr",ST_STRING);
	P_setlimits(GLOBAL,"vnmraddr",(double)STR128,0.0,0.0);
	P_setstring(GLOBAL,"vnmraddr",addr,0);
	P_setprot(GLOBAL,"vnmraddr",4);  /* do not allow any user change */
    }
    GET_ACQ_ADDR(addr);
    e=P_setstring(GLOBAL,"acqaddr",addr,0);
    if (e==-2)
    {	P_creatvar(GLOBAL,"acqaddr",ST_STRING);
	P_setlimits(GLOBAL,"acqaddr",(double)STR128,0.0,0.0);
	P_setstring(GLOBAL,"acqaddr",addr,0);
	P_setprot(GLOBAL,"acqaddr",4);  /* do not allow any user change */
    }
    e=P_setstring(GLOBAL,"owner",UserName,0);
    if (e==-2)
    {	P_creatvar(GLOBAL,"owner",ST_STRING);
	P_setlimits(GLOBAL,"owner",(double)STR128,0.0,0.0);
	P_setstring(GLOBAL,"owner",UserName,0);
	P_setprot(GLOBAL,"owner",P_VAL+P_GLO);  /* do not allow any user change */
    }
    e=P_setstring(GLOBAL,"operator",OperatorName,0);
    if (e==-2)
    {	P_creatvar(GLOBAL,"operator",ST_STRING);
	P_setlimits(GLOBAL,"operator",(double)STR128,0.0,0.0);
	P_setstring(GLOBAL,"operator",UserName,0);
	P_setprot(GLOBAL,"operator",P_VAL+P_GLO);  /* do not allow any user change */
    }
    e=P_getVarInfo(GLOBAL,"department",&info); /* do not set value, read from file */
    if (e==-2)
    {	P_creatvar(GLOBAL,"department",ST_STRING);
	P_setlimits(GLOBAL,"department",(double)STR128,0.0,0.0);
	P_setstring(GLOBAL,"department","nmr",0);
	P_setprot(GLOBAL,"department",P_VAL+P_GLO);  /* do not allow any user change */
    }
}