Skip to content

Commit

Permalink
Merge pull request #91 from IN-CORE/release/1.8.0
Browse files Browse the repository at this point in the history
Release/1.8.0
  • Loading branch information
ywkim312 committed Sep 14, 2022
2 parents dc54f8f + 0da97b1 commit 3b97d42
Show file tree
Hide file tree
Showing 15 changed files with 172 additions and 47 deletions.
52 changes: 52 additions & 0 deletions .github/workflows/pytest.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: PYTEST

on:
push:

env:
MAIN_REPO: IN-CORE/pyincore-viz

jobs:

#-----------------------------------------------------------------------
# UNIT TEST
# ----------------------------------------------------------------------
unit-test:
runs-on: ubuntu-latest
steps:
- name: Checkout source code
uses: actions/checkout@v2

- name: Cache conda
uses: actions/cache@v2
env:
# Increase this value to reset cache if environment.yml has not changed
CACHE_NUMBER: 0
with:
path: ~/conda_pkgs_dir
key:
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-${{
hashFiles('environment.yml') }}

- name: Install miniconda
uses: conda-incubator/setup-miniconda@v2
with:
miniconda-version: "latest"
mamba-version: "*"
use-mamba: true
python-version: 3.8
activate-environment: base
channels: conda-forge,in-core
environment-file: environment.yml
use-only-tar-bz2: true
conda-build-version: "*"

- name: Run pyincore viz tests with pytest
run: |
echo "${{secrets.PYTEST_USER_TOKEN}}" > tests/pyincore_viz/.incorepw
$CONDA/bin/pytest --cache-clear -s tests/pyincore_viz/test_pyincore_viz.py --junitxml=test-reports/viz_results.xml
- name: Run analysis viz tests with pytest
run: |
echo "${{secrets.PYTEST_USER_TOKEN}}" > tests/pyincore_viz/.incorepw
$CONDA/bin/pytest --cache-clear -s tests/pyincore_viz/test_analysis_viz.py --junitxml=test-reports/analysis_results.xml
27 changes: 27 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,25 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

## [1.8.0] - 2022-09-14

