-
Notifications
You must be signed in to change notification settings - Fork 12
fix: corrected mu vs muD usage, remove packing fraction option #198
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
Open
yucongalicechen
wants to merge
1
commit into
diffpy:main
Choose a base branch
from
yucongalicechen:mud-remove-pf
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
**Added:** | ||
|
||
* no news added - corrected mu vs muD usage and removed packing fraction option for estimating muD | ||
|
||
**Changed:** | ||
|
||
* <news item> | ||
|
||
**Deprecated:** | ||
|
||
* <news item> | ||
|
||
**Removed:** | ||
|
||
* <news item> | ||
|
||
**Fixed:** | ||
|
||
* <news item> | ||
|
||
**Security:** | ||
|
||
* <news item> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,17 +34,15 @@ | |
|
||
# Exclude wavelength to avoid duplication, | ||
# as it's written explicitly by diffpy.utils dump function. | ||
# Exclude "theoretical_from_density" and "theoretical_from_packing" | ||
# as they are only used for theoretical mu*D estimation | ||
# and will be written into separate arguments for clarity. | ||
# Exclude "theoretical_estimation" | ||
# as it will be written into separate arguments for clarity. | ||
METADATA_KEYS_TO_EXCLUDE = [ | ||
"output_correction", | ||
"force_overwrite", | ||
"input", | ||
"input_paths", | ||
"wavelength", | ||
"theoretical_from_density", | ||
"theoretical_from_packing", | ||
"theoretical_estimation", | ||
"subcommand", | ||
] | ||
|
||
|
@@ -320,49 +318,37 @@ def _set_mud_from_zscan(args): | |
def _parse_theoretical_input(input_str): | ||
"""Helper function to parse and validate the input string.""" | ||
parts = [part.strip() for part in input_str.split(",")] | ||
if len(parts) != 3: | ||
if len(parts) != 4: | ||
raise ValueError( | ||
f"Invalid mu*D input '{input_str}'. " | ||
f"Invalid muD input '{input_str}'. " | ||
"Expected format is 'sample composition, energy, " | ||
"sample mass density or packing fraction' " | ||
"(e.g., 'ZrO2,17.45,0.5').", | ||
"sample mass density, capillary diameter' " | ||
"(e.g., 'ZrO2,17.45,0.5,1.0').", | ||
) | ||
sample_composition = parts[0] | ||
energy = float(parts[1]) | ||
mass_density_or_packing_fraction = float(parts[2]) | ||
return sample_composition, energy, mass_density_or_packing_fraction | ||
sample_mass_density = float(parts[2]) | ||
capillary_diameter = float(parts[3]) | ||
return sample_composition, energy, sample_mass_density, capillary_diameter | ||
|
||
|
||
def _set_theoretical_mud_from_density(args): | ||
"""Theoretical estimation of mu*D from sample composition, energy, and | ||
sample mass density.""" | ||
sample_composition, energy, sample_mass_density = _parse_theoretical_input( | ||
args.theoretical_from_density | ||
def _set_theoretical_mud(args): | ||
"""Theoretical estimation of muD from sample composition, energy, sample | ||
mass density, and capillary diameter.""" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove packing fraction as an option, add capillary diameter |
||
sample_composition, energy, sample_mass_density, capillary_diameter = ( | ||
_parse_theoretical_input(args.theoretical_estimation) | ||
) | ||
args.sample_composition = sample_composition | ||
args.energy = energy | ||
args.sample_mass_density = sample_mass_density | ||
args.mud = compute_mu_using_xraydb( | ||
args.sample_composition, | ||
args.energy, | ||
sample_mass_density=args.sample_mass_density, | ||
) | ||
return args | ||
|
||
|
||
def _set_theoretical_mud_from_packing(args): | ||
"""Theoretical estimation of mu*D from sample composition, energy, and | ||
packing fraction.""" | ||
sample_composition, energy, packing_fraction = _parse_theoretical_input( | ||
args.theoretical_from_packing | ||
) | ||
args.sample_composition = sample_composition | ||
args.energy = energy | ||
args.packing_fraction = packing_fraction | ||
args.mud = compute_mu_using_xraydb( | ||
args.sample_composition, | ||
args.energy, | ||
packing_fraction=args.packing_fraction, | ||
args.capillary_diameter = capillary_diameter | ||
args.mud = ( | ||
compute_mu_using_xraydb( | ||
args.sample_composition, | ||
args.energy, | ||
sample_mass_density=args.sample_mass_density, | ||
) | ||
* args.capillary_diameter | ||
) | ||
return args | ||
|
||
|
@@ -373,8 +359,7 @@ def set_mud(args): | |
Options include: | ||
1. Manually entering a value. | ||
2. Estimating from a z-scan file. | ||
3. Estimating theoretically based on sample mass density. | ||
4. Estimating theoretically based on packing fraction. | ||
3. Estimating theoretically based on relevant chemical info. | ||
|
||
Parameters | ||
---------- | ||
|
@@ -384,14 +369,12 @@ def set_mud(args): | |
Returns | ||
------- | ||
args : argparse.Namespace | ||
The updated arguments with mu*D. | ||
The updated arguments with muD. | ||
""" | ||
if args.z_scan_file: | ||
return _set_mud_from_zscan(args) | ||
elif args.theoretical_from_density: | ||
return _set_theoretical_mud_from_density(args) | ||
elif args.theoretical_from_packing: | ||
return _set_theoretical_mud_from_packing(args) | ||
elif args.theoretical_estimation: | ||
return _set_theoretical_mud(args) | ||
return args | ||
|
||
|
||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Adding capillary diameter as a requirement