desihub / desiutil

General DESI utilities, shell scripts, desiInstall, etc.
BSD 3-Clause "New" or "Revised" License
3 stars 9 forks source link

Add units to a Table #199

Closed weaverba137 closed 1 year ago

weaverba137 commented 1 year ago

This PR addresses parts of #191, focussed on adding units to a astropy.table.Table.

Here's a simple test snippet:

import os
import importlib.resources as ir
from astropy.table import Table
import desiutil.annotate as da
from desiutil.log import get_logger, DEBUG
da.log = get_logger(DEBUG)
csvFile = os.path.join(str(ir.files('desidatamodel')), 'data', 'column_descriptions.csv')
units, comments = da.csv_units(csvFile)
coadd = '/global/cfs/cdirs/desi/public/edr/spectro/redux/fuji/healpix/sv3/dark/99/9994/coadd-sv3-dark-9994.fits'
t = Table.read(coadd, hdu='FIBERMAP')
tt = da.annotate_table(t, units)  # tt is a copy of t; t is not supposed to be modified in this example.
# Try writing out tt.

TO DO:

coveralls commented 1 year ago

Coverage Status

coverage: 74.314% (-0.08%) from 74.392% when pulling 466159f1c52f091adc2f33d583934ac8be1f6780 on fits-units into 5d2b9d271af19c332837fa92592412527dc18485 on main.

weaverba137 commented 1 year ago

@sbailey, I suggest moving forward with merging this and splitting off the task of verifying unit format into a separate issue.

There is already unit format verification code in desidatamodel, and I additionally propose moving that code to desiutil so that desiutil doesn't have to depend on desidatamodel.