Read the band in native blocks.
1884
def read_band_blocks(self, blocksize=CHUNK_SIZE):
        """"""
        # For sentinel 1 data, the block are 1 line, and dask seems to choke on that.
        band = self.filehandle

        shape = band.shape
        token = tokenize(blocksize, band)
        name = 'read_band-' + token
        dskx = dict()
        if len(band.block_shapes) != 1:
            raise NotImplementedError('Bands with multiple shapes not supported.')
        else:
            chunks = band.block_shapes[0]

        def do_read(the_band, the_window, the_lock):
            with the_lock:
                return the_band.read(1, None, window=the_window)

        for ji, window in band.block_windows(1):
            dskx[(name, ) + ji] = (do_read, band, window, self.read_lock)

        res = da.Array(dskx, name, shape=list(shape),
                       chunks=chunks,
                       dtype=band.dtypes[0])
        return DataArray(res, dims=('y', 'x'))
966074
public static void fillBand(InterleavedF64 input, int band , double value) {

		final int numBands = input.numBands;
		for (int y = 0; y < input.height; y++) {
			int index = input.getStartIndex() + y * input.getStride() + band;
			int end = index + input.width*numBands - band;
			for (; index < end; index += numBands ) {
				input.data[index] = value;
			}
		}
	}
143807
def get_fixed_block(self, keys=[], unbuffered=False):
        """"""
        if unbuffered or not self._fixed_block:
            self._fixed_block = self._read_fixed_block()
        format = self.fixed_format
        # navigate down list of keys to get to wanted data
        for key in keys:
            format = format[key]
        return _decode(self._fixed_block, format)
928011
def read_data(self, block_samples=1024):
        """"""
        old_width = self._file.getsampwidth()

        while True:
            data = self._file.readframes(block_samples)
            if not data:
                break

            # Make sure we have the desired bitdepth and endianness.
            data = audioop.lin2lin(data, old_width, TARGET_WIDTH)
            if self._needs_byteswap and self._file.getcomptype() != 'sowt':
                # Big-endian data. Swap endianness.
                data = byteswap(data)
            yield data
130919
def plot_band(plt_in, band_name, rsr_obj, **kwargs):
    """"""
    if 'platform_name_in_legend' in kwargs:
        platform_name_in_legend = kwargs['platform_name_in_legend']
    else:
        platform_name_in_legend = False

    detectors = rsr_obj.rsr[band_name].keys()
    # for det in detectors:
    det = sorted(detectors)[0]
    resp = rsr_obj.rsr[band_name][det]['response']
    wvl = rsr_obj.rsr[band_name][det]['wavelength']

    resp = np.ma.masked_less_equal(resp, minimum_response)
    wvl = np.ma.masked_array(wvl, resp.mask)
    resp.compressed()
    wvl.compressed()

    if platform_name_in_legend:
        plt_in.plot(wvl, resp, label='{platform} - {band}'.format(
            platform=rsr_obj.platform_name, band=band_name))
    else:
        plt_in.plot(wvl, resp, label='{band}'.format(band=band_name))

    return plt_in
436101
def _get_bandgap_from_bands(energies, nelec):
        """"""
        nelec = int(nelec)
        valence = [x[nelec-1] for x in energies]
        conduction = [x[nelec] for x in energies]
        return max(min(conduction) - max(valence), 0.0)
1123165
def _get_solar_flux(self, band):
        """"""
        solar_flux = self.cal['solar_flux'].isel(bands=band).values
        d_index = self.cal['detector_index'].fillna(0).astype(int)

        return da.map_blocks(self._get_items, d_index.data, solar_flux=solar_flux, dtype=solar_flux.dtype)
249050
def read_block(self, block):
        
        self.seek(block.file_offset)
        return self._fhandle.read(block.size)
161462
public static void insertBand( GrayI8 input, int band , InterleavedI8 output) {

		final int numBands = output.numBands;
		for (int y = 0; y < input.height; y++) {
			int indexIn = input.getStartIndex() + y * input.getStride();
			int indexOut = output.getStartIndex() + y * output.getStride() + band;
			int end = indexOut + output.width*numBands - band;
			for (; indexOut < end; indexOut += numBands , indexIn++ ) {
				output.data[indexOut] = input.data[indexIn];
			}
		}
	}
585305
private static int readDataBlock(String text, int offset, int length, List<byte[]> blocks)
   {
      int bytes = length / 2;
      byte[] data = new byte[bytes];

      for (int index = 0; index < bytes; index++)
      {
         data[index] = (byte) Integer.parseInt(text.substring(offset, offset + 2), 16);
         offset += 2;
      }

      blocks.add(data);
      return (offset);
   }
647980
def scan_band(self, band, **kwargs):
        

        kal_run_line = fn.build_kal_scan_band_string(self.kal_bin,
                                                     band, kwargs)
        raw_output = subprocess.check_output(kal_run_line.split(' '),
                                             stderr=subprocess.STDOUT)
        kal_normalized = fn.parse_kal_scan(raw_output)
        return kal_normalized
823934
protected function readBlocks()
	{
		$open	= false;
		$file	= new FS_File_Reader( $this->fileName );
		$lines	= $file->readArray();
		foreach( $lines as $line )
		{
			$line	= trim( $line );
			if( $line )
			{
				if( preg_match( $this->patternSection, $line ) )
				{
					$section 	= preg_replace( $this->patternSection, "\\1", $line );
					if( !isset( $this->blocks[$section] ) )
						$this->blocks[$section]	= array();
					$open = true;
				}
				else if( $open )
				{
					$this->blocks[$section][]	= $line;
				}
			}
		}
		foreach( $this->blocks as $section => $block )
			$this->blocks[$section]	= implode( "\n", $block );
	}
609244
def block(self, group=False, custom=False):
        '''
        
        '''
        reader = BlockReader()
        symbol = os.path.join(self.tdxdir, 'block_zs.dat')

        if symbol is not None:
            return reader.get_df(symbol, group)

        return None
831583
private void readBlock(int blockIndex, int startIndex, int blockLength) throws Exception
   {
      logBlock(blockIndex, startIndex, blockLength);

      if (blockLength < 128)
      {
         readTableBlock(startIndex, blockLength);
      }
      else
      {
         readColumnBlock(startIndex, blockLength);
      }
   }
231386
private void read_block_sizes_from_disk(boolean coalesce_blocks)
    throws IOException
    {
        long addr = FIRST_TAIL;
        int length;
        long new_tail = tail_ptr;

        while (addr < tail_ptr) {
            seek(addr);
            if (coalesce_blocks) {
                length = combine_blocks(addr);
            } else {
                length = readInt();
            }
            if (length > 0) {
                if ((length + addr >= tail_ptr) && (!readOnly)) {
                    // add last block to tail
                    new_tail = addr;
                } else {
                    add_to_freelist(addr, length);
                }
            } else {
                length = - length;
                allocated_blocks++;
                allocated_words += length;
            }
            addr = addr + length;
        }
        if ((new_tail != tail_ptr) && (!readOnly)) {
            tail_ptr = new_tail;
            seek(TAIL_DPTR);
            writeLong(tail_ptr);
        }

    }
631794
public static void insertBand( GrayF64 input, int band , InterleavedF64 output) {

		final int numBands = output.numBands;
		for (int y = 0; y < input.height; y++) {
			int indexIn = input.getStartIndex() + y * input.getStride();
			int indexOut = output.getStartIndex() + y * output.getStride() + band;
			int end = indexOut + output.width*numBands - band;
			for (; indexOut < end; indexOut += numBands , indexIn++ ) {
				output.data[indexOut] = input.data[indexIn];
			}
		}
	}
417220
def get_band(low_hist, high_hist, middle_hist=None):
    
    npoints = low_hist.nbins(0)
    band = Graph(npoints)
    for i in range(npoints):
        center = low_hist.x(i + 1)
        width = low_hist.xwidth(i + 1)
        low, high = low_hist.y(i + 1), high_hist.y(i + 1)
        if middle_hist is not None:
            middle = middle_hist.y(i + 1)
        else:
            middle = (low + high) / 2.
        yerrh = max(high - middle, low - middle, 0)
        yerrl = abs(min(high - middle, low - middle, 0))
        band.SetPoint(i, center, middle)
        band.SetPointError(i, width / 2., width / 2.,
                           yerrl, yerrh)
    return band