forked from JCSDA-internal/eva
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactoring for Hvplot batch plotting (JCSDA-internal#158)
* bokeh batch plot * bokeh components * first pass diag inherit * adding figure handler * bokeh scatter plot * more hvplot changes * adding figure_list to tests * adding in new test for hvplot * python code style * enforcing plotting backend in yamls * requirements * coding norms * Sort out requirements files a bit * emcpy in github requirements * review changes * Revert "review changes" This reverts commit 9214290. * review changes again --------- Co-authored-by: danholdaway <[email protected]>
- Loading branch information
1 parent
3cdabcc
commit 816f162
Showing
68 changed files
with
1,280 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -127,3 +127,7 @@ dmypy.json | |
|
||
# Pyre type checker | ||
.pyre/ | ||
|
||
# Swap files | ||
*.swp | ||
*.swo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Packages in spack stack | ||
setuptools==59.4.0 | ||
pyyaml==6.0 | ||
pycodestyle==2.8.0 | ||
netCDF4==1.5.3 | ||
matplotlib==3.7.1 | ||
cartopy==0.21.1 | ||
scipy==1.9.3 | ||
xarray==2022.3.0 | ||
pandas==1.4.0 | ||
numpy==1.22.3 | ||
|
||
# Not explicitly part of eva but dependcies of eva dependencies already in spack-stack | ||
# versions need to be set to avoid other versions being picked | ||
pyproj==3.1.0 | ||
importlib-metadata==4.8.2 | ||
|
||
# Additional packages | ||
git+https://github.com/NOAA-EMC/emcpy.git@9b6756341e9ae963baa7d3a256b8ada3da688d04#egg=emcpy | ||
scikit-learn | ||
seaborn | ||
hvplot | ||
nbconvert | ||
bokeh | ||
geopandas |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,19 @@ | ||
setuptools>=59.4.0 | ||
pyyaml>=6.0 | ||
pycodestyle>=2.8.0 | ||
netCDF4>=1.5.3 | ||
matplotlib>=3.5.2 | ||
cartopy>=0.20.2 | ||
scikit-learn>=1.0.2 | ||
xarray>=0.11.3 | ||
matplotlib>=3.7.1 | ||
cartopy>=0.21.1 | ||
scipy>=1.9.3 | ||
xarray>=2022.3.0 | ||
pandas>=1.4.0 | ||
numpy>=1.22.3 | ||
|
||
# Additional packages | ||
git+https://github.com/NOAA-EMC/emcpy.git@9b6756341e9ae963baa7d3a256b8ada3da688d04#egg=emcpy | ||
scikit-learn | ||
seaborn | ||
hvplot | ||
nbconvert | ||
bokeh | ||
geopandas |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
setuptools>=59.4.0 | ||
pyyaml>=6.0 | ||
pycodestyle>=2.8.0 | ||
netCDF4>=1.5.3 | ||
matplotlib>=3.7.1 | ||
cartopy>=0.21.1 | ||
scipy>=1.9.3 | ||
xarray>=2022.3.0 | ||
pandas>=1.4.0 | ||
numpy>=1.22.3 | ||
|
||
# Additional packages | ||
git+https://github.com/NOAA-EMC/emcpy.git@9b6756341e9ae963baa7d3a256b8ada3da688d04#egg=emcpy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# (C) Copyright 2023 United States Government as represented by the Administrator of the | ||
# National Aeronautics and Space Administration. All Rights Reserved. | ||
# | ||
# This software is licensed under the terms of the Apache Licence Version 2.0 | ||
# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. | ||
|
||
import os | ||
|
||
repo_directory = os.path.dirname(__file__) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# (C) Copyright 2023 United States Government as represented by the Administrator of the | ||
# National Aeronautics and Space Administration. All Rights Reserved. | ||
# | ||
# This software is licensed under the terms of the Apache Licence Version 2.0 | ||
# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. | ||
|
||
import os | ||
|
||
repo_directory = os.path.dirname(__file__) |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
from eva.eva_path import return_eva_path | ||
from eva.utilities.config import get | ||
from eva.utilities.utils import get_schema, update_object, slice_var_from_str | ||
import os | ||
import numpy as np | ||
|
||
from abc import ABC, abstractmethod | ||
|
||
# -------------------------------------------------------------------------------------------------- | ||
|
||
|
||
class Scatter(ABC): | ||
|
||
"""Base class for creating scatter plots.""" | ||
|
||
def __init__(self, config, logger, dataobj): | ||
|
||
""" | ||
Creates a scatter plot on a map based on the provided configuration. | ||
Args: | ||
config (dict): A dictionary containing the configuration for the scatter plot on a map. | ||
logger (Logger): An instance of the logger for logging messages. | ||
dataobj: An instance of the data object containing input data. | ||
This class initializes and configures a scatter plot on a map based on the provided | ||
configuration. The scatter plot is created using a declarative plotting library from EMCPy | ||
(https://github.com/NOAA-EMC/emcpy). | ||
Example: | ||
:: | ||
config = { | ||
"longitude": {"variable": "collection::group::variable"}, | ||
"latitude": {"variable": "collection::group::variable"}, | ||
"data": {"variable": "collection::group::variable", | ||
"channel": "channel_name"}, | ||
"plot_property": "property_value", | ||
"plot_option": "option_value", | ||
"schema": "path_to_schema_file.yaml" | ||
} | ||
logger = Logger() | ||
map_scatter_plot = MapScatter(config, logger, None) | ||
""" | ||
self.config = config | ||
self.logger = logger | ||
self.dataobj = dataobj | ||
self.xdata = [] | ||
self.ydata = [] | ||
self.plotobj = None | ||
|
||
# -------------------------------------------------------------------------------------------------- | ||
|
||
def data_prep(self): | ||
|
||
# Get the data to plot from the data_collection | ||
# --------------------------------------------- | ||
var0 = self.config['x']['variable'] | ||
var1 = self.config['y']['variable'] | ||
|
||
var0_cgv = var0.split('::') | ||
var1_cgv = var1.split('::') | ||
|
||
if len(var0_cgv) != 3: | ||
self.logger.abort('Scatter: comparison first var \'var0\' does not appear to ' + | ||
'be in the required format of collection::group::variable.') | ||
if len(var1_cgv) != 3: | ||
self.logger.abort('Scatter: comparison first var \'var1\' does not appear to ' + | ||
'be in the required format of collection::group::variable.') | ||
|
||
# Optionally get the channel to plot | ||
channel = None | ||
if 'channel' in self.config: | ||
channel = self.config.get('channel') | ||
|
||
xdata = self.dataobj.get_variable_data(var0_cgv[0], var0_cgv[1], var0_cgv[2], channel) | ||
xdata1 = self.dataobj.get_variable_data(var0_cgv[0], var0_cgv[1], var0_cgv[2]) | ||
ydata = self.dataobj.get_variable_data(var1_cgv[0], var1_cgv[1], var1_cgv[2], channel) | ||
|
||
# see if we need to slice data | ||
xdata = slice_var_from_str(self.config['x'], xdata, self.logger) | ||
ydata = slice_var_from_str(self.config['y'], ydata, self.logger) | ||
|
||
# scatter data should be flattened | ||
xdata = xdata.flatten() | ||
ydata = ydata.flatten() | ||
|
||
# Remove NaN values to enable regression | ||
# -------------------------------------- | ||
mask = ~np.isnan(xdata) | ||
xdata = xdata[mask] | ||
ydata = ydata[mask] | ||
|
||
mask = ~np.isnan(ydata) | ||
self.xdata = xdata[mask] | ||
self.ydata = ydata[mask] | ||
|
||
@abstractmethod | ||
def configure_plot(self): | ||
pass | ||
|
||
# -------------------------------------------------------------------------------------------------- |
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Oops, something went wrong.