suncasa.eovsa.eovsa_synoptic_imaging_pipeline_wsclean

Loop over SPWs once: run slfcal, disk insertion/subtraction, and imaging per SPW

This version combines all operations into a single loop over SPWs. For each SPW, it performs slfcal, inserts and subtracts the disk, and then proceeds directly to imaging before moving to the next SPW. Tasks are handled sequentially within each SPW iteration.

EOVSA/WSClean compatibility note: Use the legacy WSClean wrapper instead of a bare system wsclean path. The working stack on the pipeline server is the compatibility wrapper /usr/local/bin/wsclean-eovsa, which calls the legacy /usr/local/bin/wsclean-eovsa-bin binary with the older runtime libraries it needs and depends on casacore2: libcfitsio.so.5, libmpi.so.20, and libhwloc.so.5.

This matters because newer WSClean builds can fail on EOVSA MS files with uneven SPWs, typically with:

ArrayColumn::get: Table array conformance error

That error is the reason this pipeline should stay pinned to the known- working wrapper unless the full runtime stack has been revalidated.

Attributes

hostname

is_on_server

is_on_inti

script_mode

tasks

gaincal

applycal

clearcal

delmod

ft

uvsub

split

concat

flagmanager

flagdata

tclean

hanningsmooth

imhead

tools

qatool

iatool

cltool

mstool

tbtool

qa

ia

ms

tb

WSCLEAN_BIN

PIPELINE_CONFIG

SELFCAL_ROUNDS

FINAL_IMAGING_CONFIG

UV_CONFIG

parser

Classes

WSCleanTimeIntervals

FluxComparison

FrequencySetup

Manages frequency setup based on observation date for radio astronomy imaging.

MSselfcal

A class for imaging using WSClean and selfcal visibility data.

Functions

_resolve_wsclean_bin()

Return the preferred WSClean executable path for EOVSA.

log_print(level, message)

_format_log_state(**state)

Format a stable key=value summary for diagnostic logging.

log_step(level, step, message, **state)

Emit a log line with an explicit pipeline step and state summary.

pipeline_stage(step, **state)

Log start/end/failure for a pipeline stage with traceback on error.

get_solar_radius_mask(rsun_pix, crpix1, crpix2, ny, nx)

detect_noisy_images(data_stack, rsun_pix, crpix1, crpix2)

Detect and reject noisy frames in a stack of solar images.

extract_time_flags_from_ms(msfile[, threshold, ...])

Extracts time steps and their corresponding flag status from a Measurement Set (MS).

get_timedelta(tim)

Calculates the most frequent time difference (delta) in minutes from a sequence of time values.

plot_style(func)

A decorator to apply common plotting styles to the plotting functions.

trange2timerange(trange)

Convert a time range tuple in datetime format to a string representation.

rotateimage(data, xc_centre, yc_centre, p_angle)

Rotate an image around a specified point (xc_centre, yc_centre) by a given angle.

solar_diff_rot_heliofits(in_fits, newtime, out_fits[, ...])

Reproject a FITS file to account for solar differential rotation to a new observation time.

sunpyfits_to_j2000fits(in_fits, out_fits[, ...])

Rotate a solar FITS file from helioprojective to RA-DEC coordinates and save to a new FITS file.

get_beam_kernel([header, bmaj, bmin, bpa, ...])

Returns a normalized 2D elliptical Gaussian kernel representing the beam.

compute_disk_image(header, dsz_value, fdn_value[, ...])

add_convolved_disk_to_fits(→ List[FluxComparison])

Add a uniform disk to FITS images, convolve with beam, and save.

disk_size_function(v, c1, alpha1)

Analytic model for disk size as a function of frequency.

flux_function(v, c1, alpha1, c2, alpha2, c3, alpha3)

Analytic model for disk flux as a function of frequency.

calc_diskmodel(tim, nbands, freq)

ant_trange(vis)

Figure out nominal times for tracking of old EOVSA antennas, and return time

format_spw(spw)

Formats the spectral window (spw) string for file naming, ensuring start and end values are separated by a dash and zero-padded to two digits.

merge_FITSfiles(fitsfilesin, outfits[, snr_weight, ...])

Merges multiple FITS files into a single output file by calculating the mean of stacked data.

clean_junk(imname[, junks])

Clears junk files generated during the imaging process.

_compute_round_intervals(wsclean_intervals, multiplier)

Compute time intervals for one self-cal round.

_run_gaincal_step(msfile, workdir, spw, spwstr, ...[, ...])

Run a single gaincal step with standard boilerplate.

_run_slfcal_round(round_def, msfile, ri, spw, spwstr, ...)

Execute one round of feature self-calibration: image, gaincal, applycal.

_compute_uv_ranges(spws_indices, spws, freq, spwidx2proc)

Compute per-band UV range strings for disk and feature self-calibration.

_run_disk_selfcal(msfile, sidx, spw, spwstr, sp_index, ...)

Run disk self-calibration: predict disk model, gaincal, applycal, flag, uvsub.

