/Users/huttone/Devel/sedflux-new/sedflux/trunk/ew/sed/sed_hydrotrend.c File Reference

#include <stdio.h>
#include <glib.h>
#include "utils/utils.h"
#include "sed_hydrotrend.h"

Go to the source code of this file.

Functions

GQuark sed_hydrotrend_error_quark (void)
Sed_hydrotrend_headersed_hydrotrend_read_header (FILE *fp)
Sed_hydrotrend_headersed_hydrotrend_read_header_from_byte_order (FILE *fp, gint order)
Sed_hydrotrend_headersed_hydrotrend_join_header_from_byte_order (FILE **fp_list, gint order, GError **err)
Sed_hydrotrend_headersed_hydrotrend_header_destroy (Sed_hydrotrend_header *h)
gssize sed_hydrotrend_write_header_to_byte_order (FILE *fp, gint n_grains, gint n_seasons, gint n_samples, gchar *comment_s, gint order)
gssize sed_hydrotrend_write_header (FILE *fp, gint n_grains, gint n_seasons, gint n_samples, gchar *comment_s)
gint sed_hydrotrend_byte_order (const gchar *file, GError **error)
gint sed_hydrotrend_guess_byte_order (FILE *fp)
Sed_hydro sed_hydrotrend_read_next_rec (FILE *fp, int n_grains)
Sed_hydro sed_hydrotrend_read_next_rec_from_byte_order (FILE *fp, int n_grains, gint order)
Sed_hydro * sed_hydrotrend_read_recs (FILE *fp, gint rec_0, gint n_recs, gint byte_order, GError **error)
gssize sed_hydrotrend_write_record (FILE *fp, Sed_hydro rec)
gssize sed_hydrotrend_write_record_to_byte_order (FILE *fp, Sed_hydro rec, gint order)
gssize sed_hydrotrend_read_next_n_recs (FILE *fp, Sed_hydro *rec, int n_grains, int n_recs)
Sed_hydro * sed_hydrotrend_read (const gchar *file, gint byte_order, int *n_seasons, GError **error)
Sed_hydro * sed_hydrotrend_read_n_recs (const gchar *file, gint n_recs, gint byte_order, int *n_seasons, GError **error)
gssize sed_hydrotrend_write (gchar *file, Sed_hydro *rec_a, gint n_seasons, gchar *comment_s, GError **error)
gssize sed_hydro_array_write_hydrotrend_records_to_byte_order (FILE *fp, Sed_hydro *rec_a, gint order)
gssize sed_hydro_array_write_hydrotrend_records (FILE *fp, Sed_hydro *rec_a)
gint sed_hydrotrend_fseek (FILE *fp, gint offset, gint whence, gint byte_order)
gint sed_hydrotrend_record_size (FILE *fp, gint byte_order, Sed_hydrotrend_header *h)
gint sed_hydrotrend_n_grains (FILE *fp, gint byte_order, Sed_hydrotrend_header *h)
gint sed_hydrotrend_data_start (FILE *fp, gint byte_order, Sed_hydrotrend_header *h)


Function Documentation

gssize sed_hydro_array_write_hydrotrend_records ( FILE *  fp,
Sed_hydro *  rec_a 
)

Write records to a HydroTrend file

Parameters:
fp A HydroTrend file
rec_a A NULL-terminated array of Sed_hydro records
Returns:
The number of bytes written.

Definition at line 577 of file sed_hydrotrend.c.

References sed_hydro_array_write_hydrotrend_records_to_byte_order().

Referenced by sed_hydrotrend_write().

gssize sed_hydro_array_write_hydrotrend_records_to_byte_order ( FILE *  fp,
Sed_hydro *  rec_a,
gint  order 
)

Definition at line 554 of file sed_hydrotrend.c.

References sed_hydrotrend_write_record_to_byte_order().

Referenced by sed_hydro_array_write_hydrotrend_records().

gint sed_hydrotrend_byte_order ( const gchar *  file,
GError **  error 
)

Definition at line 223 of file sed_hydrotrend.c.

References Sed_hydrotrend_header::comment, eh_fopen_error(), eh_free, eh_require, and sed_hydrotrend_read_header_from_byte_order().

gint sed_hydrotrend_data_start ( FILE *  fp,
gint  byte_order,
Sed_hydrotrend_header h 
)

The file position that marks the start of the data

Parameters:
fp A HydroTrend file
byte_order The byte order of the HydroTrend file
h The header info for the file (or NULL)
Returns:
The offset (in bytes) from the start of the file to the start of the data

Definition at line 717 of file sed_hydrotrend.c.

References eh_free, eh_require, and sed_hydrotrend_read_header_from_byte_order().

Referenced by sed_hydrotrend_fseek().

GQuark sed_hydrotrend_error_quark ( void   ) 

Definition at line 9 of file sed_hydrotrend.c.

gint sed_hydrotrend_fseek ( FILE *  fp,
gint  offset,
gint  whence,
gint  byte_order 
)

Reposition a file-position indicator of a HydroTrend file

Set the file-position indicator for a HydroTrend file. This has two major differences from the standard fseek function. (1) The offset is measured in records rather than bytes. (2) The new position withing the file is returned (in records).

