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)

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cdspyreadme-1.9.1.tar.gz (203.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cdspyreadme-1.9.1-py3-none-any.whl (25.4 kB view details)

Uploaded Python 3

File details

Details for the file cdspyreadme-1.9.1.tar.gz.

File metadata

  • Download URL: cdspyreadme-1.9.1.tar.gz
  • Upload date:
  • Size: 203.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.12.3

File hashes

Hashes for cdspyreadme-1.9.1.tar.gz
Algorithm Hash digest
SHA256 3854449cc2482ce437ea6f73790678f6795697b2e78c48a82b03b5598723d82e
MD5 e704e39da1525ce36328cf94965bd264
BLAKE2b-256 a68f0bb840f7c8992a3a66c7248c2f10e2ccdd3660ccbadce727c073de854e0e

See more details on using hashes here.

File details

Details for the file cdspyreadme-1.9.1-py3-none-any.whl.

File metadata

  • Download URL: cdspyreadme-1.9.1-py3-none-any.whl
  • Upload date:
  • Size: 25.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.12.3

File hashes

Hashes for cdspyreadme-1.9.1-py3-none-any.whl
Algorithm Hash digest
SHA256 2c08ac8dc6f4e7d911003f879f334c0efcac9eb4f7ed9584ab1723abb85678db
MD5 0414bf14d98ae60c5c3ba7f7708e02cd
BLAKE2b-256 8273092f5b28c1721343419f8ad715c8f0ef6510bdb4316f8748c0d8d07ee6de

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

1.9.1 This release

2 files

1.9

1 file

1.7

2 files

1.5.2

2 files

1.5.1

2 files

1.5

2 files

1.3.9

1 file

1.3.8

3 files

1.3.7

2 files

1.3.5

2 files

1.3.4

2 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