_run_final_imaging(msfile, sidx, spw, spwstr, ...[, ...])

Run final imaging (segmented or non-segmented) and return output FITS paths.

pipeline_run(vis[, outputvis, workdir, slfcaltbdir, ...])

Executes the EOVSA data processing pipeline for solar observation data.

Module Contents

suncasa.eovsa.eovsa_synoptic_imaging_pipeline_wsclean.hostname[source]
suncasa.eovsa.eovsa_synoptic_imaging_pipeline_wsclean.is_on_server[source]
suncasa.eovsa.eovsa_synoptic_imaging_pipeline_wsclean.is_on_inti[source]
suncasa.eovsa.eovsa_synoptic_imaging_pipeline_wsclean.script_mode = True[source]
suncasa.eovsa.eovsa_synoptic_imaging_pipeline_wsclean.tasks[source]
suncasa.eovsa.eovsa_synoptic_imaging_pipeline_wsclean.gaincal[source]
suncasa.eovsa.eovsa_synoptic_imaging_pipeline_wsclean.applycal[source]
suncasa.eovsa.eovsa_synoptic_imaging_pipeline_wsclean.clearcal[source]
suncasa.eovsa.eovsa_synoptic_imaging_pipeline_wsclean.delmod[source]
suncasa.eovsa.eovsa_synoptic_imaging_pipeline_wsclean.ft[source]
suncasa.eovsa.eovsa_synoptic_imaging_pipeline_wsclean.uvsub[source]
suncasa.eovsa.eovsa_synoptic_imaging_pipeline_wsclean.split[source]
suncasa.eovsa.eovsa_synoptic_imaging_pipeline_wsclean.concat[source]
suncasa.eovsa.eovsa_synoptic_imaging_pipeline_wsclean.flagmanager[source]
suncasa.eovsa.eovsa_synoptic_imaging_pipeline_wsclean.flagdata[source]
suncasa.eovsa.eovsa_synoptic_imaging_pipeline_wsclean.tclean[source]
suncasa.eovsa.eovsa_synoptic_imaging_pipeline_wsclean.hanningsmooth[source]
suncasa.eovsa.eovsa_synoptic_imaging_pipeline_wsclean.imhead[source]
suncasa.eovsa.eovsa_synoptic_imaging_pipeline_wsclean.tools[source]
suncasa.eovsa.eovsa_synoptic_imaging_pipeline_wsclean.qatool[source]
suncasa.eovsa.eovsa_synoptic_imaging_pipeline_wsclean.iatool[source]
suncasa.eovsa.eovsa_synoptic_imaging_pipeline_wsclean.cltool[source]
suncasa.eovsa.eovsa_synoptic_imaging_pipeline_wsclean.mstool[source]
suncasa.eovsa.eovsa_synoptic_imaging_pipeline_wsclean.tbtool[source]
suncasa.eovsa.eovsa_synoptic_imaging_pipeline_wsclean.qa[source]
suncasa.eovsa.eovsa_synoptic_imaging_pipeline_wsclean.ia[source]
suncasa.eovsa.eovsa_synoptic_imaging_pipeline_wsclean.ms[source]
suncasa.eovsa.eovsa_synoptic_imaging_pipeline_wsclean.tb[source]
suncasa.eovsa.eovsa_synoptic_imaging_pipeline_wsclean._resolve_wsclean_bin()[source]

Return the preferred WSClean executable path for EOVSA.

Prefer the EOVSA compatibility wrapper so the pipeline stays on the casacore2-backed binary that works with the legacy runtime stack.

suncasa.eovsa.eovsa_synoptic_imaging_pipeline_wsclean.WSCLEAN_BIN = '/usr/local/bin/wsclean-eovsa'[source]
suncasa.eovsa.eovsa_synoptic_imaging_pipeline_wsclean.PIPELINE_CONFIG[source]
suncasa.eovsa.eovsa_synoptic_imaging_pipeline_wsclean.SELFCAL_ROUNDS[source]
suncasa.eovsa.eovsa_synoptic_imaging_pipeline_wsclean.FINAL_IMAGING_CONFIG[source]
suncasa.eovsa.eovsa_synoptic_imaging_pipeline_wsclean.UV_CONFIG[source]
suncasa.eovsa.eovsa_synoptic_imaging_pipeline_wsclean.log_print(level, message)[source]
suncasa.eovsa.eovsa_synoptic_imaging_pipeline_wsclean._format_log_state(**state)[source]

Format a stable key=value summary for diagnostic logging.

suncasa.eovsa.eovsa_synoptic_imaging_pipeline_wsclean.log_step(level, step, message, **state)[source]

Emit a log line with an explicit pipeline step and state summary.

suncasa.eovsa.eovsa_synoptic_imaging_pipeline_wsclean.pipeline_stage(step, **state)[source]

Log start/end/failure for a pipeline stage with traceback on error.

suncasa.eovsa.eovsa_synoptic_imaging_pipeline_wsclean.get_solar_radius_mask(rsun_pix, crpix1, crpix2, ny, nx, rsun_ratio=(1.2, 1.3))[source]
suncasa.eovsa.eovsa_synoptic_imaging_pipeline_wsclean.detect_noisy_images(data_stack, rsun_pix, crpix1, crpix2, rsun_ratio=(1.2, 1.3), rms_threshold=None, snr_threshold=None, showplt=False)[source]

Detect and reject noisy frames in a stack of solar images.

This function computes for each image:
  1. RMS noise in an annular region outside the solar disk.

  2. SNR using the 99.999th percentile inside the disk.

  3. (when rms_threshold is None) an automatic “knee” in the sorted RMS curve that separates the flat cluster from the noisy outliers.

If the knee detector fails (elbow at first/last point, or would reject zero frames), we fall back to median(rms) + std(rms).

Parameters:
  • data_stack (np.ndarray) – 3D array of images, shape (n_images, height, width).

  • rsun_pix (float) – Radius of the solar disk in pixels.

  • crpix1 (float) – X-coordinate of the disk center.

  • crpix2 (float) – Y-coordinate of the disk center.

  • rsun_ratio (tuple(float, float)) – Inner and outer scale factors for the annular mask. Defaults to (1.2, 1.3).

  • rms_threshold (float or None) – User-supplied RMS cutoff. If None, an automatic knee detection is used.

  • snr_threshold (float or None) – SNR cutoff. If None, set to median(SNR) – std(SNR).

  • showplt (bool) – If True, display a diagnostic plot of RMS and SNR with their cutoffs.

Returns:

  • select_indices (bool array): True for images kept (not noisy).

  • rms_values (float array): RMS noise for each image.

  • snr_values (float array): SNR for each image.

Return type:

tuple(np.ndarray, np.ndarray, np.ndarray)

suncasa.eovsa.eovsa_synoptic_imaging_pipeline_wsclean.extract_time_flags_from_ms(msfile, threshold=0.75, plotflag=False, return_flag=False)[source]

Extracts time steps and their corresponding flag status from a Measurement Set (MS).

This function processes the flag data from all spectral windows (SPWs) in the MS file to compute the average flag status across baselines and channels. A time step is considered flagged if the mean flag value across all data exceeds a specified threshold.

Parameters:
  • msfile (str) – Path to the Measurement Set (MS) file.

  • threshold (float, optional) – Threshold for considering a time step as flagged, defaults to 0.75. A time step is flagged if the mean flag fraction > threshold.

  • plotflag (bool, optional) – If True, generates a plot of the flag data and mean flag fraction, defaults to False.

Returns:

A tuple containing: - timedata (numpy.ndarray): Array of time steps from the MS. - timeflag (numpy.ndarray): Boolean array where True indicates

flagged time steps based on the threshold.

Return type:

tuple[numpy.ndarray, numpy.ndarray]

suncasa.eovsa.eovsa_synoptic_imaging_pipeline_wsclean.get_timedelta(tim)[source]

Calculates the most frequent time difference (delta) in minutes from a sequence of time values.

This function computes the differences between consecutive Modified Julian Dates (MJDs) in the provided tim object, converts them to minutes, and identifies the most frequently occurring time difference.

Parameters:

tim (object) – An object with an .mjd attribute containing time values in Modified Julian Date (MJD) format.

Returns:

The most frequently occurring time difference(s) in minutes.

Return type:

numpy.ndarray

suncasa.eovsa.eovsa_synoptic_imaging_pipeline_wsclean.plot_style(func)[source]

A decorator to apply common plotting styles to the plotting functions.

class suncasa.eovsa.eovsa_synoptic_imaging_pipeline_wsclean.WSCleanTimeIntervals(msfile, combine_scans=True, interval_length=50)[source]
msfile[source]
combine_scans = True[source]
scans[source]
scan_results = [][source]
tim = None[source]
tim_flag = None[source]
tdur = None[source]
tdt = None[source]
intervals_indices = None[source]
time_intervals = None[source]
nintervals_major = None[source]
nintervals_minor = 6[source]
time_intervals_major_avg = None[source]
time_intervals_minor_avg = None[source]
interval_length = 50[source]
_get_scans()[source]

Extract scan information from the MS file.

Returns:

Dictionary containing scan information.

Return type:

dict

_get_nintervals_major(tdur)[source]

Calculate the number of major intervals for WSClean.

Parameters:

tdur (float) – Total duration of the valid time range for WSClean, in minutes.

Returns:

Number of major intervals.

Return type:

int

compute_intervals(nintervals_minor=6)[source]

Compute time intervals for WSClean imaging.

Parameters:

nintervals_minor (int, optional) – Number of minor intervals within each major interval. Default is 6.

_compute_intervals_combined(nintervals_minor)[source]

Compute time intervals for WSClean imaging, treating all scans as a single entity.

_compute_intervals_individual(nintervals_minor)[source]

Compute time intervals for WSClean imaging for each scan individually.

