Skip to content

Commit

Permalink
Merge branch 'master' into image
Browse files Browse the repository at this point in the history
  • Loading branch information
dmentipl committed Aug 11, 2020
2 parents b90ab87 + bc0ac87 commit 8b5073e
Show file tree
Hide file tree
Showing 16 changed files with 410 additions and 238 deletions.
8 changes: 6 additions & 2 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
version: 2
sphinx:
configuration: docs/source/conf.py
formats: all
python:
version: 3.7
install:
- requirements: docs/requirements.txt
- method: pip
path: .
- path: .
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,26 @@ Types of changes:

## [Unreleased]

## [0.6.2] - 2020-08-11

### Changed

- Use setup.cfg for setuptools, and pyproject.toml (and setup.cfg) for config of tools.
- Version is set in setup.cfg and imported into plonk via importlib_metadata.
- Changed API documentation.
- Moved sph module from utils sub-package to analysis.

### Deprecated

- plonk.particle_plot will be removed.
- plonk.plot will change from image plots to particle plots, and plonk.image and plonk.vector will be added to replace plonk.plot.
- Default units will change from cgs to SI.

### Fixed

- Fixed bug in Profile with getting number of mixture dust species.
- Fixed bugs in animation functions (due to making physical units on by default).
- Fixed issues with colorbar size matching height of plots.

## [0.6.1] - 2020-08-09

Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ New releases and PyPI and Conda packages

### Make a release

First, increase the version number in `__init__.py`, and update the `CHANGELOG.md` adding a heading like `[v0.3.1] - yyyy-mm-dd` under "Unreleased" heading. Then commit the change with a message like "Bump version to v0.3.1".
First, increase the version number in `setup.cfg`, and update the `CHANGELOG.md` adding a heading like `[v0.3.1] - yyyy-mm-dd` under "Unreleased" heading. Then commit the change with a message like "Bump version to v0.3.1".

Then, make a new release on GitHub at <https://github.com/dmentipl/plonk/releases>. The title and tag should both be like "v0.3.1" which corresponds to the Plonk version number. Copy in the changes from the `CHANGELOG.md`. This creates a git tag for the commit, and generates a GitHub release with downloadable source as a tar.gz file.

Expand Down
Binary file added docs/source/_static/dust_profiles.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion docs/source/api/analysis.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ Smoothed particle hydrodynamics analysis tools.
.. toctree::

analysis/profile
analysis/filters
analysis/particles
analysis/total
analysis/sinks
analysis/discs
analysis/filters
analysis/sph
39 changes: 27 additions & 12 deletions docs/source/api/miscellaneous.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,30 @@ Miscellaneous

Here are some useful utility functions.

.. autofunction:: plonk.utils.geometry.cartesian_to_polar
.. autofunction:: plonk.utils.math.average
.. autofunction:: plonk.utils.math.cross
.. autofunction:: plonk.utils.math.norm
.. autofunction:: plonk.utils.utils.is_documented_by
.. autofunction:: plonk.utils.utils.time_string
.. autofunction:: plonk.utils.kernels.kernel_cubic
.. autofunction:: plonk.utils.kernels.kernel_quintic
.. autofunction:: plonk.utils.kernels.kernel_wendland_c4
.. autofunction:: plonk.utils.kernels.kernel_gradient_cubic
.. autofunction:: plonk.utils.kernels.kernel_gradient_quintic
.. autofunction:: plonk.utils.kernels.kernel_gradient_wendland_c4
~~~~~~~~
Geometry
~~~~~~~~

.. automodule:: plonk.utils.geometry
:members:

~~~~
Math
~~~~

.. automodule:: plonk.utils.math
:members:

~~~~~
Utils
~~~~~

.. automodule:: plonk.utils.utils
:members:

~~~~~~~
Kernels
~~~~~~~

