Пример #1
0
Object
dap_attributebody(DAPparsestate* state, Object attrlist)
{
    OCnode* node = newocnode(NULL,OC_Attributeset,state);
    OCASSERT((state->root == NULL));
    state->root = node;
    /* make sure to cross link */
    state->root->root = state->root;
    node->subnodes = (OClist*)attrlist;
    addedges(node);
    return NULL;
}
Пример #2
0
Object
dap_attrset(DAPparsestate* state, Object name, Object attributes)
{
    OCnode* attset;
    attset = newocnode((char*)name,OC_Attributeset,state);
    /* Check var set vs global set */
    attset->att.isglobal = isglobalname(name);
    attset->att.isdods = isdodsname(name);
    attset->subnodes = (OClist*)attributes;
    addedges(attset);
    return attset;
}
Пример #3
0
Object
dap_makesequence(DAPparsestate* state, Object name, Object members)
{
    OCnode* node;
    char* dupname;    
    if((dupname=scopeduplicates((OClist*)members)) != NULL) {
        dap_parse_error(state,"Duplicate sequence member names in same scope: %s.%s",(char*)name,dupname);
	return (Object)NULL;
    }
    node = newocnode(name,OC_Sequence,state);
    node->subnodes = members;
    addedges(node);
    return node;
}
Пример #4
0
Object
dap_makestructure(DAPparsestate* state, Object name, Object dimensions, Object fields)
{
    OCnode* node;
    char* dupname;    
    if((dupname=scopeduplicates((OClist*)fields))!= NULL) {
        dap_parse_error(state,"Duplicate structure field names in same scope: %s.%s",(char*)name,dupname);
	state->error = OC_ENAMEINUSE; /* semantic error */
	return (Object)NULL;
    }
    node = newocnode(name,OC_Structure,state);
    node->subnodes = fields;
    dimension(node,(OClist*)dimensions);
    addedges(node);
    return node;
}
Пример #5
0
Object
dap_makegrid(DAPparsestate* state, Object name, Object arraydecl, Object mapdecls)
{
    OCnode* node;
    /* Check for duplicate map names */
    char* dupname;    
    if((dupname=scopeduplicates((OClist*)mapdecls)) != NULL) {
        dap_parse_error(state,"Duplicate grid map names in same scope: %s.%s",(char*)name,dupname);
	state->error = OC_ENAMEINUSE; /* semantic error */
	return (Object)NULL;
    }
    node = newocnode(name,OC_Grid,state);
    node->subnodes = (OClist*)mapdecls;
    oclistinsert(node->subnodes,0,(void*)arraydecl);
    addedges(node);
    return node;
}
Пример #6
0
Object
dap_datasetbody(DAPparsestate* state, Object name, Object decls)
{
    OCnode* root = newocnode((char*)name,OC_Dataset,state);
    char* dupname = NULL;
    dupname = scopeduplicates((OClist*)decls);
    if(dupname != NULL) {
	/* Sometimes, some servers (i.e. Thredds)
           return a dds with duplicate field names
           at the dataset level; simulate an errorbody response
        */
        dap_parse_error(state,"Duplicate dataset field names: %s",name,dupname);
	state->error = OC_ENAMEINUSE;
	return (Object)NULL;
    }
    root->subnodes = (OClist*)decls;
    OCASSERT((state->root == NULL));
    state->root = root;
    state->root->root = state->root; /* make sure to cross link */
    addedges(root);
    setroot(root,state->ocnodes);
    return NULL;
}
Пример #7
0
// usage: 
// rescaleims  fileprefix (e.g. obsreg34) numalphas numbeliefs numactions
int main(int argc, char *argv[])
{
  char *fileprefix, *edgeimprefix;
  char filename[256];
  char *uimname;
  // prefixes
  uimname = *++argv;

  int nmgs = atoi(*++argv);
  int nt = atoi(*++argv);
  int na = atoi(*++argv);
  int ov = atoi(*++argv);

  int stepsize = 1;
  int modu = 0;

  int i,j, index,a,b,t, k;
  double ***dvals;
  double maxval, minval;
  unsigned char *im;
  int nx, ny;
  nx = 160;
  ny = 120;

  // read in edge images
  unsigned char **eims = new unsigned char*[na];
  for (a=0; a<na; a++) {
    eims[a] = new unsigned char[nx*ny];
    sprintf(filename,"edges%d.pgm",a);
    readEdgeImagePGM(filename, nx, ny, eims[a]);
  }

  
  im = new unsigned char[nx*ny*3];
  unsigned char *uim = new unsigned char[nx*ny*3];
  FILE *stream =  fopen(uimname,"r");
  if ( !stream )
    return 0;
  fscanf( stream, "%*s\n%*d %*d\n%*d\n");
  fread(uim, sizeof(unsigned char), 3*ny*nx, stream);
  fclose(stream);

  int colmap[3];
  int numcolorshades = 4;
  int colorshades[4] = {255,192,128,64};
  // now, rescale
  int *pixels  = new int[nx*ny];
  for (t=0; t<nt; t++) {
    // reset colormap
    for (k=0; k<3; k++)
      colmap[k] = 0;
    // read in mg pixel vals
    sprintf(filename,"sim%dobsreg0_%d.mgs",t,ov);
    fprintf(stderr,"reading %s\n",filename);
    readObsImageMgs(filename,nx,ny,pixels);
    for (k=0; k<nmgs; k++) {
      modu = 0;
      for (i=0; i<ny; i+=stepsize) {
	for (j=modu; j<nx; j+=stepsize) {
	  index = i*nx+j;
	  if (pixels[index] == k) {
	    im[index*3] = (unsigned char) (colorshades[colmap[0]]);
	    im[index*3+1] = (unsigned char) (colorshades[colmap[1]]);
	    im[index*3+2] = (unsigned char) (colorshades[colmap[2]]);
	  }
	}
	modu = (modu+1)%stepsize;
      }
      colmap[0]++;
      if (colmap[0] >= numcolorshades) {
	colmap[0] = 0;
	colmap[1]++;
	if (colmap[1] >= numcolorshades) {
	  colmap[1] = 0;
	  colmap[2]++;
	  if (colmap[2] >= numcolorshades) 
	    colmap[2] = 0;
	}
      }
    }
    // assumes they're always the same
    addedges(im,nx,ny,eims[0]);
    sprintf(filename,"simobsreg%d.ppm",t);
    writeImagePPM(filename,im,nx,ny);
  }
}