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

concatenate bins #543

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from
Open

concatenate bins #543

wants to merge 5 commits into from

Conversation

ahms5
Copy link
Member

@ahms5 ahms5 commented Feb 12, 2024

Which issue(s) are closed by this pull request?

Closes #469

Changes proposed in this pull request:

  • add concatenate_bins which Merge multiple FrequencyData objects along the frequency axe.
  • sort the frequency bins and the data accordingly.
  • for double frequencies if fails due to the FrequencyData object init. I leave it to the user to remove this double entries.

@ahms5 ahms5 marked this pull request as ready for review February 12, 2024 08:49
@ahms5 ahms5 added audio Classes pyfar.classes.audio v0.7.0 labels Feb 12, 2024
Copy link
Member

@mberz mberz left a comment

Choose a reason for hiding this comment

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

Hey, thanks for implementing this.
I have a few conceptual comments/questions.

  1. Would it make sense to combine this with a function which also supports merging TimeData?
  2. Since the function does sort the frequency data, it's more of a merge, rather than concatenation of the data. I'd rename to sth. like merge_data or similar.

@ahms5
Copy link
Member Author

ahms5 commented Feb 12, 2024

Good question, but then sorting the bins does not make much scence, doesn't it? or we also add concatenate, which just concatenate the data, and merge does the sorting... an other option would be to add the sorting as an option... not sure what is the best way to go for.

sure we can rename it. lets finalize your first question first.

@sikersten
Copy link
Member

+1 for the two points raised by @mberz.
@ahms5 Why do you think sorting the bins does not make sense with time data?

Copy link
Member

@f-brinkmann f-brinkmann left a comment

Choose a reason for hiding this comment

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

Also in favor for discussing suggestions from @mberz and added one more idea to improve flexibility.

"Input must be a tuple or list of pf.FrequencyData objects.")

for signal in signals:
if not isinstance(signal, (pf.FrequencyData)):
Copy link
Member

Choose a reason for hiding this comment

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

This is True for pyfar.Signal due to the inheritance. I think type(signal) != pf.FrequencyData is what you want.

Copy link
Contributor

Choose a reason for hiding this comment

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

This should also be tested then.

@@ -212,3 +212,45 @@ def concatenate_channels(signals, caxis=0, broadcasting=False):
return pf.TimeData(data, signals[0].times)
else:
return pf.FrequencyData(data, signals[0].frequencies)


def concatenate_bins(signals):
Copy link
Member

Choose a reason for hiding this comment

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

Since we now have functions to broadcast cshapes of audio objects it would be nice to include this by default to make this more flexible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
audio Classes pyfar.classes.audio v0.7.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants