-
Notifications
You must be signed in to change notification settings - Fork 20
Add class docstring for DiffractionObject
#265
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| **Added:** | ||
|
|
||
| * class docstring for `DiffractionObject` | ||
|
|
||
| **Changed:** | ||
|
|
||
| * <news item> | ||
|
|
||
| **Deprecated:** | ||
|
|
||
| * <news item> | ||
|
|
||
| **Removed:** | ||
|
|
||
| * <news item> | ||
|
|
||
| **Fixed:** | ||
|
|
||
| * <news item> | ||
|
|
||
| **Security:** | ||
|
|
||
| * <news item> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -36,50 +36,38 @@ def _setter_wmsg(attribute): | |
|
|
||
| class DiffractionObject: | ||
| """ | ||
| Initialize a DiffractionObject instance. | ||
| A class to represent diffraction data for various scientific experiments involving scattering | ||
|
Contributor
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. Let's use the numpy standard. First line is <80 chars and gives a high level statement of the purpose. Then a blank line. then a more meaty description such as you have here).
Contributor
Author
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. done - do we want to use automatic doc formatting in pre-commit? ?? This basically modifies our code to PEP 257, although it does not fix the length, it does change the format.
Contributor
Author
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.
Contributor
Author
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. (i can create a separate PR for this) |
||
| techniques such as X-ray, neutron, and electron diffraction. This object can manage diffraction | ||
| data including transformations between different scattering quantities like q (scattering vector), | ||
| 2θ (two-theta angle), and d (interplanar spacing), and perform various operations like scaling, addition, | ||
|
sbillinge marked this conversation as resolved.
Outdated
|
||
| and subtraction of diffraction patterns. | ||
|
|
||
| Parameters | ||
| Attributes | ||
|
sbillinge marked this conversation as resolved.
|
||
| ---------- | ||
| xarray : array-like | ||
| The independent variable array containing "q", "tth", or "d" values. | ||
| yarray : array-like | ||
| The dependent variable array corresponding to intensity values. | ||
| xtype : str | ||
| The type of the independent variable in `xarray`. Must be one of {*XQUANTITIES}. | ||
| wavelength : float, optional | ||
| The wavelength of the incoming beam, specified in angstroms (Å). Default is none. | ||
| scat_quantity : str, optional | ||
| all_arrays : ndarray | ||
| The array containing the quantity of q, tth, d values. | ||
| input_xtype : str | ||
| The type of the independent variable in `xarray`. Must be one of {*XQUANTITIES} | ||
| id : uuid | ||
| The unique identifier for the diffraction object. | ||
|
sbillinge marked this conversation as resolved.
Outdated
|
||
| scat_quantity : str | ||
| The type of scattering experiment (e.g., "x-ray", "neutron"). Default is an empty string "". | ||
| name : str, optional | ||
| wavelength : float | ||
| The wavelength of the incoming beam, specified in angstroms (Å). Default is none. | ||
| name: str | ||
| The name or label for the scattering data. Default is an empty string "". | ||
| metadata : dict, optional | ||
| The additional metadata associated with the diffraction object. Default is {}. | ||
|
|
||
| Examples | ||
| -------- | ||
| Create a DiffractionObject for X-ray scattering data: | ||
|
|
||
| >>> import numpy as np | ||
| >>> from diffpy.utils.diffraction_objects import DiffractionObject | ||
| ... | ||
| >>> x = np.array([0.12, 0.24, 0.31, 0.4]) # independent variable (e.g., q) | ||
| >>> y = np.array([10, 20, 40, 60]) # intensity values | ||
| >>> metadata = { | ||
| ... "sample": "rock salt from the beach", | ||
| ... "composition": "NaCl", | ||
| ... "temperature": "300 K,", | ||
| ... "experimenters": "Phill, Sally" | ||
| ... } | ||
| >>> do = DiffractionObject( | ||
| ... xarray=x, | ||
| ... yarray=y, | ||
| ... xtype="q", | ||
| ... wavelength=1.54, | ||
| ... scat_quantity="x-ray", | ||
| ... name="beach_rock_salt_1", | ||
| ... metadata=metadata | ||
| ... ) | ||
| >>> print(do.metadata) | ||
| qmin : float | ||
| The minimum q value. | ||
| qmax : float | ||
| The maximum q value. | ||
| tthmin : float | ||
| The minimum two-theta value. | ||
| tthmax : float | ||
| The maximum two-theta value. | ||
| dmin : float | ||
| The minimum d-spacing value. | ||
| dmax : float | ||
| The maximum d-spacing value. | ||
|
sbillinge marked this conversation as resolved.
|
||
| """ | ||
|
|
||
| def __init__( | ||
|
|
@@ -92,6 +80,51 @@ def __init__( | |
| name="", | ||
| metadata={}, | ||
| ): | ||
| """ | ||
|
sbillinge marked this conversation as resolved.
Outdated
|
||
| Initialize a DiffractionObject instance. | ||
|
|
||
| Parameters | ||
| ---------- | ||
| xarray : ndarray | ||
| The independent variable array containing "q", "tth", or "d" values. | ||
| yarray : ndarray | ||
| The dependent variable array corresponding to intensity values. | ||
| xtype : str | ||
| The type of the independent variable in `xarray`. Must be one of {*XQUANTITIES}. | ||
| wavelength : float, optional | ||
| The wavelength of the incoming beam, specified in angstroms (Å). Default is none. | ||
| scat_quantity : str, optional | ||
| The type of scattering experiment (e.g., "x-ray", "neutron"). Default is an empty string "". | ||
| name : str, optional | ||
| The name or label for the scattering data. Default is an empty string "". | ||
| metadata : dict, optional | ||
| The additional metadata associated with the diffraction object. Default is {}. | ||
|
|
||
| Examples | ||
| -------- | ||
| Create a DiffractionObject for X-ray scattering data | ||
| >>> import numpy as np | ||
| >>> from diffpy.utils.diffraction_objects import DiffractionObject | ||
| ... | ||
| >>> x = np.array([0.12, 0.24, 0.31, 0.4]) # independent variable (e.g., q) | ||
| >>> y = np.array([10, 20, 40, 60]) # intensity values | ||
| >>> metadata = { | ||
| ... "sample": "rock salt from the beach", | ||
| ... "composition": "NaCl", | ||
| ... "temperature": "300 K,", | ||
| ... "experimenters": "Phill, Sally" | ||
| ... } | ||
| >>> do = DiffractionObject( | ||
| ... xarray=x, | ||
| ... yarray=y, | ||
| ... xtype="q", | ||
| ... wavelength=1.54, | ||
| ... scat_quantity="x-ray", | ||
| ... name="beach_rock_salt_1", | ||
| ... metadata=metadata | ||
| ... ) | ||
| >>> print(do.metadata) | ||
| """ | ||
|
|
||
| self._id = uuid.uuid4() | ||
| self._input_data(xarray, yarray, xtype, wavelength, scat_quantity, name, metadata) | ||
|
|
||

Uh oh!
There was an error while loading. Please reload this page.