示例#1
0
void dedisp_subbands(unsigned char *data, unsigned char *lastdata,
                     int numpts, int numchan, double *dispdelays,
                     int numsubbands, float *result)
/* De-disperse a stretch of data with numpts * numchan points    */
/* into numsubbands subbands.  Each time point for each subband  */
/* is a float in the result array.  The result array order is    */
/* subbands of increasing frequency together at each time pt.    */
/* The delays (in bins) are in dispdelays for each channel.      */
/* The input data and dispdelays are always in ascending         */
/* frequency order.  Input data are ordered in time, with the    */
/* channels stored together at each time point.                  */
{
    static int approx_mean, firsttime = 1, *delays, chan_per_subband;
    static float *lastoffsets, *offsets; //, *bandpass;
    int ii, jj, kk, ll, mm, chan;

    if (firsttime) {
        delays = gen_ivect(numchan);
        /* Prep offsets (if required) to subtract from the raw values */
        read_offsets(&lastoffsets, &offsets, numpts, numchan);
        for (ii = 0; ii < numchan; ii++) {
            if (dispdelays[ii] < 0.0) {
                printf("\ndispdelays[%d] = %f is < 0.0 in dedisp_subbands().\n\n",
                       ii, dispdelays[ii]);
                exit(-1);
            }
            delays[ii] = (int) (dispdelays[ii] + 0.5);
        }
        chan_per_subband = numchan / numsubbands;
        approx_mean = 0;
        firsttime = 0;
    }
    
    /* Initialize the result array */
    for (ii = 0; ii < numpts * numsubbands; ii++)
        result[ii] = approx_mean;
    
    /* Read  offsets (if required) to subtract from the raw values */
    read_offsets(&lastoffsets, &offsets, numpts, numchan);
    
    /* De-disperse into the subbands */
    for (ii = 0; ii < numsubbands; ii++) {
        chan = ii * chan_per_subband;
        for (jj = 0; jj < chan_per_subband; jj++, chan++) {
            kk = chan + delays[chan] * numchan;
            for (ll = 0; ll < numpts - delays[chan] ; ll++, kk += numchan)
                result[ll * numsubbands + ii] += 
                    (lastdata[kk] - lastoffsets[delays[chan]+ll]);
            kk = chan;
            for (mm = 0 ; ll < numpts ; ll++, kk += numchan, mm++)
                result[ll * numsubbands + ii] += (data[kk] - offsets[mm]);
        }
    }
}
示例#2
0
void dedisp(unsigned char *data, unsigned char *lastdata, int numpts,
            int numchan, double *dispdelays, float *result)
/* De-disperse a stretch of data with numpts * numchan points. */
/* The delays (in bins) are in dispdelays for each channel.    */
/* The result is returned in result.  The input data and       */
/* dispdelays are always in ascending frequency order.         */
/* Input data are ordered in time, with the channels stored    */
/* together at each time point.                                */
{
    static int approx_mean, firsttime = 1, *delays;
    static float *lastoffsets, *offsets; //, *bandpass;
    int ii, jj, kk, ll;

    if (firsttime) {
        delays = gen_ivect(numchan);
        /* Prep offsets (if required) to subtract from the raw values */
        read_offsets(&lastoffsets, &offsets, numpts, numchan);
        for (ii = 0; ii < numchan; ii++) {
            if (dispdelays[ii] < 0.0) {
                printf("\ndispdelays[%d] = %f is < 0.0 in dedisp().\n\n",
                       ii, dispdelays[ii]);
                exit(-1);
            }
            delays[ii] = (int) (dispdelays[ii] + 0.5);
        }
        approx_mean = 0;
        firsttime = 0;
    }
    
    /* Initialize the result array */
    for (ii = 0; ii < numpts; ii++)
        result[ii] = approx_mean;
    
    /* Read offsets (if required) to subtract from the raw values */
    read_offsets(&lastoffsets, &offsets, numpts, numchan);

    /* De-disperse */
    for (ii = 0; ii < numchan; ii++) {
        jj = ii + delays[ii] * numchan;
        for (kk = 0; kk < numpts - delays[ii]; kk++, jj += numchan)
            result[kk] += (lastdata[jj] - lastoffsets[delays[ii]+kk]);
        //result[kk] += (lastdata[jj] - lastoffsets[delays[ii]+kk]*bandpass[ii]);
        jj = ii;
        for (ll = 0 ; kk < numpts; kk++, jj += numchan, ll++)
            result[kk] += (data[jj] - offsets[ll]);
        //result[kk] += (data[jj] - offsets[ll]*bandpass[ii]);
    }
}
示例#3
0
static int
loader_22dsk_open(libdisk_prop_t *prop, const char *path)
{
  dsk_data_t *data;

  if (prop == NULL)
    return -1;

  data = do_open(path);
  if (data == NULL)
      return -1;

  if (read_offsets(data) < 0)
    return -1;

  prop->head_count = 2;
  prop->cylinder_count = 80;
  prop->sector_size = 1024;
  prop->sectors_per_cylinder = 5;
  prop->data = data;
  prop->loader = &loader;
  prop->read_only = data->read_only;

  return 0;
}
示例#4
0
 ErrorCode read( ReadHDF5Dataset& offset_data,
                 ReadHDF5Dataset& value_data,
                 const Range& file_ids,
                 EntityHandle start_file_id,
                 hid_t data_type,
                 const Range* ranged = 0 )
 {
   ErrorCode rval;
   const EntityHandle nudge = 1;
   Range offsets;
   std::vector<unsigned> counts;
   rval = read_offsets( offset_data, file_ids, 
                        start_file_id, nudge,
                        offsets, counts );
   if (MB_SUCCESS != rval)
     return rval;
   Range empty;
   rval = read_data( value_data, 
                     offsets, nudge, data_type, 
                     file_ids, counts, ranged ? *ranged : empty );
   return rval;
 }
