Skip to content

Implement fiber-segregated data object creation in prepare_all_data#55

Draft
ben-sappey with Copilot wants to merge 4 commits into
mainfrom
copilot/segregate-science-results-by-fiber
Draft

Implement fiber-segregated data object creation in prepare_all_data#55
ben-sappey with Copilot wants to merge 4 commits into
mainfrom
copilot/segregate-science-results-by-fiber

Conversation

Copilot AI commented Nov 24, 2025

Copy link
Copy Markdown

The prep_data_object function needed to dynamically identify and segregate science results by fiber number, with science fibers indexed from 0.

Changes

Created prepare_all_data() function that replaces hard-coded fiber enumeration with dynamic detection:

  • Uses np.unique(fiber_list) to identify all discrete science fiber numbers present in the data
  • Groups file numbers by their corresponding fiber
  • Returns a dictionary of KPIC data objects keyed by fiber number (0-indexed)

Maintained backward compatibility:

  • prep_data_object() now wraps prepare_all_data() with deprecation notice

Example Usage

from breads.instruments.KPIC import prepare_all_data

# Files for fibers 0 and 2 only (fibers 1,3 absent)
fiber_list = [0, 0, 2, 2, 0]
file_numbers = [100, 101, 102, 103, 104]

data_objects = prepare_all_data('20210101', file_numbers, fiber_list,
                                 '/data/', 'trace.fits', 'wvs.fits', [5, 6, 7])

# Returns: {0: <KPIC obj with files 100,101,104>, 2: <KPIC obj with files 102,103>}

The implementation adapts to any fiber configuration without assuming exactly 4 fibers are present.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • simbad.cds.unistra.fr
    • Triggering command: /usr/bin/python python -m pytest breads/tests/ -v (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

In the current prepare_all_data function, for science results, I need the results to be segregated by science fiber. in the fiber list entry, I need the code to identify all of the discrete numbers that correspond to science fibers and then take the corresponding file number (everthing should be in order) and create multiple data objects that can be returned with the key corresponding to the science fiber number. In the code, we index science fibers from 0

Created from VS Code via the GitHub Pull Request extension.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 3 commits November 24, 2025 17:53
Co-authored-by: ben-sappey <74935396+ben-sappey@users.noreply.github.com>
Co-authored-by: ben-sappey <74935396+ben-sappey@users.noreply.github.com>
Co-authored-by: ben-sappey <74935396+ben-sappey@users.noreply.github.com>
Copilot AI changed the title [WIP] Segregate science results by fiber in prepare_all_data function Implement fiber-segregated data object creation in prepare_all_data Nov 24, 2025
Copilot AI requested a review from ben-sappey November 24, 2025 18:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants