Skip to content

Commit

Permalink
Merge pull request #196 from desihub/195-column_descriptions-with-sho…
Browse files Browse the repository at this point in the history
…rter-descriptions-for-fits-headers

Updated column_description.csv with short descriptions
  • Loading branch information
sbailey authored Sep 12, 2024
2 parents 6937e98 + 547accc commit 37f22ff
Show file tree
Hide file tree
Showing 7 changed files with 472 additions and 465 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ Required Data Table Columns
========================== =========== ============ =====================================================================================================================================
Name Type Units Description
========================== =========== ============ =====================================================================================================================================
TARGETID int64 ID (unique to file? and the whole survey?)
TARGETID int64 Unique DESI target ID
SURVEY [1]_ char[7] Survey name
PROGRAM [1]_ char[6] DESI program type - BRIGHT, DARK, BACKUP, OTHER
HEALPIX int32 HEALPixel containing this location at NSIDE=64 in the NESTED scheme
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ Required Data Table Columns
========================== =========== ============ =====================================================================================================================================
Name Type Units Description
========================== =========== ============ =====================================================================================================================================
TARGETID int64 ID (unique to file? and the whole survey?)
TARGETID int64 Unique DESI target ID
SURVEY [1]_ char[7] Survey name
PROGRAM [1]_ char[6] DESI program type - BRIGHT, DARK, BACKUP, OTHER
LASTNIGHT int32 Final night of observation included in a series of coadds
Expand Down
3 changes: 3 additions & 0 deletions doc/changes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,16 @@ desidatamodel Change Log
* Update definition of ``ZCAT_NSPEC`` (PR `#187`_).
* Add note about equivalent width values in ``fuji`` and ``guadalupe`` (PR `#181`_).
* Add note about units in FITS files (PR `#178`_).
* Update ``column_descriptions.csv`` for short Description (for FITS headers)
and FullDescription (longer, for data model) (PR `#196`_).

.. _`#178`: https://github.com/desihub/desidatamodel/pull/178
.. _`#181`: https://github.com/desihub/desidatamodel/pull/181
.. _`#187`: https://github.com/desihub/desidatamodel/pull/187
.. _`#189`: https://github.com/desihub/desidatamodel/pull/189
.. _`#192`: https://github.com/desihub/desidatamodel/pull/192
.. _`#193`: https://github.com/desihub/desidatamodel/pull/193
.. _`#196`: https://github.com/desihub/desidatamodel/pull/196

23.1 (2023-06-12)
-----------------
Expand Down
904 changes: 452 additions & 452 deletions py/desidatamodel/data/column_descriptions.csv

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions py/desidatamodel/stub.py
Original file line number Diff line number Diff line change
Expand Up @@ -701,7 +701,7 @@ def read_column_descriptions(filename):
"""Read column descriptions csv file and return dictionary
Args:
filename (str): csv filename with columns NAME,TYPE,UNITS,DESCRIPTION
filename (str): csv filename with columns NAME,TYPE,UNITS,DESCRIPTION,FULLDESCRIPTION
Returns:
coldesc_dict[NAME] = dict with keys TYPE, UNITS, DESCRIPTION
Expand All @@ -713,15 +713,15 @@ def read_column_descriptions(filename):

with open(filename) as fp:
header = fp.readline().strip()
correct_header = 'Name,Type,Units,Description'
correct_header = 'Name,Type,Units,Description,FullDescription'
if header != correct_header:
raise ValueError(f'{filename} header {header} should be {correct_header}')
raise ValueError(f'{filename} header {header} should be {correct_header}.')

coldesc = dict()
csvreader = csv.reader(fp)
for row in csvreader:
name, dtype, units, desc = row
coldesc[name] = dict(Type=dtype, Units=units, Description=desc)
name, dtype, units, short_desc, full_desc = row
coldesc[name] = dict(Type=dtype, Units=units, Description=full_desc)

return coldesc

Expand Down Expand Up @@ -754,7 +754,7 @@ def main():
parser.add_argument('filename', help='A FITS file.', metavar='FILE',
nargs='+')
parser.add_argument("--column_descriptions",
help="CSV file with column info Name,Type,Units,Description; "
help="CSV file with column info Name,Type,Units,Description,FullDescription; "
"default=%(default)s",
default=(ir.files('desidatamodel') / 'data' / 'column_descriptions.csv'))

Expand Down
8 changes: 4 additions & 4 deletions py/desidatamodel/test/t/column_descriptions.csv
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Name,Type,Units,Description
target,char[20],,Target Name
V_mag,float32,nanomaggy,V-band nanomaggy to test units
vdisp,float64,m/s,Velocity dispersion
Name,Type,Units,Description,FullDescription
target,char[20],,Target Name,Target Name
V_mag,float32,nanomaggy,V-band flux,V-band nanomaggy to test units
vdisp,float64,m/s,Vel Disp,Velocity dispersion
6 changes: 5 additions & 1 deletion py/desidatamodel/test/test_stub.py
Original file line number Diff line number Diff line change
Expand Up @@ -685,6 +685,10 @@ def test_Stub_with_descriptions(self, mock_log):

# incorrect format column description file
baddescfile = self.test_files / 'bad_column_descriptions.csv'
with self.assertRaises(ValueError):
header = 'Name,dtype,Units,Description'
correct_header = 'Name,Type,Units,Description,FullDescription'
with self.assertRaises(ValueError) as exc:
stub = Stub(filename, description_file=baddescfile)
lines = str(stub)
self.assertEqual(exc.exception.args[0],
f'{str(baddescfile)} header {header} should be {correct_header}.')

0 comments on commit 37f22ff

Please sign in to comment.