SEAScope package¶
Subpackages¶
- SEAScope.cli package
- SEAScope.cmds package
- Submodules
- SEAScope.cmds.add_collection module
- SEAScope.cmds.add_granule module
- SEAScope.cmds.add_variable module
- SEAScope.cmds.get_catalogues module
- SEAScope.cmds.get_current_datetime module
- SEAScope.cmds.get_data_always_visible_mode module
- SEAScope.cmds.get_extraction module
- SEAScope.cmds.get_nearest_mode module
- SEAScope.cmds.get_rendering module
- SEAScope.cmds.get_timespan module
- SEAScope.cmds.get_timestep module
- SEAScope.cmds.get_variable_identifier module
- SEAScope.cmds.list_timespans module
- SEAScope.cmds.list_timesteps module
- SEAScope.cmds.list_visible_data module
- SEAScope.cmds.look_at module
- SEAScope.cmds.reset_camera module
- SEAScope.cmds.search_granules module
- SEAScope.cmds.select_variable module
- SEAScope.cmds.select_variable_by_label module
- SEAScope.cmds.set_altitude module
- SEAScope.cmds.set_current_datetime module
- SEAScope.cmds.set_data_always_visible_mode module
- SEAScope.cmds.set_nearest_mode module
- SEAScope.cmds.set_rendering module
- SEAScope.cmds.set_timespan module
- SEAScope.cmds.set_timestep module
- SEAScope.cmds.zoom_in module
- SEAScope.cmds.zoom_out module
- Module contents
- SEAScope.lib package
- SEAScope.types package
- Submodules
- SEAScope.types.collection module
- SEAScope.types.collection_id module
- SEAScope.types.color module
- SEAScope.types.data_bucket module
- SEAScope.types.data_info module
- SEAScope.types.extraction module
- SEAScope.types.gcp module
- SEAScope.types.granule_data module
- SEAScope.types.granule_metadata module
- SEAScope.types.idf_descriptor module
- SEAScope.types.renderable_id module
- SEAScope.types.rendering_cfg module
- SEAScope.types.shape module
- SEAScope.types.source module
- SEAScope.types.tag module
- SEAScope.types.timespan module
- SEAScope.types.timestep module
- SEAScope.types.variable module
- Module contents
Submodules¶
SEAScope.upload module¶
This module provides helpers methods to interact with the SEAScope application.
- exception SEAScope.upload.CollectionIdConflict[source]¶
Bases:
ExceptionExecption raised when a collection creation request fails because the collection identifier is already used by a collection registered in SEAScope
- class SEAScope.upload.Throttler[source]¶
Bases:
objectTimer that provides a throttling mechanism.
- property min_delay¶
Minimal delay between two successive calls to
SEAScope.upload.Throttler.apply_delay(), in milliseconds- Type:
int
- SEAScope.upload.altitude(link, altitude)[source]¶
Set the altitude of the camera in SEAScope.
- Parameters:
link (socket.socket) – Stream socket connected to SEAScope
altitude (float) – Distance between the ground and the camera, in meters
- SEAScope.upload.collection(link, _collection)[source]¶
Add a collection to SEAScope catalogue.
- Parameters:
link (socket.socket) – Stream socket connected to SEAScope
_collection (dict) – Dictionary representing the collection
- Raises:
CollectionIdConflict – Raised when the numerical identifier of the collection passed in the
_collectionparameter matches a collection already registered in SEAScope.
Example
>>> import SEAScope.upload >>> import SEAScope.lib.utils >>> coll_id, coll_obj = SEAScope.lib.utils.create_collection('Dummy') >>> print(coll_obj) {'id': {'granuleLevel': False, 'sourceId': 1, 'collectionId': 10, 'granuleId': 0, 'variableId': 0}, 'mustBeCurrent': False, 'xSeamless': False, 'ySeamless': False, 'NEWSAligned': False, 'label': 'Dummy', 'tags': {}, 'variables': [], 'variablesList': {}, 'defaultVariable': 0} >>> # Edit coll_obj to customize the collection >>> # [...] >>> with SEAScope.upload.connect(host, port) as link: >>> SEAScope.upload.collection(link, coll_obj)
- SEAScope.upload.connect(host, port, check_schema_version=False)[source]¶
Create a socket and connect it to the SEAScope application which listens on the provided IP address and port.
- Parameters:
host (str) – IP address of the network interface that the SEAScope application listens to.
port (int) – Port number that the SEAScope application listens to.
- Returns:
a socket connected to SEAScope
- Return type:
socket.socket
Example
>>> import SEAScope.upload >>> with SEAScope.upload.connect('192.168.1.32', 5555) as link: >>> # Pass the link object to other method so that they can communicate >>> # with SEAScope >>> # [...]
- SEAScope.upload.current_datetime(link, dt)[source]¶
Set current datetime in SEAScope.
- Parameters:
link (socket.socket) – Stream socket connected to SEAScope
dt (datetime.datetime) – Value that will be used as current datetime
- SEAScope.upload.get_id_for(link, collection_label, variable_label)[source]¶
Get the internal identifier which corresponds to a (collection, variable) couple using their labels (i.e. the text that describes them in the SEAScope catalogue menu).
- Parameters:
link (socket) – Socket connected to the SEAScope application
collection_label (str) – Label of the collection
variable_label (str) – Label of the variable
- Returns:
Dictionary containing the numerical identifiers associated with the (collection, variable) couple
- Return type:
dict
Example
>>> import SEAScope.upload >>> with SEAScope.upload.connect('127.0.0.1', 11155) as link: >>> result = SEAScope.upload.get_id_for(link, 'ECMWF', >>> 'mean wind field') >>> print(result) {'granule_level': False, 'sourceId': 2, 'collectionId': 2, 'granuleId': 0, 'variableId': 0}
- SEAScope.upload.granule(link, _granule)[source]¶
Add a granule in SEAScope.
- Parameters:
link (socket.socket) – Stream socket connected to SEAScope
_granule (dict) – Dictionary representing the granule
Example
>>> import datetime >>> import SEAScope.upload >>> import SEAScope.lib.utils >>> # Example with 1D data: the GCPs will be the trajectory positions >>> lons = [1, 2, 3, 4, 5] # dummy longitudes for the sake of example >>> lats = [|, 2, 3, 4, 5] # dummy latitudes for the sake of example >>> gcps = [{'lon': lons[i], 'lat': lats[i], 'i': i, 'j': 0} >>> for i in range(0, len(lons))] >>> # Define the time coverage of the granule >>> start = datetime.datetime(2019, 5, 21) >>> stop = datetime.datetime(2019, 5, 22, 14, 18, 56) >>> # Create a collection >>> coll_id, coll_obj = SEAScope.lib.utils.create_collection('My data') >>> # Create the granule object >>> gra_id, gra_obj = SEAScope.lib.utils.create_granule(coll_id, gcps, >>> start, stop) >>> # Associate some data with the granule >>> values = [31, 32, 33, 34, 35] # replace this by actual measurements >>> SEAScope.lib.utils.set_field(gra_obj, 'field_name', values) >>> print(gra_obj) {'id': {'granuleLevel': True, 'sourceId': 1, 'collectionId': 10, 'granuleId': 1000, 'variableId': 0}, 'metadata': {'sourceId': 1, 'collectionId': 10, 'granuleId': 1000, 'dataId': 'user_generated_granule_1000', 'dataModel': 'TIME', 'start': 1558396800000, 'stop': 1558534736000, 'uris': [{'uri': 'Python: user_generated_granule_1000', 'xArity': 5, 'yArity': 2, 'resolution': 1000000000, 'subsampling_factor': 0, 'shape': {'xArity': 5, 'yArity': 1, 'gcps': [{'lon': 1, 'lat': 1, 'i': 0, 'j': 0}, # noqa:E501 {'lon': 2, 'lat': 2, 'i': 1, 'j': 0}, # noqa:E501 {'lon': 3, 'lat': 3, 'i': 2, 'j': 0}, # noqa:E501 {'lon': 4, 'lat': 4, 'i': 3, 'j': 0}, # noqa:E501 {'lon': 5, 'lat': 5, 'i': 4, 'j': 0}]}}], # noqa:E501 'title': 'user_generated_granule_1000', 'institution': '', 'comment': '', 'file_id': 'Python: user_generated_granule_1000', 'product_version': '0.0.0', 'lat_min': 1, 'lat_max': 5, 'lon_min': 1, 'lon_max': 5, 'creator_email': '', 'station_id': '', 'platform': '', 'sensor': ''}, 'data': {'field_name': {'info': {'channels': 1, 'xArity': 5, 'yArity': 2, 'dataType': 'uint8', 'offsets': [31], 'scaleFactors': [0.015748031496062992], 'fillValues': [255]}, 'buffer': [254, 190, 127, 63, 0]}}} >>> # Send everything to SEAScope >>> with SEAScope.upload.connect('127.0.0.1', 11155) as link: >>> # Create the collection first! >>> SEAScope.upload.collection(link, coll_obj) >>> # Then the granule >>> SEAScope.upload.granule(link, gra_obj)
- SEAScope.upload.location(link, lon, lat)[source]¶
Set the location displayed at the center of the screen (the camera’s target) in SEAScope.
- Parameters:
link (socket.socket) – Stream socket connected to SEAScope
lon (float) – Longitude of the location
lat (float) – Latitude of the location
Notes
The values passed to this method for longitudes and latitudes are wrapped automatically to match the domains that SEAScope can handle
- SEAScope.upload.read_response(link, msg_size)[source]¶
Fetch a fixed number of bytes from the socket connected to SEAScope.
- Parameters:
link (socket.socket) – Stream socket connected to SEAScope
msg_size (int) – Number of bytes to fetch from the socket
- Returns:
Raw data sent by SEAScope
- Return type:
listofbytes
- SEAScope.upload.rendering_config(link, rcfg)[source]¶
Update a rendering configuration
- Parameters:
link (socket.socket) – Stream socket connected to SEAScope
rcfg (dict) – Dictionary representing the rendering configuration
Example
>>> import SEAScope.upload >>> rcfg = {'rendered': True, >>> 'logscale': False, >>> 'min': 0.0, >>> 'max': 1.5, >>> 'opacity': 0.7, >>> 'zindex': 0.25, >>> 'color': [0, 0, 0], >>> 'colormap': 'jet', >>> 'renderMethod': 'RASTER', >>> 'filterMode': 'BILINEAR', >>> 'particlesCount': 0, >>> 'particleTTL': 0, >>> 'streamlineLength': 0, >>> 'streamlineSpeed': 0.0, >>> 'target': None} >>> with SEAScope.upload.connect('127.0.0.1', 11155) as link: >>> target = SEAScope.upload.get_id_for(link, 'My collection', >>> 'My variable') >>> # Update target in the rendering configuration dictionary >>> rcfg['target'] = target >>> SEAScope.upload.rendering_config(link, rcfg)
- SEAScope.upload.rendering_config_for(link, target)[source]¶
Get the current rendering configuration for a (collection, variable) couple.
- Parameters:
link (socket.socket) – Stream socket connected to SEAScope
target (dict) – Dictionary which contains the numerical identifiers for the target
- Returns:
Dictionary representing the rendering configuration
- Return type:
dict
Example
>>> import SEASope.upload >>> with SEAScope.upload.connect('127.0.0.1', 11155) as link: >>> target = SEAScope.upload.get_id_for(link, 'AVISO altimetry', >>> 'Mean Dynamic Topography') >>> rcfg = SEAScope.upload.rendering_config_for(link, target) >>> print(rcfg) {'rendered': True, 'logscale': False, 'min': -0.30000001192092896, 'max': 1.5, 'opacity': 0.8999999761581421, 'zindex': 0.22220000624656677, 'color': [0, 0, 0], 'colormap': b'jet', 'renderMethod': 'RASTER', 'filterMode': 'BILINEAR', 'particlesCount': 0, 'particleTTL': 0, 'streamlineLength': 0, 'streamlineSpeed': 0.0, 'target': {'granuleLevel': False, 'sourceId': 2, 'collectionId': 11, 'granuleId': 0, 'variableId': 0}}
- SEAScope.upload.reset_camera(link)[source]¶
Move camera back to its default position.
- Parameters:
link (socket.socket) – Stream socket connected to SEAScope
- SEAScope.upload.select_variable_by_id(link, source_id, collection_id, variable_id, selected, exclusive)[source]¶
Update the variables selection in SEAScope catalogue using numerical values to identify the target variable.
- Parameters:
link (socket.socket) – Stream socket connected to SEAScope
source_id (int) – Numerical identifier for the data source for the collection
collection_id (int) – Numerical identifier for the collection that contains the target variable
variable_id – Numerical identifier for the target variable
selected (bool) – New selection state for the variable (True = selected)
exclusive (bool) – When set to True, this flag tells SEAScope to unselect all the variables that were previously selected (exclusive selection)
- SEAScope.upload.select_variable_by_label(link, collection_label, variable_label, selected, exclusive)[source]¶
Update the variables selection in SEAScope catalogue using numerical values to identify the target variable.
- Parameters:
link (socket.socket) – Stream socket connected to SEAScope
collection_label (str) – Label of the collection that contains the target variable
variable_label (str) – Label of the targt variable
selected (bool) – New selection state for the variable (True = selected)
exclusive (bool) – When set to True, this flag tells SEAScope to unselect all the variables that were previously selected (exclusive selection)
- SEAScope.upload.throttler = <SEAScope.upload.Throttler object>¶
Global throttler object that is shared by all the methods provided in
SEAScope.upload. Use it to set the minimal delay between two API calls if SEAScope is not able to handle the number of requests sent by Python in a short period of time.- Type:
SEAScope.upload.Throttler
- SEAScope.upload.variable(link, _variable)[source]¶
Add a variable to SEAScope catalogue.
- Parameters:
link (socket.socket) – Stream socket connected to SEAScope
_variable (dict) – Dictionary representing the variable
Example
>>> import SEAScope.upload >>> import SEAScope.lib.utils >>> collid, coll_obj = SEAScope.lib.create_collection('My collection') >>> var_obj = SEAScope.lib.create_variable(coll_obj, 'My variable', >>> ['fieldA', 'fieldB']) >>> print(var_obj) {'id': 0, 'label': 'My variable', 'units': '', 'fields': ['fieldA', 'fieldB'], 'defaultRenderingMethod': 'RASTER', 'tags': {}, 'collection': {'granuleLevel': False, 'sourceId': 1, 'collectionId': 10, 'granuleId': 0, 'variableId': 0}, 'rendering': {'rendered': True, 'logscale': False, 'min': 0, 'max': 1, 'opacity': 1.0, 'zindex': 500, 'color': [50, 12, 87], 'colormap': 'grayscale', 'renderMethod': 'RASTER', 'particlesCount': 1000, 'particleTTL': 10, 'streamlineLength': 20, 'streamlineSpeed': 0.0, 'filterMode': 'NEAREST', 'target': {'granuleLevel': False, 'sourceId': 1, 'collectionId': 10, 'granuleId': 0, 'variableId': 0}}} >>> # You can customize the rendering configuration for the created >>> # variable by altering the content of var_obj['rendering'] >>> # [...] >>> with SEAScope.upload.connect('127.0.0.1', 11155) as link: >>> SEAScope.upload.collection(link, coll_obj) >>> SEAScope.upload.variable(link, var_obj)