|
| 1 | +/****************************************************************************** |
| 2 | +** Copyright (C) 1998 by CEA |
| 3 | +******************************************************************************* |
| 4 | +** |
| 5 | +** UNIT |
| 6 | +** |
| 7 | +** Version: 1.0 |
| 8 | +** |
| 9 | +** Author: Jean-Luc Starck |
| 10 | +** |
| 11 | +** Date: 21/09/98 |
| 12 | +** |
| 13 | +** File: im1d_convert.cc |
| 14 | +** |
| 15 | +******************************************************************************* |
| 16 | +** |
| 17 | +** DESCRIPTION |
| 18 | +** ----------- |
| 19 | +** |
| 20 | +** |
| 21 | +** |
| 22 | +******************************************************************************/ |
| 23 | + |
| 24 | + |
| 25 | +#include "Array.h" |
| 26 | +#include "IM_Obj.h" |
| 27 | +#include "IM1D_IO.h" |
| 28 | + |
| 29 | +char Name_Imag_In[256]; |
| 30 | +char Name_Imag_Out[256]; |
| 31 | + |
| 32 | +extern int OptInd; |
| 33 | +extern char *OptArg; |
| 34 | + |
| 35 | +extern int GetOpt(int argc, char *const*argv, char *opts); |
| 36 | + |
| 37 | +int NSkip=0; |
| 38 | + |
| 39 | +/****************************************************************************/ |
| 40 | + |
| 41 | +static void usage(char *argv[]) |
| 42 | +{ |
| 43 | + |
| 44 | + fprintf(stdout, "Usage: %s options image output\n\n", argv[0]); |
| 45 | + fprintf(stdout, " FITS format (.fits) \n"); |
| 46 | + fprintf(stdout, " ACII format (.dat) \n"); |
| 47 | + fprintf(stdout, " EXEL format (.csv) \n"); |
| 48 | + |
| 49 | + fprintf(stdout, " where options = \n"); |
| 50 | + |
| 51 | + fprintf(stdout, " [-s line_number_to_skip]\n"); |
| 52 | + fprintf(stdout, " Skip the s first lines of the input file.\n"); |
| 53 | + |
| 54 | + fprintf(stdout, "\n"); |
| 55 | + |
| 56 | + exit(-1); |
| 57 | +} |
| 58 | + |
| 59 | +/*********************************************************************/ |
| 60 | + |
| 61 | +/* GET COMMAND LINE ARGUMENTS */ |
| 62 | + |
| 63 | +static void transinit(int argc, char *argv[]) |
| 64 | +{ |
| 65 | + int c; |
| 66 | + |
| 67 | + /* get options */ |
| 68 | + while ((c = GetOpt(argc,argv,"s:")) != -1) |
| 69 | + { |
| 70 | + switch (c) |
| 71 | + { |
| 72 | + case 's': |
| 73 | + if (sscanf(OptArg,"%d",&NSkip) != 1) |
| 74 | + { |
| 75 | + fprintf(stdout, "bad number of lines: %s\n", OptArg); |
| 76 | + usage(argv); |
| 77 | + } |
| 78 | + break; |
| 79 | + case '?': |
| 80 | + usage(argv); |
| 81 | + } |
| 82 | + } |
| 83 | + |
| 84 | + /* get optional input file names from trailing |
| 85 | + parameters and open files */ |
| 86 | + if (OptInd < argc) strcpy(Name_Imag_In, argv[OptInd++]); |
| 87 | + else usage(argv); |
| 88 | + |
| 89 | + if (OptInd < argc) strcpy(Name_Imag_Out, argv[OptInd++]); |
| 90 | + else usage(argv); |
| 91 | + |
| 92 | + /* make sure there are not too many parameters */ |
| 93 | + if (OptInd < argc) |
| 94 | + { |
| 95 | + fprintf(stdout, "Too many parameters: %s ...\n", argv[OptInd]); |
| 96 | + usage(argv); |
| 97 | + } |
| 98 | +} |
| 99 | + |
| 100 | + |
| 101 | +/****************************************************************************/ |
| 102 | + |
| 103 | + |
| 104 | +int main(int argc, char *argv[]) |
| 105 | +{ |
| 106 | + fltarray Dat; |
| 107 | + fltarray Mallat; |
| 108 | + /* Get command line arguments, open input file(s) if necessary */ |
| 109 | + transinit(argc, argv); |
| 110 | + |
| 111 | + // Dat.fits_read(Name_Imag_In); |
| 112 | + io_1d_read_data (Name_Imag_In, Dat, NSkip); |
| 113 | + cout << endl << endl; |
| 114 | + |
| 115 | + cerr << "CONVERT " << String1DFormat(io_detect_1dformat(Name_Imag_In)); |
| 116 | + cerr << " to " << String1DFormat(io_detect_1dformat(Name_Imag_Out)) << endl; |
| 117 | + |
| 118 | + io_1d_set_format(Name_Imag_Out); |
| 119 | + io_1d_write_data (Name_Imag_Out, Dat); |
| 120 | + |
| 121 | + exit(0); |
| 122 | +} |
| 123 | + |
0 commit comments