Comments (5)
Quick try: could you replace:
pm = np.ones(xi.shape) / (xi[1,2,1]-xi[1,1,1])
pn = np.ones(xi.shape) / (yi[2,1,1]-yi[1,1,1])
with
pm = np.ones(xi.shape) / (xi[2,1,1]-xi[1,1,1])
pn = np.ones(xi.shape) / (yi[1,2,1]-yi[1,1,1])
from divand.py.
In the way you said pm and pn gives infinity while in the way I did the results are the same as DIVAnd with julia anyway I think I found a solution. It was a problem with the axes ordering using the numpy function swapaxes instead of transpose it works also with 3D fields. There is a pull-request pending. I did not check with 4D yet.
from divand.py.
Did you see this note of meshgrid? (https://docs.scipy.org/doc/numpy/reference/generated/numpy.meshgrid.html)
In the 2-D case with inputs of length M and N, the outputs are of shape (N, M) for ‘xy’ indexing and (M, N) for ‘ij’ indexing. In the 3-D case with inputs of length M, N and P, outputs are of shape (N, M, P) for ‘xy’ indexing and (M, N, P) for ‘ij’ indexing.
Does it work when you use ‘ij’ indexing and a suitable definition of pm, pn, ...
pm = np.ones(xi.shape) / (xi[1,0,0]-xi[0,0,0])
# [...]
from divand.py.
Ok yes, using the 'ij' indexing it works if you do not transpose the matrix nor use the swapaxes inside the DIVAnd wrapper function. This last in facts should be modified anyway removing the np.transpose and just preserving the masking:
def DIVAnd(mask, pmn, xi, x, f, corlen, epsilon2):
va = D.DIVAndrunfi(mask,pmn,xi,x, f, corlen, epsilon2)
return np.ma.MaskedArray(va, np.logical_not(mask))
from divand.py.
This file is an example for applying DIVAnd.py in 3D:
https://github.com/gher-ulg/DIVAnd.py/blob/88787becfff206e247dbee24a74963062050fe5e/examples/DIVAnd_3d.py
As you will see, there are 2 ways to call DIVAnd:
- either directly via pyjulia
- or via the wrapper: https://github.com/gher-ulg/DIVAnd.py/blob/88787becfff206e247dbee24a74963062050fe5e/examples/DIVAnd_3d.py#L7
Both variants do actually work for 3D.
I made the wrapper in an attempt to make DIVAnd more natural for python users because the default order of the dimensions is usually (depth, latitude, longitude, at least when I read a NetCDF file in python, or C/C++,...) while the order of Julia (and Fortran, Octave, ...) is longitude, latitude and depth. But this creates more confusion that it is actually worth. Also, numpy supports both storage orders.
So what is will do, it to skip the wrapper (what is actually what you did in the code sample in this issue) DIVAnd.py and use the first variant in the example file:
The julia code DIVAnd has also grown considerably, and it would not be feasible to have a wrapper which transpose the arguments of all functions and at the same time pyjulia made it quite convenient to call julia code directly from python.
from divand.py.
Related Issues (3)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from divand.py.