From 546ad85f80235ba2190d6ae72b3e5007d30439ae Mon Sep 17 00:00:00 2001 From: Marcello Sega Date: Wed, 11 Sep 2024 10:51:27 +0100 Subject: [PATCH] 432 new feature willard chandler density parameter (#433) * Add density cutoff argument to Willard Chandler * Delete .travis.yml. (Invalid file name causes cloning to fail on Windows) --------- Co-authored-by: Alex Moriarty <25207558+a-ws-m@users.noreply.github.com> Co-authored-by: a-ws-m --- .travis.yml. | 61 --------------------------------------- pytim/willard_chandler.py | 7 ++++- 2 files changed, 6 insertions(+), 62 deletions(-) delete mode 100644 .travis.yml. diff --git a/.travis.yml. b/.travis.yml. deleted file mode 100644 index 2cd29d8e..00000000 --- a/.travis.yml. +++ /dev/null @@ -1,61 +0,0 @@ -language: python - -branches: - except: - - dev - - extended_datafiles - - -env: - global: - - CC_TEST_REPORTER_ID=bdc5010b5f2e62769ccd2d885f0d7eb59691844de9a2018e9e3da255a37282e2 - -matrix: - include: - - - os: linux - sudo: required - python: 3.6 - env: MDAv=1.0.0 - - # - os: osx - # language: generic - # env: MDAv=0.16 - - -before_install: - - if [[ "$TRAVIS_OS_NAME" == "osx" ]] ; then - brew update; - curl -s --location "https://bootstrap.pypa.io/get-pip.py" -o get-pip.py ; - python get-pip.py --user ; - alias pip='pip2' - pip install --upgrade pip ; - fi -# - if [[ "$TRAVIS_OS_NAME" == "linux" ]] ; then sudo apt-get install liblapack-dev -y ; fi - -install: -- pip install codecov -- pip install pylama -- pip install pytest-cov -- pip install Sphinx>=1.4.3 -- pip install matplotlib -- pip install cython -- pip install MDAnalysis==$MDAv -- pip install pandas -- pip install mdtraj -- pip install nose -- pip install . -# command to run tests - -before_script: - - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter - - chmod +x ./cc-test-reporter - - ./cc-test-reporter before-build - -script: python setup.py test - - -after_script: - if ([ "$TRAVIS_OS_NAME" == "linux" ] && [ "$MDAv" == "0.19" ]) ; then - pip install codecov; pip install pytest-cov ; py.test --cov=pytim pytim/*py pytim/observables/*py pytim/datafiles/*py --doctest-modules --cov-report xml ; ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT ; codecov ; fi - diff --git a/pytim/willard_chandler.py b/pytim/willard_chandler.py index 9f433db1..1961dab5 100644 --- a/pytim/willard_chandler.py +++ b/pytim/willard_chandler.py @@ -39,6 +39,9 @@ class WillardChandler(Interface): this group :param float alpha: The width of the Gaussian kernel :param float mesh: The grid spacing for the density calculation + :param float density_cutoff: The density value used to define the + isosurface. `None` (default) uses the average + of the minimum and maximum density. :param AtomGroup group: Compute the density using this group :param dict radii_dict: Dictionary with the atomic radii of the elements in the group. @@ -127,10 +130,12 @@ def __init__(self, centered=False, warnings=False, autoassign=True, + density_cutoff=None, **kargs): self.autoassign, self.do_center = autoassign, centered self.include_zero_radius = include_zero_radius + self.density_cutoff = density_cutoff sanity = SanityCheck(self, warnings=warnings) sanity.assign_universe(universe, group) sanity.assign_alpha(alpha) @@ -245,7 +250,7 @@ def _assign_layers(self): volume = self.density_field.reshape( tuple(np.array(ngrid[::-1]).astype(int))) verts, faces, normals, values = marching_cubes( - volume, None, spacing=tuple(spacing)) + volume, self.density_cutoff, spacing=tuple(spacing)) # note that len(normals) == len(verts): they are normals # at the vertices, and not normals of the faces # verts and normals have x and z flipped because skimage uses zyx ordering