Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update pad_fieldid function #46

Merged
merged 6 commits into from
Oct 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions python/sdss_access/path/path.py
Original file line number Diff line number Diff line change
Expand Up @@ -1407,7 +1407,7 @@ def isplate(self, filetype, **kwargs):
Parameters
---------
filetype : str
File type paramter
File type parameter
run2d : str
BOSS idlspec2d run2d version

Expand All @@ -1430,7 +1430,7 @@ def pad_fieldid(self, filetype, **kwargs):
Parameters
---------
filetype : str
File type paramter
File type parameter
run2d : str
BOSS idlspec2d run2d version
fieldid : str or int
Expand All @@ -1447,9 +1447,13 @@ def pad_fieldid(self, filetype, **kwargs):

if (not run2d) & (not fieldid):
return ''
fieldid = str(fieldid)
if run2d in ['v6_0_1','v6_0_2', 'v6_0_3', 'v6_0_4']:
return str(fieldid)
return str(fieldid).zfill(6)
if fieldid.isnumeric():
return str(fieldid).zfill(6)
else:
return fieldid


class AccessError(Exception):
Expand Down
6 changes: 4 additions & 2 deletions tests/path/test_sdss5.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,11 @@ def test_apogee_paths(self, path, name, special, keys, exp):
('spFrame', '@pad_fieldid', {'run2d': 'v6_0_8', 'br': 'b', 'id': '1', 'frame': '5432', 'fieldid':'1234'},
'v6_0_8/001234/spFrame-b1-00005432.fits.gz'),
('spFrame', '@pad_fieldid', {'run2d': 'v6_0_4', 'br': 'b', 'id': '1', 'frame': '5432', 'fieldid':'1234'},
'v6_0_4/1234p/spFrame-b1-00005432.fits.gz')],
'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')],
ids=['configgrp', 'apgprefix-apo', 'apgprefix-lco', 'apgprefix-ins',
'isplate-v6_0_4','pad_fieldid-5','pad_fieldid-6', 'frame-pad', 'frame-nopadp'])
'isplate-v6_0_4','pad_fieldid-5','pad_fieldid-6', 'frame-pad', 'frame-nopadp', 'pad_fieldid-*'])
def test_special_function(self, path, name, special, keys, exp):
assert special in path.templates[name]
full = path.full(name, **keys)
Expand Down
Loading