.. automodule:: plonk.utils.kernels
:members:
2 changes: 1 addition & 1 deletion docs/source/api/visualization.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ Visualize smoothed particle hydrodynamics data.
visualization/plots
visualization/animations
visualization/interpolation
visualization/utility
visualization/utils
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
~~~~~~~
Utility
~~~~~~~
~~~~~
Utils
~~~~~

The following are utility functions for visualization.

Expand Down
7 changes: 3 additions & 4 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,11 @@
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
import configparser
import os
import sys
from pathlib import Path

import importlib_metadata

sys.path.insert(0, os.path.abspath('../..'))
path = (Path(__file__) / '../../..').resolve()
sys.path.insert(0, str(path))

# -- Project information -----------------------------------------------------

Expand Down
33 changes: 33 additions & 0 deletions docs/source/examples/dust-profiles.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
-------------
Dust profiles
-------------

Plot the dust density profile per species.

.. code-block:: python
import plonk
snap = plonk.load_snap('dstau2mj_00130.h5')
prof = plonk.load_profile(snap)
# The line below produces a list of strings like:
# ['dust_density_001',
# 'dust_density_002',
# 'dust_density_003',
# 'dust_density_004',
# 'dust_density_005',
# 'dust_density_006']
y = [f'dust_density_{n+1:03}' for n in range(snap.num_dust_species)]
ax = prof.plot(x='radius', y=y, units={'x': 'au'})
ax.set_yscale('log')
.. figure:: ../_static/dust_profiles.png

.. note::

The data is from a Phantom snapshot with multiple dust species using the
mixture (or "1-fluid") method. I.e., the particles carry a mixture of dust
and gas.
6 changes: 6 additions & 0 deletions plonk/_units.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
"""Units."""

import warnings

import pint

warnings.warn(
'In Plonk v0.7.0 default units will change from cgs to SI.', DeprecationWarning,
)

units = pint.UnitRegistry(system='cgs')
Quantity = units.Quantity

Expand Down
8 changes: 4 additions & 4 deletions plonk/analysis/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def cylinder(
Returns
-------
SubSnap
The SubSnap with particles in the box.
The SubSnap with particles in the cylinder.
"""
dh = height / 2
R = radial_distance(snap=snap, origin=center, coordinates='cylindrical')
Expand Down Expand Up @@ -106,7 +106,7 @@ def annulus(
Returns
-------
SubSnap
The SubSnap with particles in the box.
The SubSnap with particles in the annulus.
"""
dh = height / 2
R = radial_distance(snap=snap, origin=center, coordinates='cylindrical')
Expand Down Expand Up @@ -135,7 +135,7 @@ def sphere(snap: SnapLike, radius: Quantity, center: Quantity = CENTER) -> SubSn
Returns
-------
SubSnap
The SubSnap with particles in the box.
The SubSnap with particles in the sphere.
"""
R = radial_distance(snap=snap, origin=center, coordinates='spherical')
mask = R < radius
Expand Down Expand Up @@ -165,7 +165,7 @@ def shell(
Returns
-------
SubSnap
The SubSnap with particles in the box.
The SubSnap with particles in the shell.
"""
R = radial_distance(snap=snap, origin=center, coordinates='spherical')
mask = (R > radius_min) & (R < radius_max)
Expand Down
8 changes: 5 additions & 3 deletions plonk/analysis/profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,11 @@ def __init__(
self._x.magnitude, self.bin_edges.magnitude
)[0]

num_mixture_dust_species = self.snap.num_dust_species - len(
self.snap.num_particles_of_type['dust']
)
try:
num_separate_dust = len(self.snap.num_particles_of_type['dust'])
except KeyError:
num_separate_dust = 0
num_mixture_dust_species = self.snap.num_dust_species - num_separate_dust
_generate_profiles(num_mixture_dust_species)

def _setup_particle_mask(self, ignore_accreted: bool) -> ndarray:
Expand Down
Loading

0 comments on commit 8b5073e

Please sign in to comment.