Skip to content

Commit

Permalink
restore tilegrp
Browse files Browse the repository at this point in the history
  • Loading branch information
Sean-Morrison committed Nov 6, 2024
1 parent 460582f commit 6cea8e0
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 7 deletions.
36 changes: 31 additions & 5 deletions python/sdss_access/path/path.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,15 +325,15 @@ def extract(self, name, example):
# handle special functions; perform a drop in replacement
if re.match('@spectrodir[|]', template):
template = re.sub('@spectrodir[|]', os.environ['BOSS_SPECTRO_REDUX'], template)
elif re.search('@platedir[|]', template):
if re.search('@platedir[|]', template):
template = re.sub('@platedir[|]', r'(.*)/{plateid:0>6}', template)
elif re.search('@definitiondir[|]', template):
if re.search('@definitiondir[|]', template):
template = re.sub('@definitiondir[|]', '{designid:0>6}', template)
elif re.search('@apgprefix[|]', template):
if re.search('@apgprefix[|]', template):
template = re.sub('@apgprefix[|]', '{prefix}', template)
elif re.search('@healpixgrp[|]', template):
if re.search('@healpixgrp[|]', template):
template = re.sub('@healpixgrp[|]', '{healpixgrp}', template)
elif re.search('@configgrp[|]', template):
if re.search('@configgrp[|]', template):
template = re.sub('@configgrp[|]', '{configgrp}', template)
if re.search('@isplate[|]', template):
template = re.sub('@isplate[|]', '{isplate}', template)
Expand All @@ -359,6 +359,8 @@ def extract(self, name, example):
template = re.sub('@cat_id_groups[|]', '{cat_id_groups}', template)
if re.search('@sdss_id_groups[|]', template):
template = re.sub('@sdss_id_groups[|]', '{sdss_id_groups}', template)
if re.search('@tilegrp[|]', template):
template = re.sub('@tilegrp[|]', '{tilegrp}', template)

# check if template has any brackets
haskwargs = re.search('[{}]', template)
Expand Down Expand Up @@ -1738,5 +1740,29 @@ def fieldgrp(self, filetype, **kwargs):
return '{:0>3d}XXX'.format(int(fieldid) // 1000)
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
7 changes: 5 additions & 2 deletions tests/path/test_sdss5.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,14 @@ def test_apogee_paths(self, path, name, special, keys, exp):
('spAll_epoch','@epochflag',{'run2d':'v6_2_0'},
'v6_2_0/summary/epoch/spAll-v6_2_0-epoch.fits'),
('spAll_coadd','@spcoaddgrp',{'run2d':'v6_2_0','coadd':'allepoch'},
'v6_2_0/summary/allepoch/spAll-v6_2_0-allepoch.fits')],
'v6_2_0/summary/allepoch/spAll-v6_2_0-allepoch.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-*','spcoaddfolder', 'sptypefolder',
'fieldgrp','spcoaddobs','epochflag','spcoaddgrp'])
'fieldgrp','spcoaddobs','epochflag','spcoaddgrp','lvm-tileid'])
def test_special_function(self, path, name, special, keys, exp):
assert special in path.templates[name]
full = os.path.normpath(path.full(name, **keys))
Expand Down

0 comments on commit 6cea8e0

Please sign in to comment.