INSTRUCTION stringlengths 1 8.43k | RESPONSE stringlengths 75 104k |
|---|---|
Represent data as a masked array. | def ma(self):
"""Represent data as a masked array.
The array is returned with column-first indexing, i.e. for a data file with
columns X Y1 Y2 Y3 ... the array a will be a[0] = X, a[1] = Y1, ... .
inf and nan are filtered via :func:`numpy.isfinite`.
"""
a = self.array
... |
Correlation time of data. | def _tcorrel(self, nstep=100, **kwargs):
"""Correlation "time" of data.
The 0-th column of the data is interpreted as a time and the
decay of the data is computed from the autocorrelation
function (using FFT).
.. SeeAlso:: :func:`numkit.timeseries.tcorrel`
"""
t... |
Set and change the parameters for calculations with correlation functions. | def set_correlparameters(self, **kwargs):
"""Set and change the parameters for calculations with correlation functions.
The parameters persist until explicitly changed.
:Keywords:
*nstep*
only process every *nstep* data point to speed up the FFT; if
le... |
Read and cache the file as a numpy array. | def parse(self, stride=None):
"""Read and cache the file as a numpy array.
Store every *stride* line of data; if ``None`` then the class default is used.
The array is returned with column-first indexing, i.e. for a data file with
columns X Y1 Y2 Y3 ... the array a will be a[0] = X, a[1... |
Plot xvg file data. | def plot(self, **kwargs):
"""Plot xvg file data.
The first column of the data is always taken as the abscissa
X. Additional columns are plotted as ordinates Y1, Y2, ...
In the special case that there is only a single column then this column
is plotted against the index, i.e. (N... |
Plot data like: meth: XVG. plot with the range of ** all ** data shown. | def plot_coarsened(self, **kwargs):
"""Plot data like :meth:`XVG.plot` with the range of **all** data shown.
Data are reduced to *maxpoints* (good results are obtained
with low values such as 100) and the actual range of observed
data is plotted as a translucent error band around the me... |
errorbar plot for a single time series with errors. | def errorbar(self, **kwargs):
"""errorbar plot for a single time series with errors.
Set *columns* keyword to select [x, y, dy] or [x, y, dx, dy],
e.g. ``columns=[0,1,2]``. See :meth:`XVG.plot` for
details. Only a single timeseries can be plotted and the user
needs to select the... |
Decimate data * a * to * maxpoints * using * method *. | def decimate(self, method, a, maxpoints=10000, **kwargs):
"""Decimate data *a* to *maxpoints* using *method*.
If *a* is a 1D array then it is promoted to a (2, N) array
where the first column simply contains the index.
If the array contains fewer than *maxpoints* points or if
*... |
Return data * a * mean - decimated on * maxpoints *. | def decimate_mean(self, a, maxpoints, **kwargs):
"""Return data *a* mean-decimated on *maxpoints*.
Histograms each column into *maxpoints* bins and calculates
the weighted average in each bin as the decimated data, using
:func:`numkit.timeseries.mean_histogrammed_function`. The coarse g... |
Return data * a * circmean - decimated on * maxpoints *. | def decimate_circmean(self, a, maxpoints, **kwargs):
"""Return data *a* circmean-decimated on *maxpoints*.
Histograms each column into *maxpoints* bins and calculates
the weighted circular mean in each bin as the decimated data,
using
:func:`numkit.timeseries.circmean_histogramm... |
Return data * a * min - decimated on * maxpoints *. | def decimate_min(self, a, maxpoints, **kwargs):
"""Return data *a* min-decimated on *maxpoints*.
Histograms each column into *maxpoints* bins and calculates
the minimum in each bin as the decimated data, using
:func:`numkit.timeseries.min_histogrammed_function`. The coarse grained
... |
Return data * a * max - decimated on * maxpoints *. | def decimate_max(self, a, maxpoints, **kwargs):
"""Return data *a* max-decimated on *maxpoints*.
Histograms each column into *maxpoints* bins and calculates
the maximum in each bin as the decimated data, using
:func:`numkit.timeseries.max_histogrammed_function`. The coarse grained
... |
Return data * a * rms - decimated on * maxpoints *. | def decimate_rms(self, a, maxpoints, **kwargs):
"""Return data *a* rms-decimated on *maxpoints*.
Histograms each column into *maxpoints* bins and calculates
the root mean square sum in each bin as the decimated data,
using :func:`numkit.timeseries.rms_histogrammed_function`. The coarse
... |
Return data * a * percentile - decimated on * maxpoints *. | def decimate_percentile(self, a, maxpoints, **kwargs):
"""Return data *a* percentile-decimated on *maxpoints*.
Histograms each column into *maxpoints* bins and calculates
the percentile *per* in each bin as the decimated data, using
:func:`numkit.timeseries.percentile_histogrammed_funct... |
Return data * a * error - decimated on * maxpoints *. | def decimate_error(self, a, maxpoints, **kwargs):
"""Return data *a* error-decimated on *maxpoints*.
Histograms each column into *maxpoints* bins and calculates an
error estimate in each bin as the decimated data, using
:func:`numkit.timeseries.error_histogrammed_function`. The
... |
Return smoothed data * a * decimated on approximately * maxpoints * points. | def decimate_smooth(self, a, maxpoints, window="flat"):
"""Return smoothed data *a* decimated on approximately *maxpoints* points.
1. Produces a smoothed graph using the smoothing window *window*;
"flat" is a running average.
2. select points at a step size approximatelt producing ma... |
Parse a processed. top GROMACS topology file | def _parse(self, fname):
"""Parse a processed.top GROMACS topology file
The function reads in the file line-by-line, and it's a bunch of 'elif' statements,
writing parameter/atom line to current section/molecule.
ParamTypes are added to self.xyztypes (AtomType goes to self.atomtypes).
... |
Call the various member self. _make_ * functions to convert the topology object into a string | def assemble_topology(self):
"""Call the various member self._make_* functions to convert the topology object into a string"""
self.logger.debug("starting to assemble topology...")
top = ''
self.logger.debug("making atom/pair/bond/angle/dihedral/improper types")
top += self.top... |
Build Gromacs topology files from pdb. | def topology(struct=None, protein='protein',
top='system.top', dirname='top',
posres="posres.itp",
ff="oplsaa", water="tip4p",
**pdb2gmx_args):
"""Build Gromacs topology files from pdb.
:Keywords:
*struct*
input structure (**required**)
... |
Make index file with the special groups. | def make_main_index(struct, selection='"Protein"', ndx='main.ndx', oldndx=None):
"""Make index file with the special groups.
This routine adds the group __main__ and the group __environment__
to the end of the index file. __main__ contains what the user
defines as the *central* and *most important* par... |
Find vdwradii. dat and add special entries for lipids. | def get_lipid_vdwradii(outdir=os.path.curdir, libdir=None):
"""Find vdwradii.dat and add special entries for lipids.
See :data:`gromacs.setup.vdw_lipid_resnames` for lipid
resnames. Add more if necessary.
"""
vdwradii_dat = os.path.join(outdir, "vdwradii.dat")
if libdir is not None:
fi... |
Put protein into box add water add counter - ions. | def solvate(struct='top/protein.pdb', top='top/system.top',
distance=0.9, boxtype='dodecahedron',
concentration=0, cation='NA', anion='CL',
water='tip4p', solvent_name='SOL', with_membrane=False,
ndx = 'main.ndx', mainselection = '"Protein"',
dirname='solvate'... |
Check if any arguments remain in dict * d *. | def check_mdpargs(d):
"""Check if any arguments remain in dict *d*."""
if len(d) > 0:
wmsg = "Unprocessed mdp option are interpreted as options for grompp:\n"+str(d)
logger.warn(wmsg)
warnings.warn(wmsg, category=UsageWarning)
return len(d) == 0 |
Energy minimize the system. | def energy_minimize(dirname='em', mdp=config.templates['em.mdp'],
struct='solvate/ionized.gro', top='top/system.top',
output='em.pdb', deffnm="em",
mdrunner=None, mdrun_args=None,
**kwargs):
"""Energy minimize the system.
This sets... |
Run multiple energy minimizations one after each other. | def em_schedule(**kwargs):
"""Run multiple energy minimizations one after each other.
:Keywords:
*integrators*
list of integrators (from 'l-bfgs', 'cg', 'steep')
[['bfgs', 'steep']]
*nsteps*
list of maximum number of steps; one for each integrator in
in t... |
Generic function to set up a mdrun MD simulation. | def _setup_MD(dirname,
deffnm='md', mdp=config.templates['md_OPLSAA.mdp'],
struct=None,
top='top/system.top', ndx=None,
mainselection='"Protein"',
qscript=config.qscript_template, qname=None, startdir=None, mdrun_opts="", budget=None, walltime=1/3.,
... |
Set up MD with position restraints. | def MD_restrained(dirname='MD_POSRES', **kwargs):
"""Set up MD with position restraints.
Additional itp files should be in the same directory as the top file.
Many of the keyword arguments below already have sensible values. Note that
setting *mainselection* = ``None`` will disable many of the automat... |
Set up equilibrium MD. | def MD(dirname='MD', **kwargs):
"""Set up equilibrium MD.
Additional itp files should be in the same directory as the top file.
Many of the keyword arguments below already have sensible values. Note that
setting *mainselection* = ``None`` will disable many of the automated
choices and is often rec... |
Write scripts for queuing systems. | def generate_submit_scripts(templates, prefix=None, deffnm='md', jobname='MD', budget=None,
mdrun_opts=None, walltime=1.0, jobarray_string=None, startdir=None,
npme=None, **kwargs):
"""Write scripts for queuing systems.
This sets up queuing system run sc... |
Generate a array job. | def generate_submit_array(templates, directories, **kwargs):
"""Generate a array job.
For each ``work_dir`` in *directories*, the array job will
1. cd into ``work_dir``
2. run the job as detailed in the template
It will use all the queuing system directives found in the
template. If more comp... |
Return multiline string for simple array jobs over * directories *. | def array(self, directories):
"""Return multiline string for simple array jobs over *directories*.
.. Warning:: The string is in ``bash`` and hence the template must also
be ``bash`` (and *not* ``csh`` or ``sh``).
"""
if not self.has_arrays():
raise NotI... |
Primitive queuing system detection ; only looks at suffix at the moment. | def isMine(self, scriptname):
"""Primitive queuing system detection; only looks at suffix at the moment."""
suffix = os.path.splitext(scriptname)[1].lower()
if suffix.startswith('.'):
suffix = suffix[1:]
return self.suffix == suffix |
Returns the atom object corresponding to an atom number | def anumb_to_atom(self, anumb):
'''Returns the atom object corresponding to an atom number'''
assert isinstance(anumb, int), "anumb must be integer"
if not self._anumb_to_atom: # empty dictionary
if self.atoms:
for atom in self.atoms:
self._an... |
Reset the molecule s atoms: attr: number to be 1 - indexed | def renumber_atoms(self):
"""Reset the molecule's atoms :attr:`number` to be 1-indexed"""
if self.atoms:
# reset the mapping
self._anumb_to_atom = {}
for i,atom in enumerate(self.atoms):
atom.number = i+1 # starting from 1
else:
... |
Compute the total number of unmasked regular pixels in a masks. | def total_regular_pixels_from_mask(mask):
"""Compute the total number of unmasked regular pixels in a masks."""
total_regular_pixels = 0
for y in range(mask.shape[0]):
for x in range(mask.shape[1]):
if not mask[y, x]:
total_regular_pixels += 1
return total_regular_... |
Given the full ( i. e. without removing pixels which are outside the regular - masks ) pixelization grid s pixel centers and the regular - masks compute the total number of pixels which are within the regular - masks and thus used by the pixelization grid. | def total_sparse_pixels_from_mask(mask, unmasked_sparse_grid_pixel_centres):
"""Given the full (i.e. without removing pixels which are outside the regular-masks) pixelization grid's pixel centers
and the regular-masks, compute the total number of pixels which are within the regular-masks and thus used by the
... |
Compute a circular masks from an input masks radius and regular shape. | def mask_circular_from_shape_pixel_scale_and_radius(shape, pixel_scale, radius_arcsec, centre=(0.0, 0.0)):
"""Compute a circular masks from an input masks radius and regular shape."""
mask = np.full(shape, True)
centres_arcsec = mask_centres_from_shape_pixel_scale_and_centre(shape=mask.shape, pixel_scale=... |
Compute an annular masks from an input inner and outer masks radius and regular shape. | def mask_circular_annular_from_shape_pixel_scale_and_radii(shape, pixel_scale, inner_radius_arcsec, outer_radius_arcsec,
centre=(0.0, 0.0)):
"""Compute an annular masks from an input inner and outer masks radius and regular shape."""
mask = np.full(sha... |
Compute a circular masks from an input masks radius and regular shape. | def mask_elliptical_from_shape_pixel_scale_and_radius(shape, pixel_scale, major_axis_radius_arcsec, axis_ratio, phi,
centre=(0.0, 0.0)):
"""Compute a circular masks from an input masks radius and regular shape."""
mask = np.full(shape, True)
centres_ar... |
Compute a circular masks from an input masks radius and regular shape. | def mask_elliptical_annular_from_shape_pixel_scale_and_radius(shape, pixel_scale,
inner_major_axis_radius_arcsec, inner_axis_ratio, inner_phi,
outer_major_axis_radius_arcsec, outer_axis_ratio, out... |
Compute a blurring masks from an input masks and psf shape. | def mask_blurring_from_mask_and_psf_shape(mask, psf_shape):
"""Compute a blurring masks from an input masks and psf shape.
The blurring masks corresponds to all pixels which are outside of the masks but will have a fraction of their \
light blur into the masked region due to PSF convolution."""
blurri... |
Compute a 1D array that maps every unmasked pixel to its corresponding 2d pixel using its ( y x ) pixel indexes. | def masked_grid_1d_index_to_2d_pixel_index_from_mask(mask):
"""Compute a 1D array that maps every unmasked pixel to its corresponding 2d pixel using its (y,x) pixel indexes.
For howtolens if pixel [2,5] corresponds to the second pixel on the 1D array, grid_to_pixel[1] = [2,5]"""
total_regular_pixels = tot... |
Compute a 1D array that maps every unmasked pixel to its corresponding 2d pixel using its ( y x ) pixel indexes. | def masked_sub_grid_1d_index_to_2d_sub_pixel_index_from_mask(mask, sub_grid_size):
"""Compute a 1D array that maps every unmasked pixel to its corresponding 2d pixel using its (y,x) pixel indexes.
For howtolens if pixel [2,5] corresponds to the second pixel on the 1D array, grid_to_pixel[1] = [2,5]"""
tot... |
Compute the total number of borders - pixels in a masks. | def total_edge_pixels_from_mask(mask):
"""Compute the total number of borders-pixels in a masks."""
border_pixel_total = 0
for y in range(mask.shape[0]):
for x in range(mask.shape[1]):
if not mask[y, x]:
if mask[y + 1, x] or mask[y - 1, x] or mask[y, x + 1] or mask[y, x... |
Compute a 1D array listing all edge pixel indexes in the masks. An edge pixel is a pixel which is not fully \ surrounding by False masks values i. e. it is on an edge. | def edge_pixels_from_mask(mask):
"""Compute a 1D array listing all edge pixel indexes in the masks. An edge pixel is a pixel which is not fully \
surrounding by False masks values i.e. it is on an edge."""
edge_pixel_total = total_edge_pixels_from_mask(mask)
edge_pixels = np.zeros(edge_pixel_total)
... |
Compute the total number of borders - pixels in a masks. | def total_border_pixels_from_mask_and_edge_pixels(mask, edge_pixels, masked_grid_index_to_pixel):
"""Compute the total number of borders-pixels in a masks."""
border_pixel_total = 0
for i in range(edge_pixels.shape[0]):
if check_if_border_pixel(mask, edge_pixels[i], masked_grid_index_to_pixel):
... |
Compute a 1D array listing all borders pixel indexes in the masks. A borders pixel is a pixel which: | def border_pixels_from_mask(mask):
"""Compute a 1D array listing all borders pixel indexes in the masks. A borders pixel is a pixel which:
1) is not fully surrounding by False masks values.
2) Can reach the edge of the array without hitting a masked pixel in one of four directions (upwards, downwards,
... |
Bin up an array to coarser resolution by binning up groups of pixels and using their sum value to determine \ the value of the new pixel. | def bin_up_mask_2d(mask_2d, bin_up_factor):
"""Bin up an array to coarser resolution, by binning up groups of pixels and using their sum value to determine \
the value of the new pixel.
If an array of shape (8,8) is input and the bin up size is 2, this would return a new array of size (4,4) where \
ev... |
Plot the model datas_ of an analysis using the * Fitter * class object. | def plot_fit_subplot_lens_plane_only(
fit, should_plot_mask=True, extract_array_from_mask=False, zoom_around_mask=False, positions=None,
should_plot_image_plane_pix=False,
units='arcsec', figsize=None, aspect='square',
cmap='jet', norm='linear', norm_min=None, norm_max=None, linthresh=0.... |
Plot the model datas_ of an analysis using the * Fitter * class object. | def plot_fit_subplot_lens_and_source_planes(
fit, should_plot_mask=True, extract_array_from_mask=False, zoom_around_mask=False,
should_plot_source_grid=False, positions=None, should_plot_image_plane_pix=False, plot_mass_profile_centres=True,
units='arcsec', figsize=None, aspect='square',
... |
Plot the model datas_ of an analysis using the * Fitter * class object. | def plot_fit_individuals_lens_plane_only(
fit, should_plot_mask=True, extract_array_from_mask=False, zoom_around_mask=False, positions=None,
should_plot_image_plane_pix=False,
should_plot_image=False,
should_plot_noise_map=False,
should_plot_signal_to_noise_map=False,
sho... |
Plot the model datas_ of an analysis using the * Fitter * class object. | def plot_fit_individuals_lens_and_source_planes(
fit, should_plot_mask=True, extract_array_from_mask=False, zoom_around_mask=False, positions=None,
should_plot_image_plane_pix=False,
should_plot_image=False,
should_plot_noise_map=False,
should_plot_signal_to_noise_map=False,
... |
Setup a figure for plotting an image. | def setup_figure(figsize, as_subplot):
"""Setup a figure for plotting an image.
Parameters
-----------
figsize : (int, int)
The size of the figure in (rows, columns).
as_subplot : bool
If the figure is a subplot, the setup_figure function is omitted to ensure that each subplot does ... |
Output the figure either as an image on the screen or to the hard - disk as a. png or. fits file. | def output_figure(array, as_subplot, output_path, output_filename, output_format):
"""Output the figure, either as an image on the screen or to the hard-disk as a .png or .fits file.
Parameters
-----------
array : ndarray
The 2D array of image to be output, required for outputting the image as ... |
Output a figure which consists of a set of subplot either as an image on the screen or to the hard - disk as a \. png file. | def output_subplot_array(output_path, output_filename, output_format):
"""Output a figure which consists of a set of subplot,, either as an image on the screen or to the hard-disk as a \
.png file.
Parameters
-----------
output_path : str
The path on the hard-disk where the figure is output... |
Generate an image psf shape tag to customize phase names based on size of the image PSF that the original PSF \ is trimmed to for faster run times. | def image_psf_shape_tag_from_image_psf_shape(image_psf_shape):
"""Generate an image psf shape tag, to customize phase names based on size of the image PSF that the original PSF \
is trimmed to for faster run times.
This changes the phase name 'phase_name' as follows:
image_psf_shape = 1 -> phase_name
... |
Generate an inversion psf shape tag to customize phase names based on size of the inversion PSF that the \ original PSF is trimmed to for faster run times. | def inversion_psf_shape_tag_from_inversion_psf_shape(inversion_psf_shape):
"""Generate an inversion psf shape tag, to customize phase names based on size of the inversion PSF that the \
original PSF is trimmed to for faster run times.
This changes the phase name 'phase_name' as follows:
inversion_psf_... |
Generate a tag for the alignment of the geometry of the bulge and disk of a bulge - disk system to customize \ phase names based on the bulge - disk model. This adds together the bulge_disk tags generated in the 3 functions above | def bulge_disk_tag_from_align_bulge_disks(align_bulge_disk_centre, align_bulge_disk_axis_ratio, align_bulge_disk_phi):
"""Generate a tag for the alignment of the geometry of the bulge and disk of a bulge-disk system, to customize \
phase names based on the bulge-disk model. This adds together the bulge_disk ta... |
Given a list of galaxies ( with redshifts ) return a list of the redshifts in ascending order. | def ordered_plane_redshifts_from_galaxies(galaxies):
"""Given a list of galaxies (with redshifts), return a list of the redshifts in ascending order.
If two or more galaxies have the same redshift that redshift is not double counted.
Parameters
-----------
galaxies : [Galaxy]
The list of g... |
Given a set of lens plane redshifts the source - plane redshift and the number of planes between each setup the \ plane redshifts using these values. A lens redshift corresponds to the main lens galaxy ( s ) whereas the slices collect line - of - sight halos over a range of redshifts. | def ordered_plane_redshifts_from_lens_and_source_plane_redshifts_and_slice_sizes(lens_redshifts, planes_between_lenses,
source_plane_redshift):
"""Given a set of lens plane redshifts, the source-plane redshift and the number of planes ... |
Given a list of galaxies ( with redshifts ) return a list of the galaxies where each entry contains a list \ of galaxies at the same redshift in ascending redshift order. | def galaxies_in_redshift_ordered_planes_from_galaxies(galaxies, plane_redshifts):
"""Given a list of galaxies (with redshifts), return a list of the galaxies where each entry contains a list \
of galaxies at the same redshift in ascending redshift order.
Parameters
-----------
galaxies : [Galaxy]
... |
This function determines whether the tracer should compute the deflections at the next plane. | def compute_deflections_at_next_plane(plane_index, total_planes):
"""This function determines whether the tracer should compute the deflections at the next plane.
This is True if there is another plane after this plane, else it is False..
Parameters
-----------
plane_index : int
The index ... |
Given a plane and scaling factor compute a set of scaled deflections. | def scaled_deflection_stack_from_plane_and_scaling_factor(plane, scaling_factor):
"""Given a plane and scaling factor, compute a set of scaled deflections.
Parameters
-----------
plane : plane.Plane
The plane whose deflection stack is scaled.
scaling_factor : float
The factor the de... |
For a deflection stack comput a new grid stack but subtracting the deflections | def grid_stack_from_deflection_stack(grid_stack, deflection_stack):
"""For a deflection stack, comput a new grid stack but subtracting the deflections"""
if deflection_stack is not None:
def minus(grid, deflections):
return grid - deflections
return grid_stack.map_function(minus, d... |
Plot the observed _tracer of an analysis using the * CCD * class object. | def plot_ray_tracing_subplot(
tracer, mask=None, extract_array_from_mask=False, zoom_around_mask=False, positions=None,
units='arcsec', figsize=None, aspect='square',
cmap='jet', norm='linear', norm_min=None, norm_max=None, linthresh=0.05, linscale=0.01,
cb_ticksize=10, cb_fraction=0.047... |
Plot the observed _tracer of an analysis using the * CCD * class object. | def plot_ray_tracing_individual(
tracer, mask=None, extract_array_from_mask=False, zoom_around_mask=False, positions=None,
should_plot_image_plane_image=False,
should_plot_source_plane=False,
should_plot_convergence=False,
should_plot_potential=False,
should_plot_deflecti... |
From the pixel - neighbors setup the regularization matrix using the constant regularization scheme. | def constant_regularization_matrix_from_pixel_neighbors(coefficients, pixel_neighbors, pixel_neighbors_size):
"""From the pixel-neighbors, setup the regularization matrix using the constant regularization scheme.
Parameters
----------
coefficients : tuple
The regularization coefficients which c... |
Compute the ( scaled ) signal in each pixel where the signal is the sum of its datas_ - pixel fluxes. \ These pixel - signals are used to compute the effective regularization weight of each pixel. | def weighted_pixel_signals_from_images(pixels, signal_scale, regular_to_pix, galaxy_image):
"""Compute the (scaled) signal in each pixel, where the signal is the sum of its datas_-pixel fluxes. \
These pixel-signals are used to compute the effective regularization weight of each pixel.
The pixel signals ar... |
From the pixel - neighbors setup the regularization matrix using the weighted regularization scheme. | def weighted_regularization_matrix_from_pixel_neighbors(regularization_weights, pixel_neighbors,
pixel_neighbors_size):
"""From the pixel-neighbors, setup the regularization matrix using the weighted regularization scheme.
Parameters
----------
re... |
Plot an array of data as a figure. | def plot_array(array, origin=None, mask=None, extract_array_from_mask=False, zoom_around_mask=False,
should_plot_border=False, positions=None, centres=None, axis_ratios=None, phis=None, grid=None,
as_subplot=False,
units='arcsec', kpc_per_arcsec=None, figsize=(7, 7), aspect=... |
Open a matplotlib figure and plot the array of data on it. | def plot_figure(array, as_subplot, units, kpc_per_arcsec, figsize, aspect, cmap, norm, norm_min, norm_max,
linthresh, linscale, xticks_manual, yticks_manual):
"""Open a matplotlib figure and plot the array of data on it.
Parameters
-----------
array : data.array.scaled_array.ScaledArray... |
Get the extent of the dimensions of the array in the units of the figure ( e. g. arc - seconds or kpc ). | def get_extent(array, units, kpc_per_arcsec, xticks_manual, yticks_manual):
"""Get the extent of the dimensions of the array in the units of the figure (e.g. arc-seconds or kpc).
This is used to set the extent of the array and thus the y / x axis limits.
Parameters
-----------
array : data.array.s... |
Get the minimum and maximum of the normalization of the array which sets the lower and upper limits of the \ colormap. | def get_normalization_min_max(array, norm_min, norm_max):
"""Get the minimum and maximum of the normalization of the array, which sets the lower and upper limits of the \
colormap.
If norm_min / norm_max are not supplied, the minimum / maximum values of the array of data are used.
Parameters
-----... |
Get the normalization scale of the colormap. This will be scaled based on the input min/ max normalization \ values. | def get_normalization_scale(norm, norm_min, norm_max, linthresh, linscale):
"""Get the normalization scale of the colormap. This will be scaled based on the input min / max normalization \
values.
For a 'symmetric_log' colormap, linthesh and linscale also change the colormap.
If norm_min / norm_max ar... |
Setup the colorbar of the figure specifically its ticksize and the size is appears relative to the figure. | def set_colorbar(cb_ticksize, cb_fraction, cb_pad, cb_tick_values, cb_tick_labels):
"""Setup the colorbar of the figure, specifically its ticksize and the size is appears relative to the figure.
Parameters
-----------
cb_ticksize : int
The size of the tick labels on the colorbar.
cb_fractio... |
Convert the grid from its input units ( arc - seconds ) to the input unit ( e. g. retain arc - seconds ) or convert to \ another set of units ( pixels or kilo parsecs ). | def convert_grid_units(array, grid_arcsec, units, kpc_per_arcsec):
"""Convert the grid from its input units (arc-seconds) to the input unit (e.g. retain arc-seconds) or convert to \
another set of units (pixels or kilo parsecs).
Parameters
-----------
array : data.array.scaled_array.ScaledArray
... |
Plot the ( y x ) origin ofo the array s coordinates as a x. Parameters ----------- array: data. array. scaled_array. ScaledArray The 2D array of data which is plotted. origin: ( float float ). The origin of the coordinate system of the array which is plotted as an x on the image if input. units: str The units of the y/... | def plot_origin(array, origin, units, kpc_per_arcsec, zoom_offset_arcsec):
"""Plot the (y,x) origin ofo the array's coordinates as a 'x'.
Parameters
-----------
array : data.array.scaled_array.ScaledArray
The 2D array of data which is plotted.
origin : (float, float).
The origin... |
Plot the ( y x ) centres ( e. g. of a mass profile ) on the array as an x. | def plot_centres(array, centres, units, kpc_per_arcsec, zoom_offset_arcsec):
"""Plot the (y,x) centres (e.g. of a mass profile) on the array as an 'x'.
Parameters
-----------
array : data.array.scaled_array.ScaledArray
The 2D array of data which is plotted.
centres : [[tuple]]
The l... |
Plot the ( y x ) centres ( e. g. of a mass profile ) on the array as an x. | def plot_ellipses(fig, array, centres, axis_ratios, phis, units, kpc_per_arcsec, zoom_offset_arcsec):
"""Plot the (y,x) centres (e.g. of a mass profile) on the array as an 'x'.
Parameters
-----------
array : data.array.scaled_array.ScaledArray
The 2D array of data which is plotted.
centres ... |
Plot the mask of the array on the figure. | def plot_mask(mask, units, kpc_per_arcsec, pointsize, zoom_offset_pixels):
"""Plot the mask of the array on the figure.
Parameters
-----------
mask : ndarray of data.array.mask.Mask
The mask applied to the array, the edge of which is plotted as a set of points over the plotted array.
units ... |
Plot the borders of the mask or the array on the figure. | def plot_border(mask, should_plot_border, units, kpc_per_arcsec, pointsize, zoom_offset_pixels):
"""Plot the borders of the mask or the array on the figure.
Parameters
-----------t.
mask : ndarray of data.array.mask.Mask
The mask applied to the array, the edge of which is plotted as a set of po... |
Plot a set of points over the array of data on the figure. | def plot_points(points_arcsec, array, units, kpc_per_arcsec, pointsize, zoom_offset_arcsec):
"""Plot a set of points over the array of data on the figure.
Parameters
-----------
positions : [[]]
Lists of (y,x) coordinates on the image which are plotted as colored dots, to highlight specific pix... |
Plot a grid of points over the array of data on the figure. | def plot_grid(grid_arcsec, array, units, kpc_per_arcsec, pointsize, zoom_offset_arcsec):
"""Plot a grid of points over the array of data on the figure.
Parameters
-----------.
grid_arcsec : ndarray or data.array.grids.RegularGrid
A grid of (y,x) coordinates in arc-seconds which may be plott... |
The mapping matrix is a matrix representing the mapping between every unmasked pixel of a grid and \ the pixels of a pixelization. Non - zero entries signify a mapping whereas zeros signify no mapping. | def mapping_matrix(self):
"""The mapping matrix is a matrix representing the mapping between every unmasked pixel of a grid and \
the pixels of a pixelization. Non-zero entries signify a mapping, whereas zeros signify no mapping.
For example, if the regular grid has 5 pixels and the pixelizatio... |
Compute the mappings between a pixelization s pixels and the unmasked regular - grid pixels. These mappings \ are determined after the regular - grid is used to determine the pixelization. | def pix_to_regular(self):
"""Compute the mappings between a pixelization's pixels and the unmasked regular-grid pixels. These mappings \
are determined after the regular-grid is used to determine the pixelization.
The pixelization's pixels map to different number of regular-grid pixels, thus a ... |
Compute the mappings between a pixelization s pixels and the unmasked sub - grid pixels. These mappings \ are determined after the regular - grid is used to determine the pixelization. | def pix_to_sub(self):
"""Compute the mappings between a pixelization's pixels and the unmasked sub-grid pixels. These mappings \
are determined after the regular-grid is used to determine the pixelization.
The pixelization's pixels map to different number of sub-grid pixels, thus a list of list... |
Given the solution vector of an inversion ( see * inversions. Inversion * ) determine the reconstructed \ pixelization of the rectangular pixelization by using the mapper. | def reconstructed_pixelization_from_solution_vector(self, solution_vector):
"""Given the solution vector of an inversion (see *inversions.Inversion*), determine the reconstructed \
pixelization of the rectangular pixelization by using the mapper."""
recon = mapping_util.map_unmasked_1d_array_to_... |
The 1D index mappings between the regular pixels and Voronoi pixelization pixels. | def regular_to_pix(self):
"""The 1D index mappings between the regular pixels and Voronoi pixelization pixels."""
return mapper_util.voronoi_regular_to_pix_from_grids_and_geometry(regular_grid=self.grid_stack.regular,
regular_to_nearest_pix=self.grid_stack.pix.regular_to_nearest_pix,
... |
The 1D index mappings between the sub pixels and Voronoi pixelization pixels. | def sub_to_pix(self):
""" The 1D index mappings between the sub pixels and Voronoi pixelization pixels. """
return mapper_util.voronoi_sub_to_pix_from_grids_and_geometry(sub_grid=self.grid_stack.sub,
regular_to_nearest_pix=self.grid_stack.pix.regular_to_nearest_pix,
sub_to... |
Determine the ( y x ) arc - second central coordinates of an array from its shape pixel - scales and origin. | def centres_from_shape_pixel_scales_and_origin(shape, pixel_scales, origin):
"""Determine the (y,x) arc-second central coordinates of an array from its shape, pixel-scales and origin.
The coordinate system is defined such that the positive y axis is up and positive x axis is right.
Parameters
------... |
Compute the ( y x ) arc second coordinates at the centre of every pixel of an array of shape ( rows columns ). | def regular_grid_2d_from_shape_pixel_scales_and_origin(shape, pixel_scales, origin=(0.0, 0.0)):
"""Compute the (y,x) arc second coordinates at the centre of every pixel of an array of shape (rows, columns).
Coordinates are defined from the top-left corner, such that the first pixel at location [0, 0] has negat... |
Compute the ( y x ) arc second coordinates at the centre of every pixel of an array of shape ( rows columns ). | def regular_grid_1d_from_shape_pixel_scales_and_origin(shape, pixel_scales, origin=(0.0, 0.0)):
"""Compute the (y,x) arc second coordinates at the centre of every pixel of an array of shape (rows, columns).
Coordinates are defined from the top-left corner, such that the first pixel at location [0, 0] has negat... |
Compute the ( y x ) arc second coordinates at the centre of every pixel of a 2D mask array of shape ( rows columns ). | def regular_grid_1d_masked_from_mask_pixel_scales_and_origin(mask, pixel_scales, origin=(0.0, 0.0)):
"""Compute the (y,x) arc second coordinates at the centre of every pixel of a 2D mask array of shape (rows, columns).
Coordinates are defined from the top-left corner, where the first unmasked pixel corresponds... |
For the sub - grid every unmasked pixel of a 2D mask array of shape ( rows columns ) is divided into a finer \ uniform grid of shape ( sub_grid_size sub_grid_size ). This routine computes the ( y x ) arc second coordinates at \ the centre of every sub - pixel defined by this grid. | def sub_grid_1d_masked_from_mask_pixel_scales_and_sub_grid_size(mask, pixel_scales, sub_grid_size, origin=(0.0, 0.0)):
""" For the sub-grid, every unmasked pixel of a 2D mask array of shape (rows, columns) is divided into a finer \
uniform grid of shape (sub_grid_size, sub_grid_size). This routine computes the ... |
Convert a grid of ( y x ) arc second coordinates to a grid of ( y x ) pixel values. Pixel coordinates are \ returned as integers such that they map directly to the pixel they are contained within. | def grid_arcsec_1d_to_grid_pixel_centres_1d(grid_arcsec_1d, shape, pixel_scales, origin=(0.0, 0.0)):
""" Convert a grid of (y,x) arc second coordinates to a grid of (y,x) pixel values. Pixel coordinates are \
returned as integers such that they map directly to the pixel they are contained within.
The pixel... |
Convert a grid of ( y x ) arc second coordinates to a grid of ( y x ) pixel 1D indexes. Pixel coordinates are \ returned as integers such that they are the pixel from the top - left of the 2D grid going rights and then \ downwards. | def grid_arcsec_1d_to_grid_pixel_indexes_1d(grid_arcsec_1d, shape, pixel_scales, origin=(0.0, 0.0)):
""" Convert a grid of (y,x) arc second coordinates to a grid of (y,x) pixel 1D indexes. Pixel coordinates are \
returned as integers such that they are the pixel from the top-left of the 2D grid going rights and... |
Convert a grid of ( y x ) pixel coordinates to a grid of ( y x ) arc second values. | def grid_pixels_1d_to_grid_arcsec_1d(grid_pixels_1d, shape, pixel_scales, origin=(0.0, 0.0)):
""" Convert a grid of (y,x) pixel coordinates to a grid of (y,x) arc second values.
The pixel coordinate origin is at the top left corner of the grid, such that the pixel [0,0] corresponds to \
higher y arc-second... |
Convert a grid of ( y x ) arc second coordinates to a grid of ( y x ) pixel values. Pixel coordinates are \ returned as integers such that they map directly to the pixel they are contained within. | def grid_arcsec_2d_to_grid_pixel_centres_2d(grid_arcsec_2d, shape, pixel_scales, origin=(0.0, 0.0)):
""" Convert a grid of (y,x) arc second coordinates to a grid of (y,x) pixel values. Pixel coordinates are \
returned as integers such that they map directly to the pixel they are contained within.
The pixel... |
Setup the random seed. If the input seed is - 1 the code will use a random seed for every run. If it is \ positive that seed is used for all runs thereby giving reproducible results. | def setup_random_seed(seed):
"""Setup the random seed. If the input seed is -1, the code will use a random seed for every run. If it is \
positive, that seed is used for all runs, thereby giving reproducible results.
Parameters
----------
seed : int
The seed of the random number generator.
... |
Generate a two - dimensional poisson noise_maps - mappers from an image. | def generate_poisson_noise(image, exposure_time_map, seed=-1):
"""
Generate a two-dimensional poisson noise_maps-mappers from an image.
Values are computed from a Poisson distribution using the image's input values in units of counts.
Parameters
----------
image : ndarray
The 2D image,... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.