Пример #1
0
void start_processing()
{
	struct sourceinfo *info;

	if (autoreorder == ON) {
		if (reordering() == -1) {
			fprintf(stderr, "Error during reordering.. Exiting\n");
			return;
		}
	}

	if (optimize == ON) {
		if (do_optimization() == -1) {
			fprintf(stderr, "Error during optimization.. Exiting\n");
			return;
		}
	}

	info = search_for_registered_source(source_type);
	if (!info) {
		fprintf(stderr, "Unknown source type.\n");
		return;
	}

	if (!info->process_packets) {
		fprintf(stderr, "This source does not support process packet functionality.\n");
		return;
	}

	info->process_packets();
	return;
}
Пример #2
0
/* Here we load a snapshot file. It can be distributed
 * onto several files (for files>1).
 * The particles are brought back into the order
 * implied by their ID's.
 * A unit conversion routine is called to do unit
 * conversion, and to evaluate the gas temperature.
 */
int main(int argc, char **argv)
{
  char path[200], input_fname[200], basename[200];
  int type, snapshot_number, files;


  sprintf(path, "/home/tczhang/desktop/C");
  sprintf(basename, "snapshot");
  snapshot_number = 6;		/* number of snapshot */
  files = 1;			/* number of files per snapshot */


  sprintf(input_fname, "%s/%s_%03d", path, basename, snapshot_number);
  load_snapshot(input_fname, files);


  reordering();			/* call this routine only if your ID's are set properly */

  unit_conversion();		/* optional stuff */

  do_what_you_want();
}
Пример #3
0
/* Here we load a snapshot file. It can be distributed
 * onto several files (for files>1).
 * The particles are brought back into the order
 * implied by their ID's.
 * A unit conversion routine is called to do unit
 * conversion, and to evaluate the gas temperature.
 */