### Added
- Missing docstrings in GeoUtil. [#82](https://github.com/IN-CORE/pyincore-viz/issues/82)
- Doc strings to the methods that are missing them. [#82](https://github.com/IN-CORE/pyincore-viz/issues/82)
- Pytest github action. [#16](https://github.com/IN-CORE/pyincore-viz/issues/16)

### Changed
- Deprecated get_standard_x_y method from plotutil. [#62](https://github.com/IN-CORE/pyincore-viz/issues/62)
- Updated ipyleaflet and codes were refactored. [#81](https://github.com/IN-CORE/pyincore-viz/issues/81)

## [1.7.0] - 2022-07-27

### Changed
- Gdf map visualization accepts both dataset and gdf. [#72](https://github.com/IN-CORE/pyincore-viz/issues/72)
- Updated network visualization. [#68](https://github.com/IN-CORE/pyincore-viz/issues/68)

## [1.6.0] - 2022-06-29

### Added
- Household income and poverty visualization to pop result table. [#55](https://github.com/IN-CORE/pyincore-viz/issues/55)
- Raster hazard overlay in gdf map visualization. [#58](https://github.com/IN-CORE/pyincore-viz/issues/58)
Expand All @@ -20,10 +33,12 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- Revised README for pypi publication. [#63](https://github.com/IN-CORE/pyincore-viz/issues/63)

## [1.5.1] - 2022-04-12

### Fixed
- Boolean comparison in adding dislocation dataframe. [#52](https://github.com/IN-CORE/pyincore-viz/issues/52)

## [1.5.0] - 2022-02-07

### Added
- Multiple vector dataset visualization. [#19](https://github.com/IN-CORE/pyincore-viz/issues/19)

Expand All @@ -36,10 +51,12 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- Auto build of documentation container. [#34](https://github.com/IN-CORE/pyincore-viz/issues/34)

## [1.4.1] - 2021-12-08

### Added
- Add *mplcursors* and *palettable* libraries needed for Retrofit notebook example. [#29](https://github.com/IN-CORE/pyincore-viz/issues/29)

## [1.4.0] - 2021-10-27

### Added
- Conda build recipe for publishing the pyincore-data to conda channel. [#7](https://github.com/IN-CORE/pyincore-viz/issues/7)
- Choropleth map using single dataset with multiple field. [#2](https://github.com/IN-CORE/pyincore-viz/issues/2)
Expand All @@ -54,6 +71,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- Bug in getting gdf map from the geoserver. [#14](https://github.com/IN-CORE/pyincore-viz/issues/14)

## [1.3.0] - 2021-07-28

### Added
- pyincore-data reference link to pyincore-viz doc [INCORE1-1299](https://opensource.ncsa.illinois.edu/jira/browse/INCORE1-1299)

Expand All @@ -64,6 +82,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- Changed default map provider to "OpenStreetMaps.Mapnik" from "Stamen.Terrain" to avoid issues loading points that are not on land (bridges). User can configure map provider if needed. [INCORE1-1268](https://opensource.ncsa.illinois.edu/jira/browse/INCORE1-1268)

## [1.2.0] - 2021-06-16

### Added
- Legend for earthquake visualization [INCORE1-1214](https://opensource.ncsa.illinois.edu/jira/browse/INCORE1-1214)
- Ability to plot Raster dataset [INCORE1-1222](https://opensource.ncsa.illinois.edu/jira/browse/INCORE1-1222)
Expand All @@ -75,15 +94,18 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- Combine refactored and legacy fragility plotting into the main function "get_fragility_plot" for backward compatibility [INCORE1-1228](https://opensource.ncsa.illinois.edu/jira/browse/INCORE1-1228)

## [1.1.1] - 2021-05-21

### Added
- Ability to visualize dataset based earthquakes for a specific demand type [INCORE1-1202](https://opensource.ncsa.illinois.edu/jira/browse/INCORE1-1202)

## [1.1.0] - 2021-05-19

### Added
- Geodataframe based heatmap [INCORE1-1128](https://opensource.ncsa.illinois.edu/jira/browse/INCORE1-1128)
- Visualize refactored (equation) based 2d and 3d fragility curves [INCORE1-1144](https://opensource.ncsa.illinois.edu/jira/browse/INCORE1-1144)

## [1.0.0] - 2021-04-14

### Added
- Heatmap for point, line, and polygon dataset [INCORE1-1081](https://opensource.ncsa.illinois.edu/jira/browse/INCORE1-1081)

Expand All @@ -92,17 +114,20 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- pyincore-viz documentation [INCORE1-1103](https://opensource.ncsa.illinois.edu/jira/browse/INCORE1-1103)

## [0.3.0] - 2021-02-15

### Added
- Fit ipyleaflet map boundaries using bounding box [INCORE1-597](https://opensource.ncsa.illinois.edu/jira/browse/INCORE1-597)

### Fixed
- Update demand_types and demand_units when plotting fragility curves [INCORE1-998](https://opensource.ncsa.illinois.edu/jira/browse/INCORE1-998)

## [0.2.5] - 2020-12-10

### Changed
- updated ipyleaflet to 0.13 [INCORE1-866](https://opensource.ncsa.illinois.edu/jira/browse/INCORE1-866)

## [0.2.4] - 2020-10-28

### Added
- Method to plot fragilities [INCORE1-777](https://opensource.ncsa.illinois.edu/jira/browse/INCORE1-777)
- Plot map for table datasets. [INCORE1-821](https://opensource.ncsa.illinois.edu/jira/browse/INCORE1-821)
Expand All @@ -120,12 +145,14 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- cleaning layer when map layer selection changed. [INCORE1-808](https://opensource.ncsa.illinois.edu/jira/browse/INCORE1-808)

## [0.2.3] - 2020-09-03

### Added
- documentation, links, docker script [INCORE1-654](https://opensource.ncsa.illinois.edu/jira/browse/INCORE1-654)
- Network dataset mapping method. [INCORE1-602](https://opensource.ncsa.illinois.edu/jira/browse/INCORE1-602)
- Logger for log reporting. [INCORE1-748](https://opensource.ncsa.illinois.edu/jira/browse/INCORE1-748)

## [0.2.2] - 2020-07-31

### Added
- PEP-8 format test to the library. [INCORE1-706](https://opensource.ncsa.illinois.edu/jira/browse/INCORE1-706)
- wms layer availability checking [INCORE1-609](https://opensource.ncsa.illinois.edu/jira/browse/INCORE1-609)
Expand Down
4 changes: 2 additions & 2 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@
author = 'Yong Wook Kim'

# The short X.Y version
version = '1.7'
version = '1.8'
# The full version, including alpha/beta/rc tags
release = '1.7.0'
release = '1.8.0'

# -- General configuration ---------------------------------------------------

Expand Down
6 changes: 3 additions & 3 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ dependencies:
- contextily>=1.0.0
- deprecated
- geopandas>=0.6.1
- ipyleaflet>=0.13.4,<0.13.7
- ipywidgets>=7.6.0,<8
- ipyleaflet>=0.16.0
- ipywidgets>=7.6.0
- lxml>=4.6.3
- matplotlib>=2.1.0
- networkx>=2.2
Expand All @@ -18,7 +18,7 @@ dependencies:
- pandas>=0.24.1
- pillow
- pycodestyle>=2.6.0
- pyincore>=1.0.0
- pyincore>=1.6.0
- pytest>=3.9.0
- python-jose>=3.0
- rasterio>=1.1.3
6 changes: 6 additions & 0 deletions pyincore_viz/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# Copyright (c) 2019 University of Illinois and others. All rights reserved.
#
# This program and the accompanying materials are made available under the
# terms of the Mozilla Public License v2.0 which accompanies this distribution,
# and is available at https://www.mozilla.org/en-US/MPL/2.0/

from pyincore_viz.plotutil import PlotUtil
from pyincore_viz.geoutil import GeoUtil
from pyincore_viz.tabledatasetlistmap import TableDatasetListMap
Expand Down
78 changes: 53 additions & 25 deletions pyincore_viz/geoutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -457,8 +457,6 @@ def get_wms_map(datasets: list, wms_url=globals.INCORE_GEOSERVER_WMS_URL, layer_
for layer in wms_layers:
m.add_layer(layer)

m.add_control(ipylft.LayersControl())

return m

@staticmethod
Expand Down Expand Up @@ -960,14 +958,17 @@ def get_ipyleaflet_map(bbox=None):
obj: An ipyleaflet map.
"""
map = ipylft.Map(basemap=ipylft.basemaps.Stamen.Toner,
map = ipylft.Map(basemap=ipylft.basemaps.Stamen.Toner, zoom=10,
crs=projections.EPSG3857, scroll_wheel_zoom=True)

if bbox:
if bbox is not None:
# the boundary information should be converted to ipyleaflet code boundary
bounds = GeoUtil.convert_bound_to_ipylft_format(bbox)
map.fit_bounds(bounds)

map.add_control(ipylft.LayersControl(position='topright'))
map.add_control(ipylft.FullScreenControl(position='topright'))

return map

@staticmethod
Expand Down Expand Up @@ -1131,7 +1132,16 @@ def get_ipyleaflet_heatmap(locations=None, radius=10, blur=10, max=1, name=""):
return heatmap

@staticmethod
def plot_multiple_vector_dataset(dataset_list, zoom_level=10):
def plot_multiple_vector_dataset(dataset_list):
"""Plot multiple vector datasets on the same map.
Args:
dataset_list (list): A list of datasets
Returns:
obj: An ipyleaflet map.
"""
geodata_dic_list = []
title_list = []
bbox = None
Expand Down Expand Up @@ -1167,12 +1177,7 @@ def plot_multiple_vector_dataset(dataset_list, zoom_level=10):
except Exception:
raise ValueError("Given dataset might not be a geodataset or has an error in the attribute")

# calculate center point
center_x = ((bbox[2] - bbox[0]) / 2) + bbox[0]
center_y = ((bbox[3] - bbox[1]) / 2) + bbox[1]

out_map = ipylft.Map(center=(center_y, center_x), zoom=zoom_level,
crs=projections.EPSG3857, scroll_wheel_zoom=True)
out_map = GeoUtil.get_ipyleaflet_map(bbox)

for geodata_dic, title in zip(geodata_dic_list, title_list):
# add data to map
Expand All @@ -1190,30 +1195,49 @@ def plot_multiple_vector_dataset(dataset_list, zoom_level=10):

out_map.add_layer(tmp_layer)

out_map.add_control(ipylft.LayersControl(position='topright'))
out_map.add_control(ipylft.FullScreenControl(position='topright'))

return out_map

@staticmethod
def random_color(feature):
"""Creates random color for ipyleaflet map feature
Args:
feature (obj): geodataframe feature
Returns:
obj: dictionary for color
"""
return {
'color': 'black',
'fillColor': random.choice(['red', 'yellow', 'purple', 'green', 'orange', 'blue', 'magenta']),
}

@staticmethod
def plot_choropleth_multiple_fields_from_single_dataset(dataset, field_list, zoom_level=10):
def plot_choropleth_multiple_fields_from_single_dataset(dataset, field_list):
"""Make choropleth map using multiple fields from single dataset.
Args:
dataset (list): A dataset to be mapped
field_list (list): A list of fields in the dataset
Returns:
obj: An ipyleaflet map.
"""
in_gpd = None
center_x = None
center_y = None
bbox = None

# check if the dataset is geodataset and convert dataset to geodataframe
try:
in_gpd = gpd.read_file(dataset.local_file_path)
center_x = in_gpd.bounds.minx.mean()
center_y = in_gpd.bounds.miny.mean()
title = dataset.metadata["title"]
bbox = in_gpd.total_bounds

except Exception:
raise ValueError("Given dataset might not be a geodataset or has an error in the attribute")

Expand All @@ -1222,8 +1246,7 @@ def plot_choropleth_multiple_fields_from_single_dataset(dataset, field_list, zoo
in_gpd_tmp = in_gpd[field_list]
geo_data_dic = json.loads(in_gpd_tmp.to_json())

out_map = ipylft.Map(center=(center_y, center_x), zoom=zoom_level,
crs=projections.EPSG3857, scroll_wheel_zoom=True)
out_map = GeoUtil.get_ipyleaflet_map(bbox)

for fld in field_list:
if fld != 'geometry':
Expand All @@ -1240,13 +1263,22 @@ def plot_choropleth_multiple_fields_from_single_dataset(dataset, field_list, zoo

out_map.add_layer(tmp_layer)

out_map.add_control(ipylft.LayersControl(position='topright'))
out_map.add_control(ipylft.FullScreenControl(position='topright'))

return out_map

@staticmethod
def plot_choropleth_multiple_dataset(dataset_list, field_list, zoom_level=10):
"""Make choropleth map using multiple dataset.
Args:
dataset_list (list): A list of dataset to be mapped
field_list (list): A list of fields in the dataset.
The order of the list should be matched with the order of dataset list
zoom_level (int): Zoom level
Returns:
obj: An ipyleaflet map.
"""
geodata_dic_list = []
choro_data_list = []
title_list = []
Expand Down Expand Up @@ -1296,8 +1328,7 @@ def plot_choropleth_multiple_dataset(dataset_list, field_list, zoom_level=10):
center_x = ((bbox[2] - bbox[0]) / 2) + bbox[0]
center_y = ((bbox[3] - bbox[1]) / 2) + bbox[1]

out_map = ipylft.Map(center=(center_y, center_x), zoom=zoom_level,
crs=projections.EPSG3857, scroll_wheel_zoom=True)
out_map = GeoUtil.get_ipyleaflet_map(bbox)

for geodata_dic, choro_data, title in zip(geodata_dic_list, choro_data_list, title_list):
# add choropleth data to map
Expand All @@ -1312,9 +1343,6 @@ def plot_choropleth_multiple_dataset(dataset_list, field_list, zoom_level=10):

out_map.add_layer(tmp_layer)

out_map.add_control(ipylft.LayersControl(position='topright'))
out_map.add_control(ipylft.FullScreenControl(position='topright'))

return out_map

@staticmethod
Expand Down
2 changes: 1 addition & 1 deletion pyincore_viz/globals.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import logging
from logging import config as logging_config

PACKAGE_VERSION = "1.7.0"
PACKAGE_VERSION = "1.8.0"

INCORE_GEOSERVER_WMS_URL = "https://incore.ncsa.illinois.edu/geoserver/incore/wms"
INCORE_GEOSERVER_DEV_WMS_URL = "https://incore-dev.ncsa.illinois.edu/geoserver/incore/wms"
Expand Down
Loading

0 comments on commit 3b97d42

Please sign in to comment.