Skip to content

Added extractDX to convert Born output to DX#15

Open
ChenouZhang wants to merge 1 commit intodevelopfrom
Extract-DX
Open

Added extractDX to convert Born output to DX#15
ChenouZhang wants to merge 1 commit intodevelopfrom
Extract-DX

Conversation

@ChenouZhang
Copy link
Contributor

@ChenouZhang ChenouZhang commented Mar 1, 2022

Added an analysis script to convert BornProfiler PMF output from dat to DX by filling empty grid with high values and using spline interpolation 3D. The spline interpolation requires GridDataFormats 0.6 or higher, see MDAnalysis/GridDataFormats#84

Example usage:
python apbs-bornprofiler-extractDX.py --input welec_PaNhaP_fine.dat --output PaNhaP_fine 0.5 0.6

Copy link
Member

@orbeckst orbeckst left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have some code comments. But the main point is that we still have old functionality for this behavior in apbs-bornprofile-analyze3D.py which called the AnalyzeElec3D class

class AnalyzeElec3D(Analyzer):

Can you update the old code to use the new approach? This would be the cleanest way to update, especially as we are conceptually not changing the approach — mainly you are increasing the grid size slightly for the loose grid. See if this can be done with the old code or what needs to be changed to accomplish this.


coord = data[:, 0:3].T
weight = data[:,3]
weight = weight
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove line

# Edge offset for Grid
offset = grid_int/2.0

# For losse edge
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

loose

Comment on lines +32 to +33
df = pd.read_csv(filename,delim_whitespace=True)
df = df.to_numpy()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of using pandas, just use the numpy function; pandas isn't a dependency.

(However, if integrated with existing code, you'll already have the data.)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, calling a nump array df is confusing.

Comment on lines +75 to +79
for i, c in enumerate(coord.T):
xind = get_ind(c[0], xmin, grid_int)
yind = get_ind(c[1], ymin, grid_int)
zind = get_ind(c[2], zmin, grid_int)
grid[xind, yind, zind] = weight[i]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should be able to use np.histogramdd here — this looks very slow.

Comment on lines +71 to +73
def get_ind(x, xmin, xint):
ind = int((x-xmin)/xint)
return ind
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should not be necessary with histogramdd (or if you really need to this stuff, look at numpy digitize).

edges_L = [xedge_L, yedge_L, zedge_L]

# Filling empty points with high value
filling_value = 2* weight.max()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fill_factor should be configurable, default can be fill_factor = 2

Suggested change
filling_value = 2* weight.max()
filling_value = fill_factor * weight.max()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants