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

Fix "sampling_rate" not updating along with "dt" #568

Merged
merged 1 commit into from
Oct 22, 2024

Conversation

Cloud1e
Copy link
Collaborator

@Cloud1e Cloud1e commented Oct 20, 2024

I fixed the issue of the attribute "sampling_rate" not updating when "dt" changes.
This happens in resample in resample.py and TimeSeries2Trace in converter.py.
I also edited the test code for the resample and it passed all the cases.

Copy link

codecov bot commented Oct 20, 2024

Codecov Report

Attention: Patch coverage is 91.89189% with 3 lines in your changes missing coverage. Please review.

Project coverage is 55.82%. Comparing base (2980b79) to head (334cb51).
Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
python/mspasspy/algorithms/resample.py 89.28% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #568      +/-   ##
==========================================
+ Coverage   55.75%   55.82%   +0.07%     
==========================================
  Files         149      149              
  Lines       23171    23227      +56     
  Branches     1340     1340              
==========================================
+ Hits        12918    12966      +48     
- Misses       9912     9920       +8     
  Partials      341      341              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@wangyinz wangyinz left a comment

Choose a reason for hiding this comment

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

This is great! Thanks for fixing it! I only have two minor comments. We can merge it after you address it. Thank you!

message = "sampling_rate inconsistent with 1/dt; updating to 1/dt"
mspass_object.elog.log_error("TimeSeries2Trace",
message,
ErrorSeverity.Invalid)
Copy link
Member

Choose a reason for hiding this comment

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

The ErrorSeverity should be Complaint instead of Invalid. Also, the algorithm name here is wrong. This is inside resample not TimeSeries2Trace. There are similar issues to the rest of the changes here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I fixed it and have pushed it.

ErrorSeverity.Invalid)
# Update sampling_rate to 1/dt
mspass_object["sampling_rate"] = 1.0 / mspass_object.dt
else:
Copy link
Member

Choose a reason for hiding this comment

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

The else branch here is not covered by test. Also, I think we need to add tests for the converter, too. We also need to test for the elog here. I am actually not sure whether elog is correctly retained after the conversion to Trace and back.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I fixed it and pushed it. I think elog is correctly retained during my tests.

@wangyinz
Copy link
Member

btw, I see the python builds failed due to AttributeError: module 'pymongo' has no attribute 'database', which is something we currently have not fixed for the API change of the new pymongo. The commit 8ef0ae3 address the problem by temporarily limit our pymongo to an old version... We might need to look into implementing the changes now...

@Cloud1e
Copy link
Collaborator Author

Cloud1e commented Oct 21, 2024

btw, I see the python builds failed due to AttributeError: module 'pymongo' has no attribute 'database', which is something we currently have not fixed for the API change of the new pymongo. The commit 8ef0ae3 address the problem by temporarily limit our pymongo to an old version... We might need to look into implementing the changes now...

I fixed this and now it works well.

@wangyinz wangyinz merged commit b459473 into master Oct 22, 2024
12 checks passed
@wangyinz wangyinz deleted the chenbo/fix_resample branch October 22, 2024 15:57
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