Skip to content

Commit

Permalink
spellllinnnnggggg
Browse files Browse the repository at this point in the history
  • Loading branch information
tgalvin committed Aug 9, 2024
1 parent e78299c commit fc182fb
Show file tree
Hide file tree
Showing 11 changed files with 53 additions and 53 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ command line. They are listed below with a brief description:
- `flint_potato`: Attempt to peel out known sources from a measurement set using
[potatopeel](https://gitlab.com/Sunmish/potato/-/tree/main). Criteria used to
assess which sources to peel is fairly minimumal, and at the time of writing
only the reference set of sources paackaged within `flint` are
only the reference set of sources packaged within `flint` are
considered. -`flint_archive`: Operations around archiving and copying final
data products into place. -`flint_catalogue`: Download reference catalogues
that are expected by `flint`
Expand Down Expand Up @@ -152,15 +152,15 @@ corresponding options defined in the `defaults` scope.

`flint_config` can be used to generate a template file, which can then be
tweaked. The template file uses YAML to define scope and settings. So, use the
YAML standard when modifying this file. There are primative verification
YAML standard when modifying this file. There are primitive verification
functions to ensure the modified template file is correctly form.

## CLI Configuration file

To help manage (and avoid) long CLI calls to conffigure `flint`, most command
To help manage (and avoid) long CLI calls to configure `flint`, most command
line options may be dumped into a new-line delimited text file which can then be
set as the `--cli-config` option of some workflows. See the `configargparse`
python utility to read up on more on how options may be overridden if speficied
python utility to read up on more on how options may be overridden if specified
in both the text file and CLI call.

## Validation Plots
Expand Down
12 changes: 6 additions & 6 deletions flint/bptools/preflagger.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class PhaseOutlierResults(NamedTuple):
unwrapped_residual_std: float
"""The std. of the residual unwrapped phases in radians"""
flag_cut: float
"""The adopted signifance level that a outlier should be before outlier_mask is set to True"""
"""The adopted significance level that a outlier should be before outlier_mask is set to True"""


# TODO: Pass in parameters directly so we don't have to have an instance of PhaseOutlierResults
Expand All @@ -63,7 +63,7 @@ def plot_phase_outlier(
Returns:
Path: Path of the output image file
"""
logger.debug(f"Creating phase outlier plot, writting {str(output_path)}.")
logger.debug(f"Creating phase outlier plot, writing {str(output_path)}.")

complex_gains = phase_outlier_results.complex_gains
init_model_gains = phase_outlier_results.init_model_gains
Expand Down Expand Up @@ -315,7 +315,7 @@ def flags_over_threshold(
), f"The provided {thresh=} should be a fraction between 0 to 1. "

number_flagged = np.sum(flags)
# Use the shape incase multi-dimensional array passed in
# Use the shape in case multi-dimensional array passed in
total_flagged = np.prod(flags.shape)

frac_flagged = number_flagged / total_flagged
Expand Down Expand Up @@ -397,7 +397,7 @@ def flag_mean_residual_amplitude(
Args:
complex_gains (np.ndarray): The set of complex gains to be considered
use_robust (bool, optional): Whether to use robust statistics (median, MAD) or mean/std to calculate the statistic against. Defaults to True.
polynomical_order (int, optional): The order of the polynomical (numpy.polyfit) to use to compute the baseline. Defaults to 5.
polynomical_order (int, optional): The order of the polynomial (numpy.polyfit) to use to compute the baseline. Defaults to 5.
plot_path (Path): The location to save the output file to
plot_title (Optional[str], optional): Title to add to the figure. Defaults to None.
Expand All @@ -416,7 +416,7 @@ def flag_mean_residual_amplitude(
poly_vals = np.polyval(poly_coeffs, idxs)

residual = amplitudes - poly_vals
# Although the mask above should be sufficent, trust nothing
# Although the mask above should be sufficient, trust nothing
mask = np.isfinite(residual)

# TODO: Consider use of an iterative clipping method
Expand Down Expand Up @@ -514,7 +514,7 @@ def construct_mesh_ant_flags(mask: np.ndarray) -> np.ndarray:

assert (
len(mask.shape) == 3
), f"Expect array of shape (ant, chnnel, pol), received {mask.shape=}"
), f"Expect array of shape (ant, channel, pol), received {mask.shape=}"
accumulate_mask = np.zeros_like(mask[0], dtype=bool)

nant = mask.shape[0]
Expand Down
16 changes: 8 additions & 8 deletions flint/bptools/smoother.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,19 @@
def divide_bandpass_by_ref_ant_preserve_phase(
complex_gains: np.ndarray, ref_ant: int
) -> np.ndarray:
"""Divide the bandpass compelx gains (solved for initially by something like
"""Divide the bandpass complex gains (solved for initially by something like
calibrate) by a nominated reference antenna. In the case of ``calibrate``
there is no implicit reference antenna. This is valid for cases where the
xy-phase is set to 0 (true via the ASKAP on-dish calibrator).
This particular function is most appropriate for the `calibrate` style
solutions, which solve for the Jones in one step. In HMS notation this
are normally split into two separate 2x2 matricies, one for the gains
are normally split into two separate 2x2 matrices, one for the gains
with zero off-diagonal elements and a leakage matrix with ones on
the diagonal.
This is the preferred function to use whena attempting to set a
phase reference antenna to precomuted Jones bandpass solutions.
phase reference antenna to precomputed Jones bandpass solutions.
The input complex gains should be in the form:
>> (ant, channel, pol)
Expand Down Expand Up @@ -51,7 +51,7 @@ def divide_bandpass_by_ref_ant_preserve_phase(
f"Dividing bandpass gain solutions using reference antenna={ref_ant}, using correct phasor"
)

# Unpack the valuse for short hand use
# Unpack the values for short hand use
g_x = complex_gains[:, :, 0]
g_xy = complex_gains[:, :, 1]
g_yx = complex_gains[:, :, 2]
Expand Down Expand Up @@ -89,7 +89,7 @@ def divide_bandpass_by_ref_ant_preserve_phase(


def divide_bandpass_by_ref_ant(complex_gains: np.ndarray, ref_ant: int) -> np.ndarray:
"""Divide the bandpass compelx gains (solved for initially by something like
"""Divide the bandpass complex gains (solved for initially by something like
calibrate) by a nominated reference antenna. In the case of ``calibrate``
there is no implicit reference antenna.
Expand Down Expand Up @@ -121,7 +121,7 @@ def divide_bandpass_by_ref_ant(complex_gains: np.ndarray, ref_ant: int) -> np.nd
f"Dividing bandpass gain solutions using reference antenna={ref_ant} with shifted phasor"
)

# Make a copy of the data to avoid editing it whereever else it might be.
# Make a copy of the data to avoid editing it wherever else it might be.
# Trust nothing you pirate.
complex_gains = complex_gains.copy()

Expand Down Expand Up @@ -191,9 +191,9 @@ def smooth_data(
# This is the filling in of the blanks
data[mask] = d_interp

# Now we smooth. This savgol filter fits a polynomial to succesive subsets of data
# Now we smooth. This savgol filter fits a polynomial to successive subsets of data
# in a manner similar to a box car. The final positional argument here denoted the
# behavour of the edge where the window (second positional argument) does not have
# behaviour of the edge where the window (second positional argument) does not have
# enough data. This process is similar to the original implemented in bptools, except
# here we are using a polynomial, not a set of harmonic basis functions.
smoothed_data = savgol_filter(data, window_size, polynomial_order)
Expand Down
6 changes: 3 additions & 3 deletions flint/coadd/linmos.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class LinmosCommand(NamedTuple):
cmd: str
"""The yandasoft linmos task that will be executed"""
parset: Path
"""The output location that the generated linmos parset has been writen to"""
"""The output location that the generated linmos parset has been written to"""
image_fits: Path
"""Path to the output linmos image created (or will be). """

Expand Down Expand Up @@ -262,7 +262,7 @@ def generate_linmos_parameter_set(
weight_list (str, optional): If not None, this string will be embedded into the yandasoft linmos parset as-is. It should represent the formatted string pointing to weight files, and should be equal length of the input images. If None it is internally generated. Defaults to None.
holofile (Optional[Path], optional): Path to a FITS cube produced by the holography processing pipeline. Used by linmos to appropriate primary-beam correct the images. Defaults to None.
cutoff (float, optional): Pixels whose primary beam attenuation is below this cutoff value are blanked. Defaults to 0.001.
pol_axis (Optional[float], optional): The physical orientation of the ASKAP third-axis. This is provided (with some assumptions about the orientation of the holography) to correctly rotate the attentuation of the beams when coadding. If None we hope for the best. Defaults to None.
pol_axis (Optional[float], optional): The physical orientation of the ASKAP third-axis. This is provided (with some assumptions about the orientation of the holography) to correctly rotate the attenuation of the beams when coadding. If None we hope for the best. Defaults to None.
overwrite (bool, optional): If True and the parset file already exists, overwrite it. Otherwise a FileExistsError is raised should the parset exist. Defaults to True.
Returns:
Expand Down Expand Up @@ -317,7 +317,7 @@ def generate_linmos_parameter_set(
# f"linmos.beamangle = {beam_angle_list}\n"
f"linmos.imagetype = fits\n"
f"linmos.outname = {str(parent_dir / linmos_names.image_fits.stem)}\n"
f"linmos.outweight = {str(parent_dir / linmos_names.weight_fits.stem)}\n"
f"linmos.outweigh = {str(parent_dir / linmos_names.weight_fits.stem)}\n"
f"# For ASKAPsoft>1.3.0\n"
f"linmos.useweightslog = true\n"
f"linmos.weighttype = Combined\n"
Expand Down
8 changes: 4 additions & 4 deletions flint/flagging.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class AOFlaggerCommand(NamedTuple):
ms: MS
"""The MS object that was flagged"""
strategy_file: Optional[Path] = None
"""The path to the aoflagging stategy file to use"""
"""The path to the aoflagging strategy file to use"""


def flag_ms_zero_uvws(ms: MS, chunk_size: int = 10000) -> MS:
Expand Down Expand Up @@ -82,7 +82,7 @@ def nan_zero_extreme_flag_ms(
) -> MS:
"""Will flag a MS based on NaNs or zeros in the nominated data column of a measurement set.
These NaNs might be introduced into a column via the application of a applysolutions task.
Zeros might be introduced by the correlator dropping cycles and not appropriately settting the
Zeros might be introduced by the correlator dropping cycles and not appropriately setting the
corresponding FLAG column (although this might have been fixed).
There is also an optional component to flag based on extreme Stokes-V values.
Expand Down Expand Up @@ -181,7 +181,7 @@ def create_aoflagger_cmd(ms: MS) -> AOFlaggerCommand:
flagging_strategy = get_packaged_resource_path(
package="flint.data.aoflagger", filename="ASKAP.lua"
)
logger.info(f"Flagging using the stategy file {flagging_strategy}")
logger.info(f"Flagging using the strategy file {flagging_strategy}")

cmd = f"aoflagger -column {ms.column} -strategy {flagging_strategy} -v {str(ms.path.absolute())}"

Expand Down Expand Up @@ -316,7 +316,7 @@ def get_parser() -> ArgumentParser:
)

nan_zero_parser = subparser.add_parser(
"nanflag", help="Flag visibilities tthat are either NaN or zeros. "
"nanflag", help="Flag visibilities that are either NaN or zeros. "
)
nan_zero_parser.add_argument(
"ms", type=Path, help="The measurement set that will be flagged. "
Expand Down
10 changes: 5 additions & 5 deletions flint/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ class FieldOptions(NamedTuple):
to contain properties of the data that are being processed,
rather how those data will be processed.
These settins are not meant to be adjustable throughout
These settings are not meant to be adjustable throughout
rounds of self-calibration.
"""

Expand Down Expand Up @@ -123,15 +123,15 @@ class FieldOptions(NamedTuple):
no_imaging: bool = False
"""Whether to skip the imaging process (including self-calibration)"""
reference_catalogue_directory: Optional[Path] = None
"""Path to the directory container the refernce catalogues, used to generate valiation plots"""
"""Path to the directory container the reference catalogues, used to generate validation plots"""
linmos_residuals: bool = False
"""Linmos the cleaning residuals together into a field image"""
beam_cutoff: float = 150
"""Cutoff in arcseconds to use when calculating the common beam to convol to"""
fixed_beam_shape: Optional[List[float]] = None
"""Specify the final beamsize of linmos field images in (arcsec, arcsec, deg)"""
pb_cutoff: float = 0.1
"""Primary beam attentuation cutoff to use during linmos"""
"""Primary beam attenuation cutoff to use during linmos"""
use_preflagger: bool = True
"""Whether to apply (or search for solutions with) bandpass solutions that have gone through the preflagging operations"""
use_smoothed: bool = False
Expand All @@ -147,9 +147,9 @@ class FieldOptions(NamedTuple):
sbid_copy_path: Optional[Path] = None
"""Path that final processed products will be copied into. If None no copying of file products is performed. See ArchiveOptions. """
rename_ms: bool = False
"""Rename MSs throught rounds of imaging and self-cal instead of creating copies. This will delete data-columns throughout. """
"""Rename MSs throughout rounds of imaging and self-cal instead of creating copies. This will delete data-columns throughout. """
stokes_v_imaging: bool = False
"""Specifies whether Stokes-V imaging will be carried out after the final round of imagin (whether or not self-calibration is enabled). """
"""Specifies whether Stokes-V imaging will be carried out after the final round of imagine (whether or not self-calibration is enabled). """

def with_options(self, **kwargs) -> FieldOptions:
_dict = self._asdict()
Expand Down
10 changes: 5 additions & 5 deletions flint/selfcal/casa.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ class GainCalOptions(NamedTuple):
gaintype: str = "G"
"""The gain type that would be solved for. """
nspw: int = 1
"""The number of spectral windows to use during the self-calibration rountine. If 1, no changes
"""The number of spectral windows to use during the self-calibration routine. If 1, no changes
are made to the measurement set. If more than 1, then the measurement will be reformed to form
a new measurement set conforming to the number of spws set. This process can be fragile as the
casa tasks sometimes do not like the configurate, so ye warned."""
casa tasks sometimes do not like the configure, so ye warned."""

def with_options(self, **kwargs) -> GainCalOptions:
_dict = self._asdict()
Expand Down Expand Up @@ -194,7 +194,7 @@ def merge_spws_in_ms(ms_path: Path) -> Path:
set using the `cvel` casa task. This can be a little fragile.
The `cvel` task creates a new measurement set, so there would
temporially be a secondary measurment set.
temporially be a secondary measurement set.
Args:
ms_path (Path): The measurement set that should have its SPWs merged together.
Expand Down Expand Up @@ -261,7 +261,7 @@ def gaincal_applycal_ms(
# Pirates like easy things though.
cal_ms = copy_and_clean_ms_casagain(ms=ms, round=round, rename_ms=rename_ms)

# Archive straight after copying incase we skip the gaincal and return
# Archive straight after copying in case we skip the gaincal and return
if archive_input_ms and not rename_ms:
zip_folder(in_path=ms.path)

Expand Down Expand Up @@ -317,7 +317,7 @@ def gaincal_applycal_ms(

# This is used for when a frequency dependent self-calibration solution is requested
# It is often useful (mandatory!) to have a single spw for some tasks - both of the casa
# and everyone else varity.
# and everyone else variety.
if gain_cal_options.nspw > 1:
# putting it all back to a single spw
cal_ms_path = merge_spws_in_ms(ms_path=cal_ms.path)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_aocalibrate.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ def test_known_bad_sols(ao_sols_known_bad):

def test_sols_same_with_plots(ao_sols_known_bad):
# Had a thought at one point the plktting was updating th mutable numpy array before
# it was writen back to file. Wrote the test, and it passed. Test stays
# it was written back to file. Wrote the test, and it passed. Test stays
a = flag_aosolutions(
solutions_path=ao_sols_known_bad, plot_solutions_throughout=False
)
Expand Down
28 changes: 14 additions & 14 deletions tests/test_configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ def strategy(tmpdir):
output_yaml=Path(tmpdir) / "example.yaml", selfcal_rounds=3
)

strat = load_strategy_yaml(input_yaml=output, verify=False)
strategy = load_strategy_yaml(input_yaml=output, verify=False)

return strat
return strategy


@pytest.fixture
Expand Down Expand Up @@ -88,7 +88,7 @@ def test_verify_options_with_class_operations(package_strategy_operations):


def test_verify_getoptions_with_class_operations(package_strategy_operations):
"""Check whether the get options inteface works with the operations
"""Check whether the get options interface works with the operations
section of the strategy file"""
strategy = package_strategy_operations
verify_configuration(input_strategy=strategy)
Expand Down Expand Up @@ -132,7 +132,7 @@ def test_verify_options_with_class(package_strategy):


def test_create_yaml_file(tmpdir):
# ensure a default yaml stategy can be created
# ensure a default yaml strategy can be created
output = create_default_yaml(
output_yaml=Path(tmpdir) / "example.yaml", selfcal_rounds=3
)
Expand All @@ -148,11 +148,11 @@ def test_create_and_load(tmpdir):

assert output.exists()

strat = load_strategy_yaml(input_yaml=output)
assert isinstance(strat, Strategy)
strategy = load_strategy_yaml(input_yaml=output)
assert isinstance(strategy, Strategy)

strat = load_strategy_yaml(input_yaml=output, verify=False)
assert isinstance(strat, Strategy)
strategy = load_strategy_yaml(input_yaml=output, verify=False)
assert isinstance(strategy, Strategy)


def test_verify(tmpdir):
Expand All @@ -163,22 +163,22 @@ def test_verify(tmpdir):
)

assert output.exists()
strat = load_strategy_yaml(input_yaml=output, verify=False)
assert isinstance(strat, Strategy)
strategy = load_strategy_yaml(input_yaml=output, verify=False)
assert isinstance(strategy, Strategy)

_ = verify_configuration(input_strategy=strat)
_ = verify_configuration(input_strategy=strategy)

strat["ddd"] = 123
strategy["ddd"] = 123
with pytest.raises(ValueError):
verify_configuration(input_strategy=strat)
verify_configuration(input_strategy=strategy)


def test_load_yaml_none():
# make sure an error is raise if None is passed in. This
# should be checked as the default value of FieldOptions.imaging_strategy
# is None.
with pytest.raises(TypeError):
_ = load_strategy_yaml(input_yaml=None)
_ = load_strategy_yaml(input_yaml=None) # type: ignore


def test_mode_options_mapping_creation():
Expand Down
2 changes: 1 addition & 1 deletion tests/test_linmos_coadd.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Tests related to components in the yandasoft linmos coadd.
At the moment this is not testing the actual application. Just
some of trhe helper functions around it.
some of the helper functions around it.
"""

from pathlib import Path
Expand Down
4 changes: 2 additions & 2 deletions tests/test_potato.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def ms_example(tmpdir):


def test_source_in_image_fov():
"""Test to see if souce is within an image FoV"""
"""Test to see if source is within an image FoV"""
# This comes from a test wsclean produced image. Not sure
# why or how a minus crval1 has come out.
wcs_dict = dict(
Expand Down Expand Up @@ -204,7 +204,7 @@ def test_load_peel_sources():


def test_pb_models():
"""See if the respones can be loaded and executed"""
"""See if the responses can be loaded and executed"""
freq = 1.0 * u.GHz
aperture = 12 * u.m
offset = np.arange(0, 200) * u.arcmin
Expand Down

0 comments on commit fc182fb

Please sign in to comment.