Skip to content

Align output formats and data return options between inspiral-only and IMR generation functions#12

Draft
Copilot wants to merge 5 commits into
masterfrom
copilot/align-output-formats-imr-inspiral
Draft

Align output formats and data return options between inspiral-only and IMR generation functions#12
Copilot wants to merge 5 commits into
masterfrom
copilot/align-output-formats-imr-inspiral

Conversation

Copy link
Copy Markdown

Copilot AI commented May 5, 2026

IMR waveform functions had two inconsistencies with their inspiral counterparts: modes/polarizations were returned first (inspiral returns them last), and there was no return_pycbc_timeseries flag to skip the overhead of packaging numpy arrays into PyCBC TimeSeries objects.

Changes

get_imr_esigma_modes / get_imr_esigma_waveform (generator.py)

  • Added return_pycbc_timeseries=True parameter; when False, returns raw numpy arrays with a time grid as the first element
  • Fixed return order — modes/polarizations are now last: (orbital_vars_dict, hyb_info, modes_imr) instead of (modes_imr, orbital_vars_dict, hyb_info)
  • get_imr_esigma_waveform now calls modes internally with return_pycbc_timeseries=False and handles PyCBC wrapping itself, consistent with inspiral waveform
  • Renamed internal inspiral retvalinspiral_retval to disambiguate from hybridization retval

get_imr_esigmasur_mode / get_imr_esigmasur_waveform (surrogate/generator.py)

  • Same return_pycbc_timeseries=True addition with numpy+time-grid path
  • Fixed a pre-existing bug in get_imr_esigmasur_waveform where unpacking from get_imr_esigmasur_mode incorrectly assumed modes-first ordering (that function already returned modes last)
  • Polarizations now returned last in get_imr_esigmasur_waveform

Misc

  • Replaced exec() f-string pattern for orbital vars PyCBC wrapping with direct dict assignment

Usage after this change

# NumPy path (no PyCBC overhead):
t, modes = get_imr_esigma_modes(..., return_pycbc_timeseries=False)

# Extra return values now come before modes/polarizations:
t, orbital_vars, hp, hc = get_imr_esigma_waveform(
    ..., return_orbital_params=True, return_pycbc_timeseries=False
)

# Default (PyCBC) behaviour is unchanged:
hp, hc = get_imr_esigma_waveform(...)  # still returns PyCBC TimeSeries

Copilot AI and others added 3 commits May 5, 2026 16:56
…meseries flag, fix return order (modes/polarizations last)

Agent-Logs-Url: https://github.com/gwnrtools/esigmapy/sessions/57837241-fb95-4316-a67c-050fb712fdda

Co-authored-by: Akash-Maurya-0899 <100226598+Akash-Maurya-0899@users.noreply.github.com>
Agent-Logs-Url: https://github.com/gwnrtools/esigmapy/sessions/57837241-fb95-4316-a67c-050fb712fdda

Co-authored-by: Akash-Maurya-0899 <100226598+Akash-Maurya-0899@users.noreply.github.com>
… with f-strings

Agent-Logs-Url: https://github.com/gwnrtools/esigmapy/sessions/57837241-fb95-4316-a67c-050fb712fdda

Co-authored-by: Akash-Maurya-0899 <100226598+Akash-Maurya-0899@users.noreply.github.com>
Copilot AI changed the title [WIP] Align output formats and data return options for IMR functions Align output formats and data return options between inspiral-only and IMR generation functions May 5, 2026
Copilot AI requested a review from Akash-Maurya-0899 May 5, 2026 17:00
Comment thread esigmapy/generator.py
)
else:
modes_imr = modes_imr_numpy
t_imr = np.arange(len(next(iter(modes_imr_numpy.values())))) * delta_t - t_peak
Copy link
Copy Markdown
Collaborator

@Akash-Maurya-0899 Akash-Maurya-0899 May 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Akash-Maurya-0899 / @copilot Check if this matches with the time-grid generated by the sample_times method of the corresponding PyCBC TimeSeries modes.

Comment on lines +686 to +692
if return_hybridization_info and return_orbital_params_user:
return retval, orbital_vars_dict, modes_imr
elif return_orbital_params_user:
return orbital_vars_dict, modes_imr
elif return_hybridization_info:
return retval, modes_imr
return modes_imr
Copy link
Copy Markdown
Contributor

@prayush prayush May 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot Here and everywhere in this PR, keep the order of return objects such that modes_imr is first and all the others are packed into a tuple. e.g. these lines can be replaced with

        if return_hybridization_info and return_orbital_params_user:
            return modes_imr, (retval, orbital_vars_dict)
        elif return_orbital_params_user:
            return modes_imr, (orbital_vars_dict,)
        elif return_hybridization_info:
            return modes_imr, (retval,)
        return modes_imr

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.

Align output formats and data return options between Inspiral-only and IMR generation functions

3 participants