Repository: RadioAstronomySoftwareGroup/pyuvdata

Issue:
UVCal objects don't use x_orientation properly
This occurs twice.

https://github.com/RadioAstronomySoftwareGroup/pyuvdata/blob/fb15b4a3f1546da06ba2531e04455eb3e6d9a7ea/pyuvdata/uvcal.py#L764

https://github.com/RadioAstronomySoftwareGroup/pyuvdata/blob/fb15b4a3f1546da06ba2531e04455eb3e6d9a7ea/pyuvdata/uvcal.py#L780

Both times, `jstr2num` should use `self.x_orientation` to allow for queries with `Jee` or `Jnn` in `get_gains()`, `get_flags()`, and `get_qualities()`.

Discussion:
jsdillon: Thanks for a super quick review @bhazelton!

Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index bf6fdbd7..1b3a4981 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -8,6 +8,7 @@ All notable changes to this project will be documented in this file.
 - `utils.apply_uvflag` for applying UVFlag objects to UVData objects
 
 ### Fixed
+- A bug in `UVCal` objects that prevented them from properly getting data with `ee`/`nn`-style polarizations.
 - a bug in `UVFlag` where `x_orientation` was not set during initialization.
 - A bug in `UVCal.read_fhd_cal` that caused calibration solutions to be approximately doubled.
 - A bug in UVFlag where polarization array states were not updated when using `force_pol` keyword in `to_antenna` and `to_baseline`
diff --git a/ci/pyuvdata_linting.yml b/ci/pyuvdata_linting.yml
index 2313fca0..f1a7a055 100644
--- a/ci/pyuvdata_linting.yml
+++ b/ci/pyuvdata_linting.yml
@@ -4,6 +4,7 @@ channels:
   - conda-forge
 dependencies:
   - flake8
+  - pip
   - pip:
     - flake8-docstrings
     - flake8-pytest
diff --git a/pyuvdata/uvcal.py b/pyuvdata/uvcal.py
index 94943034..e04d1ab8 100644
--- a/pyuvdata/uvcal.py
+++ b/pyuvdata/uvcal.py
@@ -761,7 +761,7 @@ class UVCal(UVBase):
             Index in data arrays
         """
         if isinstance(jpol, (str, np.str)):
-            jpol = uvutils.jstr2num(jpol)
+            jpol = uvutils.jstr2num(jpol, x_orientation=self.x_orientation)
 
         if not self._has_key(jpol=jpol):
             raise ValueError("{} not found in jones_array".format(jpol))
@@ -777,7 +777,7 @@ class UVCal(UVBase):
                 return False
         if jpol is not None:
             if isinstance(jpol, (str, np.str)):
-                jpol = uvutils.jstr2num(jpol)
+                jpol = uvutils.jstr2num(jpol, x_orientation=self.x_orientation)
             if jpol not in self.jones_array:
                 return False
 


Test patch:
diff --git a/pyuvdata/tests/test_uvcal.py b/pyuvdata/tests/test_uvcal.py
index 012e72f6..42455da1 100644
--- a/pyuvdata/tests/test_uvcal.py
+++ b/pyuvdata/tests/test_uvcal.py
@@ -1443,7 +1443,7 @@ def test_uvcal_get_methods():
     uvc.read_calfits(os.path.join(DATA_PATH, 'zen.2457698.40355.xx.gain.calfits'))
 
     # test get methods: add in a known value and make sure it is returned
-    key = (10, 'Jxx')
+    key = (10, 'Jee')
     uvc.gain_array[1] = 0.0
     d, f, q = uvc.get_gains(key), uvc.get_flags(key), uvc.get_quality(key)
 
@@ -1470,14 +1470,14 @@ def test_uvcal_get_methods():
 
     # check has_key
     assert uvc._has_key(antnum=10)
-    assert uvc._has_key(jpol='Jxx')
-    assert uvc._has_key(antnum=10, jpol='Jxx')
-    assert not uvc._has_key(antnum=10, jpol='Jyy')
-    assert not uvc._has_key(antnum=101, jpol='Jxx')
+    assert uvc._has_key(jpol='Jee')
+    assert uvc._has_key(antnum=10, jpol='Jee')
+    assert not uvc._has_key(antnum=10, jpol='Jnn')
+    assert not uvc._has_key(antnum=101, jpol='Jee')
 
     # test exceptions
     pytest.raises(ValueError, uvc.get_gains, 1)
-    pytest.raises(ValueError, uvc.get_gains, (10, 'Jyy'))
+    pytest.raises(ValueError, uvc.get_gains, (10, 'Jnn'))
     uvc.cal_type = 'delay'
     pytest.raises(ValueError, uvc.get_gains, 10)