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
geomultisens
gms_preprocessing
Commits
4e1c9426
Commit
4e1c9426
authored
Apr 01, 2020
by
Daniel Scheffler
Browse files
Some adjustments to current code.
Signed-off-by:
Daniel Scheffler
<
danschef@gfz-potsdam.de
>
parent
f3f8fd26
Pipeline
#8049
failed with stage
in 18 minutes and 26 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
gms_preprocessing/io/output_writer.py
View file @
4e1c9426
...
...
@@ -571,7 +571,7 @@ def dump_all_SRFs(outpath_dump=os.path.abspath(os.path.join(os.path.dirname(__fi
[
'ASTER_VNIR1'
,
'ASTER_VNIR2'
,
'ASTER_SWIR'
,
'ASTER_TIR'
,
'LANDSAT_TM5'
,
'LANDSAT_TM7'
,
'LANDSAT_LDCM'
,
'RapidEye_5'
,
'Spot_1'
,
'Spot_4'
,
'Spot_5'
]):
out_dict
[
out_sensorcode
]
=
SRF_Reader
(
sensorcode
,
logger
)
out_dict
[
out_sensorcode
]
=
SRF_Reader
(
sensorcode
)
with
open
(
outpath_dump
,
'wb'
)
as
outFile
:
pickle
.
dump
(
out_dict
,
outFile
)
...
...
@@ -600,7 +600,7 @@ class GMSObjWriter(object):
"""Base class for writing GMS objects."""
def
__init__
(
self
,
GMSObj
,
is_tempfile
=
False
):
# type: (GMS_object) -> None
# type: (GMS_object
, bool
) -> None
if
not
GMSObj
.
arr_shape
in
[
'cube'
,
'block'
,
'MGRS_tile'
]:
raise
ValueError
(
"GMSObjWriter supports only array shapes 'cube', 'block' and 'MGRS_tile'. "
"Received %s."
%
GMSObj
.
arr_shape
)
...
...
@@ -733,21 +733,21 @@ class GMSObjWriter(object):
def
get_updated_db_entry
(
self
):
"""Get id of updated record (needed for cross-refs in later db entrys."""
if
not
self
.
is_tempfile
and
self
.
GMSObj
.
arr_shape
in
[
'cube'
,
'block'
]:
res
=
DB_T
.
get_info_from_postgreSQLdb
(
CFG
.
job
.
conn_database
,
'scenes_proc'
,
[
'id'
],
res
=
DB_T
.
get_info_from_postgreSQLdb
(
CFG
.
conn_database
,
'scenes_proc'
,
[
'id'
],
{
'sceneid'
:
self
.
GMSObj
.
scene_ID
})
assert
len
(
res
)
==
1
,
\
'Found multiple database records for the last updated record. sceneid: %s'
%
self
.
GMSObj
.
scene_ID
self
.
updated_db_entry
.
update
(
dict
(
table
=
'scenes_proc'
,
ID
=
res
[
0
][
0
]))
elif
not
self
.
is_tempfile
and
self
.
GMSObj
.
arr_shape
==
'MGRS_tile'
:
res
=
DB_T
.
get_info_from_postgreSQLdb
(
CFG
.
job
.
conn_database
,
'mgrs_tiles_proc'
,
[
'id'
],
res
=
DB_T
.
get_info_from_postgreSQLdb
(
CFG
.
conn_database
,
'mgrs_tiles_proc'
,
[
'id'
],
{
'sceneid'
:
self
.
GMSObj
.
scene_ID
,
'virtual_sensor_id'
:
CFG
.
usecase
.
virtual_sensor_id
,
'virtual_sensor_id'
:
CFG
.
virtual_sensor_id
,
'mgrs_code'
:
self
.
GMSObj
.
MGRS_info
[
'tile_ID'
]})
assert
len
(
res
)
==
1
,
\
'Found multiple database records for the last updated record. sceneid: %s; mgrs_code: %s; '
\
'virtual_sensor_id: %s'
\
%
(
self
.
GMSObj
.
scene_ID
,
self
.
GMSObj
.
MGRS_info
[
'tile_ID'
],
CFG
.
usecase
.
virtual_sensor_id
)
%
(
self
.
GMSObj
.
scene_ID
,
self
.
GMSObj
.
MGRS_info
[
'tile_ID'
],
CFG
.
virtual_sensor_id
)
self
.
updated_db_entry
.
update
(
dict
(
table
=
'mgrs_tiles_proc'
,
ID
=
res
[
0
][
0
]))
return
self
.
updated_db_entry
...
...
@@ -767,7 +767,7 @@ class _BlockWriter(GMSObjWriter):
"""Base class for writing block-like objects."""
def
__init__
(
self
,
GMSObj
,
is_tempfile
=
False
):
# type: (GMS_object) -> None
# type: (GMS_object
, bool
) -> None
super
(
_BlockWriter
,
self
).
__init__
(
GMSObj
,
is_tempfile
=
is_tempfile
)
self
.
updated_ID_scenes_proc
=
None
...
...
@@ -776,7 +776,7 @@ class _BlockWriter(GMSObjWriter):
super
(
_BlockWriter
,
self
).
update_database
()
# get id of updated record (needed for cross-refs in later db entrys
res
=
DB_T
.
get_info_from_postgreSQLdb
(
CFG
.
job
.
conn_database
,
'scenes_proc'
,
[
'id'
],
res
=
DB_T
.
get_info_from_postgreSQLdb
(
CFG
.
conn_database
,
'scenes_proc'
,
[
'id'
],
{
'sceneid'
:
self
.
GMSObj
.
scene_ID
})
assert
len
(
res
)
==
1
,
\
'Found multiple database records for the last updated record. sceneid: %s'
%
self
.
GMSObj
.
scene_ID
...
...
@@ -787,7 +787,7 @@ class _BlockWriter(GMSObjWriter):
class
SceneWriter
(
_BlockWriter
):
"""Class for writing full scene objects."""
def
__init__
(
self
,
GMSObj
,
is_tempfile
=
False
):
# type: (GMS_object) -> None
# type: (GMS_object
, bool
) -> None
"""
:param GMSObj:
...
...
@@ -804,7 +804,7 @@ class TileWriter(_BlockWriter):
"""Class for writing tiles/block-subsets of full scene objects."""
def
__init__
(
self
,
GMSObj
,
is_tempfile
=
False
):
# type: (GMS_object) -> None
# type: (GMS_object
, bool
) -> None
"""
:param GMSObj:
...
...
@@ -828,7 +828,7 @@ class TileWriter(_BlockWriter):
class
MGRSTileWriter
(
TileWriter
):
def
__init__
(
self
,
GMSObj
,
is_tempfile
):
# type: (GMS_object) -> None
# type: (GMS_object
, bool
) -> None
"""
:param GMSObj:
...
...
@@ -846,13 +846,13 @@ class MGRSTileWriter(TileWriter):
super
(
MGRSTileWriter
,
self
).
update_database
()
# get id of updated record (needed for cross-refs in later db entrys
res
=
DB_T
.
get_info_from_postgreSQLdb
(
CFG
.
job
.
conn_database
,
'mgrs_tiles_proc'
,
[
'id'
],
res
=
DB_T
.
get_info_from_postgreSQLdb
(
CFG
.
conn_database
,
'mgrs_tiles_proc'
,
[
'id'
],
{
'sceneid'
:
self
.
GMSObj
.
scene_ID
,
'virtual_sensor_id'
:
CFG
.
usecase
.
virtual_sensor_id
,
'virtual_sensor_id'
:
CFG
.
virtual_sensor_id
,
'mgrs_code'
:
self
.
GMSObj
.
MGRS_info
[
'tile_ID'
]})
assert
len
(
res
)
==
1
,
'Found multiple database records for the last updated record. sceneid: %s;'
\
'mgrs_code: %s; virtual_sensor_id: %s'
\
%
(
self
.
GMSObj
.
scene_ID
,
self
.
GMSObj
.
MGRS_info
[
'tile_ID'
],
CFG
.
usecase
.
virtual_sensor_id
)
%
(
self
.
GMSObj
.
scene_ID
,
self
.
GMSObj
.
MGRS_info
[
'tile_ID'
],
CFG
.
virtual_sensor_id
)
self
.
mgrs_tiles_proc_ID
=
res
[
0
][
0
]
...
...
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