Skip to content
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

2D kCSD: setting gdX changes resolution in Y dimension #6

Open
fkloosterman opened this issue May 3, 2015 · 3 comments
Open

2D kCSD: setting gdX changes resolution in Y dimension #6

fkloosterman opened this issue May 3, 2015 · 3 comments
Labels

Comments

@fkloosterman
Copy link

Hi,

Thanks for the nice package. I have played with the 2D kCSD example (http://pykcsd.readthedocs.org/en/latest/usecases.html#sample-2d-reconstruction), but came across the following issue. If I set the gdX parameter to a higher value, say 0.5, then the resolution in the Y-dimension and not the X-dimension changes. See figure below and compare to the original in the documentation. Is this a bug, or am I missing something?

Best,
Fabian

figure

@parkag
Copy link
Member

parkag commented May 3, 2015

Thank you, Fabian!
It looks like there is a bug connected with distributing sources in space. The number of points in each direction is calculated from gdX, gdY
Code sample from KCSD2D:

nx = (self.xmax - self.xmin)/self.gdX + 1
ny = (self.ymax - self.ymin)/self.gdY + 1
lin_x = np.linspace(self.xmin, self.xmax, nx)
lin_y = np.linspace(self.ymin, self.ymax, ny)
self.space_X, self.space_Y = np.meshgrid(lin_x, lin_y)
(self.X_src, self.Y_src, self.R) = sd.make_src_2D(
self.space_X,
self.space_Y,
self.n_sources,
self.ext_x,
self.ext_y,
self.R_init
)

@fkloosterman
Copy link
Author

Hi Grzegorz,
Could it have something to do with the call to np.meshgrid, which by default switches the first two dimensions, unless you set the indexing parameter to 'ij'?
-Fabian

@ccluri
Copy link

ccluri commented May 4, 2015

Instead of

lin_x = np.linspace(self.xmin, self.xmax, nx)
lin_y = np.linspace(self.ymin, self.ymax, ny)
self.space_X, self.space_Y = np.meshgrid(lin_x, lin_y)

Use:

 self.space_X, self.space_Y = np.mgrid[xmin:xmax:np.complex(0,nx),
                                       ymin:ymax:np.complex(0,ny)]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants