Skip to content

Unified file read/write interface: binary votable format #7352

Closed

Description

@richardgmcmahon

Hello,

is it possible to write a binary votable with the unified interface. The example given is:

t.write('new_catalog.xml', table_id='updated_table', format='votable')

This produces an ASCII format file.

The VOTABLE package supports TABLEDATA, BINARY, BINARY2
http://docs.astropy.org/en/stable/io/votable/index.html#outputting-a-votable-file

If the unified interface supports BINARY votable, what is the format that I should use?

i.e. t.write('new_catalog.xml', table_id='updated_table', format=????)

Thanks

Activity

  1. pllim commented on Apr 5, 2018

    @pllim
    Member

    It is unfortunate that https://github.com/astropy/astropy/blob/master/astropy/io/votable/connect.py#L136 is not exposed in user documentation. Does 'binary' or 'binary2' work for you?

  2. richardgmcmahon commented on Apr 5, 2018

    @richardgmcmahon
    Author

    Thanks,

    format = 'binary' gives the error:

    astropy.io.registry.IORegistryError: No writer defined for format 'binary' and class 'Table'.

    I am using astropy 2.0.2 and 2.0.5
    Meanwhile I used the io.votable.to do it:

    table_thin = Table([table['RA'], table['Dec']])
    
    from astropy.io.votable import from_table, writeto
    votable = from_table(table_thin)
    writeto(votable, "output.xml", tabledata_format='binary')
    

    This could be a useful example for io.votable.

  3. pllim commented on Apr 6, 2018

    @pllim
    Member

    Hmm, looks like a bug in unified I/O connector. Documentation stated it is supported but the registry throws error. I am glad you have a workaround. Thanks for reporting this!

  4. pllim commented on Apr 6, 2018

    @pllim
    Member

    astropy.io.registry.IORegistryError: No writer defined for format 'binary' and class 'Table'.

    Actually, I need some clarification. Maybe this is not a bug after all but wrong usage due to lack of documentation. I failed to reproduce the error you reported. These both worked for me using Astropy 3.1.dev21672.

    t.write('new_catalog.xml', table_id='updated_table', format='votable',  tabledata_format='binary')
    
    t.write('new_catalog.xml', table_id='updated_table', format='votable',  tabledata_format='binary', overwrite=True)
  5. richardgmcmahon commented on Apr 6, 2018

    @richardgmcmahon
    Author

    OK, it works for me too using:

    format='votable', tabledata_format='binary'

    So it looks like a pilot PICNIC error although giving an explicit example for binary and binary2 since I think the default is ASCII which for large datasets is too bulky.

  6. pllim commented on Apr 6, 2018

    @pllim
    Member

    Perhaps the doc update can be a part of work for #1011

  7. bsipocz commented on Jun 18, 2019

    @bsipocz
    Member

    @pllim - would you think the new helps for the unified io addresses this issue, too? If yes, please close this.
    #8255

  8. pllim commented on Jun 19, 2019

    @pllim
    Member

    @bsipocz , unfortunately, not quite... The listing below does not provide all the options that are possible (e.g., tabledata_format). @taldcroft , any advice?

    In [1]: import astropy
    
    In [2]: astropy.__version__
    Out[2]: '3.2'
    
    In [3]: from astropy.table import Table
    
    In [4]: Table.read.help('votable')
    ==========================================
    Table.read(format='votable') documentation
    ==========================================
    
    Read a Table object from an VO table file
    
    Parameters
    ----------
    input : str or `~astropy.io.votable.tree.VOTableFile` or `~astropy.io.votable.tr
    ee.Table`
        If a string, the filename to read the table from. If a
        :class:`~astropy.io.votable.tree.VOTableFile` or
        :class:`~astropy.io.votable.tree.Table` object, the object to extract
        the table from.
    
    table_id : str or int, optional
        The table to read in.  If a `str`, it is an ID corresponding
        to the ID of the table in the file (not all VOTable files
        assign IDs to their tables).  If an `int`, it is the index of
        the table in the file, starting at 0.
    
    use_names_over_ids : bool, optional
        When `True` use the ``name`` attributes of columns as the names
        of columns in the `~astropy.table.Table` instance.  Since names
        are not guaranteed to be unique, this may cause some columns
        to be renamed by appending numbers to the end.  Otherwise
        (default), use the ID attributes as the column names.
    
  9. taldcroft commented on Jun 19, 2019

    @taldcroft
    Member

    @pllim - you need to check the write help. 😸

    >>> Table.write.help('votable')
    
    ===========================================
    Table.write(format='votable') documentation
    ===========================================
    
    Write a Table object to an VO table file
    
    Parameters
    ----------
    input : Table
        The table to write out.
    
    output : str
        The filename to write the table to.
    
    table_id : str, optional
        The table ID to use. If this is not specified, the 'ID' keyword in the
        ``meta`` object of the table will be used.
    
    overwrite : bool, optional
        Whether to overwrite any existing file without warning.
    
    tabledata_format : str, optional
        The format of table data to write.  Must be one of ``tabledata``
        (text representation), ``binary`` or ``binary2``.  Default is
        ``tabledata``.  See :ref:`votable-serialization`.
    
  10. pllim commented on Jun 19, 2019

    @pllim
    Member

    Ops!!! Thanks for pointing that out, @taldcroft !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions