#ifndef __DP_PROC_H
#define __DP_PROC_H

#define DEFAULT_SITE ""

#ifdef __cplusplus
extern "C" {
#endif
#if 0
}
#endif

/* Forward declarations */
struct conf_par_entry;
struct dp_proc_params;

#define DEF_SYS_PHIDP (0.0)

struct dp_proc_params {
    /* Data/scan parameters */
    float  radar_const;
    float  noise_power;
    double phase_amb;    /**< PHIdp phase ambiguity (2PI or PI) [rad] */
//    float  bin_space;    /**< Ray data bin/gate size [km] */
    float  azimuth;      /**< Azimuth of the ray [rad] */
    float  elevation;    /**< Elevation of the ray [rad] */
    float  altitude;     /**< Altitude of Radar antenna rel. to sea level [m] */

    /* Control parameters. mostly for use by the external code */
    int    report_phidp;        /**< Debug: Output internal Phi_DP in IRIS reingest */
    int    report_kdp;          /**< Debug: Output recomputed K_DP in IRIS reingest */
    int    nothresh_phidp_kdp; /**< Debug: Do not apply thresholds to computed Phi_DP and K_DP  */
    int    report_smooth_phidp; /**< Debug: Output final, segmented Phi_DP  */
    float  phidp_output_scale;  /**< Debug: Scale putput down to avoid IRIS display folding artifacts */
    int    report_masks;        /**< Debug: Output internal data mask classifications */
    int    phase_amb_is_pi;          /**< Force  phase_amb to PI  */
    int    force_conf_melting_layer; /**< Ignore data melting layer height */
    int    debug2stderr;             /**< Debug: Print temp. messages to STDERR */

    /* Parameters of processing stages */
    struct dp_mask_params dpmask_par;
    struct dp_phi_proc_params phidp_par;
    struct dp_atten_params attcorr_par;
    
};

struct dp_proc_dat;

void dp_proc_init_config(struct dp_proc_params * p);
int  dp_proc_set_config(struct dp_proc_params * p,
                        const struct conf_par_entry * conf_item);
int  dp_proc_get_config(const struct dp_proc_params * p,
                          struct conf_par_entry * conf_item);

void dp_proc_configure(struct dp_proc_params * p,
                       const char * conf_file, const char * site);

struct dp_proc_dat * dp_proc_init(struct dp_proc_params * p, size_t max_bin_count);
void   dp_proc_uninit(struct dp_proc_dat * hdl);

/** Temporary container function(formerly dp_proc()), it runs three
 * stages: PhiDP conditioning, Weather Mask, Attenuation Correction  */
void  dp_proc_run(struct dp_proc_params * p, struct dp_proc_dat * hdl, size_t bins,
                  const int * mask, const float * zh, const float * zv,
                  const float * phidp, const float * rhohv,
                  const float * snr, const float * range,
                  float * zhc, float * zvc, float * phidpf, float * kdp,
                  int * flags);

#if 0
{
#endif
#ifdef __cplusplus
}
#endif
#endif
