• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ dblookup函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中dblookup函数的典型用法代码示例。如果您正苦于以下问题:C++ dblookup函数的具体用法?C++ dblookup怎么用?C++ dblookup使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了dblookup函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: get_instype

static int
get_instype (Dbptr db, char *instype, double *samprate)
{
    static Dbptr    dbsi = INVALID_DBPTR;
    static Hook    *hook = 0;
    long            nmatches;
    Tbl            *tbl;
    char            sta[MAX_STA_SIZE],
                    chan[MAX_CHAN_SIZE];
    double          time;
    char           *s;
    int             errors = 0;

    if (dbsi.database < 0) {
	Dbptr           dbsensor,
	                dbinstrument;
	dbsensor = dblookup (db, 0, "sensor", 0, 0);
	dbinstrument = dblookup (db, 0, "instrument", 0, 0);
	dbsi = dbjoin (dbsensor, dbinstrument, 0, 0, 0, 0, 0);
    }
    nmatches = dbmatches (db, dbsi, 0, 0, &hook, &tbl);
    switch (nmatches) {
      case dbINVALID:
      case 0:
	dbgetv (db, 0, "sta", sta, "chan", chan, "time", &time, NULL);
	complain (0, "no matches in sensor/instrument join for %s:%s @ %s",
		  sta, chan, s = strydtime (time));
	free (s);
	errors++;
	break;

      default:
	dbgetv (db, 0, "sta", sta, "chan", chan, "time", &time, NULL);
	complain (0, "too many matches (%ld) in sensor/instrument join for %s:%s @ %s",
		  nmatches, sta, chan, s = strydtime (time));
	free (s);
	errors++;
	/* FALLTHRU */

      case 1:
	dbsi.record = (long) gettbl (tbl, 0);
	dbgetv (dbsi, 0, "instype", instype, "samprate", samprate, NULL);
	break;
    }

    freetbl (tbl, 0);
    return errors;
}
开发者ID:NVSeismoLab,项目名称:antelope_contrib,代码行数:48,代码来源:dbresp2autodrm.c


示例2: join_tables

Dbptr join_tables(Dbptr db, Pf *pf, Arr *tables)
{
	char *table_name;
	int *ilogic;
	Tbl *t;
	Dbptr dbj;
	long int nrec;
	int i;
	int ntables=0;

	/* This is an exact copy of above, but it is duplicated because
	this function could get stolen by another future program
	because it is pretty general */
	t = pfget_tbl(pf,"join_tables");
	if(t == NULL)
	{
		elog_die(0,"No list of tables to be joined\n");
	}
	for(i=0;i<maxtbl(t);++i)
	{
		table_name = gettbl(t,i);
		ilogic = (int *)getarr(tables,table_name);
		if(ilogic == NULL)
		{
			elog_die(0,"Table %s was not handled previously by check_tables.\nProgramming logic error\n",
				table_name);
		}
		else if(*ilogic)
		{
			if(ntables == 0)
				dbj = dblookup(db,0,table_name,0,0);
			else
				dbj=dbjoin(dbj,dblookup(db,0,table_name,0,0),
					NULL,NULL,0,NULL,0);
			++ntables;
			dbquery(dbj,dbRECORD_COUNT,&nrec);
			if(nrec == 0)
			{
				elog_complain(0,
					"join_tables error\njoined database has 0 length after joining table %s\n",
					table_name);
				dbj.record = dbINVALID;
				return(dbj);
			}
		}
	}
	return(dbj);
}
开发者ID:NVSeismoLab,项目名称:antelope_contrib,代码行数:48,代码来源:db2segy.c


示例3: dbschema2sqlcreate

Tbl *
dbschema2sqlcreate( Dbptr db, long flags )
{
	Tbl	*sql;
	char	*cmd;
	Tbl	*tables;
	char	*table;
	long	itable;

	sql = newtbl( 0 );

	if( db.table >= 0 ) {
		
		cmd = generate_sqltable_create( db, flags );

		pushtbl( sql, cmd );

	} else {

		dbquery( db, dbSCHEMA_TABLES, &tables );

		for( itable = 0; itable < maxtbl( tables ); itable++ ) {

			table = gettbl( tables, itable );

			db = dblookup( db, "", table, "", "" );
			
			cmd = generate_sqltable_create( db, flags );

			pushtbl( sql, cmd );
		}
	}

	return sql;
}
开发者ID:ittaikurzon,项目名称:antelope_contrib,代码行数:35,代码来源:db2sql.c


