#ifndef __DP_MASK_H
#define __DP_MASK_H

#define DEFAULT_SITE ""

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

/* Forward declarations */
struct conf_par_entry;

struct dp_mask_params {
     /* Gates/ranges for sticky rain detection */
    int    long_gate;     /**< "good/enter" gate or range [bins] */
    int    short_gate;    /**< "bad/exit"   gate or range [bins] */

    /* Data masking parameters */
    float  recovery_range;/**< range without polarimetric data in km */
    float  snr_lim;           /**< low limit for polarimetric data [dB] */

    float  rhohv_lim;         /**< low limit for polarimetric data  */

    /* Rain cell classification parameters */
    float  rhohv_enter_r;     /**< low  threshold to enter rain cell */
    float  rhohv_exit_r;      /**< low  threshold to leave rain cell */
    float  phidp_std_enter_r; /**< high threshold to enter rain cell [rad] */ 
    float  phidp_std_exit_r;  /**< high threshold to leave rain cell [rad] */

    /* Hail cell classification parameters.  */
    float  snr_exit_h;         /**< low threshold to leave hail cell [dB] */
    float  rhohv_exit_h;      /**< low threshold to leave hail cell */
    float  phidp_std_exit_h;  /**< high threshold to leave hail cell [rad] */   
    int debug2stderr;
};

enum bin_type {
    BT_NONE,
    BT_RAIN,
    BT_HAIL,
    BT_MAX_TYPES
};

/** set parameters to default values */
void dp_mask_init_config(struct dp_mask_params * params);

/** try to apply  conf. item. If failed return 1 */
int dp_mask_set_config(struct dp_mask_params * params,
                       const struct conf_par_entry * conf_item);

/** try to modify conf. item. If failed return 1 */
int dp_mask_get_config(const struct dp_mask_params * params,
                       struct conf_par_entry * conf_item);

void dp_mask_get_weather_mask(struct dp_mask_params * pa, float phidp_0, float alpha,
                              const int * mask,
                              const float * phidp, const float * phidp_fl,
                              const float * rhohv,
                              const float * snr_lin, const float * range,
                              enum bin_type * flags, size_t bins);

void dp_mask_get_proc_mask(struct dp_mask_params * params, int * new_mask,
                           const int * ext_mask, const float * range,
                           const float * snr, const float * rhohv,
                           size_t bins);


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