00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include <stdio.h>
00022 #include <stdlib.h>
00023 #include <unistd.h>
00024 #include <string.h>
00025 #include <glib.h>
00026 #include <utils/utils.h>
00027 #include <sed/sed_sedflux.h>
00028
00029 int main(int argc,char *argv[])
00030 {
00031 char *rec[] = { "in" , "dx" , "len" , NULL };
00032 FILE *fpout;
00033 char *infile, *outfile;
00034 double *x, *d;
00035 double dx, len;
00036 int i, n;
00037 Eh_args *args;
00038
00039 args = eh_opts_init(argc,argv);
00040 if ( eh_check_opts( args , rec , NULL , NULL )!=0 )
00041 eh_exit(-1);
00042
00043 dx = eh_get_opt_dbl( args , "dx" , -1 );
00044 len = eh_get_opt_dbl( args , "len" , -1 );
00045 infile = eh_get_opt_str( args , "in" , NULL );
00046 outfile = eh_get_opt_str( args , "out" , NULL );
00047
00048 if ( !outfile )
00049 fpout = stdout;
00050 else
00051 if ( !(fpout=fopen(outfile,"w")) )
00052 perror(outfile), eh_exit(-1);
00053
00054 n = (int) (len / dx);
00055
00056 x = g_new0( double , n );
00057 d = g_new0( double , n );
00058
00059 for (i=0;i<n;i++)
00060 x[i] = dx*i;
00061
00062 sed_get_floor_vec(infile,x,n,d,NULL);
00063
00064 fwrite(d,n,sizeof(double),fpout);
00065
00066 free(x);
00067 free(d);
00068 g_free(infile);
00069 g_free(outfile);
00070
00071 return 0;
00072 }
00073