Skip to content
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
41 changes: 35 additions & 6 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ Features on the road map:

If you are interested, have feature requests, or encounter issues, consider creating an `Issue <https://github.com/mtazzari/uvplot/issues>`_ or writing me an `email <marco.tazzari@gmail.com>`_. I am happy to have your feedback!


Installation
------------

Expand Down Expand Up @@ -67,20 +66,21 @@ Features
--------

**1) Plotting visibilities**
=========================
============================
This is an example plot:

.. image:: docs/images/uvplot.png
:width: 60 %
:alt: example uv plot
:align: center

created with:
created with uvplot:

.. code-block:: py

import numpy as np
from uvplot import UVTable, arcsec
from uvplot import COLUMNS_V0 # use uvplot >= 0.2.6

wle = 0.88e-3 # Observing wavelength [m]

Expand All @@ -91,11 +91,11 @@ created with:

uvbin_size = 30e3 # uv-distance bin [wle]

uv = UVTable(filename='uvtable.txt', wle=wle)
uv = UVTable(filename='uvtable.txt', wle=wle, columns=COLUMNS_V0)
uv.apply_phase(dRA, dDec)
uv.deproject(inc, PA)

uv_mod = UVTable(filename='uvtable_mod.txt', wle=wle)
uv_mod = UVTable(filename='uvtable_mod.txt', wle=wle, COLUMNS_V0)
uv_mod.apply_phase(dRA=dRA, dDec=dDec)
uv_mod.deproject(inc=inc, PA=PA)

Expand All @@ -104,8 +104,37 @@ created with:

axes[0].figure.savefig("uvplot.png")

From version v0.2.6 it is necessary to provide the `columns` parameter
when reading an ASCII uvtable. The `columns` parameter can be specified
either as a parameter to the `UVTable()` command, or as the **2nd** line
in the ASCII file. The available `columns` formats are:

.. code-block:: bash

FORMAT COLUMNS COLUMNS_LINE (copy-paste as 2nd line in the ASCII file)
COLUMNS_V0 ['u', 'v', 'Re', 'Im', 'weights'] '# Columns u v Re Im weights'
COLUMNS_V1 ['u', 'v', 'Re', 'Im', 'weights', 'freqs', 'spws'] '# Columns u v Re Im weights freqs spws'
COLUMNS_V2 ['u', 'v', 'V', 'weights', 'freqs', 'spws'] '# Columns u v V weights freqs spws'

To import an ASCII uvtable with 5 columns with uvplot < 0.2.6:

.. code-block:: py

from uvplot import UVTable
uvt = UVTable(filename='uvtable.txt', format='ascii', columns=COLUMNS_V0)


and with uvplot >= 0.2.6:

.. code-block:: py

from uvplot import UVTable
from uvplot import COLUMNS_V0 # ['u', 'v', 'Re', 'Im', 'weights']
uvt = UVTable(filename='uvtable.txt', format='ascii', columns=COLUMNS_V0)


**2) Exporting visibilities** from MS table to uvtable (ASCII)
===========================================================
==============================================================
Once installed **uvplot** inside CASA (see instructions above),
it is possible to export the visibilities in `mstable.ms` to an ASCII table by executing these lines **from a CASA shell**:

Expand Down
101 changes: 1 addition & 100 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,107 +3,8 @@
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.

.. include:: ../README.rst

=========
|uvplot|
=========
A simple package to make nice plots of deprojected interferometric visibilities, often called **uvplots**.
It can be installed inside the `NRAO CASA package <https://casa.nrao.edu/>`_ (see instructions below) and has functionalities to export visibilities from the MS Table format to ASCII.

The current version implements the basic plotting functionality.

Features on the road map:
- better handling of multiple spectral windows during visibilities export;
- new functionality to import visibilities from ASCII to MS Table.

If you are interested, have feature requests, or encounter issues, consider creating an `Issue <https://github.com/mtazzari/uvplot/issues>`_ or writing me an `email <marco.tazzari@gmail.com>`_. I am happy to have your feedback!


Attribution
-----------
If you use **uvplot** for your publication, please cite the `Zenodo reference <https://zenodo.org/badge/latestdoi/105298533>`_ ::

