Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Ray Garcia
himawari
Commits
daf4c746
Commit
daf4c746
authored
Sep 08, 2017
by
R.K.Garcia
Browse files
add -z (e.g. -z5) compression option to ahi2cmi
results in ~964M B03 going down to ~164M
parent
45db3bec
Changes
1
Hide whitespace changes
Inline
Side-by-side
himawari/ahi2cmi.py
View file @
daf4c746
...
...
@@ -482,7 +482,7 @@ class HimawariAHIasCMIP(object):
bwl
=
np
.
array
([
bwl_um
],
dtype
=
np
.
float32
)
yield
self
.
p
(
'band_id'
),
band
,
self
.
d
(
DEFAULT_BAND_DIM_NAME
),
a
def
walk
(
self
):
def
walk
(
self
,
extra_data_attrs
=
{}
):
"""
iterate PVDA frames equivalent to a PUG nc_walk
"""
...
...
@@ -509,7 +509,8 @@ class HimawariAHIasCMIP(object):
# we almost forgot! the data itself
v
=
self
.
data
d
=
self
.
data_dims
a
=
self
.
data_attrs
a
=
dict
(
self
.
data_attrs
)
a
.
update
(
extra_data_attrs
)
yield
self
.
p
(
self
.
_data_name
),
v
,
d
,
a
#
...
...
@@ -680,16 +681,20 @@ class tests(unittest.TestCase):
n_frames
+=
1
print
(
"%d frames"
%
n_frames
)
def
write_netcdf
(
path
,
as_radiances
=
False
,
filename_format
=
"{}.nc"
):
def
write_netcdf
(
path
,
as_radiances
=
False
,
filename_format
=
"{}.nc"
,
complevel
=
None
):
from
goesr.rockfall
import
rename
,
nc_write
,
autoscale
fnstem
=
os
.
path
.
splitext
(
os
.
path
.
split
(
path
)[
-
1
])[
0
]
fn
=
filename_format
.
format
(
fnstem
)
pathout
=
os
.
path
.
abspath
(
fn
)
lething
=
HimawariAHIasCMIP
(
path
,
as_radiances
=
as_radiances
)
varname
=
DEFAULT_CMIP_RAD_NAME
if
as_radiances
else
DEFAULT_CMIP_NAME
extra_data_attrs
=
{}
if
complevel
:
extra_data_attrs
[
'.complevel'
]
=
complevel
if
isinstance
(
complevel
,
int
)
else
7
extra_data_attrs
[
'.zlib'
]
=
True
for
fnwrit
in
nc_write
(
rename
(
autoscale
(
lething
.
walk
(),
autoscale
(
lething
.
walk
(
extra_data_attrs
=
extra_data_attrs
),
variable_names_matching
=
{
varname
}
),
pathout
...
...
@@ -721,6 +726,8 @@ def main():
help
=
'each occurrence increases verbosity 1 level through ERROR-WARNING-INFO-DEBUG'
)
parser
.
add_argument
(
'-d'
,
'--debug'
,
dest
=
'debug'
,
action
=
'store_true'
,
help
=
"enable interactive PDB debugger on exception"
)
parser
.
add_argument
(
'-z'
,
'--compress'
,
dest
=
'compress'
,
type
=
int
,
default
=
0
,
help
=
'set compression level 0..9 for image data variable'
)
parser
.
add_argument
(
'inputs'
,
nargs
=
'*'
,
help
=
"input files to process"
)
args
=
parser
.
parse_args
()
...
...
@@ -736,7 +743,7 @@ def main():
return
0
for
pn
in
args
.
inputs
:
write_netcdf
(
pn
,
args
.
rad
,
"{}_rad.nc"
if
args
.
rad
else
"{}_cmi.nc"
)
write_netcdf
(
pn
,
args
.
rad
,
"{}_rad.nc"
if
args
.
rad
else
"{}_cmi.nc"
,
complevel
=
args
.
compress
)
return
0
...
...
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