| | 146 | _doc_parameters = dict( |
|---|
| | 147 | mareturn=""" |
|---|
| | 148 | Depending on the value of the ``field`` parameter, the method returns either |
|---|
| | 149 | * a ndarray, if ``field=='_data'`` or if ``field=='_mask'``; |
|---|
| | 150 | * a :class:`~numpy.ma.MaskedArray`, if ``field`` is None or a valid field. |
|---|
| | 151 | """, |
|---|
| | 152 | tsreturn=""" |
|---|
| | 153 | Depending on the value of the ``field`` parameter, the method returns: |
|---|
| | 154 | |
|---|
| | 155 | * a :class:`~scikits.timeseries.TimeSeries`, if ``field`` is None or a valid |
|---|
| | 156 | field; |
|---|
| | 157 | * a :class:`~scikits.timeseries.DateArray`, if ``field=='_dates'``; |
|---|
| | 158 | * a ndarray, if ``field=='_data'`` or if ``field=='_mask'``; |
|---|
| | 159 | * a :class:`~numpy.ma.MaskedArray`, if ``field=='_series'``. |
|---|
| | 160 | """, |
|---|
| | 161 | readinput=""" |
|---|
| | 162 | start : {None, int}, optional |
|---|
| | 163 | Index of the first record to read. |
|---|
| | 164 | If None, records will be read starting from the very first one. |
|---|
| | 165 | stop : {None, int}, optional |
|---|
| | 166 | Index of the last record to read. |
|---|
| | 167 | If None, records will be read until the very last one. |
|---|
| | 168 | step : {None, int}, optional |
|---|
| | 169 | Increment between succesive records to read. |
|---|
| | 170 | If None, all the records between ``start`` and ``stop`` will be read. |
|---|
| | 171 | field : {None, str}, optional |
|---|
| | 172 | Name of the field to read. |
|---|
| | 173 | If None, all the fields from each record are read. |
|---|
| | 174 | """, |
|---|
| | 175 | readcoordinateinput=""" |
|---|
| | 176 | coords : sequence |
|---|
| | 177 | A sequence of integers, corresponding to the indices of the rows to |
|---|
| | 178 | retrieve |
|---|
| | 179 | field : {None, str}, optional |
|---|
| | 180 | Name of the field to read. |
|---|
| | 181 | If None, all the fields from each record are read. |
|---|
| | 182 | """, |
|---|
| | 183 | ) |
|---|
| | 184 | |
|---|
| 281 | | def read(self, start=None, stop=None, step=None, field=None): |
|---|
| 282 | | """ |
|---|
| 283 | | Reads the current :class:`MaskedTable`. |
|---|
| 284 | | |
|---|
| 285 | | Returns |
|---|
| 286 | | ------- |
|---|
| 287 | | |
|---|
| 288 | | Depending on the value of the ``field`` parameter, the method returns either |
|---|
| 289 | | * a ndarray, if ``field=='_data'`` or if ``field=='_mask'``; |
|---|
| 290 | | * a :class:`~numpy.ma.MaskedArray`, if ``field`` is None or a valid field. |
|---|
| 291 | | |
|---|
| 292 | | Parameters |
|---|
| 293 | | ---------- |
|---|
| 294 | | start : {None, int}, optional |
|---|
| 295 | | Index of the first record to read. |
|---|
| 296 | | If None, records will be read starting from the very first one. |
|---|
| 297 | | stop : {None, int}, optional |
|---|
| 298 | | Index of the last record to read. |
|---|
| 299 | | If None, records will be read until the very last one. |
|---|
| 300 | | step : {None, int}, optional |
|---|
| 301 | | Increment between succesive records to read. |
|---|
| 302 | | If None, all the records between ``start`` and ``stop`` will be read. |
|---|
| 303 | | field : {None, str}, optional |
|---|
| 304 | | Name of the field to read. |
|---|
| 305 | | If None, all the fields from each record are read. |
|---|
| 306 | | The argument should be one of the field of the series, or one of the |
|---|
| 307 | | following: ``'_data','_mask'``. |
|---|
| 308 | | """ |
|---|
| 309 | | data = Table.read(self, start=start, stop=stop, step=step, |
|---|
| 310 | | field=field) |
|---|
| | 321 | def _reader(self, meth, *args, **kwargs): |
|---|
| | 322 | """ |
|---|
| | 323 | Private function that retransforms the output of Table.read and equivalent |
|---|
| | 324 | to the proper type. |
|---|
| | 325 | """ |
|---|
| | 326 | data = meth(self, *args, **kwargs) |
|---|
| 387 | | def read(self, start=None, stop=None, step=None, field=None): |
|---|
| 388 | | """ |
|---|
| 389 | | Reads the current :class:`TimeSeriesTable`. |
|---|
| 390 | | |
|---|
| 391 | | Returns |
|---|
| 392 | | ------- |
|---|
| 393 | | |
|---|
| 394 | | Depending on the value of the ``field`` parameter, the method returns: |
|---|
| 395 | | |
|---|
| 396 | | * a :class:`~scikits.timeseries.TimeSeries`, if ``field`` is None or a valid |
|---|
| 397 | | field; |
|---|
| 398 | | * a :class:`~scikits.timeseries.DateArray`, if ``field=='_dates'``; |
|---|
| 399 | | * a ndarray, if ``field=='_data'`` or if ``field=='_mask'``; |
|---|
| 400 | | * a :class:`~numpy.ma.MaskedArray`, if ``field=='_series'``. |
|---|
| 401 | | |
|---|
| 402 | | |
|---|
| 403 | | Parameters |
|---|
| 404 | | ---------- |
|---|
| 405 | | start : {None, int}, optional |
|---|
| 406 | | Index of the first record to read. |
|---|
| 407 | | If None, records will be read starting from the very first one. |
|---|
| 408 | | stop : {None, int}, optional |
|---|
| 409 | | Index of the last record to read. |
|---|
| 410 | | If None, records will be read until the very last one. |
|---|
| 411 | | step : {None, int}, optional |
|---|
| 412 | | Increment between succesive records to read. |
|---|
| 413 | | If None, all the records between ``start`` and ``stop`` will be read. |
|---|
| 414 | | field : {None, str}, optional |
|---|
| 415 | | Name of the field to read. |
|---|
| 416 | | If None, all the fields from each record are read. |
|---|
| 417 | | The argument should be one of the field of the series, or one of the |
|---|
| 418 | | following: ``'_data','_mask','_dates','_series'``. |
|---|
| 419 | | """ |
|---|
| 420 | | # data = Table.read(self, start=start, stop=stop, step=step, |
|---|
| 421 | | # field=field) |
|---|
| | 446 | # def read(self, start=None, stop=None, step=None, field=None): |
|---|
| | 447 | # """ |
|---|
| | 448 | # Reads the current :class:`TimeSeriesTable`. |
|---|
| | 449 | # |
|---|
| | 450 | # Returns |
|---|
| | 451 | # ------- |
|---|
| | 452 | # |
|---|
| | 453 | # Depending on the value of the ``field`` parameter, the method returns: |
|---|
| | 454 | # |
|---|
| | 455 | # * a :class:`~scikits.timeseries.TimeSeries`, if ``field`` is None or a valid |
|---|
| | 456 | # field; |
|---|
| | 457 | # * a :class:`~scikits.timeseries.DateArray`, if ``field=='_dates'``; |
|---|
| | 458 | # * a ndarray, if ``field=='_data'`` or if ``field=='_mask'``; |
|---|
| | 459 | # * a :class:`~numpy.ma.MaskedArray`, if ``field=='_series'``. |
|---|
| | 460 | # |
|---|
| | 461 | # |
|---|
| | 462 | # Parameters |
|---|
| | 463 | # ---------- |
|---|
| | 464 | # start : {None, int}, optional |
|---|
| | 465 | # Index of the first record to read. |
|---|
| | 466 | # If None, records will be read starting from the very first one. |
|---|
| | 467 | # stop : {None, int}, optional |
|---|
| | 468 | # Index of the last record to read. |
|---|
| | 469 | # If None, records will be read until the very last one. |
|---|
| | 470 | # step : {None, int}, optional |
|---|
| | 471 | # Increment between succesive records to read. |
|---|
| | 472 | # If None, all the records between ``start`` and ``stop`` will be read. |
|---|
| | 473 | # field : {None, str}, optional |
|---|
| | 474 | # Name of the field to read. |
|---|
| | 475 | # If None, all the fields from each record are read. |
|---|
| | 476 | # The argument should be one of the field of the series, or one of the |
|---|
| | 477 | # following: ``'_data','_mask','_dates','_series'``. |
|---|
| | 478 | # """ |
|---|
| | 479 | ## data = Table.read(self, start=start, stop=stop, step=step, |
|---|
| | 480 | ## field=field) |
|---|
| | 481 | # special_attrs = getattr(self.attrs, 'special_attrs', {}) |
|---|
| | 482 | # fill_value = special_attrs.get('_fill_value', None) |
|---|
| | 483 | # baseclass = special_attrs.get('_baseclass', np.ndarray) |
|---|
| | 484 | # # |
|---|
| | 485 | # position_keywords = dict(start=start, stop=stop, step=step) |
|---|
| | 486 | # # |
|---|
| | 487 | # ndtype = self._get_dtype() |
|---|
| | 488 | # field_names = ndtype.names |
|---|
| | 489 | # |
|---|
| | 490 | # # Case 1. : Global read ................. |
|---|
| | 491 | # if field is None: |
|---|
| | 492 | # data = Table.read(self, **position_keywords) |
|---|
| | 493 | # dates = DateArray(data['_dates'], |
|---|
| | 494 | # freq=special_attrs.get('freq','U')) |
|---|
| | 495 | # if field_names is None: |
|---|
| | 496 | # output = time_series(data['_data'], |
|---|
| | 497 | # dates = dates, |
|---|
| | 498 | # mask=data['_mask']) |
|---|
| | 499 | # else: |
|---|
| | 500 | # output = ma.empty(data.shape, dtype=ndtype).view(TimeSeries) |
|---|
| | 501 | # for name in field_names: |
|---|
| | 502 | # current = data[name] |
|---|
| | 503 | # output[name] = ma.array(current['_data'], |
|---|
| | 504 | # mask=current['_mask']) |
|---|
| | 505 | # output._dates = dates |
|---|
| | 506 | # # Reset some attributes.................. |
|---|
| | 507 | # output._baseclass = baseclass |
|---|
| | 508 | # output.fill_value = fill_value |
|---|
| | 509 | # output._hardmask = special_attrs.get('_hardmask', False) |
|---|
| | 510 | # output._optinfo = special_attrs.get('_optinfo', {}) |
|---|
| | 511 | # # Case 2. Partial reads.................. |
|---|
| | 512 | # elif field in ['_dates','_data','_mask']: |
|---|
| | 513 | # output = Table.read(self, field=field, **position_keywords) |
|---|
| | 514 | # # Case 3. The series as a masked array |
|---|
| | 515 | # elif field == '_series': |
|---|
| | 516 | # # Special case: read the table, but keep it as MaskedArray |
|---|
| | 517 | # data = Table.read(self, field=None, **position_keywords) |
|---|
| | 518 | # if field_names is None: |
|---|
| | 519 | # output = ma.array(data['_data'], mask=data['_mask']) |
|---|
| | 520 | # else: |
|---|
| | 521 | # output = ma.empty(data.shape, dtype=ndtype) |
|---|
| | 522 | # for name in field_names: |
|---|
| | 523 | # current = data[name] |
|---|
| | 524 | # output[name] = ma.array(current['_data'], |
|---|
| | 525 | # mask=current['_mask']) |
|---|
| | 526 | # output.fill_value = fill_value |
|---|
| | 527 | # output._baseclass = baseclass |
|---|
| | 528 | # output._hardmask = special_attrs.get('_hardmask', False) |
|---|
| | 529 | # output._optinfo = special_attrs.get('_optinfo', {}) |
|---|
| | 530 | # # Case 4. Field read .................... |
|---|
| | 531 | # elif field in field_names: |
|---|
| | 532 | # data = Table.read(self, field=field, **position_keywords) |
|---|
| | 533 | # dates = Table.read(self, field='_dates', **position_keywords) |
|---|
| | 534 | # dates = DateArray(dates, freq=special_attrs.get('freq','U')) |
|---|
| | 535 | # # Get the data part |
|---|
| | 536 | # output = time_series(data['_data'], |
|---|
| | 537 | # dates=dates, |
|---|
| | 538 | # mask=data['_mask'],) |
|---|
| | 539 | # output._baseclass = baseclass |
|---|
| | 540 | # if fill_value is not None: |
|---|
| | 541 | # output.fill_value = fill_value[field] |
|---|
| | 542 | # output._hardmask = special_attrs.get('_hardmask', False) |
|---|
| | 543 | # output._optinfo = special_attrs.get('_optinfo', {}) |
|---|
| | 544 | # else: |
|---|
| | 545 | # raise KeyError("Unable to process field '%s'" % field) |
|---|
| | 546 | # return output |
|---|
| | 547 | |
|---|
| | 548 | |
|---|
| | 549 | def _reader(self, meth, *args, **kwargs): |
|---|
| | 550 | """ |
|---|
| | 551 | Private function that retransforms the output of Table.read and equivalent |
|---|
| | 552 | to the proper type. |
|---|
| | 553 | """ |
|---|
| | 554 | # Get some of the special attributes |
|---|