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
190d199b
Commit
190d199b
authored
5 years ago
by
James Harle
Browse files
Options
Download
Email Patches
Plain Diff
2to3 on main dir
parent
78941e5c
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
40 additions
and
40 deletions
+40
-40
pynemo/nemo_bdy_extr_tm3.py
pynemo/nemo_bdy_extr_tm3.py
+17
-17
pynemo/nemo_bdy_gen_c.py
pynemo/nemo_bdy_gen_c.py
+3
-3
pynemo/nemo_bdy_grid_angle.py
pynemo/nemo_bdy_grid_angle.py
+1
-1
pynemo/nemo_bdy_ncpop.py
pynemo/nemo_bdy_ncpop.py
+3
-3
pynemo/nemo_bdy_src_time.py
pynemo/nemo_bdy_src_time.py
+1
-1
pynemo/nemo_bdy_zgrv2.py
pynemo/nemo_bdy_zgrv2.py
+5
-5
pynemo/nemo_coord_gen_pop.py
pynemo/nemo_coord_gen_pop.py
+1
-1
pynemo/pynemo_ncml_generator.py
pynemo/pynemo_ncml_generator.py
+3
-3
pynemo/pynemo_settings_editor.py
pynemo/pynemo_settings_editor.py
+5
-5
setup.cfg
setup.cfg
+1
-1
No files found.
pynemo/nemo_bdy_extr_tm3.py
View file @
190d199b
...
...
@@ -43,7 +43,7 @@ from pynemo import nemo_bdy_ncgen as ncgen
from
pynemo
import
nemo_bdy_ncpop
as
ncpop
# Local Imports
import
nemo_bdy_grid_angle
as
ga
from
.
import
nemo_bdy_grid_angle
as
ga
from
pynemo.reader.factory
import
GetFile
from
pynemo.utils.nemo_bdy_lib
import
rot_rep
,
sub2ind
...
...
@@ -233,12 +233,12 @@ class Extract:
# Ann Query substitute
source_tree
=
None
try
:
source_tree
=
sp
.
cKDTree
(
zip
(
SC
.
lon
.
ravel
(
order
=
'F'
),
SC
.
lat
.
ravel
(
order
=
'F'
)),
balanced_tree
=
False
,
compact_nodes
=
False
)
source_tree
=
sp
.
cKDTree
(
list
(
zip
(
SC
.
lon
.
ravel
(
order
=
'F'
),
SC
.
lat
.
ravel
(
order
=
'F'
))
)
,
balanced_tree
=
False
,
compact_nodes
=
False
)
except
TypeError
:
#added this fix to make it compatible with scipy 0.16.0
source_tree
=
sp
.
cKDTree
(
zip
(
SC
.
lon
.
ravel
(
order
=
'F'
),
SC
.
lat
.
ravel
(
order
=
'F'
)))
dst_pts
=
zip
(
dst_lon
[:].
ravel
(
order
=
'F'
),
dst_lat
[:].
ravel
(
order
=
'F'
))
source_tree
=
sp
.
cKDTree
(
list
(
zip
(
SC
.
lon
.
ravel
(
order
=
'F'
),
SC
.
lat
.
ravel
(
order
=
'F'
)))
)
dst_pts
=
list
(
zip
(
dst_lon
[:].
ravel
(
order
=
'F'
),
dst_lat
[:].
ravel
(
order
=
'F'
))
)
nn_dist
,
nn_id
=
source_tree
.
query
(
dst_pts
,
k
=
1
)
# Find surrounding points
...
...
@@ -301,14 +301,14 @@ class Extract:
tmp_lat
[
r_id
]
=
-
9999
source_tree
=
None
try
:
source_tree
=
sp
.
cKDTree
(
zip
(
tmp_lon
.
ravel
(
order
=
'F'
),
tmp_lat
.
ravel
(
order
=
'F'
)),
balanced_tree
=
False
,
compact_nodes
=
False
)
source_tree
=
sp
.
cKDTree
(
list
(
zip
(
tmp_lon
.
ravel
(
order
=
'F'
),
tmp_lat
.
ravel
(
order
=
'F'
))
)
,
balanced_tree
=
False
,
compact_nodes
=
False
)
except
TypeError
:
#fix for scipy 0.16.0
source_tree
=
sp
.
cKDTree
(
zip
(
tmp_lon
.
ravel
(
order
=
'F'
),
tmp_lat
.
ravel
(
order
=
'F'
)))
source_tree
=
sp
.
cKDTree
(
list
(
zip
(
tmp_lon
.
ravel
(
order
=
'F'
),
tmp_lat
.
ravel
(
order
=
'F'
)))
)
dst_pts
=
zip
(
dst_lon
[
rr_id
].
ravel
(
order
=
'F'
),
dst_lat
[
rr_id
].
ravel
(
order
=
'F'
))
dst_pts
=
list
(
zip
(
dst_lon
[
rr_id
].
ravel
(
order
=
'F'
),
dst_lat
[
rr_id
].
ravel
(
order
=
'F'
))
)
junk
,
an_id
=
source_tree
.
query
(
dst_pts
,
k
=
3
,
distance_upper_bound
=
fr
)
id_121
[
rr_id
,
:]
=
an_id
...
...
@@ -347,11 +347,11 @@ class Extract:
z_ind
=
np
.
zeros
((
num_bdy
*
dst_len_z
,
2
),
dtype
=
np
.
int64
)
source_tree
=
None
try
:
source_tree
=
sp
.
cKDTree
(
zip
(
sc_z
.
ravel
(
order
=
'F'
)),
balanced_tree
=
False
,
compact_nodes
=
False
)
source_tree
=
sp
.
cKDTree
(
list
(
zip
(
sc_z
.
ravel
(
order
=
'F'
))
)
,
balanced_tree
=
False
,
compact_nodes
=
False
)
except
TypeError
:
#fix for scipy 0.16.0
source_tree
=
sp
.
cKDTree
(
zip
(
sc_z
.
ravel
(
order
=
'F'
)))
source_tree
=
sp
.
cKDTree
(
list
(
zip
(
sc_z
.
ravel
(
order
=
'F'
)))
)
junk
,
nn_id
=
source_tree
.
query
(
zip
(
dst_dep_rv
),
k
=
1
)
junk
,
nn_id
=
source_tree
.
query
(
list
(
zip
(
dst_dep_rv
)
)
,
k
=
1
)
# WORKAROUND: the tree query returns out of range val when
# dst_dep point is NaN, causing ref problems later.
...
...
@@ -453,7 +453,7 @@ class Extract:
# Get first and last date within range, init to cover entire range
first_date
=
0
last_date
=
len
(
sc_time
.
time_counter
)
-
1
rev_seq
=
range
(
len
(
sc_time
.
time_counter
))
rev_seq
=
list
(
range
(
len
(
sc_time
.
time_counter
))
)
rev_seq
.
reverse
()
for
date
in
rev_seq
:
if
src_date_seconds
[
date
]
<
dst_start
:
...
...
@@ -752,7 +752,7 @@ class Extract:
"""
vals
=
{
'gregorian'
:
365.
+
isleap
(
year
),
'noleap'
:
365.
,
'360_day'
:
360.
}
if
source
not
in
vals
.
keys
():
if
source
not
in
list
(
vals
.
keys
()
)
:
raise
ValueError
(
'Unknown source calendar type: %s'
%
source
)
# Get month length
if
dest
==
'360_day'
:
...
...
This diff is collapsed.
Click to expand it.
pynemo/nemo_bdy_gen_c.py
View file @
190d199b
...
...
@@ -13,7 +13,7 @@ import numpy as np
import
logging
#Local Imports
from
utils.nemo_bdy_lib
import
sub2ind
from
.
utils.nemo_bdy_lib
import
sub2ind
class
Boundary
:
# Bearings for overlays
...
...
@@ -211,10 +211,10 @@ class Boundary:
"""
sh
=
np
.
shape
(
t
)
if
(
len
(
sh
)
>
2
)
or
(
sh
[
0
]
==
0
)
or
(
sh
[
1
]
==
0
):
print
'Warning: Shape of expected 2D array:'
,
sh
print
(
'Warning: Shape of expected 2D array:'
,
sh
)
tlist
=
t
.
tolist
()
sortt
=
[]
indx
=
zip
(
*
sorted
([(
val
,
i
)
for
i
,
val
in
enumerate
(
tlist
)]))[
1
]
indx
=
list
(
zip
(
*
sorted
([(
val
,
i
)
for
i
,
val
in
enumerate
(
tlist
)]))
)
[
1
]
indx
=
np
.
array
(
indx
)
for
i
in
indx
:
sortt
.
append
(
tlist
[
i
])
...
...
This diff is collapsed.
Click to expand it.
pynemo/nemo_bdy_grid_angle.py
View file @
190d199b
...
...
@@ -13,7 +13,7 @@
# cd_type: define the nature of pt2d grid points
import
numpy
as
np
from
reader.factory
import
GetFile
from
.
reader.factory
import
GetFile
import
logging
# pylint: disable=E1101
...
...
This diff is collapsed.
Click to expand it.
pynemo/nemo_bdy_ncpop.py
View file @
190d199b
...
...
@@ -23,13 +23,13 @@ def write_data_to_file(filename, variable_name, data):
if
variable_name
in
three_dim_variables
:
if
len
(
count
)
==
3
:
count
+=
(
1
L
,
)
count
+=
(
1
,
)
ncid
.
variables
[
variable_name
][:,
:,
:,
:]
=
np
.
reshape
(
data
,
count
)[:,
:,
:,
:]
elif
variable_name
in
two_dim_variables
:
if
len
(
count
)
==
2
:
count
+=
(
1
L
,
)
count
+=
(
1
,
)
elif
len
(
count
)
==
1
:
count
+=
(
1
L
,
1
L
,
)
count
+=
(
1
,
1
,
)
ncid
.
variables
[
variable_name
][:,
:,
:]
=
np
.
reshape
(
data
,
count
)[:,
:,
:]
elif
variable_name
==
'time_counter'
:
ncid
.
variables
[
variable_name
][:]
=
data
[:]
...
...
This diff is collapsed.
Click to expand it.
pynemo/nemo_bdy_src_time.py
View file @
190d199b
...
...
@@ -29,7 +29,7 @@ class SourceTime:
dir_list
.
sort
()
return
filter
(
None
,
dir_list
)
return
[
_f
for
_f
in
dir_list
if
_f
]
# Returns list of dicts of date/time info
# I assume there is only one date per file
...
...
This diff is collapsed.
Click to expand it.
pynemo/nemo_bdy_zgrv2.py
View file @
190d199b
...
...
@@ -14,12 +14,12 @@ Initialise with bdy t, u and v grid attributes (Grid.bdy_i)
and settings dictionary
"""
from
reader.factory
import
GetFile
from
.
reader.factory
import
GetFile
import
numpy
as
np
import
logging
from
utils.nemo_bdy_lib
import
sub2ind
from
utils.e3_to_depth
import
e3_to_depth
from
.
utils.nemo_bdy_lib
import
sub2ind
from
.
utils.e3_to_depth
import
e3_to_depth
# pylint: disable=E1101
# Query name
class
Depth
:
...
...
@@ -95,7 +95,7 @@ class Depth:
# Set u and v grid point depths
zshapes
=
{}
for
p
in
self
.
zpoints
.
keys
():
for
p
in
list
(
self
.
zpoints
.
keys
()
)
:
zshapes
[
p
]
=
self
.
zpoints
[
p
].
shape
wshapes
=
[]
wshapes
.
append
(
wrk1
.
shape
)
...
...
@@ -111,7 +111,7 @@ class Depth:
self
.
zpoints
[
'v'
][
k
,:]
=
0.5
*
(
wrk1
[
v_ind
]
+
wrk1
[
v_ind2
])
self
.
zpoints
[
'wv'
][
k
,:]
=
0.5
*
(
wrk2
[
v_ind
]
+
wrk2
[
v_ind2
])
for
p
in
self
.
zpoints
.
keys
():
for
p
in
list
(
self
.
zpoints
.
keys
()
)
:
self
.
zpoints
[
p
]
=
self
.
zpoints
[
p
].
reshape
(
zshapes
[
p
])
self
.
logger
.
debug
(
'Done loop, zpoints: %s '
,
self
.
zpoints
[
't'
].
shape
)
...
...
This diff is collapsed.
Click to expand it.
pynemo/nemo_coord_gen_pop.py
View file @
190d199b
...
...
@@ -28,7 +28,7 @@ class Coord:
self
.
logger
=
logging
.
getLogger
(
__name__
)
self
.
logger
.
debug
(
fname
)
if
not
fname
:
print
'need some error handling in here or is this redundant?'
# TODO
print
(
'need some error handling in here or is this redundant?'
)
# TODO
# Enter define mode
self
.
ncid
=
Dataset
(
fname
,
'w'
,
clobber
=
True
,
format
=
'NETCDF4'
)
...
...
This diff is collapsed.
Click to expand it.
pynemo/pynemo_ncml_generator.py
View file @
190d199b
...
...
@@ -7,8 +7,8 @@ Used for development purposes to display the ncml editor dialog.
@author: Shirley Crompton, UK Science and Technology Facilities Council
'''
import
sys
from
PyQt
4
.QtGui
import
*
from
gui
import
nemo_ncml_generator
as
ncml_generator
from
PyQt
5
.QtGui
import
*
from
.
gui
import
nemo_ncml_generator
as
ncml_generator
import
logging
# Logging set to info
logging
.
basicConfig
(
level
=
logging
.
INFO
)
...
...
@@ -21,4 +21,4 @@ def main():
sys
.
exit
(
app
.
exec_
())
if
__name__
==
'__main__'
:
main
()
\ No newline at end of file
main
()
This diff is collapsed.
Click to expand it.
pynemo/pynemo_settings_editor.py
View file @
190d199b
...
...
@@ -5,10 +5,10 @@ Created on 7 Jan 2015
'''
# pylint: disable=E1103
# pylint: disable=no-name-in-module
from
PyQt
4
import
QtGui
from
PyQt
5
import
QtGui
from
gui.nemo_bdy_input_window
import
InputWindow
import
nemo_bdy_setup
from
.
gui.nemo_bdy_input_window
import
InputWindow
from
.
import
nemo_bdy_setup
import
sys
,
getopt
...
...
@@ -41,12 +41,12 @@ def main():
try
:
opts
,
dummy_args
=
getopt
.
getopt
(
sys
.
argv
[
1
:],
"hs:"
,
[
"help"
,
"setup="
])
except
getopt
.
GetoptError
:
print
"usage: pynemo_settings_editor -s <namelist.bdy> "
print
(
"usage: pynemo_settings_editor -s <namelist.bdy> "
)
sys
.
exit
(
2
)
for
opt
,
arg
in
opts
:
if
opt
==
"-h"
:
print
"usage: pynemo_settings_editor -s <namelist.bdy> "
print
(
"usage: pynemo_settings_editor -s <namelist.bdy> "
)
sys
.
exit
()
elif
opt
in
(
"-s"
,
"--setup"
):
setup_file
=
arg
...
...
This diff is collapsed.
Click to expand it.
setup.cfg
View file @
190d199b
[bdist_wheel]
python-tag = py27
\ No newline at end of file
python-tag = py38
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