[AstroPy] How can I preserve the precision of the data in the votable file?

Susana Sanchez Exposito sse@iaa...
Fri Mar 8 03:33:00 CST 2013


Thanks Mike!!

2013/3/7 Michael Droettboom <mdroe@stsci.edu>:
> 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.
>
>
>
> _______________________________________________
> AstroPy mailing list
> AstroPy@scipy.org
> http://mail.scipy.org/mailman/listinfo/astropy
>



-- 
Susana Sánchez Expósito

Instituto de Astrofísica de Andalucía   IAA (CSIC)
Camino Bajo de Huétor, 50. Granada E-18008
Tel:(+34) 958 121 311 / (+34) 958 230 618
Fax:(+34) 958 814 530
e-mail: sse@iaa.es


More information about the AstroPy mailing list