shimmerr package¶
Submodules¶
shimmerr.array module¶
- class shimmerr.array.Antenna(position, gain=1 + 0j)¶
Bases:
objectA class that represents the lowest level elements in the array.
Attributes¶
- p: list
Contains the 3D position of the antenna in ECEF (Earth-Centered Earth-Fixed) coordinates
- p_ENU: list
Contains the 3D position of the antenna in ENU (East-North-Up) coordinates
- g: complex
Complex gain of the element
- __init__(position, gain=1 + 0j)¶
Parameters¶
- positionlist
Contains the 3D position of the antenna in ETRS coordinates
- gaincomplex, optional
Complex gain of the element, by default 1
- calculate_response(directions, frequency, mode='omnidirectional')¶
Calculates the element response in directions.
Parameters¶
- directionsndarray
3xM array of unit length vectors that decribe the directions in ENU coordinates
- frequencyfloat
Frequency of the measurement
- modestr, optional
sets the beam shape, by default “omnidirectional” (no directivity).
Returns¶
- ndarray
M length response
- update_antenna(new_gain=None)¶
Updates antenna gain
- class shimmerr.array.Station(positions, pointing_ra=None, pointing_dec=None, gain=1 + 0j)¶
Bases:
objectA class that represents the full station.
Attributes¶
- p: list
Contains the 3D position of the station in ECEF (Earth-Centered Earth-Fixed) coordinates
- p_array: list
Contains the 3D position of the station in ENU (East-North-Up) coordinates of a specified reference stataion
- g: complex
Complex gain of the element
- d: ndarray
Complex pointing of the station (in Ra, Dec)
- tracking: bool
If set, the telescope is in tracking mode (pointed to a specific point), if False, the telescope is in drift-scan mode
- ENU_rotation_matrix()¶
Calculates the 3x3 matrix that transforms the coordinates from ECEF (Earth-Centered Earth-Fixed) to ENU (East-North-Up)
- __init__(positions, pointing_ra=None, pointing_dec=None, gain=1 + 0j)¶
Parameters¶
- positionslist
Contains the 3D position of the elements (tiles) in ECEF (Earth-Centered Earth-Fixed) coordinates
- pointing_rafloat, optional
Right ascension of the phase center in deg, default is None
- pointing_decfloat, optional
Declination of the phase center in deg, default is None
- gaincomplex, optional
Complex gain of the tile (shared by all elements), by default 1
- add_random_gain_drift(sigma_tile, sigma_antenna, seed=None)¶
Add complex Gaussian zero mean noise to the gains.
Parameters¶
- sigma_tilefloat
Standard deviation of the noise added on a tile level
- sigma_antennafloat
Standard deviation of the noise added on an antenna level
- seedNone or int, optional
Seed of the random generator. Set by an integer for reproducability, by default None
- break_elements(mode='maximum', number=0, seed=None)¶
Breaks elements within the tiles of the array (by setting their gains to 0). Set the seed for reproducability, but be aware that a different seed should be used for different stations to guarantee randomness.
Parameters¶
- modestr, optional
Sets the way in which elements are broken, by default “maximum” maximum: Uniformly breaks elements up to a maximum number. If higher than the number of elements per tile, the full tile will be flagged more often (numbers between #elements and max are shifted to max) number: Breaks the specified number of elements. If higher than the number of antennas in a tile, all antennas are broken. Rounds to nearest number of elements per tile (so 10% of 16 elements = 1.6 elements –> 2 elements flagged in every tile) percentage: Same as number but with a percentage. typical: Breaks elements according to a normal(number, number) distribution, such that on average <number> elements are broken. typical_percentage: the same as above but with a percentage.
- numberint, optional
Number that controls how many elements are broken (so maximum, percentage, etc.), by default 0
- seedint, optional
seed for the random number generator that controls how many and which elements are broken, by default None (initialize randomly every call)
Raises¶
- ValueError
either for a negative number of elements (not physically possible) or for an unknown mode
- calculate_array_factor(directions, pointing_directions, frequency, tile_beams=None)¶
Calculates the station array factor in M directions.
Parameters¶
- directionsndarray
3xM array of unit length vectors that decribe the directions in ENU coordinates
- frequencyfloat
Frequency of the measurement
- tile_beamsNone or ndarray, optional
If set to None (default) this disables the element beams and only the array factor is returned. Otherwise, give an N x M array of element responses in the requested directions
- pointing_directionsndarray
3xM array of unit length vectors that decribe the direction of the pointing center in ENU coordinates.
Returns¶
- ndarray
M length response
- calculate_response(directions, frequency, antenna_mode=None, pointing_directions=None, calculate_all_tiles=True)¶
Calculates the full station beam in M directions.
Parameters¶
- directionsndarray
3xM array of unit length vectors that decribe the directions in ENU coordinates
- frequencyfloat
Frequency of the measurement
- antenna_modeNone or str, optional
If set to None (default) this disables the element beams and only the array factor is returned. Otherwise, give the requested antenna type.
- pointing_directionsndarray, optional
3xM array of unit length vectors that decribe the direction of the pointing center in ENU coordinates. Default is None (drift-scan)
- calculate_all_tilesbool, optional
If set, all tile beams are computed separately (allows for antenna drift), if unset, a tile beam pattern is reused for all tiles. Default is False.
Returns¶
- ndarray
M length response
- get_element_property(property)¶
Helper function for the element list. Retrieves a property of the underlying elements.
- radec_to_ENU(time, right_ascension=None, declination=None, temporal_offset=0, number_of_timesteps=1, tracking_direction=False)¶
Calculates a sky direction in the stations ENU frame at a given time
Parameters¶
- timestr
Start time of observation in UTC format (YYYY-MM-DDThh:mm:ss, example: 2024-07-04T19:25:00)
- right_ascensionfloat, optional
RA in deg, default is None (for if the phase center is observed)
- declinationfloat, optional
dec in deg, default is None (for if the phase center is observed)
- temporal_offsetfloat
Time resolution in s.
- number_of_timestepsint
Number of simulated time intervals, default is 1
- tracking_directionbool
If set, compute the direction of the phase center instead of the Ra,Dec. Default is False.
Returns¶
- ndarray
source direction unit vector in ENU
- reset_elements()¶
Resets all elements in the tile to the common pointing and unit gain.
- set_ENU_positions()¶
Sets ENU (East-North-Up) coordinates.
- set_array_position(station)¶
Sets position of station within the interferometric array compared to another station (so the position is the ENU position of self in the reference frame of the other station)
Parameters¶
- stationStation object
reference station
- set_element_property(property, values, same_value=False)¶
Helper function for the element list. Sets a property of the underlying elements.
- update_station_pointing(new_pointing_ra=None, new_pointing_dec=None)¶
Updates station_pointing (including tile pointing). If the pointing is set to None, the telescope operates in drift-scan mode.
Parameters¶
- pointing_rafloat, optional
Right ascension of the phase center in deg, default is None
- pointing_decfloat, optional
Declination of the phase center in deg, default is None
- class shimmerr.array.Tile(positions, tracking, gain=1 + 0j)¶
Bases:
objectA class that represents the analogue beamformer elements in the array.
Attributes¶
- p: list
Contains the 3D position of the tile in ECEF (Earth-Centered Earth-Fixed) coordinates
- p_ENU: list
Contains the 3D position of the tile in ENU (East-North-Up) coordinates
- g: complex
Complex gain of the element
- d: ndarray
Complex pointing of the tile (in Ra, Dec)
- __init__(positions, tracking, gain=1 + 0j)¶
Parameters¶
- positionslist
Contains the 3D position of the elements in ECEF coordinates
- pointingcomplex, optional
Complex pointing of the tile (in ENU coordinates)
- gaincomplex, optional
Complex gain of the tile (shared by all elements), by default 1
- calculate_response(directions, frequency, antenna_beams=None, pointing_directions=None)¶
Calculates the tile response or array factor in M directions.
- directionsndarray
3xM array of unit length vectors that decribe the directions in ENU coordinates
- frequencyfloat
Frequency of the measurement
- antenna_beamsNone or ndarray, optional
If set to None (default) this disables the element beams and only the array factor is returned. Otherwise, give an N x M array of element responses in the requested directions
- pointing_directionsndarray, optional
3xM array of unit length vectors that decribe the direction of the pointing center in ENU coordinates. Default is None (drift-scan)
- ndarray
M length response
- get_element_property(property)¶
Helper function for the element list. Retrieves a property of the underlying elements.
- reset_elements()¶
Resets all elements in the tile to have unit gain
- set_ENU_positions(rotation_matrix, station_position)¶
Calculates the ENU (East-North-Up) coordinates of all elements and the tile itself, based on the station rotation matrix from ECEF to ENU.
- set_element_property(property, values, same_value=False)¶
Helper function for the element list. Sets a property of the underlying elements.
- update_tile_gain(new_gain)¶
- shimmerr.array.calculate_array_factor_contribution(positions, gains, k, directions)¶
Calculates the array factor contributions of all elements and passes them separately (not summed).
Parameters¶
- positionsndarray
3xN array of element positions (must be floats)
- gainsndarray
N sized array of element gains (must be complex)
- kfloat
wave number
- directionsndarray
3xM array of directions to calculate the response in
Returns¶
- ndarray
N x M array with responses
shimmerr.calibration module¶
- class shimmerr.calibration.DDEcal(array, reference_station, n_channels=1, n_times=1, uv_lambda=[250, 5000], antenna_mode='omnidirectional', n_iterations=50, tolerance=1e-06, update_speed=0.2, smoothness_scale=4000000.0)¶
Bases:
objectA class that can run DDECal in a single polarisation, with various weighting schemes.
Attributes:¶
- array: dict
Interferometer dictionary with Station objects as values.
- reference_station: str
Name (AKA array key) of the station that should act as the reference for gain phases. Subtracting the phases of this station removes unitairy ambiguity.
- n_channels: int
Number of channels per solution interval
- n_times: int
Number of time steps per solution interval
- uv_lambda: list
List containing the minimum and maximum baseline length used in calibration in lambda.
- antenna_mode: str
Mode for the antenna in the calibration beam (see: Antenna objects).
- n_iterations: int
Number of iterations for the algorithm.
- tolerance: float
If the mean change rate of the gains drops below this number, the algorithm interprets it as convergence and stops the optimisation earlier than n_iterations.
- update_spead: float
Number between 0 and 1 that determines how quick the gain solutions should update. A speed of 0 means no update, a speed of 1 means that the previous gain solution is not included in the update.
- smoothness_scale: float
Width of the spectral regularisation kernel in MHz.
- calculate_residuals(visibility_file, gain_path, skymodel, fname, data_path=None)¶
Calculate residuals with known gains
Parameters¶
- visibility_filestr
filename that contains the visibilities (path + name).
- gain_pathstr
path + filename of the gains
- skymodelSkymodel object
Used for determining the calibration directions, see sources.py
- fnamestr
output file name (including path)
- data_pathstr, optional
basepath for the model and gains, by default None (inferred from the visibility file)
- run_DDEcal(visibility_file, skymodel, reuse_predict=False, reweight_mode=None, fname=None, calculate_residual=True, data_path=None)¶
Perform DDECal
Parameters¶
- visibility_filestr
filename that contains the visibilities (path + name)
- skymodelSkymodel object
sources. Used for determining the calibration directions and possibly the predict, see sources.py
- reuse_predictbool, optional
If True, the coherency model is read from disk, if False it is computed first, by default False
- reweight_modestr, optional
Reweighting kernel (“abs”, “squared” or None), by default None - abs: robust calibrator (smooth with the expected beam response) - squared: smooth with the square of the model times gain - None: smooth with the gain
- fnamestr, optional
Name of the output files. By default None (name is set to Calibration_<reweight_mode>_<smoothness_scale>).
- calculate_residualbool, optional
Whether to also calculate the residual visibilities, by default True
- data_pathstr, optional
basepath for the model and output, by default None (inferred from the visibility file)
shimmerr.export module¶
- shimmerr.export.export_MS(array, visibility_file, output_file, template_name='/home/codex/brackenhoff/projects/beam_errors/beam_errors/files/LOFAR_HBA_Dutch_template.MS', DP3_binding='DP3')¶
Function that converts visbility CSVs from SHIMMERR into MS.
Parameters¶
- arraydict
dictionary of Station objects that form the interferometer
- visibility_filestr
path + filename of the csv with the stored visibilities
- output_filestr
path + filename of the MS in which the visibilities should be output
- template_namestr, optional
path + filename of the MS template. Currently SHIMMERR is only packages with LOFAR HBA, but another template van be supplied by the user. This will change the ELEMENT_FLAGGING, however, (see the _unflag_broken_tiles function), by default f”<SHIMMERR home directory>/files/LOFAR_HBA_Dutch_template.MS”
- DP3_bindingstr, optional
binding to call DP3 from (for example if it should be called with a container), by default “DP3”
shimmerr.load_array module¶
- shimmerr.load_array.load_LOFAR(mode='EoR', pointing_ra=None, pointing_dec=None)¶
Loads LOFAR HBA using coordinates from Michiel Brentjens’ LOFAR Antpos: https://github.com/brentjens/lofar-antenna-positions
Parameters¶
- modestr, optional
Beamforming mode, can be “CS” (only core stations), “Dutch_tapered” (all Dutch stations, with the RS beamformed to act like a CS), “Dutch_sensitive” (all Dutch stations, with all tiles in the RS functioning), “international” (all LOFAR stations from Lofarantpos), or “EoR” (stations with baselines shorter than ~10 km, in tapered setting, corresponds to the Epoch of Reionization science case), by default “EoR”
- pointing_rafloat, optional
Right ascension of the phase center in deg, by default None (drift-scan)
- pointing_decfloat, optional
Declination of the phase center in deg, by default None (drift-scan)
Returns¶
- dict
Dictionary of SHIMMERR Station objects
- shimmerr.load_array.load_array_from_file(filepath, pointing_ra=None, pointing_dec=None)¶
Loads an array from a file supplied by the user. The file should be structured as follows: - Stations are separated by empty lines, and start with a name (so the first line of the station “paragraph” is a string with its name) - The rest of the block of a station consists of lines with 4 comma separated values. – The first is a tile identifier (any string) – The later 3 are antenna positions in ETRS coordinates – New tiles are automatically created when a new tile identifier is read Comments can be added with a # sign at the start of a line
Parameters¶
- filepathstr
path + filename of the file that contains the array.
- pointing_rafloat, optional
Right ascension of the phase center in deg, by default None (drift-scan)
- pointing_decfloat, optional
Declination of the phase center in deg, by default None (drift-scan)
Returns¶
- dict
Dictionary of SHIMMERR Station objects
shimmerr.metrics module¶
- shimmerr.metrics.compute_realized_gains(directory_realized_responses, directory_ideal_responses, fname_realized_gains, patch_names=None)¶
Computes the “realised gains”, AKA the ratio between the true beam response and the calibration beam response. This is the “perfect” gain that perfectly calibrates a calibration patch. In reality, this gain can’t come out of calibration (solution intervals, noise, etc.), but it can be used to gauge gain calirbation errors NB: be careful that this uses beam _responses_ (one station) not the beam _models_ (baseline-based).
Parameters¶
- directory_realized_responsesstr
Path of the directory with true beam responses
- directory_ideal_responsesstr
Path of the directory with the calibration beam responses
- fname_realized_gainsstr
filename to save the realized gains under
- patch_nameslist, optional
list of strings with the names of the calibration directions in which the responses should be computed, by default None (uses all patches in the directory).
shimmerr.sources module¶
- class shimmerr.sources.Patch(patch_right_ascension, patch_declination)¶
Bases:
object- __init__(patch_right_ascension, patch_declination)¶
Class that contains a calibration patch (group/cluster of sources)
Parameters¶
- patch_right_ascensionstr
RA in HH:MM:SS.SSS
- patch_declinationstr
Dec in +-DD.MM.SS.SSS
- add_source(source_name, right_ascension, declination, brightness, reference_frequency, spectral_index, logSI)¶
Creates a source within the Patch. The brightness is computed as for a LOFAR sourcedb (see https://www.astron.nl/lofarwiki/doku.php?id=public:user_software:documentation:makesourcedb)
Parameters¶
- right_ascensionstr
RA in HH:MM:SS.SSS
- declinationstr
Dec in +-DD.MM.SS.SSS
- brightnessfloat
Source brightness (I0)
- reference_frequencyfloat
v0
- spectral_indexstr
str in the form [c0,c1,c2]
- logSIbool
whether the spectral index is logarithmic
- class shimmerr.sources.Skymodel(filename)¶
Bases:
object- __init__(filename)¶
Reads a skymodel from disk and converts it into a SHIMMERR sky model.
Parameters¶
- filenamestr
path + filename of the sky model
- join_patches(patch_names, joint_name=None, joint_ra=None, joint_dec=None)¶
- parse_formatstring(string)¶
- class shimmerr.sources.Source(right_ascension, declination, brightness, reference_frequency, spectral_index, logSI)¶
Bases:
object- __init__(right_ascension, declination, brightness, reference_frequency, spectral_index, logSI)¶
Class to describe a sky-model source. The brightness is computed as for a LOFAR sourcedb (see https://www.astron.nl/lofarwiki/doku.php?id=public:user_software:documentation:makesourcedb)
Parameters¶
- right_ascensionstr
RA in HH:MM:SS.SSS
- declinationstr
Dec in +-DD.MM.SS.SSS
- brightnessfloat
Source brightness (I0)
- reference_frequencyfloat
v0
- spectral_indexstr
str in the form [c0,c1,c2]
- logSIbool
whether the spectral index is logarithmic
- static linear_spectral_index_brightness(frequency, brightness, reference_frequency, spectral_index)¶
Helper function to calculate the brightness as a function of frequency for a linear spectral index
- static logarithmic_spectral_index_brightness(frequency, brightness, reference_frequency, spectral_index)¶
Helper function to calculate the brightness as a function of frequency for a logarithmic spectral index
- static parse_declination(declination_string)¶
Helper function to convert the Dec to degrees
- static parse_right_ascension(right_ascension_string)¶
Helper function to convert the RA to degrees
shimmerr.visibility module¶
- shimmerr.visibility.add_thermal_noise(filename, data_path, sefd, seed)¶
Adds thermal noise to the visibilities
Parameters¶
- filenamestr
directory of the relevant visibilities. The input file with be at <path>/<filename>/full_model.csv, and the output file at <path>/<filename>/data.csv
- data_pathstr
data path (see filename)
- sefdfloat
system equivalent flux density of the noise
- seedint
seed for the randum number generator
- shimmerr.visibility.calculate_directions(station, start_time_utc, time_resolution, number_of_timeslots, right_ascensions, declinations, n_jobs)¶
Helper function to generate source directions and tracking directions in an easy format
- shimmerr.visibility.get_time_labels(start_time_utc, duration, time_resolution)¶
Helper function to generate time labels for the visibilities
- shimmerr.visibility.predict_data(array, skymodel, frequencies, start_time_utc, filename, data_path='./data/predictions', time_resolution=2, duration=12, antenna_mode='omnidirectional', basestation=None, reuse_tile_beam=False, SEFD=4200.0, save_response=True, seed=None, n_jobs=-1)¶
Performs a full visibility predict from a sky model and interferometer.
Parameters¶
- arraydict
dict of SHIMMERR stations that describe the interferometer (see array.py and load_array.py)
- skymodeldict
dict of SHIMMERR patches that describe the sources in the sky (see sources.py)
- frequencieslist or ndarray of floats
Frequencies at which to simulate the array. We simulate no smearing etc.
- start_time_utcstr
UTC start time of the observation in format YYYY-MM-DDThh:mm:ss, example: 2024-07-04T19:25:00
- filenamestr
name of the folder in which the visibilities should be saved
- data_pathstr, optional
folder in which the destination folder should be saved, by default “./data/predictions”
- time_resolutionint, optional
time resolution in seconds, by default 2
- durationint, optional
observation duration in hours, by default 12
- antenna_modestr, optional
beam mode for the lowest level elements, by default “omnidirectional”
- basestationstr, optional
name of the station used as the ‘array center’, by default None (selects the first station in the array dictionary)
- reuse_tile_beambool, optional
If set, uses the same tile model for all tiles in a stationm. This does not allow for intra-tile variation, but does speed up the computation. Recommended for the calibration model predict, by default False (all tiles computed separately)
- SEFDfloat, optional
System equivalent flux density of the noise in Jy. Set to None to disable noise, by default 4.2e3
- save_responsebool, optional
toggles whether the station responses are saved to enable computing the expected gain. Default is True.
- seedint, optional
seed for the random number generator that creates the noise, set to anything but None for reproducability, by default None
- n_jobsint, optional
Number of prediction processes that are allowed to run in parallel (ideally equal to the number of CPU cores), by default -1 (all cores used)
- shimmerr.visibility.predict_patch_visibilities(array, skymodel, frequencies, start_time_utc, filename, data_path='./data/predictions', time_resolution=2, duration=12, antenna_mode='omnidirectional', basestation=None, reuse_tile_beam=False, save_response=True, n_jobs=-1)¶
Predicts noiseless visibilities of each patch and saves each patch to disk.
Parameters¶
- arraydict
Dictionary containing Station objects
- skymodelSkymodel object
skymodel to be simulated
- frequencieslist or ndarray of floats
Frequencies at which to simulate the array. We simulate no smearing etc.
- start_time_utcstr
UTC start time of the observation in format YYYY-MM-DDThh:mm:ss, example: 2024-07-04T19:25:00
- filenamestr
name of the folder in which the visibilities should be saved
- data_pathstr, optional
folder in which the destination folder should be saved, by default “./data/predictions”
- time_resolutionint, optional
time resolution in seconds, by default 2
- durationint, optional
observation duration in hours, by default 12
- antenna_modestr, optional
beam mode for the lowest level elements, by default “omnidirectional”
- basestationstr, optional
name of the station used as the ‘array center’, by default None (selects the first station in the array dictionary)
- prediction_batch_sizeint, optional
approximate batch size for each visibility prediction after beam calculation. This is a trade off between speed and memory virtualization. The batch will become an integer multiple of the number of stations * number of sources, so this number may be exceeded if one of such batches is larger than the specified value, by default 10000.
- save_responsebool, optional
toggles whether the station responses are saved to enable computing the expected gain. Default is True.
- shimmerr.visibility.process_batch(batch, source_powers)¶
- shimmerr.visibility.record_beams(df, new_batch, first_frequency, last_frequency, first_station, file_path)¶
Helper function to write the response beam files
- shimmerr.visibility.subtract_visibilities(filename_in_1, filename_in_2, filename_out, common_path='')¶
Function to take the difference between visibilities (for source subtraction)
Parameters¶
- filename_in_1str
filename of the visibilities from which the sources must be subtracted
- filename_in_2str
filename of the visibilities with the sources that must be subtracted
- filename_outstr
filename where the result must be stored
- common_pathstr, optional
path for these files (the paths can also be added to the filename, in which case this would be root), by default “”
- shimmerr.visibility.sum_patches(filename, data_path, skymodel)¶
Sums all patch models to create a full sky visibility prediction
Parameters¶
- filenamestr
directory of the relevant visibilities. The summed file with be at <path>/<filename>/full_model.csv, and the patch models must be at <path>/<filename>/patch_models
- data_pathstr
data path (see filename)
- skymodeldict
SHIMMERR sky model (used for patch names only)
shimmerr.visualization module¶
- shimmerr.visualization.get_beam(beam_value_mode, beam_plot_mode, station, frequency, directions, phase_center, antenna_mode, tile_number, antenna_number, calculate_all_tiles)¶
Helper function to calculate the beam so it can be plot
Parameters¶
- beam_value_modestr, optional
The way in which the beam should be calculated “element”, “tile” (array factor), “station” (array factor), “array_factor” (tile and station array factors combined), or “full” (elements and array factors), by default “full”
- beam_plot_modestr, optional
The way in which the beam should be displayed (“power” of “voltage” in dB and real and imaginary in linear scale), by default “power”
- stationStation object
Station
- frequencyfloat or int, optional
measurement frequency to plot the beam for, by default 150e6
- directionsndarray
Array with directions in which to calculate the beam, should be 3xNdir
- phase_centerndarray
Array with the pointing direction in which to calculate the beam, should be 3xNdir
- antenna_modeNone or str, optional
Gives the shape of the element beam, by default None
- tile_numberint, optional
Which tile in the station to display for tile/element option, by default 0
- antenna_numberint, optional
Which element in the chosen tile to display (for element option), by default 0
- calculate_all_tilesbool
If set, all tile beams are computed separately (allows for intra-tile variations), if unset all tile beams are identical (faster computation)
Returns¶
- ndarray
beam values that can be plotted
- str
colorbar label
- shimmerr.visualization.plot_convergence(results, plot_folder, name)¶
Plot the convergence of a calibration run
Parameters¶
- resultsdict
Results as output by the DDECal.run (see calibration.py)
- plot_folderstr
path where the plot should be save
- namestr
filename of the plot
- shimmerr.visualization.plot_gain_error(fname_gains, fname_true_gains, plot_folder, name, reference_station='CS002HBA0', amplitude_lims=[0, 2], phase_lims=[-3.141592653589793, 3.141592653589793])¶
Creates a plot of the error in estimated gains using the ideal gains (ratio between true beam response and claibration beam)
Parameters¶
- fname_gainsstr
path + filename where the estimated gains are stored
- fname_true_gainsstr
path + filename where the ideal gains are stored (see metrics.py)
- plot_folderstr
directory where the plot is to be stored
- namestr
filename of the plot
- reference_stationstr, optional
name fo the reference station used to remove unitairy ambiguity by using it as zero-phase, by default “CS002HBA0”
- amplitude_limslist, optional
range of amplitude colorbar, by default [0, 2]
- phase_limslist, optional
range of phase colorbar, by default [-np.pi, np.pi]
- shimmerr.visualization.plot_gains(fname, plot_folder, name, amplitude_lims=[0, 2], phase_lims=[-3.141592653589793, 3.141592653589793])¶
Function to plot gains
Parameters¶
- fnamestr
path + filename of the results object that contians the gails
- plot_folderstr
Folder where the plot should be saved
- namestr
name of the plot
- amplitude_limslist, optional
range of the gain amplitude in the plot, by default [0, 2]
- phase_limslist, optional
range of the gain phase in the plot, by default [-np.pi, np.pi]
- shimmerr.visualization.plot_spatial_beam(station, n_altitude, n_azimuth, frequency=150000000.0, antenna_mode=None, beam_plot_mode='power', beam_value_mode='full', tile_number=0, antenna_number=0, points_of_interest=[], plot_title=None, time='2024-01-01T00:00:00', calculate_all_tiles=True, **kwargs)¶
Helper function to create plots of station beams easily
Parameters¶
- stationStation object
Station
- n_altitudeint
Number of points in the altitude sweep (more is higher resolution)
- n_azimuthint
Number of points in the azimuth sweep (similar to n_altitude)
- frequencyfloat or int, optional
measurement frequency to plot the beam for, by default 150e6
- antenna_modeNone or str, optional
Gives the shape of the element beam, by default None
- beam_plot_modestr, optional
The way in which the beam should be displayed (“power” of “voltage” in dB and real and imaginary in linear scale), by default “power”
- beam_value_modestr, optional
The way in which the beam should be calculated “element”, “tile” (array factor), “station” (array factor), “array_factor” (tile and station array factors combined), or “full” (elements and array factors), by default “full”
- tile_numberint, optional
Which tile in the station to display for tile/element option, by default 0
- antenna_numberint, optional
Which element in the chosen tile to display (for element option), by default 0
- plot_title: str
Title of the plot
- points_of_interestlist, optional
list of directions that should be highlighted in the plot. For example the pointing direction or a bright source, by default [] (no highlighted points)
- shimmerr.visualization.plot_spectrotemporal_beam(station, right_ascension, declination, frequencies=array([1.34100e+08, 1.34295e+08, 1.34490e+08, 1.34685e+08, 1.34880e+08, 1.35075e+08, 1.35270e+08, 1.35465e+08, 1.35660e+08, 1.35855e+08, 1.36050e+08, 1.36245e+08, 1.36440e+08, 1.36635e+08, 1.36830e+08, 1.37025e+08, 1.37220e+08, 1.37415e+08, 1.37610e+08, 1.37805e+08, 1.38000e+08, 1.38195e+08, 1.38390e+08, 1.38585e+08, 1.38780e+08, 1.38975e+08, 1.39170e+08, 1.39365e+08, 1.39560e+08, 1.39755e+08, 1.39950e+08, 1.40145e+08, 1.40340e+08, 1.40535e+08, 1.40730e+08, 1.40925e+08, 1.41120e+08, 1.41315e+08, 1.41510e+08, 1.41705e+08, 1.41900e+08, 1.42095e+08, 1.42290e+08, 1.42485e+08, 1.42680e+08, 1.42875e+08, 1.43070e+08, 1.43265e+08, 1.43460e+08, 1.43655e+08, 1.43850e+08, 1.44045e+08, 1.44240e+08, 1.44435e+08, 1.44630e+08, 1.44825e+08, 1.45020e+08, 1.45215e+08, 1.45410e+08, 1.45605e+08, 1.45800e+08, 1.45995e+08, 1.46190e+08, 1.46385e+08, 1.46580e+08]), utc_starttime='2024-07-04T21:35:00', time_resolution=2, number_of_timeslots=400, antenna_mode=None, beam_plot_mode='power', beam_value_mode='full', tile_number=0, antenna_number=0, plot_title=None, calculate_all_tiles=True, **kwargs)¶
Helper function to create plots of station beams easily
Parameters¶
- stationStation object
Station
- right_ascentionfloat
Target RA in degrees
- declinationfloat
Target dec in degrees
- frequenciesndarray, optional
channel central frequencies to plot the beam for in Hz. Default is 195kHz channels between 134.1 and 146.7 MHz (LOFAR-EoR redshift bin 2).
- utc_starttimstr
Observing time in UTC format (YYYY-MM-DDThh:mm:ss. Default is “2024-07-04T21:35:00”
- time_resolutionfloat
Time resolution at which to plot the beam in seconds. Default is 2.
- number_of_timeslotsint
Number of timeslots (of size time_resolution) to plot. Default is 400
- antenna_modeNone or str, optional
Gives the shape of the element beam, by default None
- beam_plot_modestr, optional
The way in which the beam should be displayed (“power” of “voltage” in dB and real and imaginary in linear scale), by default “power”
- beam_value_modestr, optional
The way in which the beam should be calculated “element”, “tile” (array factor), “station” (array factor), “array_factor” (tile and station array factors combined), or “full” (elements and array factors), by default “full”
- tile_numberint, optional
Which tile in the station to display for tile/element option, by default 0
- antenna_numberint, optional
Which element in the chosen tile to display (for element option), by default 0
- shimmerr.visualization.plot_visibility(file, station_pairs, magnitude_range=[None, None], phase_range=[-3.141592653589793, 3.141592653589793], **kwargs)¶
Plots a visibility
Parameters¶
- filestr
pth + filename of the visibility
- station_pairslist
list of tuples with the baseline to be plotted
- magnitude_rangelist, optional
range of the magnitude scale, by default [None, None]
- phase_rangelist, optional
range of the phase scale, by default [-np.pi, np.pi]