_plot_combined(axs)[source]

Plot the time intervals for the entire MS file.

_plot_individual(axs)[source]

Plot the time intervals for each scan individually.

plot(filename=None)[source]

Plot the time intervals and optionally save the plot to a file.

Parameters:

filename (str, optional) – Path to save the plot. If None, the plot is displayed.

results()[source]

Returns the computed intervals and related information.

Returns:

If combine_scans=True, a dictionary containing: - intervals_indices (list of lists): Indices of time steps in each interval. - time_intervals (list of astropy.Time): Time values for each interval. - tdur (float): Total duration of the valid time range for WSClean, in minutes. - tdt (float): The most frequent time delta, in minutes. - nintervals_major (int): Number of major intervals. - nintervals_minor (int): Number of minor intervals within each major interval. - time_intervals_major_avg (astropy.Time): Average time for each major interval. - time_intervals_minor_avg (list of astropy.Time): Average time for each minor interval within major intervals. If combine_scans=False, a list of dictionaries, each containing: - ScanId: The ID of the scan. - SubScanId: The ID of the sub-scan. - BeginTime: The start time of the scan. - EndTime: The end time of the scan. - IntegrationTime: The integration time of the scan. - tdur: Total duration of the valid time range for WSClean, in minutes. - nintervals_major: Number of major intervals. - nintervals_minor: Number of minor intervals within each major interval. - intervals_indices: Indices of time steps in each major interval. - time_intervals: Time values for each major interval. - time_intervals_major_avg: Average time for each major interval. - time_intervals_minor: Time values for each minor interval. - time_intervals_minor_avg: Average time for each minor interval within major intervals.

Return type:

dict or list of dict

suncasa.eovsa.eovsa_synoptic_imaging_pipeline_wsclean.trange2timerange(trange)[source]

Convert a time range tuple in datetime format to a string representation.

Parameters:

trange (tuple) – A tuple containing start and end times as datetime objects.

Returns:

A string representation of the time range.

Return type:

str

suncasa.eovsa.eovsa_synoptic_imaging_pipeline_wsclean.rotateimage(data, xc_centre, yc_centre, p_angle)[source]

Rotate an image around a specified point (xc_centre, yc_centre) by a given angle.

Parameters:
  • data (numpy.ndarray) – The image data.

  • xc_centre (int) – The x-coordinate of the rotation center.

  • yc_centre (int) – The y-coordinate of the rotation center.

  • p_angle (float) – The rotation angle in degrees.

Returns:

The rotated image.

Return type:

numpy.ndarray

suncasa.eovsa.eovsa_synoptic_imaging_pipeline_wsclean.solar_diff_rot_heliofits(in_fits, newtime, out_fits, in_time=None, template_fits=None, showplt=False, overwrite_prev=True)[source]

Reproject a FITS file to account for solar differential rotation to a new observation time.

Parameters:
  • in_fits (str) – Path to the input FITS file to be reprojected

  • newtime (astropy.time.Time) – The new time to which the map is reprojected

  • out_fits (str) – Path for the output FITS file

  • in_time (astropy.time.Time, optional) – The reference time for the input map, defaults to the middle of the exposure time. This is useful when exposure time is not provided in the FITS header.

  • template_fits (str, optional) – Path to template FITS file for output. If None, uses in_fits as template

  • showplt (bool, optional) – Show plots of the original and reprojected maps, defaults to False

Returns:

Path to the output FITS file

Return type:

str

suncasa.eovsa.eovsa_synoptic_imaging_pipeline_wsclean.sunpyfits_to_j2000fits(in_fits, out_fits, template_fits=None, overwrite_prev=True)[source]

Rotate a solar FITS file from helioprojective to RA-DEC coordinates and save to a new FITS file. Originally written by Dr. Peijin Zhang :param in_fits: Path to input FITS file in helioprojective coordinates :type in_fits: str :param out_fits: Path for output FITS file in RA-DEC coordinates :type out_fits: str :param template_fits: Path to template FITS file for output format. If None, uses in_fits as template :type template_fits: str, optional :param overwrite_prev: If True, overwrites existing output file. Defaults to True :type overwrite_prev: bool, optional

Returns:

Path to the output FITS file

Return type:

str

suncasa.eovsa.eovsa_synoptic_imaging_pipeline_wsclean.get_beam_kernel(header=None, bmaj=None, bmin=None, bpa=0.0, pixel_scale_arcsec=None)[source]

Returns a normalized 2D elliptical Gaussian kernel representing the beam.

