dbread

dbread —

Synopsis




#define     DB_DESCRIP_LEN
enum        db_error_codes;
enum        CompactMethod;
typedef     dbnumber;
            db_table;
            SERIESINFO;
int         get_native_db_data              (const char *dbbase,
                                             SERIESINFO *sinfo,
                                             double **Z);
int         get_remote_db_data              (const char *dbbase,
                                             SERIESINFO *sinfo,
                                             double **Z);
int         get_pcgive_db_data              (const char *dbbase,
                                             SERIESINFO *sinfo,
                                             double **Z);
int         get_rats_db_data                (const char *fname,
                                             SERIESINFO *sinfo,
                                             double **Z);
db_table*   read_rats_db                    (FILE *fp);
db_table*   read_pcgive_db                  (FILE *fp);
double*     compact_db_series               (const double *src,
                                             SERIESINFO *sinfo,
                                             int target_pd,
                                             CompactMethod method);
double*     expand_db_series                (const double *src,
                                             SERIESINFO *sinfo,
                                             int target_pd);
void        init_datainfo_from_sinfo        (DATAINFO *pdinfo,
                                             SERIESINFO *sinfo);
int         set_db_name                     (const char *fname,
                                             int filetype,
                                             const PATHS *ppaths,
                                             PRN *prn);
int         db_set_sample                   (const char *line,
                                             DATAINFO *pdinfo);
int         db_get_series                   (const char *line,
                                             double ***pZ,
                                             DATAINFO *datainfo,
                                             PRN *prn);
void        get_db_padding                  (SERIESINFO *sinfo,
                                             DATAINFO *pdinfo,
                                             int *pad1,
                                             int *pad2);
int         check_db_import                 (SERIESINFO *sinfo,
                                             DATAINFO *pdinfo);
int         compact_data_set                (double ***pZ,
                                             DATAINFO *pdinfo,
                                             int newpd,
                                             CompactMethod default_method,
                                             int monstart,
                                             int repday);
int         expand_data_set                 (double ***pZ,
                                             DATAINFO *pdinfo,
                                             int newpd);

Description

Details

DB_DESCRIP_LEN

#define DB_DESCRIP_LEN 72  /* size of array to hold "# description" */


enum db_error_codes

typedef enum {
    DB_MISSING_DATA = E_MAX + 1,
    DB_NO_SUCH_SERIES,
    DB_PARSE_ERROR
} db_error_codes;


enum CompactMethod

typedef enum {
    COMPACT_NONE,
    COMPACT_SUM,
    COMPACT_AVG,
    COMPACT_SOP,
    COMPACT_EOP,
    COMPACT_WDAY,
    COMPACT_MAX
} CompactMethod; 


dbnumber

typedef float dbnumber;


db_table

typedef struct {
    int nvars;
    int nalloc;
    SERIESINFO *sinfo;
} db_table;


SERIESINFO

typedef struct {
    char varname[VNAMELEN];
    char descrip[MAXLABEL];
    int nobs;
    char stobs[OBSLEN];
    char endobs[OBSLEN];
    int pd;
    int offset;
    int err;
    int undated;
} SERIESINFO;


get_native_db_data ()

int         get_native_db_data              (const char *dbbase,
                                             SERIESINFO *sinfo,
                                             double **Z);

dbbase :
sinfo :
Z :
Returns :

get_remote_db_data ()

int         get_remote_db_data              (const char *dbbase,
                                             SERIESINFO *sinfo,
                                             double **Z);

dbbase :
sinfo :
Z :
Returns :

get_pcgive_db_data ()

int         get_pcgive_db_data              (const char *dbbase,
                                             SERIESINFO *sinfo,
                                             double **Z);

dbbase :
sinfo :
Z :
Returns :

get_rats_db_data ()

int         get_rats_db_data                (const char *fname,
                                             SERIESINFO *sinfo,
                                             double **Z);

Read the actual data values for a series from a RATS database.

fname : name of RATS 4.0 database to read from
sinfo : holds info on the given series (input)
Z : data matrix
Returns : 0 on successful completion, E_FOPEN if the data could not be read, and DB_MISSING_DATA if the data were found but there were some missing values.

read_rats_db ()

db_table*   read_rats_db                    (FILE *fp);

Read the series info from a RATS 4.0 database: read the base block at offset 0 in the data file, and recurse through the directory entries

fp : pre-opened stream (caller to close it)
Returns : pointer to a db_table containing the series info, or NULL in case of failure.

read_pcgive_db ()

db_table*   read_pcgive_db                  (FILE *fp);

Read the series info from a PcGive database, .in7 file

fp : pre-opened stream (caller to close it)
Returns : pointer to a db_table containing the series info, or NULL in case of failure.

compact_db_series ()

double*     compact_db_series               (const double *src,
                                             SERIESINFO *sinfo,
                                             int target_pd,
                                             CompactMethod method);

src :
sinfo :
target_pd :
method :
Returns :

expand_db_series ()

double*     expand_db_series                (const double *src,
                                             SERIESINFO *sinfo,
                                             int target_pd);

src :
sinfo :
target_pd :
Returns :

init_datainfo_from_sinfo ()

void        init_datainfo_from_sinfo        (DATAINFO *pdinfo,
                                             SERIESINFO *sinfo);

pdinfo :
sinfo :

set_db_name ()

int         set_db_name                     (const char *fname,
                                             int filetype,
                                             const PATHS *ppaths,
                                             PRN *prn);

fname :
filetype :
ppaths :
prn :
Returns :

db_set_sample ()

int         db_set_sample                   (const char *line,
                                             DATAINFO *pdinfo);

line :
pdinfo :
Returns :

db_get_series ()

int         db_get_series                   (const char *line,
                                             double ***pZ,
                                             DATAINFO *datainfo,
                                             PRN *prn);

line :
pZ :
datainfo :
prn :
Returns :

get_db_padding ()

void        get_db_padding                  (SERIESINFO *sinfo,
                                             DATAINFO *pdinfo,
                                             int *pad1,
                                             int *pad2);

sinfo :
pdinfo :
pad1 :
pad2 :

check_db_import ()

int         check_db_import                 (SERIESINFO *sinfo,
                                             DATAINFO *pdinfo);

sinfo :
pdinfo :
Returns :

compact_data_set ()

int         compact_data_set                (double ***pZ,
                                             DATAINFO *pdinfo,
                                             int newpd,
                                             CompactMethod default_method,
                                             int monstart,
                                             int repday);

Compact the data set from higher to lower frequency.

pZ : pointer to data array.
pdinfo : data information struct.
newpd : target data frequency.
default_method : code for the default compaction method.
monstart : FIXME add explanation.
repday : "representative day" for conversion from daily to weekly data (with method COMPACT_WDAY only).
Returns : 0 on success, non-zero error code on failure.

expand_data_set ()

int         expand_data_set                 (double ***pZ,
                                             DATAINFO *pdinfo,
                                             int newpd);

Expand the data set from lower to higher frequency: an "expert" option. This is supported at present only for expansion from annual to quarterly or monthly, or from quarterly to monthly.

pZ : pointer to data array.
pdinfo : data information struct.
newpd : target data frequency
Returns : 0 on success, non-zero error code on failure.