For example:

sed_hydro_fseek( fp , 0 , SEEK_SET )

moves the file-position indicator to the start of the data.

sed_hydro_fseek( fp , 365 , SEEK_SET )

moves the file-position indicator to the 365th record in the file.

Parameters:
fp A HydroTrend file
offset The offset (in HydroTrend records) to move
whence Where offset is measured from
byte_order The byte order of the HydroTrend file
Returns:
0 on success, -1 otherwise

Definition at line 609 of file sed_hydrotrend.c.

References sed_hydrotrend_data_start(), and sed_hydrotrend_record_size().

Referenced by sed_hydrotrend_read_recs().

gint sed_hydrotrend_guess_byte_order ( FILE *  fp  ) 

Definition at line 262 of file sed_hydrotrend.c.

References eh_fread_int32_swap.

Sed_hydrotrend_header* sed_hydrotrend_header_destroy ( Sed_hydrotrend_header h  ) 

Definition at line 139 of file sed_hydrotrend.c.

References Sed_hydrotrend_header::comment, and eh_free.

Referenced by main(), and sed_hydrotrend_read_header_from_byte_order().

Sed_hydrotrend_header* sed_hydrotrend_join_header_from_byte_order ( FILE **  fp_list,
gint  order,
GError **  err 
)

Definition at line 81 of file sed_hydrotrend.c.

References Sed_hydrotrend_header::comment, eh_free, eh_return_val_if_fail, Sed_hydrotrend_header::n_grains, Sed_hydrotrend_header::n_samples, Sed_hydrotrend_header::n_seasons, SED_HYDROTREND_ERROR, SED_HYDROTREND_ERROR_BAD_HEADER, and sed_hydrotrend_read_header_from_byte_order().

Referenced by main().

gint sed_hydrotrend_n_grains ( FILE *  fp,
gint  byte_order,
Sed_hydrotrend_header h 
)

The number of suspended grains of a HydroTrend record

Parameters:
fp A pointer to a HydroTrend file
byte_order The byte order of the HydroTrend file
h The header information if known, NULL otherwise
Returns:
The number of suspended grains

Definition at line 677 of file sed_hydrotrend.c.

References eh_free, eh_require, and sed_hydrotrend_read_header_from_byte_order().

Referenced by sed_hydrotrend_read_recs().

Sed_hydro* sed_hydrotrend_read ( const gchar *  file,
gint  byte_order,
int *  n_seasons,
GError **  error 
)

Definition at line 456 of file sed_hydrotrend.c.

References sed_hydrotrend_read_n_recs().

Sed_hydrotrend_header* sed_hydrotrend_read_header ( FILE *  fp  ) 

Read the header of a HydroTrend file.

Parameters:
fp The file to read.
Returns:
The header information

Definition at line 22 of file sed_hydrotrend.c.

References sed_hydrotrend_read_header_from_byte_order().

Sed_hydrotrend_header* sed_hydrotrend_read_header_from_byte_order ( FILE *  fp,
gint  order 
)

Read the header of a HydroTrend file with a specific byte order

Parameters:
fp The file to read.
order The byte order of the file
Returns:
The header information

Definition at line 35 of file sed_hydrotrend.c.

References Sed_hydrotrend_header::comment, eh_fread_int32_swap, eh_free, eh_new, Sed_hydrotrend_header::n_grains, Sed_hydrotrend_header::n_samples, Sed_hydrotrend_header::n_seasons, and sed_hydrotrend_header_destroy().

Referenced by main(), sed_hydrotrend_byte_order(), sed_hydrotrend_data_start(), sed_hydrotrend_join_header_from_byte_order(), sed_hydrotrend_n_grains(), sed_hydrotrend_read_header(), sed_hydrotrend_read_n_recs(), and sed_hydrotrend_record_size().

Sed_hydro* sed_hydrotrend_read_n_recs ( const gchar *  file,
gint  n_recs,
gint  byte_order,
int *  n_seasons,
GError **  error 
)

Definition at line 462 of file sed_hydrotrend.c.

References Sed_hydrotrend_header::comment, eh_fopen_error(), eh_free, eh_return_val_if_fail, Sed_hydrotrend_header::n_samples, Sed_hydrotrend_header::n_seasons, sed_hydrotrend_read_header_from_byte_order(), and sed_hydrotrend_read_recs().

Referenced by sed_hydro_file_guess_type(), and sed_hydrotrend_read().

gssize sed_hydrotrend_read_next_n_recs ( FILE *  fp,
Sed_hydro *  rec,
int  n_grains,
int  n_recs 
)

Read a series of HydroTrend records

Parameters:
fp The file to read from
rec The location to put the records
n_grains The number of suspended grain sizes.
n_recs The number of records to read.
Returns:
The number of records read.

Definition at line 442 of file sed_hydrotrend.c.

References sed_hydrotrend_read_next_rec().

Sed_hydro sed_hydrotrend_read_next_rec ( FILE *  fp,
int  n_grains 
)

Read one record from a HydroTrend file.

Parameters:
fp The file to read
n_grains The number of suspended grains in the file
Returns:
A newly-created Sed_hydro. Use sed_hydro_destroy to free.

Definition at line 299 of file sed_hydrotrend.c.

References sed_hydrotrend_read_next_rec_from_byte_order().

Referenced by sed_hydro_file_fill_buffer(), and sed_hydrotrend_read_next_n_recs().

Sed_hydro sed_hydrotrend_read_next_rec_from_byte_order ( FILE *  fp,
int  n_grains,
gint  order 
)

Read a Sed_hydro from a HydroTrend file of a specific byte order

Parameters:
fp A HydroTrend file
n_grains Number of suspended grains in the Sed_hydro
order The byte order to write
Returns:
A newly allocated Sed_hydro that contains the read data

Definition at line 314 of file sed_hydrotrend.c.

References eh_fread_flt_swap, eh_free, eh_new, sed_hydro_new(), sed_hydro_set_bedload(), sed_hydro_set_depth(), sed_hydro_set_nth_concentration(), sed_hydro_set_velocity(), and sed_hydro_set_width().

Referenced by sed_hydrotrend_read_next_rec(), and sed_hydrotrend_read_recs().

Sed_hydro* sed_hydrotrend_read_recs ( FILE *  fp,
gint  rec_0,
gint  n_recs,
gint  byte_order,
GError **  error 
)

Read a range of records from a HydroTrend file

Parameters:
fp A HydroTrend file
rec_0 The first record to read (starting from 0)
n_recs The number of records to read
byte_order The byte order of the hydroTrend file
error A GError
Returns:
A NULL-terminated Sed_hydro array that contains the HydroTrend data

Definition at line 353 of file sed_hydrotrend.c.

References eh_new, eh_require, eh_return_val_if_fail, sed_hydrotrend_fseek(), sed_hydrotrend_n_grains(), and sed_hydrotrend_read_next_rec_from_byte_order().

Referenced by main(), and sed_hydrotrend_read_n_recs().

gint sed_hydrotrend_record_size ( FILE *  fp,
gint  byte_order,
Sed_hydrotrend_header h 
)

The size of a HydroTrend record in bytes

Parameters:
fp A pointer to a HydroTrend file
byte_order The byte order of the HydroTrend file
h The header information if known, NULL otherwise
Returns:
The size of a record in bytes

Definition at line 638 of file sed_hydrotrend.c.

References eh_free, eh_require, and sed_hydrotrend_read_header_from_byte_order().

Referenced by sed_hydrotrend_fseek().

gssize sed_hydrotrend_write ( gchar *  file,
Sed_hydro *  rec_a,
gint  n_seasons,
gchar *  comment_s,
GError **  error 
)

Write a complete HydroTrend file

Parameters:
file The name of the file
rec_a A NULL-terminated array of Sed_hydro records
n_seasons The number of "seasons" used for the HydroTrend file
comment_s A comment string (or NULL)
error A GError
Returns:
The number of bytes written

Definition at line 524 of file sed_hydrotrend.c.

References eh_fopen_error(), eh_require, eh_return_val_if_fail, sed_hydro_array_write_hydrotrend_records(), sed_hydro_size(), and sed_hydrotrend_write_header().

gssize sed_hydrotrend_write_header ( FILE *  fp,
gint  n_grains,
gint  n_seasons,
gint  n_samples,
gchar *  comment_s 
)

Write the header of a HydroTrend file

Parameters:
fp A HydroTrend file
n_grains Number of suspended grains
n_seasons Number of "seasons" for the HydroTrend file
n_samples Number of records
comment_s String containing a comment (or NULL)
Returns:
The number of bytes written

Definition at line 194 of file sed_hydrotrend.c.

Referenced by sed_hydrotrend_write().

gssize sed_hydrotrend_write_header_to_byte_order ( FILE *  fp,
gint  n_grains,
gint  n_seasons,
gint  n_samples,
gchar *  comment_s,
gint  order 
)

Definition at line 150 of file sed_hydrotrend.c.

References eh_fwrite_int32_swap.

Referenced by main().

gssize sed_hydrotrend_write_record ( FILE *  fp,
Sed_hydro  rec 
)

Write a Sed_hydro to a HydroTrend file

Parameters:
fp A HydroTrend file
rec A Sed_hydro to write
Returns:
The number of bytes written

Definition at line 389 of file sed_hydrotrend.c.

References sed_hydrotrend_write_record_to_byte_order().

gssize sed_hydrotrend_write_record_to_byte_order ( FILE *  fp,
Sed_hydro  rec,
gint  order 
)

Write a Sed_hydro to a HydroTrend file with a specific byte order

Parameters:
fp A HydroTrend file
rec A Sed_hydro to write
order The byte order to write
Returns:
The number of bytes written

Definition at line 403 of file sed_hydrotrend.c.

References eh_free, eh_fwrite_flt_swap, eh_new, sed_hydro_bedload(), sed_hydro_depth(), sed_hydro_nth_concentration(), sed_hydro_size(), sed_hydro_velocity(), and sed_hydro_width().

Referenced by sed_hydro_array_write_hydrotrend_records_to_byte_order(), and sed_hydrotrend_write_record().


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