/Users/huttone/Devel/sedflux-new/sedflux/trunk/ew/sed/sed_hydro.h

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 #ifndef _HYDRO_INCLUDED_
00022 # define _HYDRO_INCLUDED_
00023 
00024 #include <stdio.h>
00025 #include <stdlib.h>
00026 #include <glib.h>
00027 
00028 #include "utils/eh_types.h"
00029 
00030 new_handle( Sed_hydro );
00031 new_handle( Sed_hydro_file );
00032 
00033 typedef enum
00034 {
00035    SED_HYDRO_ERROR_MISSING_LABEL ,
00036    SED_HYDRO_ERROR_BAD_PARAMETER
00037 }
00038 Sed_hydro_error;
00039 
00040 #define SED_HYDRO_ERROR sed_hydro_error_quark()
00041 
00042 #include "datadir_path.h"
00043 
00044 #if !defined( DATADIR )
00045 #define DATADIR "/usr/local/share"
00046 #endif
00047 
00048 #if G_BYTE_ORDER == G_BIG_ENDIAN
00049 # define SED_HYDRO_TEST_FILE        DATADIR "/sedflux/po_daily-be.river"
00050 # define SED_HYDRO_PO_FILE          DATADIR "/sedflux/po_daily-be.river"
00051 # define SED_HYDRO_EEL_FILE         DATADIR "/sedflux/eel_daily-be.river"
00052 # define SED_HYDRO_TEST_INLINE_FILE DATADIR "/sedflux/po_river.kvf"
00053 #else
00054 # define SED_HYDRO_TEST_FILE        DATADIR "/sedflux/po_daily-le.river"
00055 # define SED_HYDRO_PO_FILE          DATADIR "/sedflux/po_daily-le.river"
00056 # define SED_HYDRO_EEL_FILE         DATADIR "/sedflux/eel_daily-le.river"
00057 # define SED_HYDRO_TEST_INLINE_FILE DATADIR "/sedflux/po_river.kvf"
00058 #endif
00059 
00060 //# define SED_HYDRO_TEST_INLINE_FILE "/home/plum/huttone/local/ew114/share"##"/ew/po.inline"
00061 
00062 #include "sed_sediment.h"
00063 #include "sed_cell.h"
00064 #include "sed_hydrotrend.h"
00065 
00066 //#define HYDRO_INLINE        (1<<0)
00067 //#define HYDRO_HYDROTREND    (1<<1)
00068 //#define HYDRO_USE_BUFFER    (1<<2)
00069 #define HYDRO_BUFFER_LEN    (365)
00070 #define HYDRO_N_SIG_VALUES  (10)
00071 
00072 typedef enum
00073 {
00074    SED_HYDRO_INLINE        ,
00075    SED_HYDRO_HYDROTREND    ,
00076    SED_HYDRO_HYDROTREND_BE ,
00077    SED_HYDRO_HYDROTREND_LE ,
00078    SED_HYDRO_UNKNOWN
00079 }
00080 Sed_hydro_file_type;
00081 
00082 /*
00083 typedef struct
00084 {
00085    int n_grains;
00086    int n_seasons;
00087    int n_samples;
00088    unsigned char *comment;
00089 }
00090 Hydro_header G_GNUC_INTERNAL;
00091 */
00092 
00093 typedef Sed_hydrotrend_header* (*Hydro_read_header_func)(Sed_hydro_file);
00094 typedef Sed_hydro (*Hydro_read_record_func)(Sed_hydro_file);
00095 typedef double (*Hydro_get_val_func)(Sed_hydro);
00096 
00097 Sed_hydrotrend_header* sed_hydro_read_header                ( FILE *fp );
00098 Sed_hydrotrend_header* sed_hydro_read_header_from_byte_order( FILE *fp , gint order );
00099 Sed_hydro     sed_hydro_read_record                ( FILE *fp , int n_grains );
00100 Sed_hydro     sed_hydro_read_record_from_byte_order( FILE *fp , int n_grains , gint order );
00101 
00102 gssize        sed_hydro_write_record              ( FILE *fp , Sed_hydro rec , gint order );
00103 gssize        sed_hydro_write_record_to_byte_order( FILE *fp , Sed_hydro rec , gint order );
00104 gint          sed_hydro_fprint_rec                ( FILE* fp , Sed_hydro rec , const gchar* label );
00105 
00106 void          sed_hydro_fprint_default_inline_file( FILE *fp );
00107 gssize        sed_hydro_array_fprint( FILE* fp , Sed_hydro* rec_a );
00108 gssize        sed_hydro_fprint      ( FILE* fp , Sed_hydro  rec   );
00109 //Sed_hydro     sed_hydro_init( char *file );
00110 Sed_hydro*    sed_hydro_scan          ( const gchar* file , GError** error );
00111 Sed_hydro*    sed_hydro_scan_n_records( const gchar* file , gint n_recs , GError** error );
00112 
00113 Sed_hydrotrend_header* sed_hydro_scan_inline_header( FILE *fp );
00114 gssize        sed_hydro_read_n_records( FILE* fp , Sed_hydro* rec , int n_grains , int n_recs );
00115 
00116 Sed_hydro     sed_hydro_new             ( gint n_grains );
00117 Sed_hydro     sed_hydro_new_from_table  ( Eh_symbol_table t , GError** error );
00118 gboolean      sed_hydro_check           ( Sed_hydro a , GError** err );
00119 const gchar*  sed_hydro_type_to_s( Sed_hydro_file_type t );
00120 Sed_hydro_file_type sed_hydro_str_to_type( const gchar* type_s );
00121 Sed_hydro_file_type sed_hydro_file_guess_type( const gchar* file , GError** error );
00122 Sed_hydro     sed_hydro_copy            ( Sed_hydro dest , Sed_hydro src );
00123 Sed_hydro     sed_hydro_dup             ( Sed_hydro src );
00124 Sed_hydro*    sed_hydro_array_dup       ( Sed_hydro* src );
00125 gboolean      sed_hydro_is_same         ( Sed_hydro a    , Sed_hydro b );
00126 Sed_hydro     sed_hydro_resize          ( Sed_hydro a    , gssize n );
00127 gssize        sed_hydro_size            ( Sed_hydro a   );
00128 Sed_hydro     sed_hydro_destroy         ( Sed_hydro rec );
00129 Sed_hydro*    sed_hydro_array_destroy   ( Sed_hydro* arr );
00130 
00131 gssize        sed_hydro_write                ( FILE *fp , Sed_hydro a );
00132 Sed_hydro     sed_hydro_read                 ( FILE *fp );
00133 
00134 double*       sed_hydro_copy_concentration   ( double* dest , Sed_hydro a );
00135 double        sed_hydro_nth_concentration    ( Sed_hydro a , gssize n );
00136 Sed_hydro     sed_hydro_adjust_mass            ( Sed_hydro a , double f   );
00137 double        sed_hydro_flow_density           ( Sed_hydro a , double rho );
00138 gboolean      sed_hydro_is_hyperpycnal         ( Sed_hydro a );
00139 double*       sed_hydro_fraction               ( Sed_hydro a );
00140 double        sed_hydro_suspended_concentration( Sed_hydro a );
00141 double        sed_hydro_suspended_flux       ( Sed_hydro a );
00142 double        sed_hydro_suspended_volume_flux( Sed_hydro a );
00143 double        sed_hydro_water_flux           ( Sed_hydro a );
00144 double        sed_hydro_suspended_load       ( Sed_hydro a );
00145 double        sed_hydro_total_load           ( Sed_hydro a );
00146 double        sed_hydro_array_suspended_load ( Sed_hydro* arr );
00147 double        sed_hydro_array_total_load     ( Sed_hydro* arr );
00148 Sed_hydro     sed_hydro_set_nth_concentration( Sed_hydro a , gssize n , double val );
00149 Sed_hydro     sed_hydro_set_velocity         ( Sed_hydro a , double val );
00150 Sed_hydro     sed_hydro_set_width            ( Sed_hydro a , double val );
00151 Sed_hydro     sed_hydro_set_depth            ( Sed_hydro a , double val );
00152 Sed_hydro     sed_hydro_set_bedload          ( Sed_hydro a , double val );
00153 Sed_hydro     sed_hydro_set_duration         ( Sed_hydro a , double val );
00154 Sed_hydro     sed_hydro_set_time             ( Sed_hydro a , double t_0 );
00155 Sed_hydro*    sed_hydro_array_set_time( Sed_hydro* arr , double t_0 );
00156 Sed_hydro     sed_hydro_set_time             ( Sed_hydro a , double val );
00157 Sed_hydro*    sed_hydro_array_set_time       ( Sed_hydro* arr , double t_0 );
00158 double        sed_hydro_duration_in_seconds  ( Sed_hydro a );
00159 double        sed_hydro_velocity             ( Sed_hydro a );
00160 double        sed_hydro_width                ( Sed_hydro a );
00161 double        sed_hydro_depth                ( Sed_hydro a );
00162 double        sed_hydro_bedload              ( Sed_hydro a );
00163 double        sed_hydro_duration             ( Sed_hydro a );
00164 
00165 Sed_hydro     sed_hydro_add_cell             ( Sed_hydro a    , const Sed_cell s );
00166 Sed_hydro     sed_hydro_subtract_cell        ( Sed_hydro a    , const Sed_cell s );
00167 Sed_hydro     sed_hydro_average_records      ( Sed_hydro* rec , gssize n_recs );
00168 double        sed_hydro_sum_durations        ( Sed_hydro* rec , gssize n_recs );
00169 
00170 Sed_hydro*    sed_hydro_array_eventize_number  ( Sed_hydro* rec_a , gssize n_events );
00171 Sed_hydro*    sed_hydro_array_eventize_fraction( Sed_hydro* rec_a , double f        );
00172 Sed_hydro*    sed_hydro_array_eventize_conc    ( Sed_hydro* rec_a , double c );
00173 Sed_hydro*    sed_hydro_array_eventize         ( Sed_hydro* rec_a , double f        , gboolean insert );
00174 Sed_hydro*    sed_hydro_process_records        ( Sed_hydro* rec_a        ,
00175                                                  gssize     n_recs       ,
00176                                                  gssize     n_sig_values ,
00177                                                  gboolean   insert_mean_values );
00178 
00179 Sed_hydro*    sed_hydro_array_sort              ( Sed_hydro* rec_a , GCompareFunc f );
00180 Sed_hydro*    sed_hydro_array_sort_by_time      ( Sed_hydro* arr );
00181 Sed_hydro*    sed_hydro_array_sort_by_suspended_load( Sed_hydro* arr );
00182 Sed_hydro*    sed_hydro_array_sort_by_total_load( Sed_hydro* arr );
00183 
00184 Sed_hydro_file sed_hydro_file_set_wrap( Sed_hydro_file fp , gboolean wrap_is_on );
00185 Sed_hydro_file sed_hydro_file_set_buffer_length( Sed_hydro_file fp , gssize len );
00186 Sed_hydro_file sed_hydro_file_set_sig_values( Sed_hydro_file fp , int n_sig_values );
00187 
00188 Sed_hydrotrend_header*  sed_hydro_file_header( Sed_hydro_file fp );
00189 Sed_hydro      sed_hydro_file_read_record( Sed_hydro_file fp );
00190 Sed_hydro_file sed_hydro_file_new( const char*         filename     ,
00191                                    Sed_hydro_file_type type         ,
00192                                    gboolean            buffer_is_on ,
00193                                    gboolean            wrap_is_on   ,
00194                                    GError** error );
00195 Sed_hydro_file sed_hydro_file_destroy( Sed_hydro_file fp );
00196 Sed_hydro*     sed_hydro_file_fill_buffer( Sed_hydro_file fp );
00197 
00198 #endif /* hydro.h is included */

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