[AstroPy] How to append to a astropy.io.votable
Tue Apr 16 17:57:31 CDT 2013
Thanks for the pointer.
Also, I see that mapping of 'name' from VOTable to Table has been resolved so, I gather, one doesn't loose content on moving into a Table object. Great!
On 2013-04-16, at 3:15 PM, Tom Aldcroft wrote:
> Hi JJ,
> If you want to add a column you should first convert the VOtable into
> an astropy Table object, e.g.:
>>>> from astropy.table import MaskedColumn
>>>> table = t.to_table() # where t is the VOtable from your example
>>>> new_col = MaskedColumn(data=<computed values>, name='newColumn')
> The use of MaskedColumn assumes there might be missing (masked) values
> in your <computed values>. If not you can just use Column.
> Note that in the upcoming 0.3 version of astropy (or the current dev
> version), you can replace the last two lines with:
>>>> data['newColumn'] = <computed values>
> See also:
> On Tue, Apr 16, 2013 at 5:43 PM, JJ Kavelaars <firstname.lastname@example.org> wrote:
>> i've been using atpy for VOTable manipulation and I'm working to switch to astropy.io.votable.
>> I don't see how 'add_column' to a table object?
>>>>> from astropy.io.votable import parse
>>>>> from astropy.io.votable.tree import Field
>>>>> t = parse('filename.vot').get_first_table()
>>>>> print t.array['newColumn']
>> ERROR: ValueError: field named newColumn not found. [numpy.ma.core]
>> I'd like to add a column to t where that column contains a computed value based on one of t's other columns.
>> Hints appreciated.
>> AstroPy mailing list
More information about the AstroPy