@@ -23,20 +23,15 @@ with two data columns - ``flux`` and ``temp``::
2323 >>> from astropy import units as u
2424 >>> from astropy.timeseries import TimeSeries
2525 >>> ts = TimeSeries(time='2016-03-22T12:30:31',
26- ... time_delta=3 * u.s,
27- ... data={'flux': [1., 4., 5., 3., 2.],
28- ... 'temp': [40., 41., 39., 24., 20.]},
29- ... names=('flux', 'temp'))
26+ ... time_delta=3 * u.s,
27+ ... data={'flux': [1., 4., 5., 3., 2.] * u.Jy ,
28+ ... 'temp': [40., 41., 39., 24., 20.] * u.K },
29+ ... names=('flux', 'temp'))
3030
3131As for |Table |, columns can be accessed by name::
3232
3333 >>> ts['flux']
34- <Column name='flux' dtype='float64' length=5>
35- 1.0
36- 4.0
37- 5.0
38- 3.0
39- 2.0
34+ <Quantity [1., 4., 5., 3., 2.] Jy>
4035 >>> ts['time']
4136 <Time object: scale='utc' format='isot' value=['2016-03-22T12:30:31.000' '2016-03-22T12:30:34.000'
4237 '2016-03-22T12:30:37.000' '2016-03-22T12:30:40.000'
@@ -47,6 +42,7 @@ and rows can be accessed by index::
4742 >>> ts[0]
4843 <Row index=0>
4944 time flux temp
45+ Jy K
5046 object float64 float64
5147 ----------------------- ------- -------
5248 2016-03-22T12:30:31.000 1.0 40.0
@@ -55,10 +51,10 @@ Accessing individual values can then be done either by accessing a column then a
5551row, or vice-versa::
5652
5753 >>> ts[0]['flux']
58- 1.0
54+ <Quantity 1. Jy>
5955
6056 >>> ts['temp'][2]
61- 39.0
57+ <Quantity 39. K>
6258
6359.. _timeseries-accessing-times :
6460
@@ -112,6 +108,7 @@ We can create a new time series with just the ``flux`` column by doing::
112108 >>> ts['time', 'flux']
113109 <TimeSeries length=5>
114110 time flux
111+ Jy
115112 object float64
116113 ----------------------- -------
117114 2016-03-22T12:30:31.000 1.0
@@ -120,12 +117,14 @@ We can create a new time series with just the ``flux`` column by doing::
120117 2016-03-22T12:30:40.000 3.0
121118 2016-03-22T12:30:43.000 2.0
122119
123- And we can also create a plain |QTable | by extracting just the ``flux `` and
120+ Note that the new columns will be copies (not views) of the original columns.
121+ We can also create a plain |QTable | by extracting just the ``flux `` and
124122``temp `` columns::
125123
126124 >>> ts['flux', 'temp']
127125 <QTable length=5>
128126 flux temp
127+ Jy K
129128 float64 float64
130129 ------- -------
131130 1.0 40.0
@@ -143,6 +142,7 @@ e.g.::
143142 >>> ts[0:2]
144143 <TimeSeries length=2>
145144 time flux temp
145+ Jy K
146146 object float64 float64
147147 ----------------------- ------- -------
148148 2016-03-22T12:30:31.000 1.0 40.0
@@ -161,23 +161,28 @@ entries for a given timestamp::
161161 >>> ts.loc[Time('2016-03-22T12:30:31.000')] # doctest: +SKIP
162162 <Row index=0>
163163 time flux temp
164+ Jy K
164165 object float64 float64
165166 ----------------------- ------- -------
166167 2016-03-22T12:30:31.000 1.0 40.0
167168
168169or within a time range::
169170
170- >>> ts.loc[Time( '2016-03-22T12:30:31'):Time( '2016-03-22T12:30:40') ]
171+ >>> ts.loc['2016-03-22T12:30:30': '2016-03-22T12:30:41' ]
171172 <TimeSeries length=4>
172173 time flux temp
174+ Jy K
173175 object float64 float64
174176 ----------------------- ------- -------
175177 2016-03-22T12:30:31.000 1.0 40.0
176178 2016-03-22T12:30:34.000 4.0 41.0
177179 2016-03-22T12:30:37.000 5.0 39.0
178180 2016-03-22T12:30:40.000 3.0 24.0
179181
180- .. TODO: make it so that Time() is not required above
182+ Note that in this case we didn't specify |Time | - this isn't needed if the
183+ string is an ISO 8601 time string. Also, as for the |QTable | and |Table | class
184+ ``loc `` attribute, and to be consistent with `pandas
185+ <https://pandas.pydata.org/> `_, the last item in the ``loc `` range is inclusive.
181186
182187Note that the result will always be sorted by time. Similarly, the
183188:attr: `~astropy.timeseries.TimeSeries.iloc ` attribute can be used to fetch
@@ -187,6 +192,7 @@ entries (by time) can be accessed with::
187192 >>> ts.iloc[0:2]
188193 <TimeSeries length=2>
189194 time flux temp
195+ Jy K
190196 object float64 float64
191197 ----------------------- ------- -------
192198 2016-03-22T12:30:31.000 1.0 40.0
0 commit comments