示例4: opendb

int opendb( Dset *dset )
{
 
   char key[256];
   Tbl *sort_sta_ch_tm;
 
   if (dbopen_database ( dset->dbname, "r+", &(dset->db) ) == dbINVALID )
         die (0, "Can't open database %s\n",  dset->dbname );
 
    dset->db = dblookup ( dset->db, 0, "wfdisc", 0, 0);
    if ( dset->db.table == dbINVALID )
       die (0, "Can't open '%s' wfdisc table.\n", dset->dbname );
 
    /* Select specified sta&chan */
 
    sprintf( key,"(chan =~ /%s/ && sta=~ /%s/)\0", dset->chan, dset->sta );
    dset->db = dbsubset(  dset->db, key, 0 );
    sort_sta_ch_tm = strtbl("sta", "chan", "time", 0 ) ;
    dset->db = dbsort ( dset->db, sort_sta_ch_tm, 0, 0 ) ;
 
    dbquery ( dset->db, dbRECORD_COUNT, &(dset->dbrec) );
    if( dset->dbrec <= 0 )
       die( 0, " no record with sta == %s and chan == %s in %s.\n", 
                 dset->sta, dset->chan, dset->dbname );
 
 
    return 1;
 
}  
开发者ID:battistuz,项目名称:antelope_contrib,代码行数:29,代码来源:util.c


示例5: save_origerr

/*This function adds a single row to the origerr table for this event.

arguments:
	orid - orid assign to this solution
	h - Hypocenter object for this solution
	dbo - output db

This version doesn't set much of this large table.  Eventually, it 
needs to include all the error terms, but that function is not 
written yet. 

Author:  Gary L. Pavlis
Written:  February 1997
*/
void save_origerr(long orid, Hypocenter h, double **C, Dbptr dbo)
{
	double sdobs; 
	double lddate;
	/* Intentionally ignored: smajax,sminax,strike,sdepth,stime,
					conf,commid */

	dbo = dblookup(dbo,0,"origerr",0,0);

	/* Bad news here is that we can't save the more useful 
	statistics that this program calculates.  css3.0 only allows
	sdobs = sswr/ndgf */

	sdobs = h.rms_raw;
	lddate = std_now();
	if(dbaddv(dbo,0,
		"orid",orid,
                "sxx",C[0][0],
                "syy",C[1][1],
                "szz",C[2][2],
                "stt",C[3][3],
                "sxy",C[0][1],
                "sxz",C[0][2],
                "syz",C[1][2],
                "stx",C[0][3],
                "sty",C[1][3],
                "stz",C[2][3],
		"sdobs",sdobs,
                "lddate",lddate,
			NULL) == dbINVALID)
	{
		elog_die(1,"save_origerr: dbaddv error writing origerr record for orid %ld\n",
				orid);
	}
}
开发者ID:antelopeusersgroup,项目名称:antelope_contrib,代码行数:49,代码来源:relocate.c


示例6: save_emodel

/* This routines cautiously saves the emodel vector.  It is cautious
because the emodel table is not part of the css3.0 schema.  If it
cannot find info on the emodel table, it issues an error and returns.
Otherwise, it will save the emodel vector to this special table.
Author:  Gary L. Pavlis
Written: June 29, 1998 */
int save_emodel(int orid, float *emodel, Dbptr db)
{
	Dbptr dbemod;  

	dbemod = dblookup(db, 0,"emodel",0,0);
	if(dbemod.table == dbINVALID)
	{
		elog_log(0,"emodel table not defined for output database\nAdd genloc mods\n");
		return(1);
	}
	else
	{
		if(dbaddv(dbemod,0,
			"orid",orid,
			"emodelx",emodel[0],
			"emodely",emodel[1],
			"emodelz",emodel[2],
			"emodelt",emodel[3],
				NULL ) == dbINVALID)
		{
			elog_log(0,"dbaddv error for emodel table\n");
			return(-1);
		}
	}
	return(0);
}
开发者ID:EugeneGalipchak,项目名称:antelope_contrib,代码行数:32,代码来源:eqerror.c


示例7: save_run_parameters