The beam can be specified in two ways:

  1. By providing a FITS header (via the ‘header’ parameter). In this case, if not explicitly provided, the beam parameters are extracted from the header using the following keywords:

    • ‘BMAJ’ (FWHM of the major axis, in degrees)

    • ‘BMIN’ (FWHM of the minor axis, in degrees)

    • ‘BPA’ (beam position angle in degrees, measured counterclockwise from North)

    In addition, if ‘pixel_scale_arcsec’ is not provided, it is determined from the header using:
    • ‘CDELT1’ (pixel scale, in degrees or arcseconds)

    • ‘CUNIT1’ (unit of CDELT1)

  2. By directly providing the beam parameters and pixel scale:
    • bmaj: FWHM of the major axis in degrees.

    • bmin: FWHM of the minor axis in degrees.

    • bpa: Beam position angle in degrees (counterclockwise from North).

    • pixel_scale_arcsec: Pixel scale in arcseconds per pixel.

The function converts the FWHM values (in degrees) to arcseconds and then to pixels using the provided pixel scale. It then converts the FWHM to sigma (standard deviation) via sigma = FWHM / 2.35482. The beam position angle is converted to a rotation angle (theta) relative to the x-axis via theta = radians(90 - BPA).

Parameters:
  • header (astropy.io.fits.header.Header, optional) – FITS header containing the beam and pixel scale information, defaults to None.

  • bmaj (float, optional) – FWHM of the beam major axis in degrees, defaults to None.

  • bmin (float, optional) – FWHM of the beam minor axis in degrees, defaults to None.

  • bpa (float, optional) – Beam position angle in degrees (counterclockwise from North), defaults to None.

  • pixel_scale_arcsec (float, optional) – Pixel scale in arcseconds per pixel, defaults to None.

Raises:
  • KeyError – If a header is provided but required keywords (‘BMAJ’, ‘BMIN’, ‘BPA’, ‘CDELT1’, or ‘CUNIT1’) are missing.

  • ValueError – If neither a header nor the required beam parameters and pixel_scale_arcsec are provided, or if ‘CUNIT1’ is unrecognized.

Returns:

A 2D numpy array representing the normalized elliptical Gaussian beam kernel.

Return type:

numpy.ndarray

suncasa.eovsa.eovsa_synoptic_imaging_pipeline_wsclean.compute_disk_image(header, dsz_value, fdn_value, add_limb=False, bmaj=None)[source]
class suncasa.eovsa.eovsa_synoptic_imaging_pipeline_wsclean.FluxComparison[source]

Bases: NamedTuple

infile: str[source]
data_max: float[source]
data_p9999: float[source]
model_max: float[source]
flux_data: float = None[source]
flux_model: float = None[source]
flux_input: float = None[source]
tbmax_data: float = None[source]
tbmax_model: float = None[source]
rms_data: float = None[source]
snr_data: float = None[source]
suncasa.eovsa.eovsa_synoptic_imaging_pipeline_wsclean.add_convolved_disk_to_fits(in_fits: str | List[str], out_fits: str | List[str], dsz: float | List[float], fdn: float | List[float], ignore_data: bool = False, toTb: bool = False, rfreq: str = None, add_limb: bool = False, bmaj: float = None, no_negative: bool = False, doconvolve: bool = True, create_mask: bool = False) List[FluxComparison][source]

Add a uniform disk to FITS images, convolve with beam, and save.

Both dsz and fdn accept float or list. Lists are averaged internally. Returns TbComparison for each file for downstream analysis.

Parameters:
  • in_fits (str or list) – Input FITS filename(s).

  • out_fits (str or list) – Output FITS filename(s).

  • dsz (float or list) – Disk radius(es) in arcseconds.

  • fdn (float or list) – Total disk flux(es).

  • ignore_data (bool) – If True, output only the disk model.

  • toTb (bool) – If True, convert output to brightness temperature.

  • rfreq (str) – Reference frequency string (e.g., ‘5.5GHz’) for Tb conversion.

  • add_limb (bool) – If True, add a bright limb to the disk.

  • bmaj (float) – Beam FWHM (deg) for limb width calculation.

Returns:

stats

Return type:

list of FluxComparison

suncasa.eovsa.eovsa_synoptic_imaging_pipeline_wsclean.disk_size_function(v, c1, alpha1)[source]

Analytic model for disk size as a function of frequency.

R(v) = c1 / v^(alpha1) + c2 / v^(alpha2)

Parameters:
  • v – float or array_like Frequency (e.g., in GHz).

  • c1 – float Coefficient for the first term.

  • alpha1 – float Exponent for the first term.

Returns:

Disk size at frequency v.

suncasa.eovsa.eovsa_synoptic_imaging_pipeline_wsclean.flux_function(v, c1, alpha1, c2, alpha2, c3, alpha3)[source]

Analytic model for disk flux as a function of frequency.

F(v) = c1 * v^(alpha1) + c2 * v^(alpha2) + c3 * v^(alpha3)

Parameters:
  • v – float or array_like Frequency (e.g., in GHz).

  • c1 – float Coefficient for the first term.

  • alpha1 – float Exponent for the first term.

  • c2 – float Coefficient for the second term.

  • alpha2 – float Exponent for the second term.

c3float

Coefficient for the third term.

alpha3float

Exponent for the third term.

Returns:

Disk flux at frequency v.

