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
gts2
gts2_client
Commits
3625f479
Commit
3625f479
authored
Feb 23, 2018
by
Niklas Bohn
Browse files
Soft coded fill values and data ranges
parent
1ce160bf
Pipeline
#2657
passed with stages
in 15 minutes and 7 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
gts2_client/gts2_client.py
View file @
3625f479
...
...
@@ -613,7 +613,8 @@ def json_to_netcdf(out_mode, api_result, outpath, out_prefix, geo_ll, geo_ur, st
band_group
.
createDimension
(
'x'
,
band_arr
.
shape
[
2
])
band_group
.
createDimension
(
'y'
,
band_arr
.
shape
[
1
])
band_group
.
createDimension
(
't'
,
band_arr
.
shape
[
0
])
data
=
band_group
.
createVariable
(
'Data'
,
'i4'
,
(
'x'
,
'y'
,
't'
),
fill_value
=
255
)
fill
=
api_result
[
key
][
tile
][
band
][
'fill_value'
]
data
=
band_group
.
createVariable
(
'Data'
,
'i4'
,
(
'x'
,
'y'
,
't'
),
fill_value
=
fill
)
data
.
units
=
"None"
if
level
==
"L1C"
:
data
.
long_name
=
"Top of Atmosphere Reflectance"
...
...
@@ -621,13 +622,12 @@ def json_to_netcdf(out_mode, api_result, outpath, out_prefix, geo_ll, geo_ur, st
else
:
data
.
long_name
=
"Surface Reflectance"
data
.
standard_name
=
"boa_reflectance"
data
.
valid_range
=
np
.
array
((
-
2000.0
,
16000.0
)
)
data
.
actual
_range
=
np
.
array
((
np
.
min
(
band_arr
),
np
.
max
(
band_arr
)))
masked_fill
=
np
.
ma
.
masked_equal
(
band_arr
,
fill
)
data
.
data
_range
=
np
.
array
((
np
.
min
(
masked_fill
),
np
.
max
(
masked_fill
)))
data
[:,
:,
:]
=
band_arr
band_group
.
Band
=
band
.
split
(
"_"
)[
0
].
split
(
"B"
)[
-
1
]
band_group
.
Resolution
=
band
.
split
(
"_"
)[
-
1
]
band_group
.
Central_Wavelength
=
wl
[
str
(
band
.
split
(
"_"
)[
0
])]
if
key
==
'Metadata'
:
key_group
=
f
.
createGroup
(
key
)
for
tile
in
api_result
[
key
].
keys
():
...
...
@@ -664,15 +664,16 @@ def json_to_netcdf(out_mode, api_result, outpath, out_prefix, geo_ll, geo_ur, st
mask_group
.
createDimension
(
'x'
,
mask_arr
.
shape
[
2
])
mask_group
.
createDimension
(
'y'
,
mask_arr
.
shape
[
1
])
mask_group
.
createDimension
(
't'
,
mask_arr
.
shape
[
0
])
data
=
mask_group
.
createVariable
(
'Data'
,
'i4'
,
(
'x'
,
'y'
,
't'
),
fill_value
=
255
)
fill
=
api_result
[
key
][
tile
][
msk
][
'fill_value'
]
data
=
mask_group
.
createVariable
(
'Data'
,
'i4'
,
(
'x'
,
'y'
,
't'
),
fill_value
=
fill
)
data
.
units
=
"None"
data
.
long_name
=
"Mask classes"
data
.
standard_name
=
"classes"
data
.
valid_range
=
np
.
array
((
10.0
,
60.0
)
)
data
.
actual
_range
=
np
.
array
((
np
.
min
(
mask
_arr
),
np
.
max
(
mask
_arr
)))
masked_fill
=
np
.
ma
.
masked_equal
(
mask_arr
,
fill
)
data
.
data
_range
=
np
.
array
((
np
.
min
(
mask
ed_fill
),
np
.
max
(
mask
ed_fill
)))
data
[:,
:,
:]
=
mask_arr
f
.
close
()
except
:
except
Exception
:
raise
Exception
(
"Something went wrong while saving as netcdf. "
+
traceback
.
format_exc
())
...
...
Write
Preview
Supports
Markdown
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