portal
The portal module provides interactive visualization tools for exploring Nenya latent spaces and imagery.
Classes
- class nenya.portal.Image(image, Us, DT, lat=None, lon=None)
Class representing an image and its metadata.
- Parameters:
image (numpy.ndarray) – The image data
Us (tuple) – UMAP coordinates (U0, U1)
DT (float) – Temperature difference value
lat (float, optional) – Latitude (optional)
lon (float, optional) – Longitude (optional)
- class nenya.portal.OSSinglePortal(table_file, input_Image=None, init_Us=None)
Main class for the interactive portal.
- Parameters:
- __call__(doc)
Add the portal layout to a Bokeh document.
- Parameters:
doc (bokeh.document.Document) – Bokeh document
- open_files()
Open the HDF5 files containing images.
- load_images(tbl_idx)
Load images from disk based on table indices.
- set_matched(radius)
Find images within radius in UMAP space.
- Parameters:
radius (float) – Radius for matching
- find_closest_U(Us)
Find the index of the closest point in UMAP space.
- set_primary_by_objID(obj_ID)
Set the primary image by object ID.
- Parameters:
obj_ID (int) – Object ID in the table
- reset_from_primary()
Reset the interface based on the primary image.
- get_im_empty()
Get an empty image of the correct size.
- Returns:
Empty image
- Return type:
Example Usage
import os
from nenya.portal import OSSinglePortal, Image
from bokeh.server.server import Server
import numpy as np
# Path to UMAP table
table_file = os.path.join(os.getenv('OS_SST'), 'MODIS_L2', 'Nenya', 'Tables', 'MODIS_Nenya_96clear_v5_DT15.parquet')
# Optional: Create an Image object
img = np.zeros((64, 64)) # Example image
input_Image = Image(img, Us=(0.5, 0.5), DT=2.0, lat=35.0, lon=-120.0)
# Create a session
def get_session(doc):
sess = OSSinglePortal(table_file, input_Image=input_Image)
return sess(doc)
# Start Bokeh server
server = Server({'/': get_session}, num_procs=1)
server.start()
print('Opening Bokeh application on http://localhost:5006/')
server.io_loop.add_callback(server.show, "/")
server.io_loop.start()
Portal Components
The portal interface includes:
Primary Image View: - Displays the current selected image - Shows DT, U0, U1 values - Controls for color mapping
UMAP Plot: - Shows the 2D embedding of all images - Highlights the current image and matches - Color-coded by selected metric (LL, DT, etc.)
Gallery: - Displays multiple images from matched set - Navigation controls for viewing more matches
Data Table: - Shows metadata for matched images - Allows selection for setting primary image
Geographic View: - Map showing geographic locations - Points colored by the same metric as UMAP
Technical Details
The portal uses:
Bokeh for interactive visualization
HDF5 for efficient image access
Pandas for table manipulation
NumPy for numerical operations
Data Organization:
Images are stored in HDF5 files referenced by the table
The table contains metadata and UMAP coordinates
Images are loaded on-demand to minimize memory usage
Customization:
Color schemes can be adjusted
Matching radius and transparency are configurable
Metrics for coloring can be selected through the UI