Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for Stokes U and V plots #122

Merged
merged 3 commits into from
Jan 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ $ shadems <msname>

### Changing the plot axes

* To change the plot axes you can provide selections via the `--xaxis` / `--yaxis` (or `-x` / `-y`) options. Existing Measurement Set columns (e.g. `DATA`, `CORRECTED_DATA`, `TIME`) as well as standard subsets and derivatives and (e.g. `CHAN`, `FREQ`, `U`, `V`) can be provided. Note the capitalised convention.
* To change the plot axes you can provide selections via the `--xaxis` / `--yaxis` (or `-x` / `-y`) options. Existing Measurement Set columns (e.g. `DATA`, `CORRECTED_DATA`, `TIME`) as well as standard subsets and derivatives and (e.g. `CHAN`, `FREQ`, `u`, `v`) can be provided. Note the capitalised convention.

```
$ shadems --xaxis FREQ --yaxis DATA:amp <msname>
Expand Down Expand Up @@ -127,7 +127,7 @@ The example below will produce a plot per field.
If no ``--field`` selection is provided, then `shadems` will iterate over all fields in the MS:

```
$ shadems --xaxis CORRECTED_DATA:real,UV --yaxis CORRECTED_DATA:imag,CORRECTED_DATA:amp --field 0,2 --corr XX,YY --iter-field <msname>
$ shadems --xaxis CORRECTED_DATA:real,uv --yaxis CORRECTED_DATA:imag,CORRECTED_DATA:amp --field 0,2 --corr XX,YY --iter-field <msname>
```

* You can also iterate over SPWs, scans, correlations and (coming soon) antennas.
Expand All @@ -137,7 +137,7 @@ $ shadems --xaxis CORRECTED_DATA:real,UV --yaxis CORRECTED_DATA:imag,CORRECTED_D
* If you want to see how well your model fits your data then you can subtract the `MODEL_DATA` column from the `CORRECTED_DATA` column prior to plotting. For example, to show this residual product on a uv-distance plot:

```
$ shadems --xaxis UV --yaxis CORRECTED_DATA-MODEL_DATA:amp --field 0 --corr XX,YY <msname>
$ shadems --xaxis uv --yaxis CORRECTED_DATA-MODEL_DATA:amp --field 0 --corr XX,YY <msname>
```

* ``CORRECTED_DATA/MODEL_DATA`` can also be useful. For the sake of completeness, ``*`` and ``+`` are also
Expand All @@ -150,7 +150,7 @@ points in the plot according to the selected colourmap. You can instruct `shadem
using the `--colour-by` switch. For example, to plot amplitude against uv-distance coloured by antenna 1:

```
$ shadems --xaxis UV --yaxis DATA:amp:XX --colour-by ANTENNA1 <msname>
$ shadems --xaxis uv --yaxis DATA:amp:XX --colour-by ANTENNA1 <msname>
```

* The `--colour-by` option also supports full MS columns as well as metadata, allowing for
Expand All @@ -159,7 +159,7 @@ you must specify explicit limits with ``--cmin`` and ``--cmax``.
For example, to make a u,v coverage plot colourised by the corrected visibility amplitudes in XX:

```
$ shadems --xaxis U --yaxis V --colour-by CORRECTED_DATA:amp:XX --cmin 0 --cmax 5 <msname>
$ shadems --xaxis u --yaxis v --colour-by CORRECTED_DATA:amp:XX --cmin 0 --cmax 5 <msname>
```

---
Expand All @@ -180,13 +180,14 @@ Plot types and data sources:
-x XAXIS, --xaxis XAXIS
X axis of plot, e.g. "amp:CORRECTED_DATA" This
recognizes all column names (also CHAN, FREQ, CORR,
ROW, WAVEL, U, V, W, UV), and, for complex columns,
ROW, WAVEL, u, v, w, uv), and, for complex columns,
keywords such as 'amp', 'phase', 'real', 'imag'. You
can also specify correlations, e.g. 'DATA:phase:XX',
and do two-column arithmetic with "+-*/", e.g. 'DATA-
MODEL_DATA:amp'. Correlations may be specified by
label, number, or as a Stokes parameter. The order of
specifiers does not matter.
MODEL_DATA:amp'. Correlations may be specified by label,
number, or as a Stokes parameter (upper case is required
to avoid ambiguity with baseline coordinates). The order
of specifiers does not matter
-y YAXIS, --yaxis YAXIS
Y axis to plot. Must be given the same number of times
as --xaxis. Note that X/Y can employ different columns
Expand Down
5 changes: 3 additions & 2 deletions shade_ms/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,12 @@ def cli():
group_opts = parser.add_argument_group("Plot types and data sources")
group_opts.add_argument("-x", "--xaxis", action="append",
help="""X axis of plot, e.g. "amp:CORRECTED_DATA"
This recognizes all column names (also CHAN, FREQ, CORR, ROW, WAVEL, U, V, W, UV)
This recognizes all column names (also CHAN, FREQ, CORR, ROW, WAVEL, u, v, w, uv)
and, for complex columns, keywords such as 'amp', 'phase', 'real', 'imag'.
You can also specify correlations, e.g. 'DATA:phase:XX',
and do two-column arithmetic with "+-*/", e.g. 'DATA-MODEL_DATA:amp'.
Correlations may be specified by label, number, or as a Stokes parameter.
Correlations may be specified by label, number, or as a Stokes parameter
(upper case is required to avoid ambiguity with baseline coordinates).
The order of specifiers does not matter.""")
group_opts.add_argument("-y", "--yaxis", action="append",
help="""Y axis to plot.
Expand Down
8 changes: 4 additions & 4 deletions shade_ms/data_mappers.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,15 @@ def __init__(self, fullname, unit, mapper, column=None, extras=[], conjugate=Fal
CHAN = DataMapper("channel", "", column=False, axis=1, extras=["chans"], mapper=lambda x,chans: chans, const=True),
FREQ = DataMapper("frequency", "Hz", column=False, axis=1, extras=["freqs"], mapper=lambda x, freqs: freqs, const=True),
WAVEL = DataMapper("wavelength", "m", column=False, axis=1, extras=["wavel"], mapper=lambda x, wavel: wavel, const=True),
UV = DataMapper("uv-distance", "wavelengths", column="UVW", extras=["wavel"],
uv = DataMapper("uv-distance", "wavelengths", column="UVW", extras=["wavel"],
mapper=lambda uvw, wavel: da.sqrt((uvw[:,:2]**2).sum(axis=1))/wavel),
U = DataMapper("u", "wavelengths", column="UVW", extras=["wavel"],
u = DataMapper("u", "wavelengths", column="UVW", extras=["wavel"],
mapper=lambda uvw, wavel: uvw[:, 0] / wavel,
conjugate=True),
V = DataMapper("v", "wavelengths", column="UVW", extras=["wavel"],
v = DataMapper("v", "wavelengths", column="UVW", extras=["wavel"],
mapper=lambda uvw, wavel: uvw[:, 1] / wavel,
conjugate=True),
W = DataMapper("w", "wavelengths", column="UVW", extras=["wavel"],
w = DataMapper("w", "wavelengths", column="UVW", extras=["wavel"],
mapper=lambda uvw, wavel: uvw[:, 2] / wavel,
conjugate=True),
)
Expand Down
Loading