Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F65846250
variogram.pyx
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Thu, Jun 6, 14:59
Size
1 KB
Mime Type
text/x-python
Expires
Sat, Jun 8, 14:59 (2 d)
Engine
blob
Format
Raw Data
Handle
18136127
Attached To
rMYLIB MyLib
variogram.pyx
View Options
from
cython
cimport
wraparound
,
boundscheck
from
libc.math
cimport
pow
,
sqrt
from
libc.stdio
cimport
printf
@wraparound
(
False
)
@boundscheck
(
False
)
def
cvar
(
int
ia
,
int
ja
,
long
npt
,
double
[:,
:]
array
,
unsigned
char
[:,
:]
mask
,
unsigned
char
[:,
:,
:,
:]
computed
,
double
degree
,
double
[:]
dist
,
double
[:]
varg
):
cdef
long
n
cdef
int
ii
,
jj
,
i
,
j
cdef
double
idist
,
jdist
n
=
0
for
ii
in
range
(
ia
):
printf
(
"Computing variogram:
%.1f
\%
\n
"
,
100.0
*
n
/
npt
)
for
jj
in
range
(
ja
):
if
mask
[
ii
,
jj
]:
continue
else
:
for
i
in
range
(
ia
):
for
j
in
range
(
ja
):
if
mask
[
i
,
j
]
or
(
computed
[
ii
,
jj
,
i
,
j
]
!=
0
):
continue
else
:
idist
=
ii
-
i
jdist
=
jj
-
j
dist
[
n
]
=
sqrt
(
idist
*
idist
+
jdist
*
jdist
)
# Avoid repetitions
if
dist
[
n
]
==
0
:
continue
varg
[
n
]
=
0.5
*
pow
(
array
[
i
,
j
]
-
array
[
ii
,
jj
],
degree
)
computed
[
ii
,
jj
,
i
,
j
]
=
1
computed
[
i
,
j
,
ii
,
jj
]
=
1
n
+=
1
# If we filled up all combinations return
if
n
>=
npt
:
return
Event Timeline
Log In to Comment