Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
thopri
PyNEMO
Commits
2aeac03d
Commit
2aeac03d
authored
5 years ago
by
James Harle
Browse files
Options
Download
Email Patches
Plain Diff
2to3 utils
parent
fa976bb2
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
20 deletions
+20
-20
pynemo/utils/gcoms_break_depth.py
pynemo/utils/gcoms_break_depth.py
+17
-17
pynemo/utils/nemo_bdy_lib.py
pynemo/utils/nemo_bdy_lib.py
+3
-3
No files found.
pynemo/utils/gcoms_break_depth.py
View file @
2aeac03d
...
...
@@ -153,7 +153,7 @@ def polcoms_select_domain(bathy, lat, lon, roi, dr):
lon_ob
=
np
.
ravel
(
lon
,
order
=
'F'
)[
np
.
ravel
(
ob
,
order
=
'F'
)]
print
lat_ob
,
lon_ob
print
(
lat_ob
,
lon_ob
)
len_lat
=
len
(
lat
[:,
0
])
len_lon
=
len
(
lon
[
0
,:])
lat_lon_index
=
np
.
nonzero
(
np
.
logical_and
(
lat
==
lat_ob
[
0
],
lon
==
lon_ob
[
0
]))
...
...
@@ -172,19 +172,19 @@ def polcoms_select_domain(bathy, lat, lon, roi, dr):
i_e
=
i_0
+
2
lat_slice
=
slice
(
max
(
lat_lon_index
[
0
],
0
),
min
(
lat_lon_index
[
0
]
+
1
+
1
,
len_lat
))
lon_slice
=
slice
(
max
(
lat_lon_index
[
1
],
0
),
min
(
lat_lon_index
[
1
]
+
1
+
1
,
len_lon
))
print
'method2'
,
lon_slice
,
lat_slice
print
(
'method2'
,
lon_slice
,
lat_slice
)
lat_slice
=
slice
(
j_0
,
j_e
)
lon_slice
=
slice
(
i_0
,
i_e
)
print
'method1'
,
lon_slice
,
lat_slice
print
(
'method1'
,
lon_slice
,
lat_slice
)
lat_pts
=
lat
[
lat_slice
,
lon_slice
]
lon_pts
=
lon
[
lat_slice
,
lon_slice
]
print
lat_pts
,
lon_pts
print
lat_lon_index
[
0
],
lat_lon_index
[
1
]
print
len_lon
,
len_lat
,
lat_lon_index
[
0
],
lat_lon_index
[
1
]
print
(
lat_pts
,
lon_pts
)
print
(
lat_lon_index
[
0
],
lat_lon_index
[
1
]
)
print
(
len_lon
,
len_lat
,
lat_lon_index
[
0
],
lat_lon_index
[
1
]
)
dy
,
py
=
seawater
.
dist
(
lat_pts
[:,
0
],
lon_pts
[:,
0
])
dx
,
px
=
seawater
.
dist
(
lat_pts
[
0
,:],
lon_pts
[
0
,:])
r
=
np
.
rint
(
np
.
ceil
(
dr
/
np
.
amax
([
dx
,
dy
])))
print
dx
,
dy
,
r
print
(
dx
,
dy
,
r
)
lat_slice
=
slice
(
max
(
lat_lon_index
[
0
]
-
r
,
0
),
min
(
lat_lon_index
[
0
]
+
r
+
1
,
len_lat
))
lon_slice
=
slice
(
max
(
lat_lon_index
[
1
]
-
r
,
0
),
min
(
lat_lon_index
[
1
]
+
r
+
1
,
len_lon
))
lat_pts
=
lat
[
lat_slice
,
lon_slice
]
...
...
@@ -194,8 +194,8 @@ def polcoms_select_domain(bathy, lat, lon, roi, dr):
lon_pts
=
np
.
ravel
(
lon_pts
)
# NOTE: seawater package calculates the distance from point to the next point in the array
# that is the reason to insert reference point before every point
lat_pts
=
np
.
insert
(
lat_pts
,
range
(
0
,
len
(
lat_pts
)),
lat_ob
[
idx
])
lon_pts
=
np
.
insert
(
lon_pts
,
range
(
0
,
len
(
lon_pts
)),
lon_ob
[
idx
])
lat_pts
=
np
.
insert
(
lat_pts
,
list
(
range
(
0
,
len
(
lat_pts
))
)
,
lat_ob
[
idx
])
lon_pts
=
np
.
insert
(
lon_pts
,
list
(
range
(
0
,
len
(
lon_pts
))
)
,
lon_ob
[
idx
])
distance_pts
=
seawater
.
dist
(
lat_pts
,
lon_pts
)
#distances repeat themselves so only pick every alternative distance
distance_pts
=
distance_pts
[
0
][::
2
]
...
...
@@ -230,19 +230,19 @@ def polcoms_select_domain(bathy, lat, lon, roi, dr):
i_e
=
i_0
+
2
lat_slice
=
slice
(
max
(
lat_lon_index
[
0
],
0
),
min
(
lat_lon_index
[
0
]
+
1
+
1
,
len_lat
))
lon_slice
=
slice
(
max
(
lat_lon_index
[
1
],
0
),
min
(
lat_lon_index
[
1
]
+
1
+
1
,
len_lon
))
print
'method2'
,
lon_slice
,
lat_slice
print
(
'method2'
,
lon_slice
,
lat_slice
)
lat_slice
=
slice
(
j_0
,
j_e
)
lon_slice
=
slice
(
i_0
,
i_e
)
print
'method1'
,
lon_slice
,
lat_slice
print
(
'method1'
,
lon_slice
,
lat_slice
)
lat_pts
=
lat
[
lat_slice
,
lon_slice
]
lon_pts
=
lon
[
lat_slice
,
lon_slice
]
print
lat_pts
,
lon_pts
print
lat_lon_index
[
0
],
lat_lon_index
[
1
]
print
len_lon
,
len_lat
,
lat_lon_index
[
0
],
lat_lon_index
[
1
]
print
(
lat_pts
,
lon_pts
)
print
(
lat_lon_index
[
0
],
lat_lon_index
[
1
]
)
print
(
len_lon
,
len_lat
,
lat_lon_index
[
0
],
lat_lon_index
[
1
]
)
dy
,
py
=
seawater
.
dist
(
lat_pts
[:,
0
],
lon_pts
[:,
0
])
dx
,
px
=
seawater
.
dist
(
lat_pts
[
0
,:],
lon_pts
[
0
,:])
r
=
np
.
rint
(
np
.
ceil
(
dr
/
np
.
amax
([
dx
,
dy
])))
print
dx
,
dy
,
r
print
(
dx
,
dy
,
r
)
lat_slice
=
slice
(
max
(
lat_lon_index
[
0
]
-
r
,
0
),
min
(
lat_lon_index
[
0
]
+
r
+
1
,
len_lat
))
lon_slice
=
slice
(
max
(
lat_lon_index
[
1
]
-
r
,
0
),
min
(
lat_lon_index
[
1
]
+
r
+
1
,
len_lon
))
lat_pts
=
lat
[
lat_slice
,
lon_slice
]
...
...
@@ -252,8 +252,8 @@ def polcoms_select_domain(bathy, lat, lon, roi, dr):
lon_pts
=
np
.
ravel
(
lon_pts
)
# NOTE: seawater package calculates the distance from point to the next point in the array
# that is the reason to insert reference point before every point
lat_pts
=
np
.
insert
(
lat_pts
,
range
(
0
,
len
(
lat_pts
)),
lat_lb
[
idx
])
lon_pts
=
np
.
insert
(
lon_pts
,
range
(
0
,
len
(
lon_pts
)),
lon_lb
[
idx
])
lat_pts
=
np
.
insert
(
lat_pts
,
list
(
range
(
0
,
len
(
lat_pts
))
)
,
lat_lb
[
idx
])
lon_pts
=
np
.
insert
(
lon_pts
,
list
(
range
(
0
,
len
(
lon_pts
))
)
,
lon_lb
[
idx
])
distance_pts
=
seawater
.
dist
(
lat_pts
,
lon_pts
)
#distances repeat themselves so only pick every alternative distance
distance_pts
=
distance_pts
[
0
][::
2
]
...
...
This diff is collapsed.
Click to expand it.
pynemo/utils/nemo_bdy_lib.py
View file @
2aeac03d
...
...
@@ -74,7 +74,7 @@ def bdy_sections(nbidta,nbjdta,nbrdta,rw):
count
=
0
flag
=
0
mark
=
0
source_tree
=
sp
.
cKDTree
(
zip
(
outer_rim_i
,
outer_rim_j
))
source_tree
=
sp
.
cKDTree
(
list
(
zip
(
outer_rim_i
,
outer_rim_j
))
)
id_order
=
np
.
ones
((
nbdy
,),
dtype
=
np
.
int
)
*
source_tree
.
n
id_order
[
count
]
=
0
# use index 0 as the starting point
count
+=
1
...
...
@@ -85,8 +85,8 @@ def bdy_sections(nbidta,nbjdta,nbrdta,rw):
while
count
<=
nbdy
:
lcl_pt
=
zip
([
outer_rim_i
[
id_order
[
count
-
1
]]],
[
outer_rim_j
[
id_order
[
count
-
1
]]])
lcl_pt
=
list
(
zip
([
outer_rim_i
[
id_order
[
count
-
1
]]],
[
outer_rim_j
[
id_order
[
count
-
1
]]])
)
junk
,
an_id
=
source_tree
.
query
(
lcl_pt
,
k
=
3
,
distance_upper_bound
=
1.1
)
if
an_id
[
0
,
1
]
in
id_order
:
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment