Exemplo n.º 1
0
static void init_gstat_data(int n) {
	int i, n_vgms, n_outfl;

	n_vgms = (n * (n + 1))/2;
	n_outfl = n + n_vgms;
	if (n <= n_last)
		return;
	data = (DATA **) erealloc(data, n * sizeof(DATA *));
	for (i = n_last; i < n; i++)
		data[i] = init_one_data(NULL);
	vgm = (VARIOGRAM **) erealloc(vgm, n_vgms * sizeof(VARIOGRAM *));
	for (i = n_v_last; i < n_vgms; i++)
		vgm[i] = NULL;
	outfile_names = (char **) erealloc (outfile_names, n_outfl * sizeof(char *));
	for (i = n_o_last; i < n_outfl; i++)
		outfile_names[i] = NULL;
	n_last = n;
	n_o_last = n_outfl;
	n_v_last = n_vgms;
	n_vars = n;
	return;
}
Exemplo n.º 2
0
int ossfim(int argc, char *argv[]) {
	int c, n = 25, dx = 9, dy = 9, i, j, plot_vgm = 0;
	double b = 1, B = 10, s = 1, S = 10, blocksize, samplespacing, est[2],
		**table;
	DATA **d = NULL;
	DPOINT *block = NULL, where;
	char *vgm_str = "1Exp(10)", *map_name = NULL;
	VARIOGRAM *vgm;

	while ((c = getopt(argc, argv, "n:m:B:b:S:s:V:v:x:y:")) != EOF) {
		switch (c) {
			case 'n':
				if (read_int(optarg, &n) || n <= 0)
					ErrMsg(ER_ARGOPT, "n");
				break;
			case 'b':
				if (read_double(optarg, &b) || b < 0)
					ErrMsg(ER_ARGOPT, "b");
				break;
			case 'B':
				if (read_double(optarg, &B) || B <= 0)
					ErrMsg(ER_ARGOPT, "B");
				break;
			case 's':
				if (read_double(optarg, &s) || s <= 0)
					ErrMsg(ER_ARGOPT, "s");
				break;
			case 'S':
				if (read_double(optarg, &S) || S <= 0)
					ErrMsg(ER_ARGOPT, "S");
				break;
			case 'x':
				if (read_int(optarg, &dx) || dx <= 0)
					ErrMsg(ER_ARGOPT, "x");
				break;
			case 'y':
				if (read_int(optarg, &dy) || dy <= 0)
					ErrMsg(ER_ARGOPT, "y");
				break;
			case 'v':
				vgm_str = optarg;
				break;
			case 'V':
				plot_vgm = 1;
				vgm_str = optarg;
				break;
			case 'm':
				map_name = optarg;
				break;
			default:
				ErrClo(optopt);
				break;
		}
	}

	which_identifier("dummy grid");
	d = get_gstat_data();
	init_one_data(d[0]);
	d[0]->id = 0;
	d[0]->n_list = d[0]->n_max = 0;
	d[0]->mode = X_BIT_SET | Y_BIT_SET | V_BIT_SET;
	set_norm_fns(d[0]);
	vgm = get_vgm(0);
	if (read_variogram(vgm, vgm_str))
		ErrMsg(ER_SYNTAX, vgm_str);
	vgm->ev->evt = SEMIVARIOGRAM;
	vgm->id1 = vgm->id2 = d[0]->id;
	block = get_block_p();
	block->z = 0.0;
	block->x = block->y = -1.0;
	est[0] = 0.0;
	est[1] = -1.0;
	where.x = where.y = where.z = 0.0;
	where.X = (double *) emalloc(sizeof(double));
	where.X[0] = 1.0;

	if (plot_vgm)
		return fprint_gnuplot_variogram(stdout, vgm, "", GIF, 0);

	table = (double **) emalloc((dy + 1) * sizeof(double *));
	for (i = 0; i <= dy; i++)
		table[i] = (double *) emalloc((dx + 1) * sizeof(double));

	/* do it: */
	for (i = 0; i <= dx; i++) { /* sample spacing loop */
		samplespacing = s + (i / (1.0 * dx)) * (S - s);
		generate_grid(d[0], samplespacing, n);
		select_at(d[0], &where);
		for (j = 0; j <= dy; j++) { /* block sizes loop */
			reset_block_discr();
			vgm_init_block_values(vgm);
			blocksize = b + (j / (1.0 * dy)) * (B - b);
			block->x = block->y = blocksize;
			if (blocksize == 0.0)
				SET_POINT(&where);
			else
				SET_BLOCK(&where);
			gls(d, 1, GLS_BLUP, &where, est);
			if (map_name)
				table[i][j] = sqrt(est[1]);
			else
				printlog("%g %g %g\n", samplespacing, blocksize, sqrt(est[1]));
		}
	}
	if (map_name)
		ossfim2map(table, map_name, s, S, b, B, dx, dy);
	return 0;
}
Exemplo n.º 3
0
DATA *create_data_area(void) {
	data_area = init_one_data(NULL);
	return data_area;
}
Exemplo n.º 4
0
int init_global_variables(void) {
/*
 * global variables init. (glvars.h; defautls.h):
 */
 	method             = NSP;
	mode               = MODE_NSP;
	debug_level        = DB_NORMAL;
	gl_blas            = DEF_blas;
	gl_choleski        = DEF_choleski;
	gl_coincide        = DEF_coincide;
	gl_cressie         = DEF_cressie;
	gl_fit             = DEF_fit;
	gl_gauss           = DEF_gauss;
	gl_iter            = DEF_iter;
	gl_jgraph          = DEF_jgraph;
	gl_lhs             = DEF_lhs;
	gl_longlat         = DEF_longlat;
	gl_nblockdiscr     = DEF_nblockdiscr;
	gl_n_intervals     = DEF_intervals;
	gl_n_marginals     = DEF_n_marginals;
	gl_nsim            = DEF_nsim;
	gl_n_uk            = DEF_n_uk;
	gl_numbers         = DEF_numbers;
	gl_nocheck         = DEF_nocheck;
	gl_order           = DEF_order;
	gl_register_pairs  = DEF_pairs;
	gl_rowwise         = DEF_rowwise;
	gl_rp              = DEF_rp;
	gl_seed            = DEF_seed;
	gl_sim_beta        = DEF_sim_beta;
	gl_spiral          = DEF_spiral;
	gl_split           = DEF_split;
	gl_sym_ev          = DEF_sym_ev;
	gl_gls_residuals   = DEF_gls_residuals;
	gl_sparse          = DEF_sparse;
	gl_xvalid          = DEF_xvalid;
	gl_zero_est        = DEF_zero_est;
	gl_bounds          = DEF_bounds;
	gl_cutoff       = DEF_cutoff;
	gl_fit_limit    = DEF_fit_limit;
	gl_fraction     = DEF_fraction;
	gl_idp          = DEF_idp;
	gl_iwidth       = DEF_iwidth;
	gl_quantile     = DEF_quantile;
	gl_zmap         = DEF_zmap;
	gl_alpha        = DEF_alpha;
	gl_beta         = DEF_beta;
	gl_tol_hor      = DEF_tol_hor;
	gl_tol_ver      = DEF_tol_ver;
	gl_zero         = DEF_zero;
	
	init_gstat_data(0);
	/* EJPXX 
	 * 	if (valdata == NULL)
	 * 	*/
	valdata = init_one_data(valdata);
	block.x = block.y = block.z = 0.0;
	set_mv_double(&gl_zmap);
	get_covariance(NULL, 0, 0, 0);
	return 0;
}