Skip to content

Commit

Permalink
Merge pull request #49 from sdss/lvmtile
Browse files Browse the repository at this point in the history
Adds new tilegrp method for LVM
  • Loading branch information
havok2063 authored Nov 29, 2023
2 parents 8710443 + 7ead577 commit c9a6c12
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 3 deletions.
25 changes: 24 additions & 1 deletion python/sdss_access/path/path.py
Original file line number Diff line number Diff line change
Expand Up @@ -1275,7 +1275,7 @@ def sdss_id_groups(self, filetype, **kwargs):
-------
sdssid_groups : str
A set of folders.
'''
'''
# with k = 100 then even with 10 M sources, each folder will have ~1,000 files
k = 100
sdss_id = int(kwargs["sdss_id"])
Expand Down Expand Up @@ -1480,6 +1480,29 @@ def pad_fieldid(self, filetype, **kwargs):
else:
return fieldid

def tilegrp(self, filetype, **kwargs):
''' Returns LVM tile id group subdirectory
Parameters
----------
filetype : str
File type parameter.
tileid : int or str
LVM Tile ID number. Will be converted to int internally.
Returns
-------
tileidgrp : str
Tile ID group directory in the format ``NNNNXX``.
'''

tileid = kwargs.get('tileid', None)
if not tileid:
return '0000XX'
elif '*' in str(tileid):
return '{0}XX'.format(tileid)
return '{:0>4d}XX'.format(int(tileid) // 1000)

class AccessError(Exception):
pass
8 changes: 6 additions & 2 deletions tests/path/test_sdss5.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,13 @@ def test_apogee_paths(self, path, name, special, keys, exp):
('spFrame', '@pad_fieldid', {'run2d': 'v6_0_4', 'br': 'b', 'id': '1', 'frame': '5432', 'fieldid':'1234'},
'v6_0_4/1234p/spFrame-b1-00005432.fits.gz'),
('spField', '@pad_fieldid', {'run2d': 'v6_1_1', 'mjd': '59630', 'fieldid': '*'},
'v6_1_1/*/spField-*-59630.fits')],
'v6_1_1/*/spField-*-59630.fits'),
('lvm_frame', '@tilegrp', {'drpver': 'master', 'mjd': 60235,
'tileid': 1055360, 'kind': 'CFrame', 'expnum': 6817},
'1055XX/1055360/60235/lvmCFrame-00006817.fits')],
ids=['configgrp', 'apgprefix-apo', 'apgprefix-lco', 'apgprefix-ins',
'isplate-v6_0_4','pad_fieldid-5','pad_fieldid-6', 'frame-pad', 'frame-nopadp', 'pad_fieldid-*'])
'isplate-v6_0_4','pad_fieldid-5','pad_fieldid-6', 'frame-pad', 'frame-nopadp',
'pad_fieldid-*', 'lvm-tileid'])
def test_special_function(self, path, name, special, keys, exp):
assert special in path.templates[name]
full = path.full(name, **keys)
Expand Down

0 comments on commit c9a6c12

Please sign in to comment.