-
Notifications
You must be signed in to change notification settings - Fork 11
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: update functions related to diffpy.utils
update
#151
Conversation
src/diffpy/labpdfproc/functions.py
Outdated
|
||
RADIUS_MM = 1 | ||
N_POINTS_ON_DIAMETER = 300 | ||
TTH_GRID = np.arange(1, 180.1, 0.1) | ||
TTH_GRID = np.round(np.arange(1, 180.1, 0.1), decimals=1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
np.arrange
causes the value at 180 degree to go above 180 slightly because of floating-point precision errors. I think we can round every value to 1 decimal place here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I ran the interpolation and coefficient lists using np.arrange
though... but after rerunning a few angles I believe this rounding error is so small that it can be ignored
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mmm., this seems like a slightly dramatic fix to a small edge-case. Is there not a less intrusive fix for this? Let's think about this a bit more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, maybe I can round down 180 only?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that's what I had in mind.
@sbillinge ready for review. This PR includes all updates from diffpy.utils. No significant functionality changes. But it's causing a conflict because I removed the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
exciting! please see inline.
src/diffpy/labpdfproc/functions.py
Outdated
|
||
RADIUS_MM = 1 | ||
N_POINTS_ON_DIAMETER = 300 | ||
TTH_GRID = np.arange(1, 180.1, 0.1) | ||
TTH_GRID = np.round(np.arange(1, 180.1, 0.1), decimals=1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mmm., this seems like a slightly dramatic fix to a small edge-case. Is there not a less intrusive fix for this? Let's think about this a bit more.
you will have to merge in main to resolve the conflict (or add the mud calculator back....) |
src/diffpy/labpdfproc/functions.py
Outdated
|
||
RADIUS_MM = 1 | ||
N_POINTS_ON_DIAMETER = 300 | ||
TTH_GRID = np.arange(1, 180.1, 0.1) | ||
# Round down the last element if it's slightly above 180 due to floating point precision | ||
TTH_GRID[-1] = 180 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
round down 180 only
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe 180.00 so it is clear you want to keep it as a float?
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #151 +/- ##
==========================================
- Coverage 99.31% 99.27% -0.05%
==========================================
Files 6 5 -1
Lines 293 275 -18
==========================================
- Hits 291 273 -18
Misses 2 2
|
@sbillinge ready for another review. I fixed the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't quite finish the review and have to run, but I am posting this now so you can work on it.
news/utils-updates.rst
Outdated
|
||
**Changed:** | ||
|
||
* Updated functions related to changes in `diffpy.utils` version 3.6.0. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you try and think more precisely about how to say this. "Updated" is the same as "changed" so the message contains close to zero information.....
src/diffpy/labpdfproc/functions.py
Outdated
|
||
RADIUS_MM = 1 | ||
N_POINTS_ON_DIAMETER = 300 | ||
TTH_GRID = np.arange(1, 180.1, 0.1) | ||
# Round down the last element if it's slightly above 180 due to floating point precision | ||
TTH_GRID[-1] = 180 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe 180.00 so it is clear you want to keep it as a float?
src/diffpy/labpdfproc/tools.py
Outdated
from diffpy.utils.scattering_objects.diffraction_objects import QQUANTITIES, XQUANTITIES | ||
from diffpy.utils.tools import get_package_info, get_user_info | ||
from diffpy.utils.diffraction_objects import ANGLEQUANTITIES, QQUANTITIES, XQUANTITIES | ||
from diffpy.utils.tools import check_and_build_global_config, compute_mud, get_package_info, get_user_info | ||
|
||
WAVELENGTHS = {"Mo": 0.71, "Ag": 0.59, "Cu": 1.54} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we want a few more sig figs on these
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I found for Mo and Cu the values should be around 0.7107 and 1.5406. I couldn't find the values for Ag though..
src/diffpy/labpdfproc/tools.py
Outdated
config = get_user_info(config) | ||
args.username = config["username"] | ||
args.email = config["email"] | ||
check_and_build_global_config() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since here we are allowing people to pass in this info as an arg, probably the workflow should be
-
if the arg is set, use the arg and don't even run the config updater
-
if the arg is not set, run the config updater
-
run get_user_info passing in the args if they are not None.
src/diffpy/labpdfproc/tools.py
Outdated
args.email = config["email"] | ||
check_and_build_global_config() | ||
config = get_user_info(owner_name=args.username, owner_email=args.email) | ||
args.username = config["owner_name"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is there a reason you are not using config.get()
here? That is usually better practice.
news/utils-updates.rst
Outdated
|
||
**Changed:** | ||
|
||
* Functions related to diffraction_objects and tools modules in `diffpy.utils` to reflect changes in version 3.6.0. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
better wording..?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not really. None of the users reading this will have any idea about diffpy.utils 3.6.0.
Something like
* Functions that use DiffractionObject` in `diffpy.utils` to follow the new API.
src/diffpy/labpdfproc/tools.py
Outdated
|
||
WAVELENGTHS = {"Mo": 0.71, "Ag": 0.59, "Cu": 1.54} | ||
WAVELENGTHS = {"Mo": 0.71073, "Ag": 0.55941, "Cu": 1.5406} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need a little help on the value for Ag. I found it here https://x-server.gmca.aps.anl.gov/cgi/www_dbli.exe?x0hdb=waves but it's a bit off from our original value..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Cu", "CuKa1", "CuKa1Ka2"
CuKa1 : 1.54056
CuKa1Ka2 : =(1.54056*2 + 1.544398)/3 = 1.54184
Cu : 1.542
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@yucongalicechen will need docs to explain what is going on.
@sbillinge ready for some more feedback. The error in the tests is related to the wavelength for Ag. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please see inline
news/utils-updates.rst
Outdated
|
||
**Changed:** | ||
|
||
* Functions related to diffraction_objects and tools modules in `diffpy.utils` to reflect changes in version 3.6.0. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not really. None of the users reading this will have any idea about diffpy.utils 3.6.0.
Something like
* Functions that use DiffractionObject` in `diffpy.utils` to follow the new API.
src/diffpy/labpdfproc/tools.py
Outdated
|
||
WAVELENGTHS = {"Mo": 0.71, "Ag": 0.59, "Cu": 1.54} | ||
WAVELENGTHS = {"Mo": 0.71073, "Ag": 0.55941, "Cu": 1.5406} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Cu", "CuKa1", "CuKa1Ka2"
CuKa1 : 1.54056
CuKa1Ka2 : =(1.54056*2 + 1.544398)/3 = 1.54184
Cu : 1.542
src/diffpy/labpdfproc/tools.py
Outdated
|
||
WAVELENGTHS = {"Mo": 0.71, "Ag": 0.59, "Cu": 1.54} | ||
WAVELENGTHS = {"Mo": 0.71073, "Ag": 0.55941, "Cu": 1.5406} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@yucongalicechen will need docs to explain what is going on.
closes #129