void save_run_parameters(Dbptr db,Pf *pf)
{
	char *dir,*dfile;
	char filename[512];
	char *vm,*vm3d;
	int ierr;
	
	dir = pfget_string(pf,"pmelrun_archive_directory");
	if(dir==NULL)elog_die(0,"Parameter pmelrun_archive_directory not in parameter file\n");
	if(makedir(dir))
		elog_die(0,"makedir failed on directory %s\n",dir);
	dfile = pfget_string(pf,"pmel_run_name");

	
	vm = pfget_string(pf,"travel_time_model");
	vm3d=pfget_string(pf,"3Dreference_model");
	if( (vm==NULL) || (vm3d==NULL) )
		elog_die(0,"Missing required velocity model definitions\nCheck parameters travel_time model and 3Dreference_model\n");
	db = dblookup(db,0,"pmelruns",0,0);
	ierr=dbaddv(db,0,"pmelrun",dfile,
		"vmodel",vm,
		"vmodel3d",vm3d,
		"dir",dir,
		"dfile",dfile,0);
	if(ierr < 0) elog_die(0,
		   "dbaddv error on pmelrun table\nVerify schema extensions for dbpmel and that the pmel_run_name parameter is unique\n");

	strcpy(filename,dir);
	strcat(filename,"/");
	strcat(filename,dfile);
	if(pfwrite(filename,pf))
		elog_die(0,"pfwrite error for file %s\n",filename);
}
开发者ID:battistuz,项目名称:antelope_contrib,代码行数:33,代码来源:dbpmel.c


示例8: dbtable_invalid

/* This first little function returns 0 if the table defined by
the string t is a valid table name for the database pointed
to by the database pointer db.  Otherwise it returns a 1.
This allows a general way to safely check for the validity of 
extension tables to a common schema like css3.0.  General usage would be:

if(dbtable_invalid(db,t)) elog_die(0,"blah blah");

Generally this routine should be called once for a given table, but
it can be called repeatedly at the cost of efficiency.  The later
is specially bad if the table involved is hit often.  
*/
int dbtable_invalid(Dbptr db,char *t)
{
	Dbptr dbcheck;

	dbcheck = dblookup(db,0,t,0,0);
	if(dbcheck.table == dbINVALID)
		return(-1);
	else
		return(0);
}
开发者ID:EugeneGalipchak,项目名称:antelope_contrib,代码行数:22,代码来源:save_predarr.c


示例9: dbtable_empty

/* returns true if the table t is empty */
int dbtable_empty(Dbptr db,char *t)
{
	long nrows;
	db=dblookup(db,0,t,0,0);
	dbquery(db,dbRECORD_COUNT,&nrows);
	if(nrows>0) 
		return(0);
	else
		return(1);
}
开发者ID:EugeneGalipchak,项目名称:antelope_contrib,代码行数:11,代码来源:save_predarr.c


示例10: set_shot_variable

void set_shot_variable(Dbptr db, Arr *tables, int evid, SEGYTraceHeader *h)
{
	int *ok;
	char ss_string[30];
	long int ntest;
	double dnorth, deast, elev, edepth;

	ok = getarr(tables,"shot");
	if(ok)
	{
		db = dblookup(db,0,"shot",0,0);
		sprintf(ss_string,"evid == %d",evid);
		db = dbsubset(db,ss_string,0);
		dbquery(db,dbRECORD_COUNT,&ntest);
		if(ntest <= 0)
		{
			elog_complain(0,"evid %d not found in shot table\nShot coordinates will not be saved in segy headers\n",
				evid);
			dbfree(db);
			return;
		}
		else if(ntest > 1)
		{
			elog_notify(0,"multiple rows in shot found for evid %d\n",
				evid);
		}
		db.record = 0;
		if(dbgetv(db,0,
			"dnorth",&dnorth,
			"deast", &deast,
			"elev", &elev,
			"edepth",&edepth,
				NULL) == dbINVALID)
		{
			elog_complain(0,"dbgetv error for evid %d\nShot coordinates will not be saved in segy headers\n",
				evid);
			return;
		}
		/*convert to m from km */
		deast *= 1000.0;
		dnorth *= 1000.0;
		h->sourceLongOrX          = htonl((int32_t) deast);
		h->sourceLatOrY           = htonl((int32_t) dnorth);
		h->sourceSurfaceElevation = htonl((int32_t) elev);
		h->sourceDepth            = htonl((int32_t) edepth);
		/* WARNING:  This assumes receiver coordinates have already been set */
		h->sourceToRecDist = htonl( (int32_t) hypot(
					dnorth - ((double)(ntohl(h->recLatOrY ))),
					deast  - ((double)(ntohl(h->recLongOrX)))
		));
	}
	dbfree(db);
}
开发者ID:NVSeismoLab,项目名称:antelope_contrib,代码行数:53,代码来源:db2segy.c


