Esempio n. 1
0
int plot_xy_command(const char* cmd, const char* cmdargs,
					plot_args_t* plotargs, void* baton) {
	plotxy_t* args = (plotxy_t*)baton;
	if (streq(cmd, "xy_file")) {
		plot_xy_set_filename(args, cmdargs);
	} else if (streq(cmd, "xy_ext")) {
		args->ext = atoi(cmdargs);
	} else if (streq(cmd, "xy_xcol")) {
		plot_xy_set_xcol(args, cmdargs);
	} else if (streq(cmd, "xy_ycol")) {
		plot_xy_set_ycol(args, cmdargs);
	} else if (streq(cmd, "xy_xoff")) {
		args->xoff = atof(cmdargs);
	} else if (streq(cmd, "xy_yoff")) {
		args->yoff = atof(cmdargs);
	} else if (streq(cmd, "xy_firstobj")) {
		args->firstobj = atoi(cmdargs);
	} else if (streq(cmd, "xy_nobjs")) {
		args->nobjs = atoi(cmdargs);
	} else if (streq(cmd, "xy_scale")) {
		args->scale = atof(cmdargs);
		//} else if (streq(cmd, "xy_wcs")) {
		//return plot_xy_set_wcs_filename(args, cmdargs);
	} else if (streq(cmd, "xy_vals")) {
		plotstuff_append_doubles(cmdargs, args->xyvals);
	} else {
		ERROR("Did not understand command \"%s\"", cmd);
		return -1;
	}
	return 0;
}
Esempio n. 2
0
int main(int argc, char *args[]) {
	int argchar;
	char* progname = args[0];

	plot_args_t pargs;
	plotxy_t* xy;
	plotimage_t* img;
	int loglvl = LOG_MSG;

    // log errors to stderr, not stdout.
    errors_log_to(stderr);

	plotstuff_init(&pargs);
	pargs.fout = stdout;
	pargs.outformat = PLOTSTUFF_FORMAT_PNG;

	xy = plotstuff_get_config(&pargs, "xy");
	img = plotstuff_get_config(&pargs, "image");
	assert(xy);
	assert(img);

	plotstuff_set_color(&pargs, "white");
	plotstuff_set_bgcolor(&pargs, "black");
	
	img->format = PLOTSTUFF_FORMAT_PPM;

	while ((argchar = getopt(argc, args, OPTIONS)) != -1)
		switch (argchar) {
		case 'v':
			loglvl++;
			break;
        case 'C':
			plotstuff_set_color(&pargs, optarg);
            break;
        case 'b':
			plotstuff_set_bgcolor(&pargs, "optarg");
            break;
        case 'o':
            pargs.outfn = optarg;
            break;
        case 'X':
			plot_xy_set_xcol(xy, optarg);
            break;
        case 'Y':
			plot_xy_set_ycol(xy, optarg);
            break;
        case 'P':
            pargs.outformat = PLOTSTUFF_FORMAT_PPM;
            break;
		case 'J':
            pargs.outformat = PLOTSTUFF_FORMAT_PDF;
			break;
		case 'p':
			img->format = PLOTSTUFF_FORMAT_PNG;
            break;
        case 'I':
			plot_image_set_filename(img, optarg);
            break;
		case 'S':
			xy->scale = atof(optarg);
			break;
		case 'i':
			plot_xy_set_filename(xy, optarg);
			break;
		case 'x':
			xy->xoff = atof(optarg);
			break;
		case 'y':
			xy->yoff = atof(optarg);
			break;
		case 'W':
			pargs.W = atoi(optarg);
			break;
		case 'H':
			pargs.H = atoi(optarg);
			break;
		case 'n':
			xy->firstobj = atoi(optarg);
			break;
		case 'N':
			xy->nobjs = atoi(optarg);
			break;
		case 'e':
			xy->ext = atoi(optarg);
			break;
		case 'r':
			pargs.markersize = atof(optarg);
			break;
		case 'w':
			pargs.lw = atof(optarg);
			break;
		case 's':
			plotstuff_set_marker(&pargs, optarg);
			break;
		case 'h':
			printHelp(progname);
            exit(0);
		case '?':
		default:
			printHelp(progname);
            exit(-1);
		}

	if (optind != argc) {
		printHelp(progname);
		exit(-1);
	}
	if (!xy->fn) {
		printHelp(progname);
		exit(-1);
	}
	log_init(loglvl);
	log_to(stderr);
	fits_use_error_system();
	if (img->fn) {
		if (plot_image_setsize(&pargs, img)) {
			ERROR("Failed to set plot size from image");
			exit(-1);
		}
		plotstuff_run_command(&pargs, "image");
	} else {
		if (pargs.W == 0 || pargs.H == 0) {
			if (plot_xy_setsize(&pargs, xy)) {
				ERROR("Failed to set plot size from xylist");
				exit(-1);
			}
		}
	}

	plotstuff_run_command(&pargs, "xy");

	plotstuff_output(&pargs);
	plotstuff_free(&pargs);

	return 0;
}