The Field class¶
The Field class is used to manage the overall state and parameters of observed field, including observations, images, calibration solutions, etc.
- class rapthor.lib.field.Field(parset, minimal=False)¶
The Field object stores parameters needed for processing of the field
- Parameters:
- parsetdict
Parset with processing parameters
- minimalbool
If True, only initialize the minimal set of required parameters
- adjust_sector_boundaries()¶
Adjusts the imaging sector boundaries for overlaping sources
Note: this adjustment is only done when there are multiple sectors in a grid, since its purpose is to ensure that sources don’t get split between two neighboring sectors
- check_selfcal_progress()¶
Checks whether selfcal has converged or diverged by comparing the current image noise to that of the previous cycle. A check is also done on the absolute value of the noise.
Convergence is determined by comparing the noise and dynamic range ratios to self.convergence_ratio, which is the minimum ratio of the current noise to the previous noise above which selfcal is considered to have converged (must be in the range 0.5 – 2). E.g., self.convergence_ratio = 0.95 means that the image noise must decrease by ~ 5% or more from the previous cycle for selfcal to be considered as not yet converged. The same is true for the dynamic range but reversed (the dynamic range must increase by ~ 5% or more from the previous cycle for selfcal to be considered as not yet converged).
Divergence is determined by comparing the noise ratio to self.divergence_ratio, which is the minimum ratio of the current noise to the previous noise above which selfcal is considered to have diverged (must be >= 1). E.g., divergence_ratio = 1.1 means that, if image noise worsens by ~ 10% or more from the previous cycle, selfcal is considered to have diverged.
Failure is determined by comparing the absolute value of the noise in the current cycle with the theoretical noise. If the ratio of the current median noise to the theoretical one is greater than failure_ratio, selfcal is considered to have failed.
- Returns:
- selfcal_statenamedtuple
- The selfcal state, with the following elements:
- selfcal_state.converged - True if selfcal has converged in all
sectors
- selfcal_state.diverged - True if selfcal has diverged in one or
more sectors
- selfcal_state.failed - True if selfcal has failed in one or
more sectors
- chunk_observations(mintime)¶
Break observations into smaller time chunks if desired
Chunking is done if:
obs.data_fraction < 1 (so part of an observation is to be processed)
nobs * nsectors < nnodes (so all nodes can be used efficiently. In particular, the predict operation parallelizes over sectors and observations, so we need enough observations to allow all nodes to be occupied.)
- Parameters:
- mintimefloat
Minimum time in sec for a chunk
- define_bright_source_sectors(index)¶
Defines the bright source sectors
- Parameters:
- indexint
Iteration index
- define_imaging_sectors()¶
Defines the imaging sectors
- define_non_calibrator_source_sectors(index)¶
Defines the non-calibrator source sectors
These sectors are defined if peeling of non-calibrator sources is explicitly enabled or if the antenna is LBA (where it’s always needed)
- Parameters:
- indexint
Iteration index
- define_outlier_sectors(index)¶
Defines the outlier sectors
- Parameters:
- indexint
Iteration index
- define_predict_sectors(index)¶
Defines the predict sectors
- Parameters:
- indexint
Iteration index
- find_intersecting_sources()¶
Finds sources that intersect with the intial sector boundaries
- Returns:
- intersecting_source_polys: list of Polygons
List of source polygons that intersect one or more sector boundaries
- get_calibration_radius()¶
Returns the radius in degrees that encloses all calibrators
- get_obs_parameters(parameter)¶
Returns list of parameters for all observations
- Parameters:
- parameterstr
Name of parameter to return
- Returns:
- parameterslist
List of parameters of each observation
- get_source_distances(source_dict: Dict[str, List[float]])¶
Returns source distances in degrees from the phase center
- Parameters:
- source_dictdict
Dict of source patch names and coordinates in degrees (e.g., {‘name’: [RA, Dec]})
- Returns:
- namesnumpy array
Array of source names
- distancesnumpy array
Array of distances from the phase center in degrees
- makeWCS()¶
Makes simple WCS object
- Returns:
- wastropy.wcs.WCS object
A simple TAN-projection WCS object for specified reference position
- make_non_calibrator_skymodel()¶
Make a sky model of any non-calibrator sources
Since the peeling of non-calibrator sources uses the calibration solutions from the previous cycle (if any), the calibration patches from that cycle are applied to the current sky model to ensure agreement between the sky model patches and the calibration patches.
Note: if a previous cycle was not done (and therefore a model from it does not exist), then either peeling will be done without using calibration solutions (and therefore the patches are ignored) or a solutions file and sky model have been provided by the user, in which case the patches in the model and solutions must already agree with each other.
- make_outlier_skymodel()¶
Make a sky model of any outlier calibration sources, not included in any imaging sector
- make_skymodels(skymodel_true_sky, skymodel_apparent_sky=None, regroup=True, find_sources=False, target_flux=None, target_number=None, calibrator_max_dist_deg=None, index=0)¶
Groups a sky model into source and calibration patches
Grouping is done on the apparent-flux sky model if available. Note that the source names in the true- and apparent-flux models must be the same (i.e., the only differences between the two are the fluxes and spectral indices)
- Parameters:
- skymodel_true_skystr or LSMTool skymodel object
Filename of input makesourcedb true-flux sky model file
- skymodel_apparent_skystr or LSMTool skymodel object, optional
Filename of input makesourcedb apparent-flux sky model file
- regroupbool, optional
If False, the calibration sky model is not regrouped to the target flux. Instead, the existing calibration groups are used
- find_sourcesbool, optional
If True, group the sky model by thresholding to find sources. This is not needed if the input sky model was filtered by PyBDSF in the imaging operation
- target_fluxfloat, optional
Target flux in Jy for grouping
- target_numberint, optional
Target number of patches for grouping
- calibrator_max_dist_degfloat, optional
Maximum distance in degrees from phase center for grouping
- indexindex
Iteration index
- plot_field(skymodel_radius=0, moc=None)¶
Plots an overview of how the imaged field compares against the skymodel used.
- Parameters:
- skymodel_radiusfloat
Radius in degrees out to which the skymodel catalogue was queried.
- mocstr or None
If not None, the multi-order coverage map to plot alongside the usual quantiies.
- radec2xy(RA, Dec)¶
Returns x, y for input RA, Dec
- Parameters:
- RAlist
List of RA values in degrees
- Declist
List of Dec values in degrees
- Returns:
- x, ylist, list
Lists of x and y pixel values corresponding to the input RA and Dec values
- remove_skymodels()¶
Remove sky models to minimize memory usage
- scan_h5parms()¶
Scans the calibration h5parms
The basic structure is checked for correctness and for the presence of amplitude solutions (which may require different processing steps).
- scan_observations()¶
Checks input MS files and initializes the associated Observation objects
- set_obs_parameters()¶
Sets parameters for all observations from current parset and sky model
- transfer_patches(from_skymodel, to_skymodel, patch_dict=None)¶
Transfers the patches defined in from_skymodel to to_skymodel.
- Parameters:
- from_skymodelsky model
Sky model from which to transfer patches
- to_skymodelsky model
Sky model to which to transfer patches
- patch_dictdict, optional
Dict of patch positions
- Returns:
- to_skymodelsky model
Sky model with patches matching those of from_skymodel
- update(step_dict, index, final=False)¶
Updates parameters, sky models, etc. for current step
- Parameters:
- step_dictdict
Dict of parameter values for given iteration
- indexint
Index of iteration
- finalbool, optional
If True, process as the final pass (needed for correct processing of the sky models)
- update_skymodels(index, regroup, target_flux=None, target_number=None, calibrator_max_dist_deg=None, final=False)¶
Updates the source and calibration sky models from the output sector sky model(s)
- Parameters:
- indexint
Iteration index (counts starting from 1)
- regroupbool
Regroup sky model. This parameter is not used for the first cycle, as its value is taken from the parset. For later cycles, it controls whether the sky models that come from imaging are to be regrouped into calibration patches. In almost all cases, regrouping should be done. The exception is when using small imaging sectors when the sources in each sector should be grouped into a single patch together.
- target_fluxfloat, optional
Target flux in Jy for grouping
- target_numberint, optional
Target number of patches for grouping
- calibrator_max_dist_degfloat, optional
Maximum distance in degrees from phase center for grouping
- finalbool, optional
If True, process as the final pass (combine initial and new sky models)
- xy2radec(x, y)¶
Returns input RA, Dec for input x, y
- Parameters:
- xlist
List of x values in pixels
- ylist
List of y values in pixels
- Returns:
- RA, Declist, list
Lists of RA and Dec values corresponding to the input x and y pixel values