<commit_before>/*
  This file is part of the Astrometry.net suite.
  Copyright 2006, 2007 <NAME>, <NAME> and <NAME>.

  The Astrometry.net suite is free software; you can redistribute
  it and/or modify it under the terms of the GNU General Public License
  as published by the Free Software Foundation, version 2.

  The Astrometry.net suite is distributed in the hope that it will be
  useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with the Astrometry.net suite ; if not, write to the Free Software
  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
*/

#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <errno.h>
#include <string.h>
#include <sys/mman.h>
#include <math.h>

#include "starutil.h"
#include "mathutil.h"
#include "boilerplate.h"
#include "xylist.h"

const char* OPTIONS = "h";

void printHelp(char* progname) {
	boilerplate_help_header(stderr);
	fprintf(stderr, "\nUsage: %s <xyls-file>\n"
			"\n", progname);
}

extern char *optarg;
extern int optind, opterr, optopt;

int main(int argc, char** args) {
    int argchar;
	char* progname = args[0];
	char** inputfiles = NULL;
	int ninputfiles = 0;
	xylist_t* xyls;
	xy_t* xy;

    while ((argchar = getopt (argc, args, OPTIONS)) != -1) {
		switch (argchar) {
		case 'h':
		default:
			printHelp(progname);
			exit(-1);
		}
	}
	if (optind < argc) {
		ninputfiles = argc - optind;
		inputfiles = args + optind;
	}
	if (ninputfiles != 1) {
		printHelp(progname);
		exit(-1);
	}

	xyls = xylist_open(inputfiles[0]);
	if (!xyls) {
		fprintf(stderr, "Failed to open xyls file %s.\n", inputfiles[0]);
		exit(-1);
	}
    xylist_set_include_flux(xyls, FALSE);
    xylist_set_include_background(xyls, FALSE);

	xy = xylist_read_field(xyls, NULL);
	if (!xy) {
		fprintf(stderr, "Failed to get XYLS field.\n");
		exit(-1);
	}

	{
        qfits_header* hdr;
		double xmax, xmin, ymax, ymin;
		double diag;
		int imw, imh;
		int i;
		xmax = ymax = -HUGE_VAL;
		xmin = ymin =  HUGE_VAL;
		for (i=0; i<xy_n(xy); i++) {
			double x = xy_getx(xy, i);
			double y = xy_gety(xy, i);
			if (x > xmax) xmax = x;
			if (x < xmin) xmin = x;
			if (y > ymax) ymax = y;
			if (y < ymin) ymin = y;
		}
 
		diag = hypot(xmax-xmin, ymax-ymin);
        hdr = xylist_get_primary_header(xyls);
		imw = qfits_header_getint(hdr, "IMAGEW", -1);
		imh = qfits_header_getint(hdr, "IMAGEH", -1);
		if (imw > -1)
			printf("imagew %i\n", imw);
		if (imh > -1)
			printf("imageh %i\n", imh);

		printf("x_min %g\n", xmin);
		printf("x_max %g\n", xmax);
		printf("y_min %g\n", ymin);
		printf("y_max %g\n", ymax);
		printf("width %g\n", xmax-xmin);
		printf("height %g\n", ymax-ymin);
		printf("x_center %g\n", (xmin + xmax) / 2.0);
		printf("y_center %g\n", (ymin + ymax) / 2.0);
		printf("diag %g\n", diag);
	}

	xy_free(xy);
	xylist_close(xyls);
	return 0;
}<commit_msg>maybe it was the right header...<commit_after>/*
  This file is part of the Astrometry.net suite.
  Copyright 2006, 2007 <NAME>, <NAME> and <NAME>.

  The Astrometry.net suite is free software; you can redistribute
  it and/or modify it under the terms of the GNU General Public License
  as published by the Free Software Foundation, version 2.

  The Astrometry.net suite is distributed in the hope that it will be
  useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with the Astrometry.net suite ; if not, write to the Free Software
  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
*/

#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <errno.h>
#include <string.h>
#include <sys/mman.h>
#include <math.h>

#include "starutil.h"
#include "mathutil.h"
#include "boilerplate.h"
#include "xylist.h"

const char* OPTIONS = "h";

void printHelp(char* progname) {
	boilerplate_help_header(stderr);
	fprintf(stderr, "\nUsage: %s <xyls-file>\n"
			"\n", progname);
}

extern char *optarg;
extern int optind, opterr, optopt;

int main(int argc, char** args) {
    int argchar;
	char* progname = args[0];
	char** inputfiles = NULL;
	int ninputfiles = 0;
	xylist_t* xyls;
	xy_t* xy;

    while ((argchar = getopt (argc, args, OPTIONS)) != -1) {
		switch (argchar) {
		case 'h':
		default:
			printHelp(progname);
			exit(-1);
		}
	}
	if (optind < argc) {
		ninputfiles = argc - optind;
		inputfiles = args + optind;
	}
	if (ninputfiles != 1) {
		printHelp(progname);
		exit(-1);
	}

	xyls = xylist_open(inputfiles[0]);
	if (!xyls) {
		fprintf(stderr, "Failed to open xyls file %s.\n", inputfiles[0]);
		exit(-1);
	}
    xylist_set_include_flux(xyls, FALSE);
    xylist_set_include_background(xyls, FALSE);

	xy = xylist_read_field(xyls, NULL);
	if (!xy) {
		fprintf(stderr, "Failed to get XYLS field.\n");
		exit(-1);
	}

	{
        qfits_header* hdr;
		double xmax, xmin, ymax, ymin;
		double diag;
		int imw, imh;
		int i;
		xmax = ymax = -HUGE_VAL;
		xmin = ymin =  HUGE_VAL;
		for (i=0; i<xy_n(xy); i++) {
			double x = xy_getx(xy, i);
			double y = xy_gety(xy, i);
			if (x > xmax) xmax = x;
			if (x < xmin) xmin = x;
			if (y > ymax) ymax = y;
			if (y < ymin) ymin = y;
		}
 
		diag = hypot(xmax-xmin, ymax-ymin);
        hdr = xylist_get_header(xyls);
		imw = qfits_header_getint(hdr, "IMAGEW", -1);
		imh = qfits_header_getint(hdr, "IMAGEH", -1);
		if (imw > -1)
			printf("imagew %i\n", imw);
		if (imh > -1)
			printf("imageh %i\n", imh);

		printf("x_min %g\n", xmin);
		printf("x_max %g\n", xmax);
		printf("y_min %g\n", ymin);
		printf("y_max %g\n", ymax);
		printf("width %g\n", xmax-xmin);
		printf("height %g\n", ymax-ymin);
		printf("x_center %g\n", (xmin + xmax) / 2.0);
		printf("y_center %g\n", (ymin + ymax) / 2.0);
		printf("diag %g\n", diag);
	}

	xy_free(xy);
	xylist_close(xyls);
	return 0;
}
{'fraction_non_alphanumeric': 0.14953423762052623, 'fraction_numerical': 0.013074031704526883, 'mean_word_length': 3.4900953778429935, 'pattern_counts': {'":': 0, '<': 33, '<?xml version=': 0, '>': 33, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5955963', 'n_tokens_mistral': 2659, 'n_tokens_neox': 2441, 'n_words': 713}