コード例 #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
ファイル: Code_Values.c プロジェクト: chengchen09/earthdata
void fixed_surfaces(unsigned char **sec, int *type1, float *surface1, 
	int *undef_val1, int *type2, float *surface2, int *undef_val2) {

    int pdt;
    unsigned char *p1, *p2;
    pdt = code_table_4_0(sec);
    *undef_val1 = *undef_val2 = 1;
    *surface1 = *surface2 = UNDEFINED;
    *type1 = *type2 = 255;

    switch (pdt) {
    case 0:
    case 1:
    case 2:
    case 3:
    case 4:
    case 5:
    case 6:
    case 7:
    case 8:
    case 9:
    case 10:
    case 11:
    case 12:
    case 13:
    case 14:
    case 15:
    case 1100:
    case 1101:
	p1 = sec[4]+22; p2 = sec[4]+28; break;
    case 40:
    case 41:
    case 42:
    case 43:
	p1 = sec[4]+24; p2 = sec[4]+30; break;
    case 20:
    case 30:
    case 31:
    case 1000:
    case 1001:
    case 1002:
    case 254:
	return; break;
    default: 
	fprintf(stderr,"levels: product definition template #%d not supported\n", pdt);
	return;
	break;
    }

    if (*p1 != 255) {
	*type1 = *p1;
        if (p1[1] != 255) {
	    if (p1[2] != 255 || p1[3] != 255 || p1[4] != 255 || p1[5] != 255) {
		*undef_val1 = 0;
                *surface1 = scaled2flt(INT1(p1[1]), int4(p1+2));
	    }
	}
    }
    if (*p2 != 255) {
	*type2 = *p2;
        if (p2[1] != 255) {
	    if (p2[2] != 255 || p2[3] != 255 || p2[4] != 255 || p2[5] != 255) {
		*undef_val2 = 0;
                *surface2 = scaled2flt(INT1(p2[1]), int4(p2+2));
	    }
	}
    }
    return ;
}
コード例 #3
0
ファイル: mri_dup.c プロジェクト: LJWilliams/Neuroimaging
void upsample_1( int nup , int nar , float * far , float * fout )
{
   int kk,ii , ibot,itop ;
   static int nupold=-1 ;
   static int nupmax=0;
   static float *f00=NULL, *fp1=NULL ;

   /*-- sanity checks --*/

   if( nup < 1 || nar < 2 || far == NULL || fout == NULL ) return ;

   if (nupmax < nup) {
      nupmax = nup;
      RENUP_VEC(f00,nup);
      RENUP_VEC(fp1,nup);
   }

   if( nup == 1 ){ memcpy( fout, far, sizeof(float)*nar ); return; }

   /*-- initialize interpolation coefficient, if nup has changed --*/

   if( nup != nupold ){
     float val ;
     for( kk=0 ; kk < nup ; kk++ ){
       val = ((float)kk) / ((float)nup) ;
       f00[kk] = 1.0 - val ; fp1[kk] = val ;
     }
     nupold = nup ;
   }

   /*-- interpolate the intermediate places --*/

   ibot = 0 ; itop = nar-2 ;

   switch( nup ){
      default:
        for( ii=ibot ; ii <= itop ; ii++ )
          for( kk=0 ; kk < nup ; kk++ ) fout[kk+ii*nup] = INT1(kk,ii) ;
      break ;

      case 2:
        for( ii=ibot ; ii <= itop ; ii++ ){
          fout[ii*nup]   = INT1(0,ii) ; fout[ii*nup+1] = INT1(1,ii) ;
        }
      break ;

      case 3:
        for( ii=ibot ; ii <= itop ; ii++ ){
          fout[ii*nup]   = INT1(0,ii) ; fout[ii*nup+1] = INT1(1,ii) ;
          fout[ii*nup+2] = INT1(2,ii) ;
        }
      break ;

      case 4:
        for( ii=ibot ; ii <= itop ; ii++ ){
          fout[ii*nup]   = INT1(0,ii) ; fout[ii*nup+1] = INT1(1,ii) ;
          fout[ii*nup+2] = INT1(2,ii) ; fout[ii*nup+3] = INT1(3,ii) ;
        }
      break ;
   }

   /*-- interpolate the outside edges --*/

#if 0                             /* nugatory */
   for( ii=0 ; ii < ibot ; ii++ )
     for( kk=0 ; kk < nup ; kk++ ) fout[kk+ii*nup] = FINT1(kk,ii) ;
#endif

   for( ii=itop+1 ; ii < nar ; ii++ )
     for( kk=0 ; kk < nup ; kk++ ) fout[kk+ii*nup] =  FINT1(kk,ii) ;

   return ;
}