Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
yori
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Paolo Veglio
yori
Commits
8cec38fa
There was an error fetching the commit references. Please try again later.
Commit
8cec38fa
authored
6 years ago
by
Paolo Veglio
Browse files
Options
Downloads
Patches
Plain Diff
changes to improve speed, pt.2
parent
a5c2abc7
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
yori/gridtools.py
+4
-2
4 additions, 2 deletions
yori/gridtools.py
yori/run_yori.py
+10
-10
10 additions, 10 deletions
yori/run_yori.py
with
14 additions
and
12 deletions
yori/gridtools.py
+
4
−
2
View file @
8cec38fa
...
...
@@ -47,7 +47,9 @@ def create_index(self):
latidx
[
idx
]
=
0
idx
=
np
.
where
(
lonidx
<
0
)
lonidx
[
idx
]
=
0
self
.
edges
=
[
np
.
min
(
lonidx
),
np
.
max
(
lonidx
),
np
.
min
(
latidx
),
np
.
max
(
latidx
)]
# THIS PART WAS DEFINED FOR THE EQUAL_AREA PROJECTION
# WHENEVER WE BELIEVE WE ARE READY TO MOVE BACK TO IT
# WE CAN POSSIBLY START FROM HERE
...
...
@@ -226,7 +228,7 @@ def compute_2D_histogram(self, var1, var2, binvec1, binvec2, varname, var_name_o
if
(
len
(
xx
)
>
0
)
&
(
len
(
yy
)
>
0
):
var2Dstat
[
self
.
srt_idx
[
self
.
box_idx
[
i
]],
:,
:]
=
(
np
.
histogram2d
(
xx
,
yy
,
(
binvec1
,
binvec2
))[
0
])
np
.
histogram2d
(
xx
,
yy
,
bins
=
(
binvec1
,
binvec2
))[
0
])
elif
((
len
(
xx
)
==
0
)
|
(
len
(
yy
)
==
0
)):
var2Dstat
[
self
.
srt_idx
[
self
.
box_idx
[
i
]],
:,
:]
=
np
.
nan
else
:
...
...
This diff is collapsed.
Click to expand it.
yori/run_yori.py
+
10
−
10
View file @
8cec38fa
...
...
@@ -7,7 +7,7 @@
from
pkg_resources
import
get_distribution
import
yori.ioutils
as
iou
import
yori.
new_
ioutils
as
iou
import
yori.gridtools
as
grid
import
yori.config_reader
as
cfg
...
...
@@ -134,7 +134,7 @@ def runYori(self, debug=False, compression=0):
lat
=
data_in
[
self
.
lat_key
][:]
lon
=
data_in
[
self
.
lon_key
][:]
myGrid
=
grid
.
ComputeVariables
(
lat
,
lon
,
self
.
grid_size
,
self
.
grid_proj
,
self
.
fv
)
for
i
in
range
(
len
(
self
.
ymlSet
.
var_settings
)):
var_settings
=
self
.
ymlSet
.
var_settings
[
i
]
...
...
@@ -144,7 +144,6 @@ def runYori(self, debug=False, compression=0):
only_hist
=
True
masked_data_in
,
var_name_out
=
self
.
setVariable
(
var_settings
,
lat
,
data_in
)
myGrid
=
grid
.
ComputeVariables
(
lat
,
lon
,
self
.
grid_size
,
self
.
grid_proj
,
self
.
fv
)
if
only_hist
is
False
:
tmp_gridvar
=
myGrid
.
compute_stats
(
masked_data_in
,
var_name_out
)
...
...
@@ -172,7 +171,7 @@ def runYori(self, debug=False, compression=0):
if
debug
is
False
:
write_output
(
self
.
output_file
,
gridvar
,
compression
,
self
.
grid_size
,
self
.
ymlSet
,
self
.
fv
)
self
.
grid_size
,
self
.
ymlSet
,
self
.
fv
,
edges
=
myGrid
.
edges
)
else
:
for
k
in
gridvar
.
keys
():
...
...
@@ -187,8 +186,8 @@ def callYori(config_file, input_file, output_file, debug=False, compression=0):
Yori
.
runYori
(
debug
,
compression
)
def
write_output
(
output_file
,
gridvar
,
compression
,
grid_size
,
ymlSet
,
fv
):
outInst
=
iou
.
CreateMatchfile
(
output_file
,
gridvar
,
comp
=
compression
)
def
write_output
(
output_file
,
gridvar
,
compression
,
grid_size
,
ymlSet
,
fv
,
edges
=
[]
):
outInst
=
iou
.
CreateMatchfile
(
output_file
,
gridvar
,
comp
=
compression
,
edges
=
edges
)
outInst
.
createFile
()
fout
=
nc
.
Dataset
(
output_file
,
mode
=
'
a
'
)
...
...
@@ -197,14 +196,15 @@ def write_output(output_file, gridvar, compression, grid_size, ymlSet, fv):
fout
.
setncattr
(
'
YAML_config
'
,
ymlSet
.
yaml_str
)
fout
.
setncattr
(
'
Yori_version
'
,
str
(
VERSION
))
fout
.
close
()
#
fout.close()
for
k
in
list
(
gridvar
):
if
k
.
split
(
'
/
'
)[
-
1
]
==
'
Pixel_Counts
'
or
gridvar
[
k
].
ndim
>
2
:
outInst
.
saveNewVar
(
k
,
fillvalue
=
fv
,
vartype
=
'
i4
'
)
outInst
.
saveNewVar
(
fout
,
gridvar
,
k
,
fillvalue
=
fv
,
vartype
=
'
i4
'
)
else
:
outInst
.
saveNewVar
(
k
,
fillvalue
=
fv
)
outInst
.
saveNewVar
(
fout
,
gridvar
,
k
,
fillvalue
=
fv
)
fout
.
close
()
fout
=
nc
.
Dataset
(
output_file
,
mode
=
'
a
'
)
for
settings
in
ymlSet
.
var_settings
:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment