Skip to content

Commit

Permalink
Merge pull request #29 from chrishavlin/release_prep_v020
Browse files Browse the repository at this point in the history
0.2.0 release prep
  • Loading branch information
chrishavlin authored Jul 26, 2023
2 parents 10fe773 + 96e9a74 commit ada18c8
Show file tree
Hide file tree
Showing 5 changed files with 176 additions and 10 deletions.
170 changes: 169 additions & 1 deletion examples/ex_001_load_VBRc_structure.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
"name": "stderr",
"output_type": "stream",
"text": [
"pyVBRc : [INFO ] 2023-07-26 13:51:22,065: /home/chavlin/src/vbrProjects/pyVBRc/pyVBRc/sample_data/VBRc_sample_LUT.mat loaded.\n"
"pyVBRc : [INFO ] 2023-07-26 15:06:33,017: /home/chavlin/src/vbrProjects/pyVBRc/pyVBRc/sample_data/VBRc_sample_LUT.mat loaded.\n"
]
}
],
Expand Down Expand Up @@ -216,6 +216,174 @@
"plt.ylabel(\"Q$^{-1}$, andrade pseudo-period\")\n",
"f.savefig('andrade_psp_T_dep.png')"
]
},
{
"cell_type": "markdown",
"id": "ecfac287-8cec-4d52-9707-4162cc782a0a",
"metadata": {},
"source": [
"## units\n",
"\n",
"When loading a `VBR` structure generated by newer versions of the `VBRc` (>=v1.0.0), the arrays that get loaded in will be `unyt` arrays:"
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "054230e5-0392-4113-8652-917b94d847e9",
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"pyVBRc : [WARNING ] 2023-07-26 15:06:34,117: Ch2o in SV has unsupported units (ppm), using nondimensional\n",
"pyVBRc : [INFO ] 2023-07-26 15:06:34,123: /home/chavlin/src/vbrProjects/pyVBRc/pyVBRc/sample_data/VBRc_sample_LUT_v1pt0pt0.mat loaded.\n"
]
}
],
"source": [
"from pyVBRc.sample_data import get_sample_filename\n",
"from pyVBRc.vbrc_structure import VBRCstruct\n",
"\n",
"file = get_sample_filename(\"VBRc_sample_LUT_v1pt0pt0.mat\")\n",
"vbr = VBRCstruct(file)"
]
},
{
"cell_type": "markdown",
"id": "ef18d5a0-7675-40ae-92a3-ea7020bcae72",
"metadata": {},
"source": [
"Inspecting the first 3 elements of the density array, for example:"
]
},
{
"cell_type": "code",
"execution_count": 7,
"id": "e9025117-c7fb-4593-9e75-eda9066ec135",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"unyt_array([3300., 3300., 3300.], 'kg/m**3')"
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"vbr.input.SV.rho[1:4,0,0]"
]
},
{
"cell_type": "markdown",
"id": "9bf3691c-3b1c-4b7b-a7ef-da48361f3fe6",
"metadata": {},
"source": [
"To change the units, "
]
},
{
"cell_type": "code",
"execution_count": 8,
"id": "27ddb8ee-1f88-465c-af3f-3361a575122f",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"unyt_array([3.3, 3.3, 3.3], 'g/cm**3')"
]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"vbr.input.SV.rho[1:4,0,0].to('g/cm**3')"
]
},
{
"cell_type": "markdown",
"id": "4629c955-5e18-4827-b19b-3e420560b4e8",
"metadata": {},
"source": [
"`unyt` arrays will track and convert units throuhgout operations. For example, to calculate the hydrostaic pressure at 10 km depth for a single density value:"
]
},
{
"cell_type": "code",
"execution_count": 9,
"id": "4cd341a9-21fd-4711-94b7-435144262b56",
"metadata": {},
"outputs": [],
"source": [
"from unyt import unyt_quantity, unyt_array "
]
},
{
"cell_type": "code",
"execution_count": 10,
"id": "0d645a0d-d132-43d8-8a80-ccf199b1bd3d",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"unyt_quantity(3.234e+08, 'kg/(m*s**2)')"
]
},
"execution_count": 10,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"P = vbr.input.SV.rho[1,0,0] * unyt_quantity(9.8, 'm/s**2') * unyt_quantity(10, 'km')\n",
"P"
]
},
{
"cell_type": "code",
"execution_count": 11,
"id": "6623f460-2bf2-462c-ba87-bc58f3436d61",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"unyt_quantity(0.3234, 'GPa')"
]
},
"execution_count": 11,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"P.to('GPa')"
]
},
{
"cell_type": "markdown",
"id": "55079833-f25c-4901-b0cc-1cc0a118e29e",
"metadata": {},
"source": [
"check out the [full `unyt` docs](https://unyt.readthedocs.io/en/stable/) for more on working with `unyt` arrays and quantities"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "1ebaa242-faae-4f48-91fc-cd8b0ec9f83c",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand Down
2 changes: 1 addition & 1 deletion pyVBRc/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.1.1"
__version__ = "0.2.0"
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "pyVBRc"
version = "0.1.1"
version = "0.2.0"
authors = [
{ name="Chris Havlin", email="[email protected]" },
]
Expand Down
6 changes: 0 additions & 6 deletions release_history.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
# v0.1.2

maintenance release
* full switch to pyproject
* docs improvements

# v0.1.1

Initial release of pyVBRc, still experimental
Expand Down
6 changes: 5 additions & 1 deletion release_notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,16 @@ Main change is adding support for unit-ful arrays via the unyt package.
## New Features

- units support: when loading a VBRc .mat file, arrays will be loaded as unyt arrays if possible (requires VBRc version >= 1.0.0)
- pyVBRc logger
- nicely formatted logging with the pyVBRc logger
- anisotropy calculations for aligned inclusions (experimental, consider in beta form)
- documentation updates (scripts are now notebooks in examples/)

## Bug Fixes

None

## Other changes
- code coverage reporting enabled for the repository
- style checks now done by precommit.ci bot
- switch to pyproject.toml build

0 comments on commit ada18c8

Please sign in to comment.