suncasa.eovsa.eovsa_synoptic_imaging_pipeline_wsclean.calc_diskmodel(tim, nbands, freq)[source]
suncasa.eovsa.eovsa_synoptic_imaging_pipeline_wsclean.ant_trange(vis)[source]

Figure out nominal times for tracking of old EOVSA antennas, and return time range in CASA format

suncasa.eovsa.eovsa_synoptic_imaging_pipeline_wsclean.format_spw(spw)[source]

Formats the spectral window (spw) string for file naming, ensuring start and end values are separated by a dash and zero-padded to two digits.

Parameters:

spw (str) – The spectral window in the format “start~end”, where start and end are integers.

Returns:

A formatted string with start and end values zero-padded to two digits, separated by a dash.

Return type:

str

class suncasa.eovsa.eovsa_synoptic_imaging_pipeline_wsclean.FrequencySetup(tim=None)[source]

Manages frequency setup based on observation date for radio astronomy imaging.

This class is initialized with an observation time and calculates essential frequency parameters such as effective observing frequencies (eofreq) and spectral windows (spws) based on the observation date. It provides methods to calculate reference frequency and bandwidth for given spectral windows.

Parameters:

tim (astropy.time.Time) – Observation time used to determine the frequency setup.

Attributes: - tim (astropy.time.Time): The observation time. - spw2band (numpy.ndarray): An array mapping spectral window indices to band numbers. - bandwidth (float): The bandwidth in GHz. - defaultfreq (numpy.ndarray): The default effective observing frequencies in GHz. - nbands (int): Number of bands. - eofreq (numpy.ndarray): Effective observing frequencies based on the observation time. - spws (list of str): Spectral window selections based on the observation time.

Example:

>>> from astropy.time import Time
>>> tim = Time('2022-01-01T00:00:00', format='isot')
>>> freq_setup = FrequencySetup(tim)
>>> crval, cdelt = freq_setup.get_reffreq_and_cdelt('5~10')
>>> print(crval, cdelt)
tim = None[source]
spw2band[source]
bandwidth = 0.325[source]
defaultfreq[source]
spws_indices = [][source]
get_reffreq_and_cdelt(spw, return_bmsize=False)[source]

Calculates the reference frequency (CRVAL) and the frequency delta (CDELT) for a given spectral window range.

This method takes a spectral window selection and computes the mean of the effective observing frequencies (eofreq) within that range as the reference frequency. It also calculates the bandwidth covered by the spectral window range as the frequency delta.

Parameters:
  • spw (str) – Spectral window selection, specified as a range ‘start~end’ or a single value.

  • return_bmsize (bool) – If True, return the beam size based on the reference frequency. Defaults to False.

Returns:

A tuple containing the reference frequency and frequency delta, both in GHz.

Return type:

(str, str)

Example:

>>> crval, cdelt = freq_setup.get_reffreq_and_cdelt('5~10')
>>> print(crval, cdelt)
get_bmsize(cfreq, refbmsize=75.0, reffreq=1.0, minbmsize=4.0)[source]

Calculate the beam size at given frequencies based on a reference beam size at a reference frequency. This function supports both single frequency values and lists of frequencies.

Parameters:
  • cfreq (float or list) – Input frequencies in GHz, can be a float or a list of floats.

  • refbmsize (float, optional) – Reference beam size in arcsec, defaults to 60.0.

  • reffreq (float, optional) – Reference frequency in GHz, defaults to 1.0.

  • minbmsize (float, optional) – Minimum beam size in arcsec, defaults to 4.0.

Returns:

Beam size at the given frequencies, same type as input (float or numpy array).

Return type:

float or numpy.ndarray

suncasa.eovsa.eovsa_synoptic_imaging_pipeline_wsclean.merge_FITSfiles(fitsfilesin, outfits, snr_weight=None, deselect_index=None, overwrite=True, snr_threshold=None, rms_threshold=None, showplt=False)[source]

Merges multiple FITS files into a single output file by calculating the mean of stacked data.

This function stacks the data from a list of input FITS files along a new axis, optionally applying exposure time weighting and suppression of on-disk residuals based on a threshold relative to the disk brightness temperature. The mean of the stacked data is then written to a specified output FITS file.

Parameters:
  • fitsfilesin (list of str) – List of file paths to the input FITS files to be merged.

  • outfits (str) – File path for the output FITS file where the merged data will be saved.

  • snr_weight (list of float, optional) – List of signal-to-noise ratios (SNRs) to use as weights for calculating the mean of the stacked data. If both exposure time and SNR weights are provided, the weights will be the product of the two. Defaults to None.

  • deselect_index (list of int, optional) – index of the images to be deselected. Defaults to None.

  • overwrite (bool, optional) – If True, the output file is overwritten if it already exists. Defaults to True.

  • snr_threshold (float, optional) – SNR threshold for selecting images to be deselected. Defaults to 10.

Raises:

ValueError – If any of the input FITS files cannot be read.

Return type:

None

Notes

