[AstroPy] How can I preserve the precision of the data in the votable file?
Michael Droettboom
mdroe at stsci.edu
Thu Mar 7 11:12:11 EST 2013
By default, floating point values are output using 4 decimal points of
precision. You can control the amount of precision using the
"precision" attribute on the field. This is either "F" followed by a
number of decimal places, or "E" followed by the number of significant
digits. For example, when you define your fields, you can do:
# Define some fields
table.fields.extend([
Field(votable, name="float", datatype="double", precision="E8"))
See also:
http://www.ivoa.net/Documents/VOTable/20040811/REC-VOTable-1.1-20040811.html#ToC26
Mike
On 03/07/2013 06:33 AM, Susana Sanchez Exposito wrote:
> Hello again,
>
> I have followed the instructions given by Tom Aldcroft as answer of my
> previous mail (thanks for that!), and finally I get the xml file with
> the VOTable, but I realized the number are rounded when they are
> written in the xml file.
>
> For example, if I have a table like this:
> (I built this Table following the example in
> https://astropy.readthedocs.org/en/v0.2/io/votable/index.html,
> "Building a new table from scratch"):
>
> In [62]: table
> Out[62]: <astropy.io.votable.tree.Table object at 0x32bcbd0>
>
> In [63]: table.array
> Out[63]:
> masked_rec.array(data = [(17.257360147629999, 18.999976544568401)
> (13.257360147629999, 78.999976544568398)],
> mask = [(False, False) (False, False)],
> fill_value = (1e+20, 1e+20),
> dtype = [('precision', '<f8'), ('precision2', '<f8')])
>
>
> When I build the xml file with the comand votable.to_xml, the file
> contains this data:
>
> <TABLEDATA>
> <TR>
> <TD>17.2574</TD>
> <TD>19</TD>
> </TR>
> <TR>
> <TD>13.2574</TD>
> <TD>79</TD>
> </TR>
> </TABLEDATA>
>
>
> As you can see, the numbers have been rounded, but I would like to
> preserve the precision of these data. Is this possible?
>
>
> Thanks again for your useful help!
>
> Susana.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/astropy/attachments/20130307/0e184472/attachment.html>
More information about the AstroPy
mailing list