Repository: wright-group/WrightTools

Issue:
from_PyCMDS:  retrieve units for filling unfinished data
When importing data that isn't filled to the shape reported in header, values of axes are assigned based on header content, but the units are not read.  Example at https://drive.google.com/open?id=1ta8AEOR-Ck3IENRAHkYbyIjumHP0oiii

```
d = wt.data.from_PyCMDS(...)
print(d.w1.points)
```


Discussion:
I'll note that I don't know if axes units are ever read/used for data coming from the fs system. We take our data in wn and ps for `axes` but if I don't call `convert`, wt plots the data as taken in the `variable` native units, in this case nm and fs. (would love for this to not be the case).

Resolving patch:
diff --git a/WrightTools/data/_pycmds.py b/WrightTools/data/_pycmds.py
--- a/WrightTools/data/_pycmds.py
+++ b/WrightTools/data/_pycmds.py
@@ -10,6 +10,7 @@
 
 from ._data import Data
 from .. import kit as wt_kit
+from .. import units as wt_units
 
 
 # --- define --------------------------------------------------------------------------------------
@@ -152,6 +153,7 @@ def from_PyCMDS(filepath, name=None, parent=None, verbose=True) -> Data:
                         pointsshape[i] = len(points)
                         break
                 points.shape = pointsshape
+                points = wt_units.converter(points, headers["axis units"][i], units)
                 for i in range(points.ndim):
                     if points.shape[i] == 1:
                         points = np.repeat(points, values.shape[i], axis=i)
@@ -168,6 +170,8 @@ def from_PyCMDS(filepath, name=None, parent=None, verbose=True) -> Data:
         expression.replace("=D", "=")
         a["expression"] = expression
     data.transform(*[a["expression"] for a in axes])
+    for a, u in zip(data.axes, headers["axis units"]):
+        a.convert(u)
     # return
     if verbose:
         print("data created at {0}".format(data.fullpath))


Test patch:
diff --git a/tests/data/axis/convert_axis.py b/tests/data/axis/convert_axis.py
--- a/tests/data/axis/convert_axis.py
+++ b/tests/data/axis/convert_axis.py
@@ -32,7 +32,7 @@ def test_exception():
         assert True
     else:
         assert False
-    assert data.w1.units == "nm"
+    assert data.w1.units == "wn"
     assert data["w1"].units == "nm"
     data.close()
 
@@ -40,7 +40,7 @@ def test_exception():
 def test_w1_wa():
     p = datasets.PyCMDS.w1_wa_000
     data = wt.data.from_PyCMDS(p)
-    assert data.wa.units == "nm"
+    assert data.wa.units == "wn"
     data.wa.convert("eV")
     assert data.wa.units == "eV"
     assert np.isclose(data.wa.max(), 1.5802564757220569)
diff --git a/tests/data/convert_data.py b/tests/data/convert_data.py
--- a/tests/data/convert_data.py
+++ b/tests/data/convert_data.py
@@ -32,7 +32,7 @@ def test_w1_wa():
     p = datasets.PyCMDS.w1_wa_000
     data = wt.data.from_PyCMDS(p)
     data.create_constant("w2")
-    assert data.wa.units == "nm"
+    assert data.wa.units == "wn"
     assert data.constants[0].units == "nm"
     data.convert("eV")
     assert data.wa.units == "eV"
diff --git a/tests/data/get_nadir.py b/tests/data/get_nadir.py
--- a/tests/data/get_nadir.py
+++ b/tests/data/get_nadir.py
@@ -9,7 +9,8 @@
 def test_nadir():
     p = wt.datasets.PyCMDS.wm_w2_w1_000
     data = wt.data.from_PyCMDS(p)
-    assert np.allclose(list(data.get_nadir()), [483.0833, 1590., 6250.])
+    data.wm.convert("nm")
+    assert np.allclose(list(data.get_nadir()), [483.0833, 1590., 1600.])
 
 
 if __name__ == "__main__":
diff --git a/tests/data/get_zenith.py b/tests/data/get_zenith.py
--- a/tests/data/get_zenith.py
+++ b/tests/data/get_zenith.py
@@ -9,6 +9,8 @@
 def test_zenith():
     p = wt.datasets.PyCMDS.wm_w2_w1_000
     data = wt.data.from_PyCMDS(p)
+    data.wm.convert("nm")
+    data.w1.convert("nm")
     assert np.allclose(list(data.get_zenith()), [499.9893, 1575., 6349.206349])