[AstroPy] (Table) unit formatting

Peter Weilbacher pweilbacher at aip.de
Wed Nov 1 05:58:16 EDT 2017


Hmm, was my problem not clearly stated? Or does really nobody have a hint?
   P.

On Wed, 25 Oct 2017, Peter Weilbacher wrote:

> Dear all,
>
> I'm trying to add units to table columns with AstroPy (v2.0.1) and save
> the resulting table as FITS (for now). So I enter unit strings like this
>    table['colname'].unit = 'erg/s/cm**2'
> and write the table to disk. Unfortunately, I not only get the annoying
> units warning about the multiple slashes (any way to turn that off?) but
> also discover that the strong got converted to 'cm-2 erg s-1' which
> while correct is really ugly -- nobody would write it like that in a
> paper! And actually, when I use print to look at the table before
> saving, I see that units as 'erg / (cm2 s)' which is not nice, either,
> but that I can live with.
>
> Can I adjust this behavior of do I have to edit the TUNITn manually
> after saving the file?
>
> By the way, I was also looking for a way to influence the display of the
> columns, i.e. the TDISPn keywords. If I set a format using
>    t['colname'].format = '%4.2f'
> this is used when printing the table, but does not end up in the
> corresponding TDISPn after writing to FITS. Am I missing something?
>
> Finally, I'd like to give potential users of my file a longer
> description, and hoped there was a way to write something to the FITS
> comment part (after the slash of the TTYPEn keywords). Setting
>    t['colname'].description = 'a descriptive message'
> works, but influences neither printing of the table nor writing to FITS.
>
> Any hints?
>    Peter.

-- 
Dr. Peter M. Weilbacher             http://www.aip.de/People/PWeilbacher
Phone +49 331 74 99-667                       encryption key ID 7D6B4AA0
------------------------------------------------------------------------
Leibniz-Institut für Astrophysik Potsdam (AIP)
An der Sternwarte 16, D-14482 Potsdam

Vorstand: Prof. Dr. Matthias Steinmetz, Matthias Winker
Stiftung bürgerlichen Rechts, Stiftungsverz. Brandenburg: 26 742-00/7026


More information about the AstroPy mailing list