Skip to main content

ReadMe Generator Python library

The cdspyreadme library is a Python package dedicated for authors who want to submit data in VizieR or AAS.

The package builts ReadMe, standardized tables (in ASCII aligned format) or MRT tables from tables which can be in different formats (CSV, votable, FITS, astropy table, MRT)

by G.Landais (CDS) 24 june 2016

Requirements

The cdspyreadme library works with Python3 and requires :

  • astropy
  • numpy

Notes: for large tables, we recommend to use the C- anafile package

Anafile download: http://cdsarc.unistra.fr/ftp/sw/anafile.tar.gz Anafile documentation: http://cdsarc.unistra.fr/doc/anafile.htx

Install

pip install .

Examples

import cdspyreadme

tablemaker = cdspyreadme.CDSTablesMaker()

# add a table
table = tablemaker.addTable("table.csv", description="my CSV table")
# write table in CDS-ASCII aligned format (required)
tablemaker.writeCDSTables()

# Customize ReadMe output
tablemaker.title = "catalogue title"
tablemaker.author = 'G.Landais'
tablemaker.date = 2020
tablemaker.abstract = "This is my abstract..."
tablemaker.license = "CC0-1.0"
tablemaker.more_description = "Additional information of the data context."
tablemaker.putRef("II/246", "2mass catalogue")
tablemaker.putRef("http://...", "external link")

# Save ReadMe (in current directory)
tablemaker.makeReadMe()

# print ReadMe
import sys
tablemaker.makeReadMe(out=sys.stdout)

add astropy table

from astropy.table import Table
import cdspyreadme

astropy_table = Table([(1.4845, 1.4835, -1.234),
               (24.5,  18.2401, 23.426),
               ('HD100', 'HD101', None)],
              names=['ra', 'dec','name'])
tablemaker = cdspyreadme.CDSTablesMaker()
tablemaker.addTable(astropy_table, name="table1")

# add an other local table (in VOTable) 
table2 = Table.read("table.vot")
tablemaker.addTable(table2, name="table2")

tablemaker.writeCDSTables()
tablemaker.makeReadMe()

use astropy Masked Column to remove values according criteria

from astropy.table import Table, MaskedColumn
import cdspyreadme

tablemaker = cdspyreadme.CDSTablesMaker()
csv = Table.read("table.csv")
csv.columns[0] = MaskedColumn(csv.columns[0], mask=[(val>10) for val in csv.columns[0]])
tablemaker.addTable(csv, name="data.cds")

tablemaker.writeCDSTables()
tablemaker.makeReadMe()

Sexagesimal columns

Flag sexagesimal columns in ReadMe.

The method transforms string columns (ie: ra_sexa, de_sexa) in columns RAh, Ram, RAs, DEsign, DEd, DEm, DEs.

from astropy.table import Table
import cdspyreadme

tablemaker = cdspyreadme.CDSTablesMaker()
csv = Table.read("table.csv")
table = tablemaker.addTable(csv, name="data.cds")
ra = table.get_column("ra_sexa")
ra.setSexaRa()
de = table.get_column("dec_sexa")
de.setSexaDe()

tablemaker.writeCDSTables()
tablemaker.makeReadMe()

add ASCII aligned table

from astropy.table import Table
import cdspyreadme

tablemaker = cdspyreadme.CDSTablesMaker()
ascii = cdspyreadme.CDSAsciiTable("table.ascii", "table1", description="ascii table")
table = tablemaker.addTable(ascii)

tablemaker.writeCDSTables()
tablemaker.makeReadMe()

MRT example

The following example builds MRT table from a CSV table

from astropy.table import Table
import cdspyreadme

tablemaker = cdspyreadme.CDSTablesMaker()
tablemaker.title = "catalogue title"
tablemaker.author = 'G.Landais'

csv = Table.read("table.csv")
# rename columns
colra = csv["ra"]
colra.name = "RAdeg"
colra.description="Right ascension"
colra.unit='deg'
...
table = tablemaker.addTable(ascii, name='table.mrt', description='csv file')
tablemaker.toMRT()

update column

...

table = tablemaker.addTable(...)
column = table.get_column("mag")

# modify format
column.set_format("F6.3")

# modify name and description
column.name = "umag"
column.description = "Magnitude in U band"
# Add a note
column.note = "filter INT/WFC/U" 

tablemaker.writeCDSTables()
tablemaker.makeReadMe()

FITS update

How to add columns description using TCOMMx cards -

from astropy.io import fits
from astropy.table import Table
import cdspyreadme

tab = Table.read("catalogue.fits")
fitstable = fits.open("catalogue.fits")
hdu = fitstable[1]

# update description from FITS header
for i in range(len(tab.columns)):
    tab.columns[i].description = hdu.header["TCOMM"+str(i+1)]
fits.close()

tablemaker = cdspyreadme.CDSTablesMaker()
table = tablemaker.addTable(tab)

tablemaker = cdspyreadme.CDSTablesMaker()
table = tablemaker.addTable(tab)
tablemaker.writeCDSTables()

Manage output directory

Update the output directory:

import cdspyreadme

tablemaker = cdspyreadme.CDSTablesMaker(outfolder="/tmp")

Manage ReadMe output

# save ReadMe in a .bak file
with open("/tmp/ReadMe.bak", "w") as fd:
    tablemaker.makeReadMe(out=fd)

Metadata

Release files for cdspyreadme 1.9.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cdspyreadme 1.9.2
File Size Uploaded
cdspyreadme-1.9.2.tar.gz 240.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for cdspyreadme 1.9.2
File Interpreter ABI Platform
cdspyreadme-1.9.2-py3-none-any.whl Python 3 none any Details

Total release size: 266.3 kB

Release files / cdspyreadme-1.9.2.tar.gz

Download URL cdspyreadme-1.9.2.tar.gz
Size 240.9 kB
Tags Source
SHA-256 checksum
How to use checksums
82ff3588b7b128c4ff50e32536f5018b599f39f34426fa1bf058370a8c0798c5
BLAKE2b-256 checksum
How to use checksums
e3fc09c320b339f9107b1dec74c2c03df1268ab250b5112751be2e61f71edb85
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Release files / cdspyreadme-1.9.2-py3-none-any.whl

Download URL cdspyreadme-1.9.2-py3-none-any.whl
Size 25.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7e85bb32db5222e0907f481788c4e19a7158dc49314d0a644ad3ab23de2f4739
BLAKE2b-256 checksum
How to use checksums
f9fa15f96e4b961cacf956a60b9a28ea74f7e2c170109a69d3e186c321f647a6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Release history Release notifications | RSS feed

This release

1.9.2 This release

2 release files

1.9.1

2 release files

1.9

1 release file

1.7

2 release files

1.5.2

2 release files

1.5.1

2 release files

1.5

2 release files

1.3.9

1 release file

1.3.8

3 release files

1.3.7

2 release files

1.3.5

2 release files

1.3.4

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page