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

add sdss_id_groups #45

Merged
merged 1 commit into from
Oct 10, 2023
Merged
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
25 changes: 25 additions & 0 deletions python/sdss_access/path/path.py
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,8 @@
template = re.sub('@component_default[|]', '{component_default}', template)
if re.search('@cat_id_groups[|]', template):
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)

Check warning on line 349 in python/sdss_access/path/path.py

View check run for this annotation

Codecov / codecov/patch

python/sdss_access/path/path.py#L349

Added line #L349 was not covered by tests

# check if template has any brackets
haskwargs = re.search('[{}]', template)
Expand Down Expand Up @@ -1257,6 +1259,29 @@
cat_id = int(kwargs['cat_id'])
return f"{(cat_id // k) % k:0>2.0f}/{cat_id % k:0>2.0f}"

def sdss_id_groups(self, filetype, **kwargs):
'''
Return a folder structure to group data together based on their SDSS
identifier so that we don't have too many files in any one folder.

Parameters
----------
filetype : str
File type parameter.
sdss_id : int or str
SDSS-V identifier

Returns
-------
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"])
return f"{(sdss_id // k) % k:0>2.0f}/{sdss_id % k:0>2.0f}"

Check warning on line 1282 in python/sdss_access/path/path.py

View check run for this annotation

Codecov / codecov/patch

python/sdss_access/path/path.py#L1280-L1282

Added lines #L1280 - L1282 were not covered by tests


def component_default(self, filetype, **kwargs):
''' Return the component name, if given.

Expand Down
Loading