Repository: StingraySoftware/stingray

Issue:
Docstring improvement request
https://github.com/StingraySoftware/stingray/blob/e3a8eea835a035e4a307e8cfde06d212c7cf3925/stingray/lightcurve.py#L30-L31

It would be great if this docstring said something about what the assumed units were for these times (e.g. is it expecting seconds or MJDs?, or other?), and whether things like an astropy Time object could be used. 

Discussion:

Patch:
diff --git a/stingray/lightcurve.py b/stingray/lightcurve.py
index 41f8c240..467be5fa 100644
--- a/stingray/lightcurve.py
+++ b/stingray/lightcurve.py
@@ -27,8 +27,11 @@ class Lightcurve(object):
 
     Parameters
     ----------
-    time: iterable
-        A list or array of time stamps for a light curve
+    time: Iterable, `:class:astropy.time.Time`, or `:class:astropy.units.Quantity` object
+        A list or array of time stamps for a light curve. Must be a type that
+        can be cast to `:class:np.array` or `:class:List` of floats, or that
+        has a `value` attribute that does (e.g. a
+        `:class:astropy.units.Quantity` or `:class:astropy.time.Time` object).
 
     counts: iterable, optional, default ``None``
         A list or array of the counts in each bin corresponding to the
@@ -133,6 +136,8 @@ class Lightcurve(object):
                  gti=None, err_dist='poisson', mjdref=0, dt=None,
                  skip_checks=False, low_memory=False):
 
+        if hasattr(time, 'value'):
+            time = time.value
         time = np.asarray(time)
         counts = np.asarray(counts)
         if err is not None:


Test patch:
diff --git a/stingray/tests/test_lightcurve.py b/stingray/tests/test_lightcurve.py
index 326e74f2..23cefbc8 100644
--- a/stingray/tests/test_lightcurve.py
+++ b/stingray/tests/test_lightcurve.py
@@ -5,6 +5,8 @@ import warnings
 import os
 import matplotlib.pyplot as plt
 from numpy.testing import assert_allclose
+import astropy.units as u
+from astropy.time import Time
 
 from stingray import Lightcurve
 from stingray.exceptions import StingrayError
@@ -65,6 +67,20 @@ class TestProperties(object):
         _ = lc.bin_lo
         assert lc._bin_lo is not None
 
+    def test_time_is_quantity_or_astropy_time(self):
+        counts = [34, 21.425]
+        times = [57000, 58000]
+
+        times_q = times * u.d
+        times_t = Time(times, format='mjd')
+
+        lc = Lightcurve(time=times, counts=counts)
+        lc_q = Lightcurve(time=times_q, counts=counts)
+        lc_t = Lightcurve(time=times_t, counts=counts)
+        assert_allclose(lc.time, lc_q.time)
+        assert_allclose(lc.time, lc_t.time)
+
+
     def test_gti(self):
         lc = copy.deepcopy(self.lc)
         assert lc._mask is None