示例11: save_origin

int save_origin(int nass, int evid, Dbptr master_db, Dbptr dbtmp,
			Hypocenter h,Location_options o, int orb)
{
	int ndef;
	char dtype[2];
        char algorithm[16]="ggnloc";
	char auth[16]="orbgenloc";
	int grn, srn;
	int orid;  /* orid returned */

	orid = dbnextid(master_db,"orid");
	if(orid  < 0 )
		elog_die(1,"save_origin:  dbnextid failure asking for new orid\n");
        if(o.fix[2])
        {
                ndef = h.degrees_of_freedom + 3;
                strcpy(dtype,"r");
        }
        else
        {
                ndef = h.degrees_of_freedom + 4;
                strcpy(dtype,"f");
        }
	grn = grnumber(h.lat, h.lon) ;
	srn = srnumber ( grn ) ;
	dbtmp = dblookup(dbtmp,0,"origin",0,0);
	dbtmp.record = dbSCRATCH;
	if((dbputv(dbtmp,0,
                "lat",h.lat,
                "lon",h.lon,
                "depth",h.z,
                "time",h.time,
                "orid",orid,
		"evid",evid,
		"nass",nass,
		"grn", grn,
		"srn", srn,
		"dtype",dtype,
		"ndef",ndef,
		"algorithm",algorithm,
		"auth",auth,0))
			 == dbINVALID)
	{
		elog_complain(0,"dbputv error while building origin record for orid %d\nNo results saved\n",
			orid);
	}
	else
	{
		if(save_dbrecord(dbtmp,orb))
			elog_complain(0,"Errors saving orid %d\n",orid);
	}
	return(orid);
}
开发者ID:EugeneGalipchak,项目名称:antelope_contrib,代码行数:53,代码来源:orbgenloc.c


示例12: save_origerr

/*This function adds a single row to the origerr table for this event.

arguements:
	orid - orid assign to this solution
	h - Hypocenter object for this solution
	dbo - output db

This version doesn't set much of this large table.  Eventually, it 
needs to include all the error terms, but that function is not 
written yet. 

Author:  Gary L. Pavlis
Written:  February 1997
*/
void save_origerr(int orid, Hypocenter h, double **C, Dbptr db, int orb)
{
	double sdobs; 
	int rc;
	double smajax,sminax,strike,sdepth,stime;
	double conf=0.683;

	db = dblookup(db,0,"origerr",0,0);
	db.record = dbSCRATCH;

	/* computer error ellipse parameters */
	rc = project_covariance(C,CHI_SQUARE,&conf,
			h.rms_weighted,h.degrees_of_freedom,
			&smajax,&sminax,&strike,&sdepth,&stime);

	/* Bad news here is that we can't save the more useful 
	statistics that this program calculates.  css3.0 only allows
	sdobs = sswr/ndgf */

	sdobs = h.rms_raw;
	if(dbputv(db,0,
		"orid",orid,
                "sxx",C[0][0],
                "syy",C[1][1],
                "szz",C[2][2],
                "stt",C[3][3],
                "sxy",C[0][1],
                "sxz",C[0][2],
                "syz",C[1][2],
                "stx",C[0][3],
                "sty",C[1][3],
                "stz",C[2][3],
		"sdobs",sdobs,
		"smajax",smajax,
		"sminax",sminax,
		"strike",strike,
		"sdepth",sdepth,
		"stime",stime,
		"conf",conf,
			0) == dbINVALID)
	{
		elog_complain(0,"save_origerr: dbputv error writing origerr record for orid %d\norigerr record not saved anywhere\n",
				orid);
	}
	else
	{
		if(save_dbrecord(db,orb))
			elog_complain(0,"Error saving origerr record for orid %d\n",
				orid);
	}

}
开发者ID:EugeneGalipchak,项目名称:antelope_contrib,代码行数:66,代码来源:orbgenloc.c


示例13: dbget

