2021-04-03 10:46:00 +02:00
|
|
|
/*
|
|
|
|
* exporting a floatimg to a FITS file
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <unistd.h>
|
2021-05-20 09:31:28 +02:00
|
|
|
#include <stdint.h>
|
2021-04-03 10:46:00 +02:00
|
|
|
|
|
|
|
#include "../floatimg.h"
|
|
|
|
|
|
|
|
int verbosity;
|
|
|
|
|
|
|
|
/* ----------------------------------------------------------------- */
|
|
|
|
int export_fimg_plane_as_fits(char *infile, char *outfile, char plane)
|
|
|
|
{
|
|
|
|
FloatImg fimg;
|
|
|
|
int foo;
|
|
|
|
|
|
|
|
foo = fimg_create_from_dump(infile, &fimg);
|
|
|
|
if (foo) {
|
|
|
|
fprintf(stderr, "%s: create fimg from '%s' -> %d\n", __func__,
|
|
|
|
infile, foo);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
foo = fimg_save_plane_as_fits(&fimg, outfile, plane, 0);
|
|
|
|
if (foo) {
|
|
|
|
fprintf(stderr, "%s: err %d on fits export\n", __func__, foo);
|
|
|
|
return foo;
|
|
|
|
}
|
|
|
|
|
|
|
|
fimg_destroy(&fimg);
|
|
|
|
|
2024-08-29 18:24:01 +02:00
|
|
|
return 0;
|
2021-04-03 10:46:00 +02:00
|
|
|
}
|
|
|
|
/* ----------------------------------------------------------------- */
|
|
|
|
static void help(int k)
|
|
|
|
{
|
|
|
|
puts("export to FITS format");
|
|
|
|
puts("\t-p select colorplane : R, G, B");
|
2024-08-29 18:24:01 +02:00
|
|
|
puts("\t default is blue");
|
|
|
|
puts("\t-v increase verbosity");
|
2022-07-06 10:27:55 +02:00
|
|
|
fimg_print_version(k);
|
2021-04-03 10:46:00 +02:00
|
|
|
}
|
|
|
|
/* ----------------------------------------------------------------- */
|
|
|
|
|
|
|
|
int main(int argc, char *argv[])
|
|
|
|
{
|
2024-08-29 18:24:01 +02:00
|
|
|
int opt, foo;
|
|
|
|
int plane = 'b';
|
2021-04-03 10:46:00 +02:00
|
|
|
|
|
|
|
while ((opt = getopt(argc, argv, "p:hv")) != -1) {
|
|
|
|
switch(opt) {
|
|
|
|
case 'p': plane = optarg[0]; break;
|
|
|
|
case 'v': verbosity++; break;
|
|
|
|
case 'h': help(1); exit(1);
|
2023-05-29 09:06:57 +02:00
|
|
|
default: exit(1);
|
2021-04-03 10:46:00 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (2 != argc-optind) {
|
|
|
|
fprintf(stderr, "error: %s need two filenames\n", argv[0]);
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
2024-08-29 18:24:01 +02:00
|
|
|
foo = export_fimg_plane_as_fits(argv[optind], argv[optind+1], plane);
|
|
|
|
if (foo) {
|
|
|
|
fprintf(stderr, "export_fimg_plane_as_fits --> %d\n", foo);
|
|
|
|
exit(1);
|
|
|
|
}
|
2021-04-03 10:46:00 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
/* ----------------------------------------------------------------- */
|