The suppression of on-disk residuals is achieved by applying a sigmoid function to pixels within a specified range of the disk brightness temperature, effectively reducing the contribution of residuals while preserving the overall structure.

Examples

Merge three FITS files without exposure time weighting and with on-disk residual suppression:

>>> merge_FITSfiles(['sun_01.fits', 'sun_02.fits', 'sun_03.fits'], 'sun_merged.fits',
...                 overwrite=True)
class suncasa.eovsa.eovsa_synoptic_imaging_pipeline_wsclean.MSselfcal(msfile, time_intervals, time_intervals_major_avg, time_intervals_minor_avg, spw, N1, N2, workdir, image_marker='', niter=5000, gain=0.1, briggs=0.0, auto_mask=6, auto_threshold=3, maxuv_l=None, minuv_l=None, maxuvw_m=None, minuvw_m=None, data_column='CORRECTED_DATA', pols='XX', beam_size=None, circular_beam=True, no_negative=True, fits_mask=None, theoretic_beam=False, reftime_daily=None)[source]

A class for imaging using WSClean and selfcal visibility data.

This class facilitates the creation of images by imaging major intervals for WSClean imaging and applying solar differential rotation corrections to minor intervals (new model). the model will be written to the visibility data for selfcalibration.

Parameters:
  • msfile (str) – Path to the Measurement Set (MS) file.

  • time_intervals (list) – List of major time intervals.

  • time_intervals_major_avg (list) – Average times for major intervals.

  • time_intervals_minor_avg (list) – Average times for minor intervals within major intervals.

  • spw (str) – Spectral window index or range.

  • sp_index (str) – String representation of the spectral window indices.

  • N1 (int) – Number of major intervals.

  • N2 (int) – Number of minor intervals within each major interval.

  • workdir (str) – Directory for storing intermediate and output files.

  • image_marker (str, optional) – Optional marker to add to output image names, defaults to ‘’

  • niter (int, optional) – Maximum number of iterations for WSClean, defaults to 5000.

  • data_column (str, optional) – Column name in the MS file to process, defaults to “CORRECTED_DATA”.

  • beam_size (float, optional) – Beam size for imaging, defaults to None.

  • reftime_daily (astropy.Time, optional) – Reference time for daily rotation corrections, defaults to None.

Raises:
  • OSError – If any file operation fails.

  • Exception – For errors during heliocentric frame registration or rotation corrections.

Returns:

Path to the final model name string.

Return type:

str

msfile[source]
time_intervals[source]
time_intervals_major_avg[source]
time_intervals_minor_avg[source]
spw = ''[source]
N1[source]
N2[source]
workdir[source]
image_marker = ''[source]
niter = 5000[source]
gain = 0.1[source]
pols = 'XX'[source]
data_column = 'CORRECTED_DATA'[source]
beam_size = None[source]
reftime_daily = None[source]
model_minor_name_str = None[source]
model_ref_name_str = None[source]
briggs = 0.0[source]
maxuv_l = None[source]
minuv_l = None[source]
maxuvw_m = None[source]
minuvw_m = None[source]
auto_mask = 6[source]
auto_threshold = 3[source]
succeeded = True[source]
no_negative = True[source]
circular_beam = True[source]
fits_mask = None[source]
theoretic_beam = False[source]
run(imaging_only=False, predict=True, gen_minor_model=True, clearcache=True)[source]

Processes the visibility data and generates model images using WSClean.

This method performs the following steps: 1. Initial imaging to generate rough model images. 2. Rotate each model image to the corresponding minor time intervals. This step converts N1 images to N1*N2 images.

This model will be used for self-calibration and will be subtracted from the visibility data after self-calibration.

  1. Rotate each model image to 20 UT of the day (if the reference time daily is provided; otherwise, skip this step). This model will be added back to the visibility data.

  2. Predict visibilities based on the rotated models.

Parameters:
  • imaging_only (bool) – If True, only perform the initial imaging step and skip the rotation and prediction steps. Default is False.

  • predict (bool) – If True, predict visibilities based on the rotated models. Default is True.

  • gen_minor_model (bool) – If True, generate model images for minor time intervals. Default is True. If False, skip the rotation and prediction steps.

Raises:
  • OSError – If any file operation fails.

  • Exception – For errors during heliocentric frame registration or rotation corrections.

Returns:

Path to the final model name string.

Return type:

str

suncasa.eovsa.eovsa_synoptic_imaging_pipeline_wsclean.clean_junk(imname, junks=['dirty', 'model', 'psf', 'residual'])[source]

Clears junk files generated during the imaging process. :param imname: The base name of the image files to clean. :type imname: str :param junks: List of junk file suffixes to remove, defaults to [‘dirty’, ‘model’, ‘psf’, ‘residual’]. :type junks: list of str, optional

suncasa.eovsa.eovsa_synoptic_imaging_pipeline_wsclean._compute_round_intervals(wsclean_intervals, multiplier, base_interval=50, nintervals_minor=3)[source]

Compute time intervals for one self-cal round.

