Пример #1
0
void plot_add_model(plot *p, model_func *f, const mat *x_0, const size_t j, \
                    const mat *par, void *f_param, const double xmin,       \
                    const double xmax, const size_t npt, const strbuf title,\
                    const strbuf color)
{
    mat *x,*y,*X;
    size_t i;
    double x_i,y_i;
    
    x = mat_create(npt,1);
    y = mat_create(npt,1);
    X = mat_create_from_mat(x_0);
    
    for (i=0;i<npt;i++)
    {
        x_i = xmin + (xmax-xmin)*DRATIO(i,npt-1);
        mat_set(X,j,0,x_i);
        y_i = f(X,par,f_param);
        mat_set(x,i,0,x_i);
        mat_set(y,i,0,y_i);
    }
    plot_add_line(p,x,y,title,color);
    
    mat_destroy(x);
    mat_destroy(y);
    mat_destroy(X);
}
Пример #2
0
void plot_add_fit_predband(plot *p, const fit_data *d, const size_t ky,\
                           const mat *x_ex, const size_t kx,           \
                           const rs_sample *par, const double xmin,    \
                           const double xmax, const size_t npt,        \
                           const strbuf color)
{
    mat *x,*yp,*ym,*y_i_err,*X;
    rs_sample *s_y_i;
    size_t i;
    double x_i,yp_i,ym_i;
    
    x       = mat_create(npt,1);
    yp      = mat_create(npt,1);
    ym      = mat_create(npt,1);
    y_i_err = mat_create(1,1);
    s_y_i   = rs_sample_create(1,1,rs_sample_get_nsample(par));
    X       = mat_create_from_mat(x_ex);
    
    for (i=0;i<npt;i++)
    {
        x_i = xmin + (xmax-xmin)*DRATIO(i,npt-1);
        mat_set(X,kx,0,x_i);
        fit_data_model_rs_xeval(s_y_i,d,ky,X,par);
        rs_sample_var(y_i_err,s_y_i);
        mat_eqsqrt(y_i_err);
        yp_i = mat_get(rs_sample_pt_cent_val(s_y_i),0,0) + mat_get(y_i_err,0,0);
        ym_i = mat_get(rs_sample_pt_cent_val(s_y_i),0,0) - mat_get(y_i_err,0,0);
        mat_set(yp,i,0,yp_i);
        mat_set(ym,i,0,ym_i);
        mat_set(x,i,0,x_i);
    }
    
    plot_add_line(p,x,yp,"",color);
    plot_add_line(p,x,ym,"",color);
    
    mat_destroy(x);
    mat_destroy(yp);
    mat_destroy(ym);
    mat_destroy(y_i_err);
    rs_sample_destroy(s_y_i);
    mat_destroy(X);
}
Пример #3
0
void plot_add_func(plot *p, univar_func *f, void *f_param, const double xmin,\
                   const double xmax, const size_t npt, const strbuf title,  \
                   const strbuf color)
{
    mat *x,*y;
    size_t i;
    double x_i,y_i;
    
    x = mat_create(npt,1);
    y = mat_create(npt,1);
    
    for (i=0;i<npt;i++)
    {
        x_i = xmin + (xmax-xmin)*DRATIO(i,npt-1);
        y_i = f(x_i,f_param);
        mat_set(x,i,0,x_i);
        mat_set(y,i,0,y_i);
    }
    plot_add_line(p,x,y,title,color);
    
    mat_destroy(x);
    mat_destroy(y);
}
Пример #4
0
void ProfileGraphicsView::plot_pp_gas_profile()
{
    int i;
    struct plot_data *entry;
    struct plot_info *pi = &gc.pi;

    setup_pp_limits(&gc);
    QColor c;
    QPointF from, to;
    if (prefs.pp_graphs.pn2) {
        c = getColor(PN2);
        entry = pi->entry;
        from = QPointF(SCALEGC(entry->sec, entry->pn2));
        for (i = 1; i < pi->nr; i++) {
            entry++;
            if (entry->pn2 < prefs.pp_graphs.pn2_threshold)
                plot_add_line(entry->sec, entry->pn2, c, from);
            else
                from = QPointF(SCALEGC(entry->sec, entry->pn2));
        }

        c = getColor(PN2_ALERT);
        entry = pi->entry;
        from = QPointF(SCALEGC(entry->sec, entry->pn2));
        for (i = 1; i < pi->nr; i++) {
            entry++;
            if (entry->pn2 >= prefs.pp_graphs.pn2_threshold)
                plot_add_line(entry->sec, entry->pn2, c, from);
            else
                from = QPointF(SCALEGC(entry->sec, entry->pn2));
        }
    }

    if (prefs.pp_graphs.phe) {
        c = getColor(PHE);
        entry = pi->entry;

        from = QPointF(SCALEGC(entry->sec, entry->phe));
        for (i = 1; i < pi->nr; i++) {
            entry++;
            if (entry->phe < prefs.pp_graphs.phe_threshold)
                plot_add_line(entry->sec, entry->phe, c, from);
            else
                from = QPointF(SCALEGC(entry->sec, entry->phe));
        }

        c = getColor(PHE_ALERT);
        entry = pi->entry;
        from = QPointF(SCALEGC(entry->sec, entry->phe));
        for (i = 1; i < pi->nr; i++) {
            entry++;
            if (entry->phe >= prefs.pp_graphs.phe_threshold)
                plot_add_line(entry->sec, entry->phe, c, from);
            else
                from = QPointF(SCALEGC(entry->sec, entry->phe));
        }
    }
    if (prefs.pp_graphs.po2) {
        c = getColor(PO2);
        entry = pi->entry;
        from = QPointF(SCALEGC(entry->sec, entry->po2));
        for (i = 1; i < pi->nr; i++) {
            entry++;
            if (entry->po2 < prefs.pp_graphs.po2_threshold)
                plot_add_line(entry->sec, entry->po2, c, from);
            else
                from = QPointF(SCALEGC(entry->sec, entry->po2));
        }

        c = getColor(PO2_ALERT);
        entry = pi->entry;
        from = QPointF(SCALEGC(entry->sec, entry->po2));
        for (i = 1; i < pi->nr; i++) {
            entry++;
            if (entry->po2 >= prefs.pp_graphs.po2_threshold)
                plot_add_line(entry->sec, entry->po2, c, from);
            else
                from = QPointF(SCALEGC(entry->sec, entry->po2));
        }
    }
}