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
0c3cb167
Commit
0c3cb167
authored
Jul 19, 2017
by
RKGarcia
Browse files
py36 division fixes
parent
a8c2311f
Changes
1
Hide whitespace changes
Inline
Side-by-side
himawari/scmi.py
View file @
0c3cb167
...
...
@@ -340,7 +340,7 @@ SCMI_FGF_ATT=dict(
grid_mapping_name
=
'geostationary'
,
semi_major
=
None
,
# 6378137.0,
# semi_major_axis=6378137.0, # CF
sweep_angle_axis
=
"
x
"
,
sweep_angle_axis
=
"
y
"
,
)
def
_ahi_bit_depth
(
channel
):
...
...
@@ -491,7 +491,7 @@ class AttributeHelper(object):
self
.
offset
=
offset
self
.
tile_count
=
tile_count
self
.
scene_shape
=
scene_shape
self
.
tile_shape
=
(
scene_shape
[
0
]
/
tile_count
[
0
],
scene_shape
[
1
]
/
tile_count
[
1
])
self
.
tile_shape
=
(
int
(
scene_shape
[
0
]
/
tile_count
[
0
]
)
,
int
(
scene_shape
[
1
]
/
tile_count
[
1
])
)
if
(
scene_shape
[
0
]
%
tile_count
[
0
]
!=
0
)
or
(
scene_shape
[
1
]
%
tile_count
[
1
]
!=
0
):
raise
ValueError
(
'tile shape %r does not fit evenly into scene shape %r'
%
(
self
.
tile_shape
,
scene_shape
))
...
...
@@ -561,8 +561,8 @@ class AttributeHelper(object):
def
_tile_center
(
self
):
# = None, # 88.0022078322,
# calculate center longitude of tile
# FIXME: resolve whether we need half-pixel offset
row
=
self
.
_global_tile_row_offset
()
+
self
.
tile_shape
[
0
]
/
2
col
=
self
.
_global_tile_column_offset
()
+
self
.
tile_shape
[
1
]
/
2
row
=
self
.
_global_tile_row_offset
()
+
int
(
self
.
tile_shape
[
0
]
/
2
)
col
=
self
.
_global_tile_column_offset
()
+
int
(
self
.
tile_shape
[
1
]
/
2
)
# if we're not getting proper nav from the file, substitute nominal values
args
=
dict
(
HCAST_DEFAULT_NAV_CENTER
)
if
self
.
_file_nav_is_incomplete
else
{}
nav
=
self
.
hsd
.
geo
(
line_offset
=
row
,
column_offset
=
col
,
lines
=
1
,
columns
=
1
,
**
args
)
...
...
@@ -580,10 +580,10 @@ class AttributeHelper(object):
return
self
.
scene_shape
[
1
]
def
_global_tile_row_offset
(
self
):
return
self
.
offset
[
0
]
*
self
.
tile_shape
[
0
]
return
int
(
self
.
offset
[
0
]
*
self
.
tile_shape
[
0
]
)
def
_global_tile_column_offset
(
self
):
return
self
.
offset
[
1
]
*
self
.
tile_shape
[
1
]
return
int
(
self
.
offset
[
1
]
*
self
.
tile_shape
[
1
]
)
def
_global_tile_center_latitude
(
self
):
# = None, # 88.0022078322,
nav
=
self
.
_tile_center
()
...
...
@@ -935,7 +935,7 @@ def hsd2scmi(scene, filename=None, include_rad=False,
reduction_factor
=
1
# create file, dimensions and variables before proceeding to attributes, then values
shape
=
tuple
(
q
/
reduction_factor
for
q
in
shape
)
shape
=
tuple
(
int
(
q
/
reduction_factor
)
for
q
in
shape
)
resolution
=
RESOLUTION_FROM_WIDTH
[
scene
.
extents
[
1
]]
tiles_total
=
tile_count
[
0
]
*
tile_count
[
1
]
...
...
@@ -1018,8 +1018,9 @@ def hsd2scmi(scene, filename=None, include_rad=False,
my
=
fgf
.
my
,
by
=
fgf
.
by
,
mx
=
fgf
.
mx
,
bx
=
fgf
.
bx
)
if
reduction_factor
>
1
:
fgf
=
himawari
.
fgf_yxmb
(
fgf
.
y
[
reduction_factor
/
2
::
reduction_factor
],
fgf
.
x
[
reduction_factor
/
2
::
reduction_factor
],
rfo2
=
int
(
reduction_factor
/
2
)
fgf
=
himawari
.
fgf_yxmb
(
fgf
.
y
[
rfo2
::
reduction_factor
],
fgf
.
x
[
rfo2
::
reduction_factor
],
my
=
fgf
.
my
,
by
=
fgf
.
by
,
mx
=
fgf
.
mx
,
bx
=
fgf
.
bx
)
y
=
fgf
.
y
[
ty
*
tile_shape
[
0
]:(
ty
+
1
)
*
tile_shape
[
0
]]
...
...
@@ -1090,6 +1091,16 @@ def _parse_tile_count(s):
else
:
raise
ValueError
(
'cannot get tile count out of %r'
%
s
)
def
_debug
(
type
,
value
,
tb
):
"enable with sys.excepthook = debug"
if
not
sys
.
stdin
.
isatty
():
sys
.
__excepthook__
(
type
,
value
,
tb
)
else
:
import
traceback
,
pdb
traceback
.
print_exception
(
type
,
value
,
tb
)
# …then start the debugger in post-mortem mode.
pdb
.
post_mortem
(
tb
)
# more “modern”
def
main
():
parser
=
argparse
.
ArgumentParser
(
description
=
"PURPOSE"
,
...
...
@@ -1109,6 +1120,8 @@ def main():
help
=
'factor to stride by, typically 1, 2 or 4'
)
parser
.
add_argument
(
'-t'
,
'--tiles'
,
dest
=
'tiles'
,
default
=
'1'
,
help
=
'number of tiles to create in each dimension, or y,x tile count pair'
)
parser
.
add_argument
(
'--debug'
,
dest
=
'debug'
,
action
=
'store_true'
,
help
=
"enable interactive PDB debugger on exception"
)
# FUTURE: include a resolution tag for 2km/1km/0p5km
# http://docs.python.org/2.7/library/argparse.html#nargs
...
...
@@ -1118,6 +1131,9 @@ def main():
help
=
"positional arguments don't have the '-' prefix"
)
args
=
parser
.
parse_args
()
if
args
.
debug
:
sys
.
excepthook
=
_debug
levels
=
[
logging
.
ERROR
,
logging
.
WARN
,
logging
.
INFO
,
logging
.
DEBUG
]
logging
.
basicConfig
(
level
=
levels
[
min
(
3
,
args
.
verbosity
)])
...
...
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