/Users/huttone/Devel/sedflux-new/sedflux/trunk/ew/sedutils/create_hydro.c

Go to the documentation of this file.
00001 //---
00002 //
00003 // This file is part of sedflux.
00004 //
00005 // sedflux is free software; you can redistribute it and/or modify
00006 // it under the terms of the GNU General Public License as published by
00007 // the Free Software Foundation; either version 2 of the License, or
00008 // (at your option) any later version.
00009 //
00010 // sedflux is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 // GNU General Public License for more details.
00014 //
00015 // You should have received a copy of the GNU General Public License
00016 // along with sedflux; if not, write to the Free Software
00017 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00018 //
00019 //---
00020 
00021 #include <stdio.h>
00022 #include <utils/utils.h>
00023 #include <sed/sed_sedflux.h>
00024 
00025 static char *help_msg[] = {
00026 " create_hydro - create a hydrotrend file from         ",
00027 "                discharge data.                       ",
00028 "                                                      ",
00029 " options:                                             ",
00030 "  in    : name of the input file.                     ",
00031 "  v     : be verbose [no]                             ",
00032 "                                                      ",
00033 NULL };
00034 
00035 Sed_hydro discharge_to_hydro_record( double q );
00036 
00037 #define FORGET_THIS_FOR_NOW
00038 int main(int argc,char *argv[])
00039 {
00040 #if !defined(FORGET_THIS_FOR_NOW)
00041    char *req[] = { "in" , NULL };
00042    char *infile;
00043    gboolean verbose;
00044    Eh_args *args;
00045    int i, n_cols, n_rows;
00046    double *row;
00047    double novalue;
00048    Eh_data_file *fp_in;
00049    Eh_data_record *data;
00050    Symbol_table *header;
00051    Sed_hydro rec;
00052 
00053    args = eh_opts_init(argc,argv);
00054    if ( eh_check_opts( args , req , NULL , help_msg )!=0 )
00055       eh_exit(-1);
00056 
00057    verbose = eh_get_opt_bool( args , "v"  , FALSE );
00058    infile  = eh_get_opt_str ( args , "in" , NULL  );
00059 
00060    fp_in = eh_open_data_file( infile , NULL );
00061 
00062    data = eh_get_data_from_file( fp_in , 0 );
00063 
00064    header = eh_get_data_record_sym_table( data );
00065 
00066    novalue = g_strtod( eh_symbol_table_lookup(header,"no value") , NULL );
00067 
00068    n_rows = eh_get_data_record_size( data , 0 );
00069    n_cols = eh_get_data_record_size( data , 1 );
00070 
00071    row = eh_get_data_record_row_ptr( data , 0 , double );
00072    for ( i=0 ; i<n_cols ; i++ )
00073    {
00074       if ( fabs(row[i]-novalue) > 1e-5 )
00075       {
00076          rec = discharge_to_hydro_record( row[i] );
00077          fprintf(stderr,"%f , %f\n",row[i],rec->velocity);
00078          hydro_destroy_hydro_record( rec );
00079       }
00080    }
00081 #endif
00082    return 0;
00083 }
00084 
00085 #undef FORGET_THIS_FOR_NOW
00086 
00087 Sed_hydro discharge_to_hydro_record( double q )
00088 {
00089    Sed_hydro rec = sed_hydro_new( 1 );
00090    double a, b, c, d, e, f;
00091    
00092    a = c = e = 1.;
00093    b = d = f = 1/3.;
00094    
00095    sed_hydro_set_velocity         ( rec , a*pow(q,b) );
00096    sed_hydro_set_width            ( rec , c*pow(q,d) );
00097    sed_hydro_set_depth            ( rec , e*pow(q,f) );
00098    sed_hydro_set_bedload          ( rec , 0.         );
00099    sed_hydro_set_nth_concentration( rec , 0 , 0.     );
00100 
00101    return rec;
00102 }
00103 

Generated on Fri Jan 4 18:04:16 2008 for sedflux by  doxygen 1.5.2