@misc{uvplot_mtazzari,
author = {Marco Tazzari},
title = {mtazzari/uvplot: v0.1.1},
month = oct,
year = 2017,
doi = {10.5281/zenodo.1003113},
url = {https://doi.org/10.5281/zenodo.1003113}
}


License
-------
**uvplot** is free software licensed under the LGPLv3 License. For more details see the LICENSE.
© Copyright 2018 Marco Tazzari.


Changelog
---------
- **v0.2.2**: a new export visibilities option in UVTable.plot(), automatically mask empty uv-bins, bugfixes.
- **v0.2.0**: a new `export_uvtable` function to export visibilities from an MS to an ASCII table.


Installation
------------

**uvplot** works on `Python` >=2.7 and >=3.6 and can be installed with:

.. code-block :: bash

pip install uvplot

To make **uvplot** available in CASA, run from the shell:

.. code-block :: bash

casa-pip install uvplot

where `casa-pip` is a tool that can be downloaded `here <https://github.com/radio-astro-tools/casa-python>`_ .

**uvplot** has been tested on CASA versions >= 4.7.0.

Example
-------
This is an example plot:

.. image:: images/uvplot.png
:width: 60 %
:alt: example uv plot
:align: center

created with:

.. code-block:: py

import numpy as np
from uvplot import UVTable, arcsec

wle = 0.88e-3 # Observing wavelength [m]

dRA = 0.3 * arcsec # Delta Right Ascension offset [rad]
dDec = 0.07 * arcsec # Delta Declination offset [rad]
inc = np.radians(73.) # Inclination [rad]
PA = np.radians(59) # Position Angle [rad]

uvbin_size = 30e3 # uv-distance bin [wle]

uv = UVTable(filename='uvtable.txt', wle=wle)
uv.apply_phase(dRA, dDec)
uv.deproject(inc, PA)

uv_mod = UVTable(filename='uvtable_mod.txt', wle=wle)
uv_mod.apply_phase(dRA=dRA, dDec=dDec)
uv_mod.deproject(inc=inc, PA=PA)

axes = uv.plot(label='Data', uvbin_size=uvbin_size)
uv_mod.plot(label='Model', uvbin_size=uvbin_size, axes=axes, yerr=False, linestyle='-', color='r')

axes[0].figure.savefig("uvplot.png")


© Copyright 2018 Marco Tazzari.

.. Contents
--------
Expand Down
2 changes: 1 addition & 1 deletion uvplot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@
if matplotlib.get_backend().lower() == 'macosx':
matplotlib.use('TkAgg')

from .uvtable import UVTable
from .uvtable import UVTable, COLUMNS_V0, COLUMNS_V1, COLUMNS_V2
from .io import export_uvtable
from .constants import arcsec
2 changes: 1 addition & 1 deletion uvplot/_version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '0.2.5'
__version__ = '0.2.6'
13 changes: 8 additions & 5 deletions uvplot/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
from numpy.testing import assert_allclose

from uvplot import UVTable
from .uvtable import COLUMNS_V0


def create_sample_uvtable(uvtable_filename):
u = np.random.randn(10000)*1e4 # m
Expand All @@ -22,6 +24,7 @@ def create_sample_uvtable(uvtable_filename):

return (u, v, re, im, w), wle


def test_init_uvtable():

uvtable_filename = "/tmp/uvtable.txt"
Expand All @@ -30,12 +33,12 @@ def test_init_uvtable():

# test reading from file
# format='uvtable'
uvt_file = UVTable(filename=uvtable_filename, wle=wle)
uvt_file = UVTable(filename=uvtable_filename, wle=wle, columns=COLUMNS_V0)

# test providing uvtable tuple
# takes u, v in units of observing wavelength
uvt_uvtable1 = UVTable(uvtable=(u, v, re, im, w), wle=wle)
uvt_uvtable2 = UVTable(uvtable=(u/wle, v/wle, re, im, w))
uvt_uvtable1 = UVTable(uvtable=(u, v, re, im, w), wle=wle, columns=COLUMNS_V0)
uvt_uvtable2 = UVTable(uvtable=(u/wle, v/wle, re, im, w), columns=COLUMNS_V0)

reference = np.hypot(u/wle, v/wle)

Expand All @@ -49,7 +52,7 @@ def test_deproject():
uvtable_filename = "/tmp/uvtable.txt"
uvtable, wle = create_sample_uvtable(uvtable_filename)

uv = UVTable(filename=uvtable_filename, wle=wle)
uv = UVTable(filename=uvtable_filename, wle=wle, columns=COLUMNS_V0)

inc = np.radians(30)
uv_30 = uv.deproject(inc, inplace=False)
Expand All @@ -65,7 +68,7 @@ def test_uvcut():
uvtable_filename = "/tmp/uvtable.txt"
uvtable, wle = create_sample_uvtable(uvtable_filename)

uv = UVTable(filename=uvtable_filename, wle=wle)
uv = UVTable(filename=uvtable_filename, wle=wle, columns=COLUMNS_V0)

maxuv = 5e3
uvt = uv.uvcut(maxuv)
Expand Down
Loading