Gridder#
- class pyvisgrid.core.gridder.Gridder(u_meter: ndarray, v_meter: ndarray, times: ndarray, img_size: int, fov: float, ref_frequency: float, frequency_offsets: _Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | bytes | str | _NestedSequence[complex | bytes | str])[source]#
Bases:
objectMethods Summary
from_fits(path, img_size, fov[, uv_colnames])Initializes the gridder with the visibility data in a given FITS file using the default Gridder for the radionets-project.
from_ms(path, img_size, fov[, desc_id, ...])Initializes the Gridder with a measurement which is saved in an NRAO CASA Measurement Set.
from_pyvisgen(vis_data, obs, img_size, fov)Initializes the gridder with the visibility data which is generated by the
pyvisgen.simulation.vis_loopfunction.grid([stokes_component])Grids given visibility data using the default Gridder for the radionets-project.
plot_dirty_image([stokes_component])Plots the (u,v) dirty image, meaning the 2d Fourier transform of the gridded visibilities.
plot_mask([stokes_component])Plots the (u,v) mask (the binned visibilities) of the gridded interferometric image.
plot_ungridded_uv(**kwargs)Plots the ungridded (u,v) points as a scatter plot.
Methods Documentation
- classmethod from_fits(path: str, img_size: int, fov: float, uv_colnames: dict = None)[source]#
Initializes the gridder with the visibility data in a given FITS file using the default Gridder for the radionets-project. Currently only extraction of the Stokes I component is supported. More on the
Griddercan be found in the constructor of theGridder.- Parameters:
- pathstr
The path to the FITS file.
- img_sizeint
The size of the image in pixels.
- fovfloat
The physical size of the image in asec.
- uv_colnamesdict, optional
Alternative names for the U and V columns in the FITS file. Default is {‘u’: None, ‘v’: None}, meaning the default values of ‘UU’ and ‘VV’ or ‘UU–’ and ‘VV–’ will be used.
- classmethod from_ms(path: str, img_size: int, fov: float, desc_id: int | None = None, ref_frequency_id: int = 0, use_calibrated: bool = False, filter_flagged: bool = True)[source]#
Initializes the Gridder with a measurement which is saved in an NRAO CASA Measurement Set. Currently only extraction of the Stokes I component is supported.
- Parameters:
- path: str
The path of the measurement set root directory.
- img_size: int
The size of the image in pixels.
- fov: float
The physical size of the image in asec.
- desc_id: int, optional
The desc_id of the visibilites which should be gridded. This can be used to choose the component of a composite observation. Default is
None, which means that all observations will be used.- ref_frequency_id: int, optional
The index of the reference frequency that will be used if the measurement is a composite observation and no desc_id is given.
- use_calibrated: bool, optional
Whether to use the calibrated data from the MODEL_DATA column or the raw data from the DATA column. Default is
True.- filter_flagged: bool, optional
Whether to filter out flagged data rows. Default is
True.
- classmethod from_pyvisgen(vis_data: Visibilities, obs: Observation, img_size: int, fov: float, stokes_components: list[str] | str = 'I', polarizations: list[str] | str | None = None)[source]#
Initializes the gridder with the visibility data which is generated by the
pyvisgen.simulation.vis_loopfunction. Additionally one can define which stokes components should be calculated with a given polarization.More on the
Griddercan be found in the constructor of theGridder.- Parameters:
- obspyvisgen.simulation.Observation
The observation which is returned by the
pyvisgen.simulation.vis_loopfunction.- vis_datapyvisgen.simulation.Visibilities
The visibility data which is returned by the
pyvisgen.simulation.vis_loopfunction.- img_sizeint
The size of the image in pixels.
- fovfloat
The physical size of the image in asec.
- stokes_componentslist[str] | str, optional
The Stokes components which are to be calculated and saved in the gridder. This can either be a list of components (e.g.
['I', 'V']) or a single string. Default is'I'.- polarizationslist[str] | str | None, optional
The polarization type. Default is
None.
- grid(stokes_component: str = 'I')[source]#
Grids given visibility data using the default Gridder for the radionets-project.
- Parameters:
- stokes_componentstr, optional
The stokes component which should be gridded. The specified component has to be initialized first! Otherwise this will result in a
KeyError. Default is'I'.
- Returns:
- masknumpy.ndarray, optional
The mask created from the given (u,v) coordinates. The mask contains the number of (u,v) coordinates per pixel.
- mask_realnumpy.ndarray, optional
The gridded real part of the visibilites.
- mask_imagnumpy.ndarray, optional
The gridded imaginary part of the visibilities.
- dirty_img_complexnumpy.ndarray, optional
The complex Dirty Image. This is the 2-dimensional Fourier transform of the gridded visibilities.
- plot_dirty_image(stokes_component: str = 'I', **kwargs)[source]#
Plots the (u,v) dirty image, meaning the 2d Fourier transform of the gridded visibilities.
- Parameters:
- stokes_componentstr, optional
The symbol of the stokes component whose dirty image should be plotted. The specified component has to be initialized and gridded first! Otherwise this will result in a
KeyError. Default is'I'.- modestr, optional
The mode specifying which values of the mask should be plotted.
Possible values are:
real: Plots the real part of the dirty image.imag: Plots the imaginary part of the dirty image.abs: Plot the absolute value of the dirty image.
Default is
real.- ax_unit: str | astropy.units.unit, optional
The unit in which to show the ticks of the x and y-axes in. The y-axis is the Declination (DEC) and the x-axis is the Right Ascension (RA). The latter one is defined as increasing from left to right! The unit has to be given as a string or an
astropy.units.Unit. The string must correspond to the string representation of anastropy.units.Unit.Valid units are either
pixelor angle units likearcsec,degreeetc. Default ispixel.- center_pos: tuple | None, optional
The coordinate center of the image. The coordinates have to be given in the unit defined in the parameter
ax_unitabove. Ifax_unitis set topixelthis parameter is ignored. Default isNone, meaning the coordinates of the axes will be given as relative.- normstr | matplotlib.colors.Normalize | None, optional
The name of the norm or a matplotlib norm. Possible values are:
log: Returns a logarithmic norm with clipping on (!), meaningvalues above the maximum will be mapped to the maximum and values below the minimum will be mapped to the minimum, thus avoiding the appearance of a colormaps ‘over’ and ‘under’ colors (e.g. in case of negative values). Depending on the use case this is desirable but in case that it is not, one can set the norm to
log_noclipor provide a custom norm.
log_noclip: Returns a logarithmic norm with clipping off.centered: Returns a linear norm which centered around zero.sqrt: Returns a power norm with exponent 0.5, meaning thesquare-root of the values.
- other: A value not declared above will be returned as is,
meaning that this could be any value which exists in matplotlib itself.
Default is
None, meaning no norm will be applied.- colorbar_shrink: float, optional
The shrink parameter of the colorbar. This can be needed if the plot is included as a subplot to adjust the size of the colorbar. Default is
1, meaning original scale.- cmap: str | matplotlib.colors.Colormap | None, optional
The colormap to be used for the plot. Default is
None, meaning the colormap will be default to a value fitting for the chosen mode.- plot_argsdict, optional
The additional arguments passed to the scatter plot. Default is
{"color":"royalblue"}.- fig_argsdict, optional
The additional arguments passed to the figure. If a figure object is given in the
figparameter, this value will be discarded. Default is{}.- save_tostr | None, optional
The name of the file to save the plot to. Default is
None, meaning the plot won’t be saved.- save_argsdict, optional
The additional arguments passed to the
fig.savefigcall. Default is{"bbox_inches":"tight"}.- figmatplotlib.figure.Figure | None, optional
A custom figure object. If set to
None, theaxparameter also has to beNone! Default isNone.- axmatplotlib.axes.Axes | None, optional
A custom axes object. If set to
None, thefigparameter also has to beNone! Default isNone.
- Returns:
- figmatplotlib.figure.Figure
The figure object.
- axmatplotlib.axes.Axes
The axes object.
- plot_mask(stokes_component: str = 'I', **kwargs)[source]#
Plots the (u,v) mask (the binned visibilities) of the gridded interferometric image.
- Parameters:
- stokes_componentstr, optional
The symbol of the stokes component whose mask should be plotted. The specified component has to be initialized and gridded first! Otherwise this will result in a
KeyError. Default is'I'.- modestr, optional
The mode specifying which values of the mask should be plotted. Possible values are:
hist: Plots the number of (u,v) points which are sorted ineach pixel of the image in the (u,v) space.
abs: Plots the absolute value of the gridded visibilities,meaning the magnitude of the complex numbers in Euler representation.
phase: Plots the phase angle of the gridded visibilities,meaning the angle in the exponent of the complex numbers in Euler representation.
real: Plots the real part of the gridded visibilities.imag: Plots the imaginary part of the gridded visibilities.
Default is
hist.- croptuple[list[float | None]], optional
The crop of the image. This has to have the format
([x_left, x_right], [y_left, y_right]), where the left and right values for each axis are the upper and lower limits of the axes which should be shown. IMPORTANT: If one supplies theplt.imshowanextentparameter via theplot_argsparameter, this will be the scale in which one has to give the crop! If not, the crop has to be in pixels.- normstr | matplotlib.colors.Normalize | None, optional
The name of the norm or a matplotlib norm. Possible values are:
log: Returns a logarithmic norm with clipping on (!), meaningvalues above the maximum will be mapped to the maximum and values below the minimum will be mapped to the minimum, thus avoiding the appearance of a colormaps ‘over’ and ‘under’ colors (e.g. in case of negative values). Depending on the use case this is desirable but in case that it is not, one can set the norm to
log_noclipor provide a custom norm.
log_noclip: Returns a logarithmic norm with clipping off.centered: Returns a linear norm which centered around zero.sqrt: Returns a power norm with exponent 0.5, meaning thesquare-root of the values.
- other: A value not declared above will be returned as is,
meaning that this could be any value which exists in matplotlib itself.
Default is
None, meaning no norm will be applied.- colorbar_shrink: float, optional
The shrink parameter of the colorbar. This can be needed if the plot is included as a subplot to adjust the size of the colorbar. Default is
1, meaning original scale.- cmap: str | matplotlib.colors.Colormap | None, optional
The colormap to be used for the plot. Default is
None, meaning the colormap will be default to a value fitting for the chosen mode.- plot_argsdict, optional
The additional arguments passed to the scatter plot. Default is
{"color":"royalblue"}.- fig_argsdict, optional
The additional arguments passed to the figure. If a figure object is given in the
figparameter, this value will be discarded. Default is{}.- save_tostr | None, optional
The name of the file to save the plot to. Default is
None, meaning the plot won’t be saved.- save_argsdict, optional
The additional arguments passed to the
fig.savefigcall. Default is{"bbox_inches":"tight"}.- figmatplotlib.figure.Figure | None, optional
A custom figure object. If set to
None, theaxparameter also has to beNone! Default isNone.- axmatplotlib.axes.Axes | None, optional
A custom axes object. If set to
None, thefigparameter also has to beNone! Default isNone.
- Returns:
- figmatplotlib.figure.Figure
The figure object.
- axmatplotlib.axes.Axes
The axes object.
- plot_ungridded_uv(**kwargs)[source]#
Plots the ungridded (u,v) points as a scatter plot.
- Parameters:
- gridderpyvisgrid.Gridder
The gridder from which to take the (u,v) coordinates.
- modestr, optional
The mode specifying the scale of the (u,v) coordinates. This can be either
wave, meaning the coordinates are plotted in units of the reference wavelength, ormeter, meaning the (u,v) coordinates will be plotted in meter. Default iswave.- show_timesbool, optional
Whether to show the timestamps of the measured visibilities as a colormap. Default is
True.- use_relative_timebool, optional
Whether to show the times relative to the timestamp of the first measurement in hours. Default is
True.- times_cmap: str | matplotlib.colors.Colormap, optional
The colormap to be used for the time component of the plot. Default is
'inferno'.- colorbar_shrink: float, optional
The shrink parameter of the colorbar. This can be needed if the plot is included as a subplot to adjust the size of the colorbar. Default is
1, meaning original scale.- marker_sizefloat | None, optional
The size of the scatter markers in points**2. Default is
None, meaning the default value supplied by your matplotlib rcParams.- plot_argsdict, optional
The additional arguments passed to the scatter plot. Default is
{"color":"royalblue"}.- fig_argsdict, optional
The additional arguments passed to the figure. If a figure object is given in the
figparameter, this value will be discarded. Default is{}.- save_tostr | None, optional
The name of the file to save the plot to. Default is
None, meaning the plot won’t be saved.- save_argsdict, optional
The additional arguments passed to the
fig.savefigcall. Default is{"bbox_inches":"tight"}.- figmatplotlib.figure.Figure | None, optional
A custom figure object. If set to
None, theaxparameter also has to beNone! Default isNone.- axmatplotlib.axes.Axes | None, optional
A custom axes object. If set to
None, thefigparameter also has to beNone! Default isNone.
- Returns:
- figmatplotlib.figure.Figure
The figure object.
- axmatplotlib.axes.Axes
The axes object.