/* Initializes the scratch records for each table used in this program.  
That is, origin, origerr, and assoc.  This only needs to be done
once.  The procedure loads NULL files into each attribute of the
scratch records for these tables.  This function is based
on a tricky initialization condition using dbget.  Setting
the db record to dbNULL and then calling dbget(db,0) loads the
scratch record with the contents of the NULL record.  This works
because the NULL record is initialized the first time it is
accessed, and passing 0 to dbget is a shortcut that directly 
copies the NULL record to the scratch record.  IMPORTANT:  note
that because this program uses dbputv directly to the scratch
record the assumption is that the SAME set of attributes are
always written to the scratch record of each table.  This is
correct for this program, but you are warned if you try to use
functions from this program elsewhere.  

Arguments:  db - db pointer of open database 

returns 0 on success.  Any errors will always result in
a return of dbINVALID.  The later should, of course, be
trapped but should probably not normally be fatal.
*/
initialize_scratch_records(Dbptr db)
{
	int return_code;
	int error_count=0;

	db = dblookup(db,0,"origin",0,0);
	db.record = dbNULL;
	return_code = dbget(db,0);
	if(return_code) ++error_count;
	db = dblookup(db,0,"origerr",0,0);
	db.record = dbNULL;
	return_code = dbget(db,0);
	if(return_code) ++error_count;
	db = dblookup(db,0,"assoc",0,0);
	db.record = dbNULL;
	return_code = dbget(db,0);
	if(return_code) ++error_count;
	if(error_count)
		return(dbINVALID);
	else
		return(0);
}
开发者ID:EugeneGalipchak,项目名称:antelope_contrib,代码行数:44,代码来源:orbgenloc.c


示例14: newarr

/* This routine looks for a Tbl in the parameter space that
defines a set of auxiliary tables that are to be used.  It
cautiously checks to see if that table is defined in the
schema and is nonempty.  It sets logical variables in associative
array it returns that define if the table is "ok".  This is serious
overkill added to make the code for expandable in the future.
At the moment the only table that would be used is "shot".
It would, however, be easy to add similar auxiliary tables for
segy constructs like statics, mute definition, etc.  In that
case there probably should be a more general mechanism than this
but I'm more or less laying out a useful functionality here rather
than doing it in a completely general way.
*/
Arr *check_tables(Dbptr db, Pf *pf)
{
	char *table;
	int *ilogic;
	int i;
	Tbl *t;
	Dbptr dbtmp;
	int table_ok;
	long int nrec;
	Arr *a;

	a = newarr(0);
	t = pfget_tbl(pf,"join_tables");
	if(t == NULL)
	{
		elog_die(0,"No list of tables to be joined\n");
	}
	for(i=0;i<maxtbl(t);++i)
	{
		/* This series of conditionals is safe:  It certifies
		a table (a) is defined in this schema and (b) is
		not empty.  */
		table = (char *)gettbl(t,i);
		dbtmp = dblookup(db,0,table,0,0);
		if(dbtmp.table == dbINVALID)
			table_ok = 0;
		else
			table_ok = 1;
		if(table_ok)
		{
			dbquery(dbtmp,dbRECORD_COUNT,&nrec);
			if(nrec > 0)
				table_ok = 1;
			else
				table_ok = 0;
		}
		ilogic = (int *) malloc(sizeof(int));
		if(ilogic == NULL) elog_die(0,"malloc error\n");
		*ilogic = table_ok;
		setarr(a,table,ilogic);
	}
	return(a);
}
开发者ID:NVSeismoLab,项目名称:antelope_contrib,代码行数:56,代码来源:db2segy.c


示例15: save_event

/* Changed to int from void by JN in order to return evid. */
long save_event(Dbptr dbi, long is, long ie, long orid, Dbptr dbo)

{
	/* these are variables in dbi copied to dbo */
	long evid;
	char evname[16];
	
	/*altered in output by this program */
	long prefor;
	char auth[20];
	double lddate;

	/* intentionally ignored:  commid */

	dbo = dblookup(dbo,0,"event",0,0);
	dbi.record = is;
	if( dbgetv(dbi,0,
		"event.evid",&evid,
		"event.evname",evname,	
				NULL) == dbINVALID)
	{
		elog_die(1,"save_event: dbgetv error reading event fields of input view at record %ld\n",
				is);
	}
	prefor = orid;
	my_username(auth);
	lddate = std_now();
	if(dbaddv(dbo,0,
                "evid",evid,
		"evname",evname,
		"prefor",prefor,
                "auth",auth,
                "lddate",lddate,
			NULL ) == dbINVALID)
	{
		elog_die(1,"save_event: dbaddv error writing event record for orid %ld\n",
				orid);
	}
        /* Added by JN */
	return(evid);
}
开发者ID:antelopeusersgroup,项目名称:antelope_contrib,代码行数:42,代码来源:relocate.c


