예제 #1
0
파일: Prob.c 프로젝트: erget/wgrib2
/*
 * HEADER:100:prob:inv:0:probability information
 */
int f_prob(ARG0) {
    unsigned char *p;

    if (mode == -1) {
	return 0;
    }
    else if (mode >= 0) {
	p = code_table_4_9_location(sec);
	if (p == NULL) return 0;
	sprintf(inv_out,"probtype=%d ",*p);
	switch (*p) {

	case 0: sprintf(inv_out,"prob <%g", LOWER_LIMIT); break;
	case 1: sprintf(inv_out,"prob >%g", UPPER_LIMIT); break;
	
	case 2: if (LOWER_LIMIT == UPPER_LIMIT) {
		sprintf(inv_out,"prob =%g", LOWER_LIMIT); break;
		}
		sprintf(inv_out,"prob >=%g <%g", LOWER_LIMIT, UPPER_LIMIT); break;
	case 3: sprintf(inv_out,"prob >%g", LOWER_LIMIT);
		break;
	case 4: sprintf(inv_out,"prob <%g", UPPER_LIMIT);
		break;
	}
	if (mode == 99) {
	    inv_out += strlen(inv_out);
            sprintf(inv_out, " LOWER LIMIT scale=%d, val= 0x%.2x 0x%.2x 0x%.2x 0x%.2x",
		INT1(p[1]), p[2], p[3], p[4], p[5]);
	}
    }
    return 0;
}
예제 #2
0
파일: Prob.c 프로젝트: erget/wgrib2
int fix_ncep_2(unsigned char **sec) {
    unsigned char *p;
    int i;

    p = code_table_4_9_location(sec);
    if (p == NULL) return 0;

    if ((p[2] & 0x0c) == 0x0c) {	// fix bug
	i = int4_comp(p+2);
	int_char(i, p+2);
    }
    if ((p[7] & 0x0c) == 0x0c) {	// fix bug
	i = int4_comp(p+7);
	int_char(i, p+7);
    }
    return 0;
}
예제 #3
0
파일: Set_prob.c 프로젝트: mmase/wgrib2
int f_set_prob(ARG5) {

    int pdt, val, scale;
    double value;
    unsigned char *p;

    if (mode < 0) return 0;
    pdt = code_table_4_0(sec);

    switch(pdt) {
	case 0:
	case 1:
	case 2:
	case 4:
	case 6:
	    f_set_pdt(call_ARG1(inv_out, NULL, "+5"));
	    break;
	case 8:
	case 10:
	case 11:
	case 12:
	case 13:
	case 14:
	case 15:
	    f_set_pdt(call_ARG1(inv_out, NULL, "+9"));
	    break;
    }
    p = code_table_4_9_location(sec);
    p[-2] = (unsigned char) atoi(arg1);
    p[-1] = (unsigned char) atoi(arg2);
    p[0] = (unsigned char) atoi(arg3);

    // encode lower limit
    value = atof(arg4);
    best_scaled_value(value, &scale,&val);
    p[1] = scale & 255;
    uint_char(val, p+2);

    // encode upper limit
    value = atof(arg5);
    best_scaled_value(value, &scale,&val);
    p[6] = scale & 255;
    uint_char(val, p+7);
    return 0;
}
예제 #4
0
int code_table_4_9(unsigned char **sec) {
    unsigned char *p;
    p = code_table_4_9_location(sec);
    if (p == NULL) return -1;
    return *p;
}