suncasa.eovsa.eovsa_synoptic_imaging_pipeline_wsclean._run_gaincal_step(msfile, workdir, spw, spwstr, antenna, caltbs, tdur, N1, N2, step_name, solint, calmode, refantmode='flex', uvrange='', gaintype='G', minsnr=1.0, overwrite_caltb=True)[source]

Run a single gaincal step with standard boilerplate.

suncasa.eovsa.eovsa_synoptic_imaging_pipeline_wsclean._run_slfcal_round(round_def, msfile, ri, spw, spwstr, workdir, antenna, caltbs, tdur, pols, bmsize, fits_mask_sidx, datacolumn, overwrite_caltb, uvmin_l_str_sidx, do_sbdcal=False, clearcache=True)[source]

Execute one round of feature self-calibration: image, gaincal, applycal.

Parameters:
  • round_def – Configuration dict from SELFCAL_ROUNDS.

  • ri – Interval dict from _compute_round_intervals().

  • datacolumn – Data column to use (may be overridden by round_def).

Returns:

(slfcal_obj, caltbs, datacolumn) tuple.

suncasa.eovsa.eovsa_synoptic_imaging_pipeline_wsclean._compute_uv_ranges(spws_indices, spws, freq, spwidx2proc)[source]

Compute per-band UV range strings for disk and feature self-calibration.

suncasa.eovsa.eovsa_synoptic_imaging_pipeline_wsclean._run_disk_selfcal(msfile, sidx, spw, spwstr, sp_index, workdir, antenna, caltbs, slfcal_init_obj, imname_init_disk_strlist, freq_setup, dsize, fdens, ri_init, ri_final, tdur, uvmin_l_str_sidx, overwrite_caltb, pols)[source]

Run disk self-calibration: predict disk model, gaincal, applycal, flag, uvsub.

suncasa.eovsa.eovsa_synoptic_imaging_pipeline_wsclean._run_final_imaging(msfile, sidx, spw, spwstr, sp_index, workdir, imgoutdir, msname, ri_final, briggs_val, bmsize, pols, reftime_daily, viz_timerange, date_str, is_segmented, imaging_objs, freq_setup, tr_series_time=None)[source]

Run final imaging (segmented or non-segmented) and return output FITS paths.

Parameters:

tr_series_time – List of (start_Time, end_Time) tuples to filter imaging intervals. If provided, only processes intervals overlapping with these ranges.

suncasa.eovsa.eovsa_synoptic_imaging_pipeline_wsclean.pipeline_run(vis, outputvis='', workdir=None, slfcaltbdir=None, imgoutdir=None, figoutdir=None, clearcache=False, clearlargecache=False, pols='XX', verbose=True, hanning=False, do_sbdcal=False, overwrite=False, overwrite_caltb=True, mergeFITSonly=False, niter_init=None, ncpu='auto', tr_series_imaging=None, spws_imaging=None)[source]

Executes the EOVSA data processing pipeline for solar observation data.

Parameters:
  • vis (str) – Path to the input measurement set (MS) data.

  • outputvis (str, optional) – Output path for the processed MS, defaults to an empty string.

  • workdir (str, optional) – Working directory for intermediate data, defaults to None which uses ‘./’.

  • slfcaltbdir (str, optional) – Directory for storing calibration tables, defaults to None.

  • imgoutdir (str, optional) – Output directory for image files, defaults to None.

  • figoutdir (str, optional) – Output directory for diagnostic figures, defaults to None.

  • clearcache (bool, optional) – If True, clears all cache files after processing, defaults to False.

  • clearlargecache (bool, optional) – If True, clears large cache files (model directories) after processing. When set, clearcache is forced to False. Defaults to False.

  • pols (str, optional) – Polarization types to process, defaults to ‘XX’.

  • verbose (bool, optional) – Enables verbose output during processing, defaults to True.

  • hanning (bool, optional) – If True, applies Hanning smoothing to the data, defaults to False.

  • do_sbdcal (bool) – Boolean flag to perform single-band delay calibration, defaults to False.

  • overwrite (bool, optional) – If True, overwrites existing files, defaults to False.

  • overwrite_caltb (bool, optional) – If True, overwrites existing calibration tables, defaults to True.

  • mergeFITSonly (bool, optional) – If True, skips all processing and only merges existing FITS files.

  • niter_init (int, optional) – Override number of iterations for the init self-cal round. If None, uses the value from SELFCAL_ROUNDS config.

  • ncpu (str or int, optional) – Number of CPUs for parallel processing. ‘auto’ uses all available cores.

  • tr_series_imaging (list, optional) – Time ranges for imaging as list of time range strings. If provided, only processes intervals that overlap with these ranges.

  • spws_imaging (list, optional) – Spectral windows to process. If provided, overrides the default spwidx2proc.

Returns:

Dictionary mapping spectral window index to output FITS file paths.

Return type:

dict

suncasa.eovsa.eovsa_synoptic_imaging_pipeline_wsclean.parser[source]