示例16: frequency

/* This routine saves array average amplitude estimates in a table
called mwavgamp.  This routine always adds one and only one record.

arguments:

array - array name assigned to the group of stations used to produce
	this set of averages
evid - css3.0 event id
bankid - multiwavelet group id 
phase - phase name as in css3.0
fc - center frequency (in Hz) of the wavelets used
t0 - start time at reference station
twin - length of analysis time window relative to t0
mwamp - computed array average amplitude
erramp - estimate of error in mwamp 
	Note: both mwap and erramp are log10 values derived from nm/s
	converted trace data (assumed).
ndgf - degrees of freedom in estimate of mwamp
db - pointer to output database 

Author:  G Pavlis
Written:  March 2000
*/
int MWdb_save_avgamp(char *array,
	int evid, 
	int bankid,
	char *phase,
	double fc,
	double t0,
	double twin,
	double mwamp,
	double erramp,
	int ndgf,
	Dbptr db)
{

	db = dblookup(db,0,"mwavgamp",0,0);

	/* Note algorithm and ampcomp are frozen here.   */

	if( dbaddv(db,0,"sta",array,
		"evid",evid,
		"bankid",bankid,
		"phase", phase,
		"fc",fc,
		"ampcomp",AMPCOMP,
		"time",t0,
		"twin",twin,
		"mwamp",mwamp,
		"erramp",erramp,
		"ndgf",ndgf,
		"algorithm","mwap",0) < 0) 
	{
		elog_notify(0,
			"dbaddv error for mwavgamp table on evid %d with  fc=%lf\n",
				evid,fc);
		return(-1);
	}
	else
		return(0);
}
开发者ID:EugeneGalipchak,项目名称:antelope_contrib,代码行数:61,代码来源:dbsubs.c


示例17: announce_StachanCalib

void
announce_StachanCalib( void *sccp, char *sta, char *chan ) 
{
	StachanCalib *scc = (StachanCalib *) sccp;
	static Dbptr db = { dbINVALID, dbINVALID, dbINVALID, dbINVALID };

	if( db.database == dbINVALID ) {

		db = dbtmp( "rt1.0" );

		db = dblookup( db, "", "wfoffset", "", "dbSCRATCH" );
	}

	if( abs( scc->offset ) < DBL_MIN ) {
		
		return;
	}

	dbputv( db, 0, "sta", sta, 
		       "chan", chan, 
		       "time", now(), 
		       "endtime", 9999999999.999,
		       "valoffset", scc->offset,
		       0 );

	if( db2orbpkt( db, Orbfd ) < 0 ) {
		
		elog_complain( 0, "Orbput failed for wfoffset packet!\n" );

	} else {
		
		scc->announced++;
	}

	return;
}
开发者ID:battistuz,项目名称:antelope_contrib,代码行数:36,代码来源:ryo2orb.c


示例18: save_origin