int main(int argc, char **argv)
{
  char input_fname[200];
  int  type, files, i, ok;
  int  quiteon= 0;
  char *p;

  if(argc<2)
    {
      printf("\n>readsnap <filename> <[option]>\n\n");
      printf("options\n");
      printf("-------\n");
      printf(" -info   prints byte information for all fields present\n");
      printf(" -h      only the header information is printed to the screen\n");
      printf(" -m      prints the mass of a particle when displaying other information\n");
      printf(" -id     prints the ID for each particle.\n");
      printf(" -pot    prints the Potential for every particle.\n");
      printf(" -tm     prints the total mass of each type\n");
      printf(" -gm     prints the gas mass\n");
      printf("\n\n");
      exit(0);
    }

  files=1;                               /* number of files per snapshot */
  ShowHeader=0;
  ShowMass=0;
  ShowId=0;
  ShowPot=0;
  Reorder=0;
  PrintDefault=0;
  SnapFile=0;

  strcpy(input_fname, argv[1]);

  /* problem, what if we give a path rather then just filename 
  if(!strncmp(input_fname, "snapshot", 8))  SnapFile = 1; */
  if(strstr(input_fname,"snapshot")!=0)  SnapFile = 1;

  if(argc==2) PrintDefault = 1;

  for(i=2; i<argc; i++)
  {
	ok = 0;
	if(!(strcmp(argv[i],"-info"))) ok = SnapInfo = 1;
	if(!(strcmp(argv[i],"-h"))) ok = ShowHeader = 1;
	if(!(strcmp(argv[i],"-tm"))) ok = PrintTotalMass =1;
	if(!(strcmp(argv[i],"-gm"))) ok = PrintGasMass = quiteon= 1;
	if(!(strcmp(argv[i],"-m"))) PrintDefault = ShowMass = 1;
	if(!(strcmp(argv[i],"-id"))) PrintDefault = ShowId = 1;
	if(!(strcmp(argv[i],"-pot"))) PrintDefault = ShowPot = 1;

	if((ok==0) && (PrintDefault==0))
	{
		printf("Unknown parameter: %s\n",argv[i]);
		printf("Please use correct parameters.\n");
		exit(0); 
	}
  }


  ok= load_snapshot(input_fname, files, quiteon, ShowHeader);

  if(Reorder) reordering();  /* call this routine only if your ID's are set properly */

  if(!ShowHeader) unit_conversion();  /* optional stuff */

  if(PrintDefault) write_std_to_file();
  if(ShowHeader) write_header();
  if(PrintTotalMass) print_totalmass();
  if(PrintGasMass) print_gasmass();

  return(0);
}
Пример #4
0
void Scrazy_family(double *ridgemap,float *orderedmap,int *chain,
		   int *pnbchain,int *psigsize,int *pnscale,
		   int *pbstep,float *pthreshold)
{
  int bstep, nscale, sigsize, nbchain;
  int i, j, k, id, count, a, b, found, k1;
  double *mridge;
  float threshold;

  threshold = *pthreshold;
  bstep = *pbstep;
  nscale = *pnscale;
  sigsize = *psigsize;
  nbchain = *pnbchain;

  if(!(mridge = (double *)calloc(sigsize * nscale, sizeof(double))))
    error("Memory allocation failed for mridge in crazy_family.c \n");


  /* Compute local maxima of modulus (for fixed b)
     -------------------------------------------- */
  Scwt_mridge(ridgemap,mridge,psigsize,pnscale);


  id = 0;

  /* Start looking for ridges as connected curves
     -------------------------------------------- */
  for(i = 0; i < sigsize; i+= bstep) {
    for(j = 0; j < nscale; j++) {
      b = i;
      a = j;
      k = b + sigsize * a;
      if((mridge[k] > 0.000001) && (orderedmap[k] == 0.0)) {
	found = YES;

	/* backwarding: looking for previous points of the chain
	   ----------------------------------------------------- */
	while(found && (b > 0)) {
	  found = NO;
	  b = b-1;
	  k1 = b + sigsize * max(a-1, 0);
	  if((mridge[k1] > 0.000001) && (orderedmap[k1] == 0.0)) {
	    found = YES;
	    a = max(a-1,0);
	  }
	  else {
	    k1 = b + sigsize * max(a, 0);
	    if((mridge[k1] > 0.000001) && (orderedmap[k1] == 0.0)) {
	      found = YES;
	    }
	    else {
	      k1 = b + sigsize * min(a+1, nscale-1);
	      if((mridge[k1] > 0.000001) && (orderedmap[k1] == 0.0)) {
		found = YES;
		a = min(a+1,nscale-1);
	      }
	    }
	  }
	}

	/* forwarding
	   ---------- */
	id ++;
	if(id > nbchain) {
	  printf("Nb of chains > reserved number. Increase the nbchain. \n");
	  return;
	}
	b = b+1;
	k = b + sigsize * a;
	chain[(id-1)] = b;
	chain[(id-1) + nbchain]= a;
	count = 2;
	found = YES;

	while(found) {
	  orderedmap[k] =(float)(id);
	  found = NO;

	  b = min(b+1, sigsize-1);
	  k1 = b + sigsize * max(a-1, 0);
	  if((mridge[k1] > 0.000001) && (orderedmap[k1] == 0.0)) {
	    found = YES;
	    a = max(a-1,0);
	  }
	  else {
	    k1 = b + sigsize * max(a, 0);
	    if((mridge[k1] > 0.000001) && (orderedmap[k1] == 0.0)) {
	      found = YES;
	    }
	    else {
	      k1 = b + sigsize * min(a+1, nscale-1);
	      if((mridge[k1] > 0.000001) && (orderedmap[k1] == 0.0)) {
		found = YES;
		a = min(a+1,nscale-1);
	      }
	    }
	  }
	  if(found) {
	    k = b + sigsize * a;
	    chain[(id -1) + nbchain * count] = a;
	    count ++;
	  }
	}
	/* Threshold and chain the ridges
	   ------------------------------ */
	chain_thresholded(mridge,sigsize,chain,&id,nbchain,threshold,bstep);
      }
    }
  }

  /* Generate the image of the chains
     -------------------------------- */
  orderedmap_thresholded(orderedmap,sigsize,nscale,chain,nbchain);


  /* Order the output according to the chosen data structure
     ------------------------------------------------------- */
  reordering(chain, sigsize, nbchain);


  free((char *)mridge);
  printf("There are %d chains. \n", id);
  *pnbchain = id;

  return;
}