示例#5
0
文件: wipefs.c 项目: tcdog001/autelan
int
main(int argc, char **argv)
{
	struct wipe_desc *wp = NULL;
	int c, all = 0, has_offset = 0, noact = 0, mode = 0;
	const char *fname;

	struct option longopts[] = {
	    { "all",       0, 0, 'a' },
	    { "help",      0, 0, 'h' },
	    { "no-act",    0, 0, 'n' },
	    { "offset",    1, 0, 'o' },
	    { "parsable",  0, 0, 'p' },
	    { NULL,        0, 0, 0 }
	};

	setlocale(LC_ALL, "");
	bindtextdomain(PACKAGE, LOCALEDIR);
	textdomain(PACKAGE);

	while ((c = getopt_long(argc, argv, "ahno:p", longopts, NULL)) != -1) {
		switch(c) {
		case 'a':
			all++;
			break;
		case 'h':
			usage(stdout);
			break;
		case 'n':
			noact++;
			break;
		case 'o':
			wp = add_offset(wp, strtoll_offset(optarg), 1);
			has_offset++;
			break;
		case 'p':
			mode = WP_MODE_PARSABLE;
			break;
		default:
			usage(stderr);
			break;
		}
	}

	if (wp && all)
		errx(EXIT_FAILURE, _("--offset and --all are mutually exclusive"));
	if (optind == argc)
		usage(stderr);

	fname = argv[optind++];

	wp = read_offsets(wp, fname, all);

	if (wp) {
		if (has_offset || all)
			do_wipe(wp, fname, noact);
		else
			print_all(wp, mode);

		free_wipe(wp);
	}
	return EXIT_SUCCESS;
}
示例#6
0
int
main(int argc, char **argv)
{
	struct wipe_desc *wp0 = NULL, *wp;
	int c, all = 0, has_offset = 0, noact = 0, quiet = 0;
	int mode = WP_MODE_PRETTY;

	static const struct option longopts[] = {
	    { "all",       0, 0, 'a' },
	    { "help",      0, 0, 'h' },
	    { "no-act",    0, 0, 'n' },
	    { "offset",    1, 0, 'o' },
	    { "parsable",  0, 0, 'p' },
	    { "quiet",     0, 0, 'q' },
	    { "types",     1, 0, 't' },
	    { "version",   0, 0, 'V' },
	    { NULL,        0, 0, 0 }
	};

	static const ul_excl_t excl[] = {       /* rows and cols in in ASCII order */
		{ 'a','o' },
		{ 0 }
	};
	int excl_st[ARRAY_SIZE(excl)] = UL_EXCL_STATUS_INIT;

	setlocale(LC_ALL, "");
	bindtextdomain(PACKAGE, LOCALEDIR);
	textdomain(PACKAGE);
	atexit(close_stdout);

	while ((c = getopt_long(argc, argv, "ahno:pqt:V", longopts, NULL)) != -1) {

		err_exclusive_options(c, longopts, excl, excl_st);

		switch(c) {
		case 'a':
			all++;
			break;
		case 'h':
			usage(stdout);
			break;
		case 'n':
			noact++;
			break;
		case 'o':
			wp0 = add_offset(wp0, strtosize_or_err(optarg,
					 _("invalid offset argument")), 1);
			has_offset++;
			break;
		case 'p':
			mode = WP_MODE_PARSABLE;
			break;
		case 'q':
			quiet++;
			break;
		case 't':
			type_pattern = optarg;
			break;
		case 'V':
			printf(_("%s from %s\n"), program_invocation_short_name,
				PACKAGE_STRING);
			return EXIT_SUCCESS;
		default:
			usage(stderr);
			break;
		}
	}

	if (optind == argc)
		usage(stderr);

	if (!all && !has_offset) {
		/*
		 * Print only
		 */
		while (optind < argc) {
			wp0 = read_offsets(NULL, argv[optind++]);
			if (wp0)
				print_all(wp0, mode);
			free_wipe(wp0);
		}
	} else {
		/*
		 * Erase
		 */
		while (optind < argc) {
			wp = clone_offset(wp0);
			wp = do_wipe(wp, argv[optind++], noact, all, quiet);
			free_wipe(wp);
		}
	}

	return EXIT_SUCCESS;
}
示例#7
0
int
main(int argc, char **argv)
{
	struct wipe_desc *wp0 = NULL, *wp;
	int c, has_offset = 0, flags = 0;
	int mode = WP_MODE_PRETTY;

	static const struct option longopts[] = {
	    { "all",       0, 0, 'a' },
	    { "backup",    0, 0, 'b' },
	    { "force",     0, 0, 'f' },
	    { "help",      0, 0, 'h' },
	    { "no-act",    0, 0, 'n' },
	    { "offset",    1, 0, 'o' },
	    { "parsable",  0, 0, 'p' },
	    { "quiet",     0, 0, 'q' },
	    { "types",     1, 0, 't' },
	    { "version",   0, 0, 'V' },
	    { NULL,        0, 0, 0 }
	};

	static const ul_excl_t excl[] = {       /* rows and cols in in ASCII order */
		{ 'a','o' },
		{ 0 }
	};
	int excl_st[ARRAY_SIZE(excl)] = UL_EXCL_STATUS_INIT;

	setlocale(LC_ALL, "");
	bindtextdomain(PACKAGE, LOCALEDIR);
	textdomain(PACKAGE);
	atexit(close_stdout);

	while ((c = getopt_long(argc, argv, "afhno:pqt:V", longopts, NULL)) != -1) {

		err_exclusive_options(c, longopts, excl, excl_st);

		switch(c) {
		case 'a':
			flags |= WP_FL_ALL;
			break;
		case 'b':
			flags |= WP_FL_BACKUP;
			break;
		case 'f':
			flags |= WP_FL_FORCE;
			break;
		case 'h':
			usage(stdout);
			break;
		case 'n':
			flags |= WP_FL_NOACT;
			break;
		case 'o':
			wp0 = add_offset(wp0, strtosize_or_err(optarg,
					 _("invalid offset argument")), 1);
			has_offset++;
			break;
		case 'p':
			mode = WP_MODE_PARSABLE;
			break;
		case 'q':
			flags |= WP_FL_QUIET;
			break;
		case 't':
			type_pattern = optarg;
			break;
		case 'V':
			printf(UTIL_LINUX_VERSION);
			return EXIT_SUCCESS;
		default:
			usage(stderr);
			break;
		}
	}

	if (optind == argc)
		usage(stderr);

	if ((flags & WP_FL_BACKUP) && !((flags & WP_FL_ALL) || has_offset))
		warnx(_("The --backup option is meaningless in this context"));

	if (!(flags & WP_FL_ALL) && !has_offset) {
		/*
		 * Print only
		 */
		while (optind < argc) {
			wp0 = read_offsets(NULL, argv[optind++]);
			if (wp0)
				print_all(wp0, mode);
			free_wipe(wp0);
		}
	} else {
		/*
		 * Erase
		 */
		while (optind < argc) {
			wp = clone_offset(wp0);
			wp = do_wipe(wp, argv[optind++], flags);
			free_wipe(wp);
		}
	}

	return EXIT_SUCCESS;
}