long save_origin(Dbptr dbi, long is, long ie, int depth_fixed,
	Hypocenter h, Dbptr dbo)
{
	long orid;

	/* These are parameters copied from input db -- names = css names */
	long evid;
	long jdate;
	long grn;
	long srn;
	char etype[8];
	double mb;
	long mbid;
	double ms;
	long msid;
	double ml;
	long mlid;
	/* These obtained from this solution */

	long nass;
	long ndef;
	char dtype[2];
	char algorithm[16]="genloc-nlls";
	char auth[20];
	double lddate;
	

	/* these are intentionally left null: ndp,depdp,commid*/


	/* set but obtained directly from hypo structure 
	lat, lon, depth, time */

	dbo = dblookup(dbo,0,"origin",0,0);
	
	/* Grab what we need from the input db for copying.  Note
	that because the joins used here, each of the input db
	records have the same origin entries.  Thus, we just fetch
	stuff from row is.  */
	dbi.record = is;
	if( dbgetv(dbi,0,
		"origin.evid", &evid,
		"origin.jdate", &jdate,
		"origin.grn", &grn,
		"origin.srn", &srn,
		"origin.etype", etype,
		"origin.mb", &mb,
		"origin.mbid", &mbid,
		"origin.ms", &ms,
		"origin.msid", &msid,
		"origin.ml", &ml,
		"origin.mlid", &mlid,
				NULL) == dbINVALID)
	{
		elog_die(1,"save_origin: dbgetv error reading origin fields of input view at record %ld\n",
				is);
	}
	nass = ie - is;
	/* ndef is potentially wrong by this calculation.  We set ndef 
	from the number of degrees of freedom in the solution + npar
	where npar is 3 when depth is fixed and 4 otherwise.  This does
	not match the real definition of ndef, especially when array 
	data are used because each arrival then then has 3 data points
	used to constrain the solution.  These is either an error in 
	my (glp) understanding of the css3.0 schema or a flaw in its 
	design.*/
	if(depth_fixed)
	{
		ndef = h.degrees_of_freedom + 3;
		strcpy(dtype,"r");
	}
	else
	{
		ndef = h.degrees_of_freedom + 4;
		strcpy(dtype,"f");
	}
	my_username(auth);
	lddate = std_now();
	orid = dbnextid(dbo,"orid");
	if(dbaddv(dbo,0,
                "lat",h.lat,
                "lon",h.lon,
                "depth",h.z,
                "time",h.time,
                "orid",orid,
                "evid",evid,
                "jdate",jdate,
                "nass",nass,
                "ndef",ndef,
                "grn",grn,
                "srn",srn,
                "etype",etype,
                "dtype",dtype,
                "mb",mb,
                "mbid",mbid,
                "ms",ms,
                "msid",msid,
                "ml",ml,
                "mlid",mlid,
                "algorithm",algorithm,
//.........这里部分代码省略.........
开发者ID:antelopeusersgroup,项目名称:antelope_contrib,代码行数:101,代码来源:relocate.c


示例19: main

int main(int argc, char **argv)
{
	char *dbin;  /* Input db name */
	char *dbout;  /* output db name */
	Dbptr db;  /* input db pointer */
	Dbptr dbo;  /* base output db pointer */
	Dbptr dbv;  /* set to view formed by join */
	char *pfin=NULL;  /* input parameter file */
	char *sift_exp;  /* sift expression for subset */
	int sift = 0;  /* default is no sift.  */
	Tbl *sortkeys;
	Tbl *joinkey1, *joinkey2;
	/*Pointers to views returned by dbgroup (keyed to origin and event
	respectively */
	Dbptr dborigin_group;
	Tbl *origin_group;  /* relation keys used in grouping*/
	long nevents;
	/* db row variables */
	long evid;
	long nrows, nrows_raw;

	int useold=0;
	Pf *pf;
	Tbl *ta,*tu;
	Tbl *reason_converged, *residual;
	Location_options o;
	Arr *arr_phase;
	int i;
	Tbl *converge_history;

	Hypocenter h0;
	Hypocenter *hypos;
	long niterations;

	char *vmodel;

	int ret_code;  /* ggnloc return code */
	double **C;   /* covariance matrix*/
	float emodel[4];  

	/* entries for S-P feature */
	long nbcs;
	Arr *badclocks;
	/* need global setting of this to handle fixed depth solutions*/
	int global_fix_depth;

	C=dmatrix(0,3,0,3);

	if(argc < 3) usage();
	dbin = argv[1];
	dbout = argv[2];
	for(i=3;i<argc;++i)
	{
		if(!strcmp(argv[i],"-pf"))
		{
			++i;
			if(i>=argc) usage();
			pfin = argv[i];
		}
		else if(!strcmp(argv[i],"-sift"))
		{
			++i;
			if(i>=argc) usage();
			sift_exp = argv[i];
			sift = 1;
		}
		else if(!strcmp(argv[i],"-useold"))
			useold = 1;
		else
			usage();
	}
	/* set default this way*/
	if(pfin == NULL) pfin = strdup("relocate");


	/* Initialize the error log and write a version notice */
	elog_init (argc, argv) ;
	cbanner("Version $Revision$ $Date$\n",
			"relocate inputdb outputdb [-pf pf -sift expression -useold]\n",
			"Gary Pavlis",
                        "Indiana University",
                        "[email protected]");

	/* Alway join assoc, arrival, and site.  We join site 
	to make sure station table is properly dynamic to account for
	time changes.  With this setup, the stations can even move
	around and this should still work.*/


	if(dbopen(dbin,"r",&db) == dbINVALID) 
		elog_die(1,"Unable to open input database %s\n",dbin);
	if(dbopen(dbout,"r+",&dbo) == dbINVALID) 
		elog_die(1,"Unable to open output database %s\n",dbout);

	dbv = dbjoin ( dblookup(db,0,"event",0,0),
		dblookup(db,0,"origin",0,0),
		0,0,0,0,0);
	if(dbv.table == dbINVALID)
		elog_die(1,"event->origin join failed\n");
	dbv = dbjoin ( dbv, dblookup(db,0,"assoc",0,0),
//.........这里部分代码省略.........
开发者ID:antelopeusersgroup,项目名称:antelope_contrib,代码行数:101,代码来源:relocate.c


示例20: save_assoc

void save_assoc(Dbptr dbi, long is, long ie, long orid, char *vmodel,
	Tbl *residual,Hypocenter h, Dbptr dbo)
{
	/* These fields are copied from input assoc table */
	long arid;
	char sta[8];
	char phase[10];
	double belief;
	/* These fields are set here */
	double delta;
	double seaz;
	double esaz;
	double timeres;
	double azres;
	double slores;
	double lddate;
	double wgt;
	char timedef[2],slodef[2], azdef[2];
	
	/* intentionally ignored:  emares, commid */


	/* passed through arg list;  orid*/

	/* We use this to produce a keyed arr list of the residual 
	list passed into here as a Tbl */

	Arr *residual_array;
	long i;
	char key[40]; 

	double r, w, reswt,uxresid, uyresid;
	double stalat, stalon; 
	double ux, uy, azimuth;
	double u,phi;  /* polar form of measured slowness vector */
	double duphi;

	dbo = dblookup(dbo,0,"assoc",0,0);
	lddate = std_now();

	/* We build an associate array for the residual tbl keying
	each entry with a sta/phase/type key  where type is 
	set in ggnloc as time, ux, or uy.  This complication is
	needed to sort out array residuals. */
	residual_array = newarr(0);
	for(i=0;i<maxtbl(residual);++i)
	{
		char *s;
		char keysta[10], keyphase[10], keytype[5];
		s = (char *)gettbl(residual,i);
		sscanf(s,"%s %s %s",keysta,keyphase,keytype);
		/* handle S-P case by having the same residual mapped
		to each half of - phase pair */
		if(strchr(keyphase,'-'))
		{
			char *phase1,*phase2;
			/* algorithm to split phase names cloned from dbgenloc */
			phase1 = strdup(keyphase);
			phase2= strchr(phase1,'-');
			*phase2 = '\0';
			++phase2;
			sprintf(key,"%s %s %s",keysta,phase1,keytype);
			setarr(residual_array,key,s);
                        sprintf(key,"%s %s %s",keysta,phase2,keytype);
                        setarr(residual_array,key,s);
			free(phase1);
		}
		else
		{
			/* normal phases are one to one */
			sprintf(key,"%s %s %s",keysta,keyphase,keytype);
			setarr(residual_array,key,s);
		}
	}
		

	for(dbi.record=is;dbi.record < ie;++dbi.record)
	{
		char *time_residual_record;
		char *ux_residual_record,*uy_residual_record;
		if( dbgetv(dbi,0,
      	    		"assoc.arid",&arid,
          		"assoc.sta",sta,
          		"assoc.phase",phase,
          		"assoc.belief",&belief,
				NULL) == dbINVALID)
		{
		  elog_die(1,"save_assoc: dbgetv error reading assoc fields of input view at record %ld\n",
				dbi.record);
		}
		if( dbgetv(dbi,0,
			"site.lat",&stalat,
			"site.lon",&stalon,
				NULL) == dbINVALID)
		{
		  elog_die(1,"save_assoc: dbgetv error reading site fields of input view at record %ld\n",
				dbi.record);
		}
		/* Find the time residual record for this arrival */
		sprintf(key,"%s %s time",sta,phase);
//.........这里部分代码省略.........
开发者ID:antelopeusersgroup,项目名称:antelope_contrib,代码行数:101,代码来源:relocate.c



注:本文中的dblookup函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ dbm_close函数代码示例发布时间:2022-05-30
下一篇:
C++ dblogin函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap