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

resample! is slow on NodalData #107

Open
stepholinger opened this issue Feb 3, 2023 · 3 comments
Open

resample! is slow on NodalData #107

stepholinger opened this issue Feb 3, 2023 · 3 comments

Comments

@stepholinger
Copy link
Contributor

stepholinger commented Feb 3, 2023

At the moment, resample! is about two orders of magnitude slower when applied to NodalData than to CorrData. The two result in very sightly different but essentially identical outputs. The example below should demonstrate the issue.

# choose original fs and new fs
fs = 100.
resample_fs = 10.

# generate some 'data'
sz = 500
data = rand(Float32,sz,sz)

# resample CorrData with same underlying data
C = CorrData(corr=data,fs=fs)
corr_time = @elapsed SeisNoise.resample!(C,resample_fs)

# resample  NodalData with same underlying data
S = SeisNoise.NodalData()
S.data=data
S.fs=ones(sz).*fs
nodal_time = @elapsed SeisNoise.resample!(S,resample_fs)

# print results
print("CorrData time: ", corr_time, " s\n")
print("NodalData time: ", nodal_time, " s\n")

# verify the results are almost identical
print("Total difference: ",sum(C.corr-S.data))

CorrData time: 0.032703704 s
NodalData time: 3.133497156 s
Total difference: 7.137656e-6

At the moment, it seems to be faster to load data into a CorrData object, resample, and then put the data back into a NodalData object.

@tclements
Copy link
Collaborator

Hmmm, this is puzzling! It's odd that resample even works with NodalData, as it looks like I didn't write a resample method that accepts NodalData.

@stepholinger
Copy link
Contributor Author

I think the SeisIO method resample takes any type of geophysical data, so I'm probably inadvertently using that method. I attempted to make sure I wasn't calling the SeisIO method by using SeisNoise.resample instead of just resample, but there may be an import line in SeisNoise that's allowing me to access the SeisIO method.

@tclements
Copy link
Collaborator

Yes, that's right! SeisNoise is just using SeisIO's resample method, which processes data trace by trace rather than as a matrix so it's suuper slow..

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

No branches or pull requests

2 participants