Commit e8770a6b authored by Daniel Scheffler's avatar Daniel Scheffler
Browse files

Updated deprecated import statements. Updated deprecated link to controller...

Updated deprecated import statements. Updated deprecated link to controller file of SpatialIndexMediator.
updated __version__ and __versionalias__
Former-commit-id: c25ef78d
Former-commit-id: 2354d9d1
parent 5b1de329
......@@ -2,8 +2,8 @@
__author__ = """Daniel Scheffler"""
__email__ = 'daniel.scheffler@gfz-potsdam.de'
__version__ = '0.3.0'
__versionalias__ = '20170601.01'
__version__ = '0.3.1'
__versionalias__ = '20170609.01'
from . import algorithms
......
......@@ -52,10 +52,10 @@ from shapely.geometry import MultiPoint, Polygon
from shapely.ops import cascaded_union
from geoarray import GeoArray
from py_tools_ds.ptds.geo.coord_grid import snap_bounds_to_pixGrid
from py_tools_ds.ptds.geo.coord_trafo import transform_utm_to_wgs84, transform_wgs84_to_utm, mapXY2imXY, imXY2mapXY
from py_tools_ds.ptds.geo.projection import get_UTMzone, EPSG2WKT, isProjectedOrGeographic
from py_tools_ds.ptds.geo.raster.reproject import warp_ndarray
from py_tools_ds.geo.coord_grid import snap_bounds_to_pixGrid
from py_tools_ds.geo.coord_trafo import transform_utm_to_wgs84, transform_wgs84_to_utm, mapXY2imXY, imXY2mapXY
from py_tools_ds.geo.projection import get_UTMzone, EPSG2WKT, isProjectedOrGeographic
from py_tools_ds.geo.raster.reproject import warp_ndarray
from ..config import GMS_config as CFG
from ..misc import helper_functions as HLP_F
......
......@@ -18,10 +18,10 @@ except ImportError:
SD = None
from geoarray import GeoArray
from py_tools_ds.ptds.geo.coord_calc import calc_FullDataset_corner_positions
from py_tools_ds.ptds.geo.coord_trafo import pixelToLatLon
from py_tools_ds.ptds.geo.map_info import mapinfo2geotransform
from py_tools_ds.ptds.geo.projection import EPSG2WKT
from py_tools_ds.geo.coord_calc import calc_FullDataset_corner_positions
from py_tools_ds.geo.coord_trafo import pixelToLatLon
from py_tools_ds.geo.map_info import mapinfo2geotransform
from py_tools_ds.geo.projection import EPSG2WKT
from ..config import GMS_config as CFG
from . import GEOPROCESSING as GEOP
......
......@@ -2,7 +2,7 @@
###############################################################################
#
# Level 1B Processor:
#
#
# Performed operations:
# Generation of RPCs for later Orthorectification:
# - for satellite data
......@@ -29,11 +29,11 @@ from shapely.geometry import box
from CoReg_Sat import COREG, DESHIFTER
from geoarray import GeoArray
from py_tools_ds.ptds.geo.coord_grid import is_coord_grid_equal
from py_tools_ds.ptds.geo.coord_calc import corner_coord_to_minmax
from py_tools_ds.ptds.geo.coord_trafo import reproject_shapelyGeometry, transform_any_prj
from py_tools_ds.ptds.geo.projection import prj_equal, EPSG2WKT, WKT2EPSG
from py_tools_ds.ptds.geo.vector.topology import get_overlap_polygon
from py_tools_ds.geo.coord_grid import is_coord_grid_equal
from py_tools_ds.geo.coord_calc import corner_coord_to_minmax
from py_tools_ds.geo.coord_trafo import reproject_shapelyGeometry, transform_any_prj
from py_tools_ds.geo.projection import prj_equal, EPSG2WKT, WKT2EPSG
from py_tools_ds.geo.vector.topology import get_overlap_polygon
from ..config import GMS_config as CFG
from .L1A_P import L1A_object
......
......@@ -23,7 +23,7 @@ except ImportError:
import osr
from geoarray import GeoArray
from py_tools_ds.ptds.geo.map_info import mapinfo2geotransform
from py_tools_ds.geo.map_info import mapinfo2geotransform
from ..config import GMS_config as CFG
from . import GEOPROCESSING as GEOP
......
......@@ -14,7 +14,7 @@ import warnings
import numpy as np
from geoarray import GeoArray
from py_tools_ds.ptds.geo.map_info import mapinfo2geotransform
from py_tools_ds.geo.map_info import mapinfo2geotransform
from ..config import GMS_config as CFG
from .L1C_P import L1C_object
......
......@@ -39,8 +39,8 @@ from ..misc.database_tools import get_overlapping_scenes_from_postgreSQLdb
from ..misc.path_generator import path_generator, get_tempfile
from geoarray import GeoArray
from py_tools_ds.ptds.geo.coord_calc import corner_coord_to_minmax
from py_tools_ds.ptds.geo.coord_trafo import transform_any_prj
from py_tools_ds.geo.coord_calc import corner_coord_to_minmax
from py_tools_ds.geo.coord_trafo import transform_any_prj
......@@ -375,7 +375,7 @@ def get_dem_by_extent(cornerCoords_tgt, prj, tgt_xgsd, tgt_ygsd):
# handle coordinate infos
tgt_corner_coord_lonlat = [transform_any_prj(prj, 4326, X,Y) for X,Y in cornerCoords_tgt]
#tgt_corner_coord_lonlat = [(-114, 52), (-117, 52), (-117, 50), (-114, 50)] # this is a test
#from py_tools_ds.ptds.geo.projection import EPSG2WKT
#from py_tools_ds.geo.projection import EPSG2WKT
#prj = EPSG2WKT(32612)
# handle coordinates crossing the 180 degress meridian
......
......@@ -7,10 +7,10 @@ import re
import warnings
from datetime import datetime, timedelta
from shapely.geometry import Polygon
class SpatialIndexMediatorServer:
controller = 'index-mediator-server'
controller = 'index-mediator-server.sh'
def __init__(self, rootDir):
self.rootDir = rootDir
......@@ -79,7 +79,7 @@ class SpatialIndexMediatorServer:
os.chdir(curdir)
if exitcode:
raise err
raise Exception(err)
else:
if output:
return output.decode('UTF-8')
......@@ -89,7 +89,7 @@ class SpatialIndexMediatorServer:
class SpatialIndexMediator:
FULL_SCENE_QUERY_MSG = 3
""" message value for a full scene query message """
......@@ -105,29 +105,29 @@ class SpatialIndexMediator:
self.host = host
self.port = port
self.timeout = timeout
@staticmethod
def __deriveSeasonCode(refDate, maxDaysDelta):
if refDate is None or maxDaysDelta is None:
return 0
delta = timedelta(days=maxDaysDelta)
startMonth = (refDate - delta).month - 1
endMonth = (refDate + delta).month - 1
seasonCode = 0
for x in range(12):
month = (startMonth + x) % 12
seasonCode |= 1 << month
if month == endMonth: break
return seasonCode
def getFullSceneDataForDataset(self, envelope, timeStart, timeEnd, minCloudCover, maxCloudCover, datasetid, refDate=None, maxDaysDelta=None):
"""
Query the spatial index with the given parameters in order to get a list of matching scenes intersecting the
......@@ -145,65 +145,65 @@ class SpatialIndexMediator:
:param maxDaysDelta: maximum allowed number of days the target scenes might be apart from the given refDate
[optional]
"""
filterTimerange = not (refDate is None or maxDaysDelta is None)
# prepare buffer
# numbytes = 1 + 4*8 + 8 + 8 + 4 + 1 + 1 + 2 + 2
b = bytearray(59)
# pack msg header and envelope
offset = 0
struct.pack_into('> b 4d', b, offset, self.FULL_SCENE_QUERY_MSG, *envelope)
offset += 33
# pack the dates
struct.pack_into('> h 6b', b, offset, timeStart.year, timeStart.month, timeStart.day, timeStart.hour, timeStart.minute, timeStart.second, 0)
offset += 8
struct.pack_into('> h 6b', b, offset, timeEnd.year, timeEnd.month, timeEnd.day, timeEnd.hour, timeEnd.minute, timeEnd.second, 0)
offset += 8
# derive season code
seasonCode = self.__deriveSeasonCode(refDate, maxDaysDelta)
# pack the rest
# TODO: send unconstraint min/max proclevel values
struct.pack_into('> i 2b h 2b', b, offset, seasonCode, minCloudCover, maxCloudCover, datasetid, 0, 127)
# get connection and lock the channel
con = Connection(self.host, self.port, self.timeout)
# send the buffer
con.socket.sendall(b)
# receive the response
# read first byte, indicating the response type, must match full scene query msg
if con.recvByte() != self.FULL_SCENE_QUERY_MSG:
raise EnvironmentError('Bad Protocol')
# now read the number of bytes that follow
numBytes = con.recvInt()
b = bytearray(numBytes)
offset = 0
# read all data from the channel and unlock it
con.recvBuffer(b, numBytes)
# we received the entire message - return the connection to the global pool
con.disconnect()
# interpret received data
# extract datasetid and number of scenes
# extract datasetid and number of scenes
dataset = struct.unpack_from('> h', b, offset)[0]
offset += 2
if dataset != datasetid:
raise EnvironmentError('Bad Protocol')
numScenes = struct.unpack_from('> i', b, offset)[0]
offset += 4
scenes = []
for _x in range(numScenes):
scenedata = struct.unpack_from('> i h 9b', b, offset)
offset += 15
......@@ -211,8 +211,8 @@ class SpatialIndexMediator:
#print(scenedata)
timestamp = datetime(scenedata[1], scenedata[2], scenedata[3], scenedata[4], scenedata[5], scenedata[6])
# ignore unused scenedata[7]
# ignore unused scenedata[7]
# read bounds
numBounds = scenedata[10]
fmt = "> {0}d".format(numBounds)
......@@ -224,33 +224,33 @@ class SpatialIndexMediator:
if timestamp.month == 2 and timestamp.day == 29:
# deal with feb.29th
timestampInRefYear = timestamp.replace(refDate.year, 3, 1)
else:
else:
timestampInRefYear = timestamp.replace(refDate.year)
if abs(refDate - timestampInRefYear).days > maxDaysDelta:
# skip scene
continue
# create scene
scenes.append(Scene(scenedata[0], timestamp, scenedata[8], scenedata[9], bounds))
return scenes
class Connection:
""" Connection to the spatial index mediator server """
HELLO_MSG = 1
""" message value for a "hello" message """
DISCONNECT_MSG = 6
""" message value for a disconnect message """
def __init__(self, host, port, timeout):
# connect to index mediator server
self.socket = socket.create_connection((host, port), timeout)
# send hello and confirm response
if not self.__greet():
raise EnvironmentError('Bad protocol')
......@@ -259,22 +259,22 @@ class Connection:
def __greet(self):
# send hello byte
self.writeByte(self.HELLO_MSG)
# receive hello byte echo
response = self.recvByte()
return response == self.HELLO_MSG
def writeByte(self, byte):
# send byte
self.socket.sendall(struct.pack('b', byte))
def recvByte(self):
return struct.unpack('b', self.socket.recv(1))[0]
def recvInt(self):
return struct.unpack('>i', self.socket.recv(4))[0]
def recvBuffer(self, buffer, numBytes):
toread = numBytes
view = memoryview(buffer)
......@@ -282,14 +282,14 @@ class Connection:
nbytes = self.socket.recv_into(view, toread)
view = view[nbytes:]
toread -= nbytes
def disconnect(self):
"""
Closes the connection to the index mediator server. No further communication, like placing queries will be possible.
Closes the connection to the index mediator server. No further communication, like placing queries will be possible.
"""
self.writeByte(self.DISCONNECT_MSG)
self.socket.close()
class Scene:
"""Scene Metadata class"""
......
......@@ -48,8 +48,8 @@ from ..algorithms.L2C_P import L2C_object
from ..misc.definition_dicts import proc_chain
from py_tools_ds.ptds.geo.coord_trafo import mapXY2imXY, reproject_shapelyGeometry
from py_tools_ds.ptds.geo.coord_calc import corner_coord_to_minmax
from py_tools_ds.geo.coord_trafo import mapXY2imXY, reproject_shapelyGeometry
from py_tools_ds.geo.coord_calc import corner_coord_to_minmax
......@@ -109,7 +109,7 @@ def sorted_nicely(iterable):
""" Sort the given iterable in the way that humans expect.
:param iterable:
"""
convert = lambda text: int(text) if text.isdigit() else text
convert = lambda text: int(text) if text.isdigit() else text
alphanum_key = lambda key: [ convert(c) for c in re.split('([0-9]+)', key) ]
return sorted(iterable, key = alphanum_key)
......@@ -596,4 +596,4 @@ def subplot_3dsurface(ims,shapetuple=None):
ax.contour(X, Y, Z, zdir='x', cmap=plt.cm.coolwarm, offset=0)
ax.contour(X, Y, Z, zdir='y', cmap=plt.cm.coolwarm, offset=im.shape[1])
ax.set_xlabel('X'); ax.set_ylabel('Y'); ax.set_zlabel('Z')
plt.show()
\ No newline at end of file
plt.show()
......@@ -2,7 +2,7 @@
__author__='Daniel Scheffler'
import shapely
from py_tools_ds.ptds.geo.coord_trafo import reproject_shapelyGeometry
from py_tools_ds.geo.coord_trafo import reproject_shapelyGeometry
from shapely.geometry import Polygon
from ..config import GMS_config as CFG
......
......@@ -33,8 +33,8 @@ from pyorbital import astronomy
try: from osgeo import osr
except ImportError: import osr
from py_tools_ds.ptds.geo.map_info import geotransform2mapinfo
from py_tools_ds.ptds.geo.projection import WKT2EPSG
from py_tools_ds.geo.map_info import geotransform2mapinfo
from py_tools_ds.geo.projection import WKT2EPSG
from geomultisens.config import GMS_config as CFG
from geomultisens.io import envifilehandling as ef
......
......@@ -14,10 +14,10 @@ except ImportError:
from geoarray import GeoArray, NoDataMask, CloudMask
from py_tools_ds.ptds.geo.projection import WKT2EPSG
from py_tools_ds.ptds.geo.coord_calc import calc_FullDataset_corner_positions
from py_tools_ds.ptds.geo.coord_trafo import pixelToLatLon, pixelToMapYX, imXY2mapXY
from py_tools_ds.ptds.geo.map_info import geotransform2mapinfo, mapinfo2geotransform
from py_tools_ds.geo.projection import WKT2EPSG
from py_tools_ds.geo.coord_calc import calc_FullDataset_corner_positions
from py_tools_ds.geo.coord_trafo import pixelToLatLon, pixelToMapYX, imXY2mapXY
from py_tools_ds.geo.map_info import geotransform2mapinfo, mapinfo2geotransform
from ..misc.logging import GMS_logger as DatasetLogger
from ..model.METADATA import METADATA, get_LayerBandsAssignment
......
......@@ -25,10 +25,10 @@ except ImportError:
import gdalnumeric
from geoarray import GeoArray
from py_tools_ds.ptds.geo.coord_grid import is_coord_grid_equal
from py_tools_ds.ptds.geo.map_info import geotransform2mapinfo, mapinfo2geotransform
from py_tools_ds.ptds.geo.coord_calc import calc_FullDataset_corner_positions
from py_tools_ds.ptds.geo.coord_trafo import pixelToLatLon, pixelToMapYX
from py_tools_ds.geo.coord_grid import is_coord_grid_equal
from py_tools_ds.geo.map_info import geotransform2mapinfo, mapinfo2geotransform
from py_tools_ds.geo.coord_calc import calc_FullDataset_corner_positions
from py_tools_ds.geo.coord_trafo import pixelToLatLon, pixelToMapYX
from S2SCAPEM.options import get_options as get_ac_options
from ..misc.logging import GMS_logger as DatasetLogger
......
......@@ -20,7 +20,7 @@ test_requirements = [
setup(
name='geomultisens',
version='0.3.0',
version='0.3.1',
description="GeoMultiSens - Scalable Multi-Sensor Analysis of Remote Sensing Data",
long_description=readme + '\n\n' + history,
author="Daniel Scheffler",
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment