Skip to content

Commit

Permalink
grass.jupyter: add authorship and add missing docstrings (OSGeo#4159)
Browse files Browse the repository at this point in the history
  • Loading branch information
29riyasaxena authored Aug 13, 2024
1 parent cb013cc commit d8dd589
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 9 deletions.
15 changes: 15 additions & 0 deletions python/grass/jupyter/baseseriesmap.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
#
# AUTHOR(S): Riya Saxena <29riyasaxena AT gmail>
#
# PURPOSE: This module provides the base class for interactive visualizations
# used by `TimeSeriesMap` and `SeriesMap` in Jupyter Notebooks. It
# includes methods for rendering visualizations and creating interactive
# sliders to navigate through time-series or series data, while reducing
# redundancy and enhancing functionality.
#
# COPYRIGHT: (C) 2024 Riya Saxena, and by the GRASS Development Team
#
# This program is free software under the GNU General Public
# License (>=v2). Read the file COPYING that comes with GRASS
# for details.

"""Base class for SeriesMap and TimeSeriesMap"""

import os
Expand Down
1 change: 1 addition & 0 deletions python/grass/jupyter/interactivemap.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#
# AUTHOR(S): Caitlin Haedrich <caitlin DOT haedrich AT gmail>
# Anna Petrasova <kratochanna AT gmail>
# Riya Saxena <29riyasaxena AT gmail>
#
# PURPOSE: This module contains functions for interactive visualizations
# in Jupyter Notebooks.
Expand Down
3 changes: 2 additions & 1 deletion python/grass/jupyter/seriesmap.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
# MODULE: grass.jupyter.seriesmap
#
# AUTHOR(S): Caitlin Haedrich <caitlin DOT haedrich AT gmail>
# Riya Saxena <29riyasaxena AT gmail>
#
# PURPOSE: This module contains functions for visualizing series of rasters in
# Jupyter Notebooks
#
# COPYRIGHT: (C) 2022 Caitlin Haedrich, and by the GRASS Development Team
# COPYRIGHT: (C) 2022-2024 Caitlin Haedrich, and by the GRASS Development Team
#
# This program is free software under the GNU General Public
# License (>=v2). Read the file COPYING that comes with GRASS
Expand Down
3 changes: 2 additions & 1 deletion python/grass/jupyter/timeseriesmap.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
# MODULE: grass.jupyter.timeseriesmap
#
# AUTHOR(S): Caitlin Haedrich <caitlin DOT haedrich AT gmail>
# Riya Saxena <29riyasaxena AT gmail>
#
# PURPOSE: This module contains functions for visualizing raster and vector
# space-time datasets in Jupyter Notebooks
#
# COPYRIGHT: (C) 2022 Caitlin Haedrich, and by the GRASS Development Team
# COPYRIGHT: (C) 2022-2024 Caitlin Haedrich, and by the GRASS Development Team
#
# This program is free software under the GNU General Public
# License (>=v2). Read the file COPYING that comes with GRASS
Expand Down
24 changes: 17 additions & 7 deletions python/grass/jupyter/utils.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
#
# AUTHOR(S): Caitlin Haedrich <caitlin DOT haedrich AT gmail>
# Riya Saxena <29riyasaxena AT gmail>
#
# PURPOSE: This module contains utility functions for InteractiveMap.
#
# COPYRIGHT: (C) 2021-2022 Caitlin Haedrich, and by the GRASS Development Team
# COPYRIGHT: (C) 2021-2024 Caitlin Haedrich, and by the GRASS Development Team
#
# This program is free software under the GNU General Public
# License (>=v2). Read the file COPYING that comes with GRASS
Expand Down Expand Up @@ -417,8 +418,7 @@ def get_rendering_size(region, width, height, default_width=600, default_height=


def save_vector(name, geo_json):
"""
Saves the user drawn vector.
"""Saves the user drawn vector.
:param geo_json: name of the geojson file to be saved
:param name: name with which vector should be saved
Expand All @@ -435,7 +435,13 @@ def save_vector(name, geo_json):


def get_number_of_cores(requested, env=None):
"""Get the number of cores to use for multiprocessing."""
"""Get the number of cores to use for multiprocessing.
:param int requested: Desired number of cores.
:param dict env: Optional process environment.
:return int: Number of cores to use, constrained by system availability.
"""
nprocs = gs.gisenv(env).get("NPROCS")
if nprocs is not None:
return int(nprocs)
Expand All @@ -448,7 +454,11 @@ def get_number_of_cores(requested, env=None):


def get_region_bounds_latlon():
"""Gets the current computational region bounds in latlon."""
"""Gets the current computational region bounds in latlon.
:return list of tuples: represent the southwest and northeast
corners of the region in (latitude, longitude) format.
"""
region = gs.parse_command("g.region", flags="gbp")
return [
(float(region["ll_s"]), float(region["ll_w"])),
Expand All @@ -459,6 +469,7 @@ def get_region_bounds_latlon():
def update_region(region):
"""Updates the computational region bounds.
:param dict region: region dictionary
:return: the new region
"""
current = gs.region()
Expand All @@ -484,8 +495,7 @@ def save_gif(
text_size=12,
text_color="gray",
):
"""
Creates a GIF animation
"""Creates a GIF animation
param list input_files: list of paths to source
param str output_filename: destination gif filename
Expand Down

0 comments on commit d8dd589

Please sign in to comment.