HelioBatch¶
-
class
HelioBatch
(index)[source]¶ Batch class for solar observations processing.
-
index
¶ Unique identifiers of batch items.
- Type
-
aia_intscale
(i, src, dst, wavelength)[source]¶ Adjust intensity to AIA standard.
- Parameters
- Returns
batch – Batch with adjusted images.
- Return type
-
apply
(i, func, src, dst, **kwargs)[source]¶ Apply a
func
to each item insrc
and write results indst
.- Parameters
src (str, tuple of str) – A source for data.
dst (same type as src) – A destination for results.
func (callable) – A function to apply.
kwargs (misc) – Any additional named arguments to
func
.
- Returns
batch – Processed batch.
- Return type
-
apply_meta
(i, func, src, dst, **kwargs)[source]¶ Apply a
func
to each item in meta.- Parameters
src (str, tuple of str) – A source for meta.
dst (same type as src) – A destination for results.
func (callable) – A function to apply.
kwargs (misc) – Any additional named arguments to
func
.
- Returns
batch – Processed batch.
- Return type
-
property
attributes
¶ List of data keys.
-
correct_degradation
(i, src, dst, **kwargs)[source]¶ Apply
aiapy.calibrate.correct_degradation
procedure to AIA data.- Parameters
- Returns
batch – Batch with corrected AIA maps.
- Return type
-
property
data
¶ Observational data.
-
deg2sin
(i, src, dst)[source]¶ Transform a Latitude synoptic map to Sine Latitude.
- Parameters
- Returns
batch – Batch with transformed synoptic maps.
- Return type
-
disk_center_crop
(i, src, dst)[source]¶ Crop disk to radius.
- Parameters
- Returns
batch – Batch cropped data.
- Return type
-
disk_resize
(i, src, dst, output_shape, **kwargs)[source]¶ Resize solar disk image and update center location and radius.
- Parameters
- Returns
batch – Batch with resized images and adjusted meta.
- Return type
-
downscale_local_mean
(i, func, src, dst, **kwargs)¶ Apply downscale_local_mean to batch data.
- Parameters
src (str) – Attribute to get data from. Data from this attribute will be passed to the first argument of
skimage.transform.downscale_local_mean
.dst (str, optional) – Attribute to put data in. Will be same as input if not specified.
factors (array_like) – Array containing down-sampling integer factor along each axis.
cval (float, optional) – Constant padding value if image is not perfectly divisible by the integer factors.
clip (bool, optional) – Unused, but kept here for API consistency with the other transforms in this module. (The local mean will never fall outside the range of values in the input image, assuming the provided cval also falls within that range.)
- Returns
batch – Down-sampled image with same number of dimensions as input image.
- Return type
Batch
-
drop_empty_days
(mask)[source]¶ Drop batch items without active regions.
- Parameters
mask (str) – A source for active regions masks.
- Returns
batch – Batch without empty observations.
- Return type
-
dtype_limits
(i, func, src, dst, **kwargs)¶ Apply dtype_limits to batch data.
- Parameters
src (str) – Attribute to get data from. Data from this attribute will be passed to the first argument of
skimage.dtype_limits
.dst (str, optional) – Attribute to put data in. Will be same as input if not specified.
clip_negative (bool, optional) – If True, clip the negative range (i.e. return 0 for min intensity) even if the image dtype allows negative values.
- Returns
batch – Lower and upper intensity limits.
- Return type
Batch
-
dump
(src, path, format, **kwargs)[source]¶ Dump data in various formats.
Supported formats: npz, txt, binary, fits, abp, blosc and any of matplotlib.pyplot.imsave supported formats.
- Parameters
- Returns
batch – Batch unchanged.
- Return type
-
dump_group_patches
(i, src, dst, meta=None, min_area=0)[source]¶ Dump group pathes into separate .npz files.
-
fillna
(i, src, dst, value=0.0)[source]¶ Replace NaN with a given value.
- Parameters
- Returns
batch – Batch NaN replaced.
- Return type
-
filter_regions
(i, src, dst, min_area, **kwargs)[source]¶ Filter regions with pixel area less than npix.
- Parameters
- Returns
batch – Batch with filtered masks.
- Return type
-
fit_mask
(i, src, dst, target)[source]¶ Fit mask to new disk center and radius.
- Parameters
- Returns
batch – Batch with new masks.
- Return type
-
fit_scale
(i, src, dst, target, labels=False, background=0)[source]¶ Fit data scale to the target disk radius.
- Parameters
- Returns
batch – Batch with rescaled images.
- Return type
-
flip
(i, src, axis, dst=None, p=True, update_meta=False)[source]¶ Apply axis reversing. Accepts random parameter p for aurgemntation.
- Parameters
src (str, tuple of str) – A source for images.
dst (same type as src) – A destination for results.
axis (int) – Axis in array, which entries are reversed.
p (bool or R) – Probabilistic parameter for augmentation, e.g. p = R(‘choice’, a=[True, False], p=[0.5, 0.5]) will flip images with probability 0.5.
update_meta (bool) – Update meta with new image orientation. Default to False.
- Returns
batch – Batch with flipped images.
- Return type
ImageBatch
-
get_pixel_params
(i, src, dst, meta=None)[source]¶ Get coordinates and area of individual pixels for regions identified in solar disk image.
- Parameters
- Returns
batch – Batch with parameters calculated.
- Return type
-
get_polygons
(src, dst, coords='hgc', tolerance=3, cache=True)[source]¶ Get polygons from binary mask.
- Parameters
- Returns
batch – Batch with polygons calculated.
- Return type
-
get_radius
(i, src, dst, hough_radii, sigma=2, raise_limits=False, logger=None)[source]¶ Estimate solar disk center and radius.
- Parameters
src (str) – A source for solar disk images.
hough_radii (tuple) – Mininal and maximal radius to search.
sigma (scalar, optional) – Canny filter parameter. Default 2.
raise_limits (bool, optional) – Raise error if radius found is in the end of search interval. Default False.
logger (logger, optional) – Logger for messages. Default None.
- Returns
batch – Batch with updated meta.
- Return type
-
get_region_props
(i, src, dst, level=0.5, tolerance=3, cache=True)[source]¶ Get region properties.
- Parameters
- Returns
batch – Batch with props calculated.
- Return type
-
group_by_index
()[source]¶ Stack batch items according to batch index.
- Returns
batch – A new batch with stacked items.
- Return type
Notes
Meta will be lost.
-
hough_circle
(i, func, src, dst, **kwargs)¶ Apply hough_circle to batch data.
- Parameters
src (str) – Attribute to get data from. Data from this attribute will be passed to the first argument of
skimage.transform.hough_circle
.dst (str, optional) – Attribute to put data in. Will be same as input if not specified.
radius (scalar or sequence of scalars) – Radii at which to compute the Hough transform. Floats are converted to integers.
normalize (boolean, optional (default True)) – Normalize the accumulator with the number of pixels used to draw the radius.
full_output (boolean, optional (default False)) – Extend the output size by twice the largest radius in order to detect centers outside the input picture.
- Returns
batch – Hough transform accumulator for each radius.
- Return type
Batch
-
hough_ellipse
(i, func, src, dst, **kwargs)¶ Apply hough_ellipse to batch data.
- Parameters
src (str) – Attribute to get data from. Data from this attribute will be passed to the first argument of
skimage.transform.hough_ellipse
.dst (str, optional) – Attribute to put data in. Will be same as input if not specified.
threshold (int, optional) – Accumulator threshold value.
accuracy (double, optional) – Bin size on the minor axis used in the accumulator.
min_size (int, optional) – Minimal major axis length.
max_size (int, optional) – Maximal minor axis length. If None, the value is set to the half of the smaller image dimension.
- Returns
batch – Where
(yc, xc)
is the center,(a, b)
the major and minor- Return type
Batch
-
hough_line
(i, func, src, dst, **kwargs)¶ Apply hough_line to batch data.
- Parameters
src (str) – Attribute to get data from. Data from this attribute will be passed to the first argument of
skimage.transform.hough_line
.dst (str, optional) – Attribute to put data in. Will be same as input if not specified.
theta (1D ndarray of double, optional) – Angles at which to compute the transform, in radians. Defaults to a vector of 180 angles evenly spaced from -pi/2 to pi/2.
- Returns
batch – Hough transform accumulator.
- Return type
Batch
-
img_as_bool
(i, func, src, dst, **kwargs)¶ Apply img_as_bool to batch data.
- Parameters
src (str) – Attribute to get data from. Data from this attribute will be passed to the first argument of
skimage.img_as_bool
.dst (str, optional) – Attribute to put data in. Will be same as input if not specified.
force_copy (bool, optional) – Force a copy of the data, irrespective of its current dtype.
- Returns
batch – Output image.
- Return type
Batch
-
img_as_float
(i, func, src, dst, **kwargs)¶ Apply img_as_float to batch data.
- Parameters
src (str) – Attribute to get data from. Data from this attribute will be passed to the first argument of
skimage.img_as_float
.dst (str, optional) – Attribute to put data in. Will be same as input if not specified.
force_copy (bool, optional) – Force a copy of the data, irrespective of its current dtype.
- Returns
batch – Output image.
- Return type
Batch
-
img_as_float32
(i, func, src, dst, **kwargs)¶ Apply img_as_float32 to batch data.
- Parameters
src (str) – Attribute to get data from. Data from this attribute will be passed to the first argument of
skimage.img_as_float32
.dst (str, optional) – Attribute to put data in. Will be same as input if not specified.
force_copy (bool, optional) – Force a copy of the data, irrespective of its current dtype.
- Returns
batch – Output image.
- Return type
Batch
-
img_as_float64
(i, func, src, dst, **kwargs)¶ Apply img_as_float64 to batch data.
- Parameters
src (str) – Attribute to get data from. Data from this attribute will be passed to the first argument of
skimage.img_as_float64
.dst (str, optional) – Attribute to put data in. Will be same as input if not specified.
force_copy (bool, optional) – Force a copy of the data, irrespective of its current dtype.
- Returns
batch – Output image.
- Return type
Batch
-
img_as_int
(i, func, src, dst, **kwargs)¶ Apply img_as_int to batch data.
- Parameters
src (str) – Attribute to get data from. Data from this attribute will be passed to the first argument of
skimage.img_as_int
.dst (str, optional) – Attribute to put data in. Will be same as input if not specified.
force_copy (bool, optional) – Force a copy of the data, irrespective of its current dtype.
- Returns
batch – Output image.
- Return type
Batch
-
img_as_ubyte
(i, func, src, dst, **kwargs)¶ Apply img_as_ubyte to batch data.
- Parameters
src (str) – Attribute to get data from. Data from this attribute will be passed to the first argument of
skimage.img_as_ubyte
.dst (str, optional) – Attribute to put data in. Will be same as input if not specified.
force_copy (bool, optional) – Force a copy of the data, irrespective of its current dtype.
- Returns
batch – Output image.
- Return type
Batch
-
img_as_uint
(i, func, src, dst, **kwargs)¶ Apply img_as_uint to batch data.
- Parameters
src (str) – Attribute to get data from. Data from this attribute will be passed to the first argument of
skimage.img_as_uint
.dst (str, optional) – Attribute to put data in. Will be same as input if not specified.
force_copy (bool, optional) – Force a copy of the data, irrespective of its current dtype.
- Returns
batch – Output image.
- Return type
Batch
-
imshow
(src, i, mask=None, ax=None, figsize=None, cmap=None, s=None, color=None, **kwargs)[source]¶ Show image data with optional mask countours overlayed.
- Parameters
src (str) – Image data source.
i (int) – Integer data index.
mask (str, optional) – Mask to be overlayed.
ax (matplotlib axes, optional) – Axes to plot in.
figsize (tuple, optional) – Size of figure.
cmap (cmap) – Matplotlib color map for image.
s (int) – Point size for contours.
color (color) – Matplotlib color for contours.
kwargs (misc) – Additional imshow keywords.
-
property
index
Batch index.
-
property
indices
¶ Batch items identifiers.
-
integral_image
(i, func, src, dst, **kwargs)¶ Apply integral_image to batch data.
- Parameters
- Returns
batch – Integral image/summed area table of same shape as input image.
- Return type
Batch
-
jsoc_load
(path, series, email, method='url', protocol='fits', verbose=True)[source]¶ Download data from JSOC based on DateTime column in the batch index.
- Parameters
- Returns
batch – Batch unchanged.
- Return type
-
label_synoptic_map
(src, dst)[source]¶ Label regions in a binary synoptic map. Takes into account connections at 360 and 0 longitude.
- Parameters
- Returns
batch – Batch with labeled synoptic maps.
- Return type
-
load
(src, dtype=None, meta=None, **kwargs)[source]¶ Load batch data from source.
- Parameters
- Returns
batch – Batch with loaded data.
- Return type
-
make_polar_plots
(i, src, dst, path, figsize=None, axes=False, labelsize=14, pad=None, **kwargs)[source]¶ Make polar projections from a synoptic map.
- Parameters
- Returns
batch – Batch unchanged.
- Return type
-
map_to_synoptic
(i, src, dst, bins, average=None, deg=True)[source]¶ Make a synoptic map from a solar disk image.
- Parameters
- Returns
batch – Batch with synoptic maps.
- Return type
-
mask_disk
(i, src, dst, fill_value=nan)[source]¶ Set dummy value to pixels outside the solar disk.
- Parameters
- Returns
batch – Batch with masked disk.
- Return type
-
match_histogram
(i, src, dst, reference)[source]¶ Histogram matching.
- Parameters
- Returns
batch – Batch with adjusted images.
- Return type
-
match_histograms
(i, func, src, dst, **kwargs)¶ Apply match_histograms to batch data.
- Parameters
src (str) – Attribute to get data from. Data from this attribute will be passed to the first argument of
skimage.transform.match_histograms
.dst (str, optional) – Attribute to put data in. Will be same as input if not specified.
reference (ndarray) – Image to match histogram of. Must have the same number of channels as image.
multichannel (bool, optional) – Apply the matching separately for each channel.
- Returns
batch – Transformed input image.
- Return type
Batch
-
property
meta
¶ Meta information on observations.
-
probabilistic_hough_line
(i, func, src, dst, **kwargs)¶ Apply probabilistic_hough_line to batch data.
- Parameters
src (str) – Attribute to get data from. Data from this attribute will be passed to the first argument of
skimage.transform.probabilistic_hough_line
.dst (str, optional) – Attribute to put data in. Will be same as input if not specified.
threshold (int, optional) – Threshold
line_length (int, optional) – Minimum accepted length of detected lines. Increase the parameter to extract longer lines.
line_gap (int, optional) – Maximum gap between pixels to still form a line. Increase the parameter to merge broken lines more aggressively.
theta (1D ndarray, dtype=double, optional) – Angles at which to compute the transform, in radians. If None, use a range from -pi/2 to pi/2.
seed (int, optional) – Seed to initialize the random number generator.
- Returns
batch – List of lines identified, lines in format ((x0, y0), (x1, y1)),
- Return type
Batch
-
props2hgc
(src, meta)[source]¶ Map props in i,j coordinates to HGC (Heliographic-Carrington) coordinates.
- Parameters
- Returns
batch – Batch with props calculated.
- Return type
-
props2hpc
(src, meta, resolution)[source]¶ Map props in i,j coordinates to HPC (Helioprojective-Cartesian) coordinates.
- Parameters
- Returns
batch – Batch with props calculated.
- Return type
-
pyramid_expand
(i, func, src, dst, **kwargs)¶ Apply pyramid_expand to batch data.
- Parameters
src (str) – Attribute to get data from. Data from this attribute will be passed to the first argument of
skimage.transform.pyramid_expand
.dst (str, optional) – Attribute to put data in. Will be same as input if not specified.
upscale (float, optional) – Upscale factor.
sigma (float, optional) – Sigma for Gaussian filter. Default is 2 * upscale / 6.0 which corresponds to a filter mask twice the size of the scale factor that covers more than 99% of the Gaussian distribution.
order (int, optional) – Order of splines used in interpolation of upsampling. See skimage.transform.warp for detail.
mode ({'reflect', 'constant', 'edge', 'symmetric', 'wrap'}, optional) – The mode parameter determines how the array borders are handled, where cval is the value when mode is equal to ‘constant’.
cval (float, optional) – Value to fill past edges of input if mode is ‘constant’.
multichannel (bool, optional) – Whether the last axis of the image is to be interpreted as multiple channels or another spatial dimension.
- Returns
batch – Upsampled and smoothed float image.
- Return type
Batch
-
pyramid_gaussian
(i, func, src, dst, **kwargs)¶ Apply pyramid_gaussian to batch data.
- Parameters
src (str) – Attribute to get data from. Data from this attribute will be passed to the first argument of
skimage.transform.pyramid_gaussian
.dst (str, optional) – Attribute to put data in. Will be same as input if not specified.
max_layer (int, optional) – Number of layers for the pyramid. 0th layer is the original image. Default is -1 which builds all possible layers.
downscale (float, optional) – Downscale factor.
sigma (float, optional) – Sigma for Gaussian filter. Default is 2 * downscale / 6.0 which corresponds to a filter mask twice the size of the scale factor that covers more than 99% of the Gaussian distribution.
order (int, optional) – Order of splines used in interpolation of downsampling. See skimage.transform.warp for detail.
mode ({'reflect', 'constant', 'edge', 'symmetric', 'wrap'}, optional) – The mode parameter determines how the array borders are handled, where cval is the value when mode is equal to ‘constant’.
cval (float, optional) – Value to fill past edges of input if mode is ‘constant’.
multichannel (bool, optional) – Whether the last axis of the image is to be interpreted as multiple channels or another spatial dimension.
- Returns
batch – Generator yielding pyramid layers as float images.
- Return type
Batch
-
pyramid_laplacian
(i, func, src, dst, **kwargs)¶ Apply pyramid_laplacian to batch data.
- Parameters
src (str) – Attribute to get data from. Data from this attribute will be passed to the first argument of
skimage.transform.pyramid_laplacian
.dst (str, optional) – Attribute to put data in. Will be same as input if not specified.
max_layer (int, optional) – Number of layers for the pyramid. 0th layer is the original image. Default is -1 which builds all possible layers.
downscale (float, optional) – Downscale factor.
sigma (float, optional) – Sigma for Gaussian filter. Default is 2 * downscale / 6.0 which corresponds to a filter mask twice the size of the scale factor that covers more than 99% of the Gaussian distribution.
order (int, optional) – Order of splines used in interpolation of downsampling. See skimage.transform.warp for detail.
mode ({'reflect', 'constant', 'edge', 'symmetric', 'wrap'}, optional) – The mode parameter determines how the array borders are handled, where cval is the value when mode is equal to ‘constant’.
cval (float, optional) – Value to fill past edges of input if mode is ‘constant’.
multichannel (bool, optional) – Whether the last axis of the image is to be interpreted as multiple channels or another spatial dimension.
- Returns
batch – Generator yielding pyramid layers as float images.
- Return type
Batch
-
pyramid_reduce
(i, func, src, dst, **kwargs)¶ Apply pyramid_reduce to batch data.
- Parameters
src (str) – Attribute to get data from. Data from this attribute will be passed to the first argument of
skimage.transform.pyramid_reduce
.dst (str, optional) – Attribute to put data in. Will be same as input if not specified.
downscale (float, optional) – Downscale factor.
sigma (float, optional) – Sigma for Gaussian filter. Default is 2 * downscale / 6.0 which corresponds to a filter mask twice the size of the scale factor that covers more than 99% of the Gaussian distribution.
order (int, optional) – Order of splines used in interpolation of downsampling. See skimage.transform.warp for detail.
mode ({'reflect', 'constant', 'edge', 'symmetric', 'wrap'}, optional) – The mode parameter determines how the array borders are handled, where cval is the value when mode is equal to ‘constant’.
cval (float, optional) – Value to fill past edges of input if mode is ‘constant’.
multichannel (bool, optional) – Whether the last axis of the image is to be interpreted as multiple channels or another spatial dimension.
- Returns
batch – Smoothed and downsampled float image.
- Return type
Batch
-
radon
(i, func, src, dst, **kwargs)¶ Apply radon to batch data.
- Parameters
- Returns
batch – Radon transform (sinogram). The tomography rotation axis will lie
- Return type
Batch
-
region_statistics
(i, src, dst, sin, hmi=None)[source]¶ - Calculates statistics for regions in a binary synoptic map:
area (\(10^{12}\) \(km^2\))
mean latitude (in degrees, North at \(90^{\circ}\))
largest Carrington longitude (in degrees)
positive flux (\(10^{22}\) Mx, if hmi is not None and in Gauss)
negative flux (\(10^{22}\) Mx, if hmi is not None and in Gauss)
- Parameters
- Returns
batch – Batch with statistics.
- Return type
-
rescale
(i, func, src, dst, **kwargs)¶ Apply rescale to batch data.
- Parameters
src (str) – Attribute to get data from. Data from this attribute will be passed to the first argument of
skimage.transform.rescale
.dst (str, optional) – Attribute to put data in. Will be same as input if not specified.
scale ({float, tuple of floats}) – Scale factors. Separate scale factors can be defined as (rows, cols[, …][, dim]).
- Returns
batch – Scaled version of the input.
- Return type
Batch
-
resize
(i, func, src, dst, **kwargs)¶ Apply resize to batch data.
- Parameters
src (str) – Attribute to get data from. Data from this attribute will be passed to the first argument of
skimage.transform.resize
.dst (str, optional) – Attribute to put data in. Will be same as input if not specified.
output_shape (tuple or ndarray) – Size of the generated output image (rows, cols[, …][, dim]). If dim is not provided, the number of channels is preserved. In case the number of input channels does not equal the number of output channels a n-dimensional interpolation is applied.
- Returns
batch – Resized version of the input.
- Return type
Batch
-
rot90
(i, src, dst, axes=(0, 1), k=1, update_meta=False)[source]¶ Apply rotation of an image by 90 degrees given number of times.
- Parameters
src (str, tuple of str) – A source for images.
dst (same type as src) – A destination for results.
axes ((2,) array_like) – The array is rotated in the plane defined by the axes. Axes must be different. Default to (0, 1).
k (int or R) – Probabilistic parameter for augmentation, e.g. k = R(‘choice’, a=np.arange(4)) will rotate images random number of times.
update_meta (bool) – Update meta with new image orientation. Default to False.
- Returns
batch – Batch with rotated images.
- Return type
-
rotate
(i, func, src, dst, **kwargs)¶ Apply rotate to batch data.
- Parameters
src (str) – Attribute to get data from. Data from this attribute will be passed to the first argument of
skimage.transform.rotate
.dst (str, optional) – Attribute to put data in. Will be same as input if not specified.
angle (float) – Rotation angle in degrees in counter-clockwise direction.
resize (bool, optional) – Determine whether the shape of the output image will be automatically calculated, so the complete rotated image exactly fits. Default is False.
center (iterable of length 2) – The rotation center. If
center=None
, the image is rotated around its center, i.e.center=(cols / 2 - 0.5, rows / 2 - 0.5)
. Please note that this parameter is (cols, rows), contrary to normal skimage ordering.
- Returns
batch – Rotated version of the input.
- Return type
Batch
-
rotate_p_angle
(i, src, dst, deg=True, labels=False, background=0, **kwargs)[source]¶ Rotate disk image to P=0 around disk center.
- Parameters
src (str) – A source for disk images.
dst (str) – A destination for results.
deg (bool) – Angles are in degrees. Default True.
labels (bool) – Data contains labels. Default False.
background (scalar) – Background label.
kwargs (misc) – Any additional named arguments to
skimage.transform.rotate
method.
- Returns
batch – Batch with rotated disk.
- Return type
-
show_sun
(src, i, figsize=None, ax=None, c='blue', c2='red', c3='green', grid=True, grid_lw=0.5, deg=True)[source]¶ Show active regions on the solar disk.
-
sin2deg
(i, src, dst)[source]¶ Transform a Sine Latitude synoptic map to Latitude.
- Parameters
- Returns
batch – Batch with transformed synoptic maps.
- Return type
-
stack_synoptic_maps
(i, src, dst, shift, scale, weight_decay=None, deg=True)[source]¶ Stack synoptic maps corresponding to disk images into a single map.
- Parameters
src (str) – A source for synoptic maps corresponding to disk images.
dst (str) – A destination for results.
shift (scalar) – A parameter for pixel weights according to weight_decay(-(dist - shift) / scale).
scale (scalar) – A parameter for pixel weights according to weight_decay(-(dist - shift) / scale).
weight_decay (callable) – Function to get a pixel weight based on its distance from central meridian. Distance unit should be degree. Default is sigmoid function.
deg (bool) – If True, all angles are in degrees. Default to True.
- Returns
batch – Batch with synoptic maps.
- Return type
-
swirl
(i, func, src, dst, **kwargs)¶ Apply swirl to batch data.
- Parameters
src (str) – Attribute to get data from. Data from this attribute will be passed to the first argument of
skimage.transform.swirl
.dst (str, optional) – Attribute to put data in. Will be same as input if not specified.
center ((column, row) tuple or (2,) ndarray, optional) – Center coordinate of transformation.
strength (float, optional) – The amount of swirling applied.
radius (float, optional) – The extent of the swirl in pixels. The effect dies out rapidly beyond radius.
rotation (float, optional) – Additional rotation applied to the image.
- Returns
batch – Swirled version of the input.
- Return type
Batch
-
url_load
(src, path, rename=False, fmt='%Y-%m-%dT%H%M%S')[source]¶ Download data from URL address and save to local directory.
- Parameters
src (str) – Index colum label with data sources.
path (str) – Directory to save files. Directory should exist.
rename (bool) – Leave file names unchanged or make new names based on datetime and the source name. Default False.
fmt (str, optional) – Datetime format of the renamed files. Used if rename=True.
- Returns
batch – Batch unchanged.
- Return type
-
warp
(i, func, src, dst, **kwargs)¶ Apply warp to batch data.
- Parameters
src (str) – Attribute to get data from. Data from this attribute will be passed to the first argument of
skimage.transform.warp
.dst (str, optional) – Attribute to put data in. Will be same as input if not specified.
inverse_map (transformation object, callable
cr = f(cr, **kwargs)
, or ndarray) –Inverse coordinate map, which transforms coordinates in the output images into their corresponding coordinates in the input image.
There are a number of different options to define this map, depending on the dimensionality of the input image. A 2-D image can have 2 dimensions for gray-scale images, or 3 dimensions with color information.
For 2-D images, you can directly pass a transformation object, e.g. skimage.transform.SimilarityTransform, or its inverse.
For 2-D images, you can pass a
(3, 3)
homogeneous transformation matrix, e.g. skimage.transform.SimilarityTransform.params.For 2-D images, a function that transforms a
(M, 2)
array of(col, row)
coordinates in the output image to their corresponding coordinates in the input image. Extra parameters to the function can be specified through map_args.For N-D images, you can directly pass an array of coordinates. The first dimension specifies the coordinates in the input image, while the subsequent dimensions determine the position in the output image. E.g. in case of 2-D images, you need to pass an array of shape
(2, rows, cols)
, where rows and cols determine the shape of the output image, and the first dimension contains the(row, col)
coordinate in the input image. See scipy.ndimage.map_coordinates for further documentation.
Note, that a
(3, 3)
matrix is interpreted as a homogeneous transformation matrix, so you cannot interpolate values from a 3-D input, if the output is of shape(3,)
.See example section for usage.
map_args (dict, optional) – Keyword arguments passed to inverse_map.
output_shape (tuple (rows, cols), optional) – Shape of the output image generated. By default the shape of the input image is preserved. Note that, even for multi-band images, only rows and columns need to be specified.
order (int, optional) –
- The order of interpolation. The order has to be in the range 0-5:
0: Nearest-neighbor
1: Bi-linear (default)
2: Bi-quadratic
3: Bi-cubic
4: Bi-quartic
5: Bi-quintic
mode ({'constant', 'edge', 'symmetric', 'reflect', 'wrap'}, optional) – Points outside the boundaries of the input are filled according to the given mode. Modes match the behaviour of numpy.pad.
cval (float, optional) – Used in conjunction with mode ‘constant’, the value outside the image boundaries.
clip (bool, optional) – Whether to clip the output to the range of values of the input image. This is enabled by default, since higher order interpolation may produce values outside the given input range.
preserve_range (bool, optional) – Whether to keep the original range of values. Otherwise, the input image is converted according to the conventions of img_as_float. Also see https://scikit-image.org/docs/dev/user_guide/data_types.html
- Returns
batch – The warped input image.
- Return type
Batch
-
warp_polar
(i, func, src, dst, **kwargs)¶ Apply warp_polar to batch data.
- Parameters
src (str) – Attribute to get data from. Data from this attribute will be passed to the first argument of
skimage.transform.warp_polar
.dst (str, optional) – Attribute to put data in. Will be same as input if not specified. multichannel=True, 3-D arrays are accepted and the last axis is interpreted as multiple channels.
center (tuple (row, col), optional) – Point in image that represents the center of the transformation (i.e., the origin in cartesian space). Values can be of type float. If no value is given, the center is assumed to be the center point of the image.
radius (float, optional) – Radius of the circle that bounds the area to be transformed.
output_shape (tuple (row, col), optional) –
scaling ({'linear', 'log'}, optional) – Specify whether the image warp is polar or log-polar. Defaults to ‘linear’.
multichannel (bool, optional) – Whether the image is a 3-D array in which the third axis is to be interpreted as multiple channels. If set to False (default), only 2-D arrays are accepted.
**kwargs (keyword arguments) – Passed to transform.warp.
- Returns
batch – The polar or log-polar warped image.
- Return type
Batch
-