Git Product home page Git Product logo

geocat-viz's Introduction

GeoCAT-viz

GeoCAT-viz contains tools to help plot geoscience data, including convenience and plotting functions that are used to facilitate plotting geosciences data with Matplotlib, Cartopy, and other visualization packages. GeoCAT-viz functionality is used by GeoCAT-examples.

CI GitHub Workflow Status
Docs Documentation Status
Package Conda PyPI
License License
DOI DOI

Documentation

GeoCAT Homepage

GeoCAT-viz Contributor's Guide

GeoCAT-viz Documentation on Read the Docs

Installation instructions

Please see our documentation for installation instructions.

Citing GeoCAT-viz

If you use this software, please cite it as described at the GeoCAT-viz - Citation page.

geocat-viz's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

geocat-viz's Issues

AttributeError

Hi, I have a problem.

Module 'geocat.viz.util' has no attribute 'set_axes_limits_and_ticks'.

I'd appreciate it if you could help me out。

AttributeError

I am having following Traceback while using NCL_corel_1.py code on ubuntu 18 LTE

Traceback (most recent call last):
File "NCL_corel_1.py", line 90, in
gvutil.add_major_minor_ticks(ax, x_minor_per_major=4, y_minor_per_major=5, labelsize=16)
AttributeError: module 'geocat.viz.util' has no attribute 'add_major_minor_ticks'

Can you please help to get out of it.

Regards

Afzaal

Function to plot contour labels manually

Create a utility function that takes in coordinates (in the form of arrays of lon/lat tuples) and plots them as labels on a contour map. All coordinate values will be transformed to match the projection they are plotted on. High and Low contour labels will be plotted with as H/L with pressure value as a subscript. High and Low contour labels will also be plotted as text boxes (rather than CLabel text objects) for increased accuracy in value and location.

Installation issue

I installed geocat-viz on both my Mac and a Linux machine using the following command:

$ conda create -n geocat -c conda-forge -c ncar geocat-viz

When I try and import any of the libraries within geocat-viz (on the Mac or Linux machine) I get a ModuleNotFoundError. For example:

from geocat.viz import util as gvutil
---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
Input In [1], in <cell line: 1>()
----> 1 from geocat.viz import util as gvutil

File ~/miniconda3/envs/geocat/lib/python3.10/site-packages/geocat/viz/__init__.py:1, in <module>
----> 1 from .contourf import *
      2 from .plot_util import *
      3 from .taylor import *

File ~/miniconda3/envs/geocat/lib/python3.10/site-packages/geocat/viz/contourf.py:6, in <module>
      3 import numpy as np
      4 import cartopy.crs as ccrs
----> 6 from src.geocat.viz.plot_util import NCL_Plot
      9 class Contour(NCL_Plot):
     10     """Create contour plot.
     11 
     12     Args
   (...)
     51         A contour plot with specified input style.
     52     """

ModuleNotFoundError: No module named 'src'

Triangulate polygonal meshes

Add support for triangulating unstructured meshes consisting of n-gons where 'n' is greater than 3. This function would facilitate plotting of unstructured meshes such as those employed by MPAS, IKON, and CAM-SE

Add CurlyVectorPlot

On the face of it, something like geocat.viz.plot.CurlyVector() might be able to replicate vcres@vcGlyphStyle = "CurlyVector". matplotlib has a FancyArrowPatch; we just need a function that computes whatever parameters it needs and calls plt.quiver() on the results.

Known Contour Usage Issues

This is just a place to collect issues we find while using the new contourf functionality. Will be updated as needed

  • does not support passing in pre-created fig
  • should make sure kwargs match up with matplotlib defaults
  • improve "unused kwargs" warning

Expand add_major_minor_ticks() to handle nonlinear scales

Currently add_major_minor_ticks() only handles linear scales. We should expand the function's capability to handle a wider range of scales including matplotlib.scale.LogScale, matplotlib.scale.SymmetricalLogScale, and matplotlib.scale.LogitScale.

Fix cb_shrink kwarg NCL_plot

cb_shrink kwarg in NCL_plot does not work correctly. The colorbar shrinks to the same size regardless of what the user inputs.

Cmap already in memory issue

If you rerun a script that loads a colormap, the script fails because the cmap already exists. This requires a kernel restart every iteration of working on a plot and is annoying.

@anissa111 is this what you meant by cmap being broken?

Which GeoCAT tutorial to start with?

I'm a long-time NCL user but have been motivated (several times) to try python. I usually land flat because of mixed functionality in environments and errors set by my institution's proxy in retrieving packages. I tried again, though, with the 'Getting Started' documentation written by the NCAR graphics team under project Pythia. Pythia started slow, which was good, understanding the audience needing to make plots and do data analysis, but it ended before it every said exactly how to start making NCL-quality plots. I've found Pangea, Metpy, and now Geocat. There are three (or four?) different Geocat repositories, with Github and Read.io documentation. Some say to clone the repo with git, some say have the conda package manager do it. All the documentation stops a bit short of a full 'Getting Started' guide like NCL used to have. I assume after I create a new environment (which sometimes fails, sometimes not), and activate it (but not seeing that activation confirmation in the command line prompt) that everything is okay, and I can 'python script-example.py', but errors are thrown.

Do I clone all three (or four), or just one? Where to I post if I run into an error? I started with the Examples, but I get an error saying xarray is not found. Xarray is a very neccessary package, if I'm understanding python correctly. I see the xarray downloaded and unzipped in the .condarc package directory, but can someone state if I should have it somewhere else? Am I missing an environment variable? Or is there another GeoCat repo I should download? After this n-th try of trying python, I'm closing in on getting a Matlab subscription. :( Thank you for your advice and help. I appreciate your vision in trying to make a one-stop shop for environments and plots for earth scientists.

Add subtitle capability to `set_titles_and_lables`

Currently, only a main title can be made with the geocat.viz.util function set_titles_and_labels. The argument maintitle implies that there should be a centered subtitle option, but there is not. The lefttitle and righttitle arguments are not sufficient for adding a subtitle to the NCL_skewt_2_2 example in GeoCAT-examples (shown below). It would be helpful to have built in functionality that creates something similar to the following with an option to change the font size, color, weights, etc of all of the possible titles individually.

Labels were created using the following combination of set_title_and_label and matplotlib functions.

# Use geocat.viz utility functions to add labels
gvutil.set_titles_and_labels(ax=ax,
                             xlabel='Temperature (C)',
                             ylabel='P (hPa)',
                             labelfontsize=14)

# Manually add suptitle and subtitle
fig.suptitle('Raob; [Wind Reports]', fontsize=24, y=0.93)
ax.set_title(subtitle, color='darkgoldenrod', fontweight='bold')

image

Add minor tick customization NCL_plot

Currently NCL_plot does not allow the user to customize the minor ticks in the plot. This feature would be helpful for pressure-height plots that generally should not have minor tick marks on the y-axis.

Documentation Docstring overhaul

Make every viz function doc string link to geocat-examples script that uses it.

Also @anissa111 mentioned a previous docstring overhaul in comp and uxarray. Find relevant PRs and issues to that for guidance. We want consistent docstring formatting across repositories. Several docstrings are rendering weirdly, will fix them all with this overhaul in one push.

CI/CD config needed

To test geocat-viz development against GeoCAT-examples and make sure they work well together, we need a CI/CD workflow in this repo.

interactive colormap editor

Develop an interactive (GUI based) color map editor that could be used within a Jupyter Notebook and would allow interactive selection of various colormap parameters. To be useful such an editor would minimally allow the selection of min and max bounds, but might also allow for the selection of:

  1. colormap
  2. normalization scheme (e.g. linear, log, etc)
  3. opacity values
  4. interactive color editing (this is an advanced feature and may or may not be doable, or beneficial for 2D plotting)

Reduce density for vector plots

A python function that reduces the density of vectors (similar to vcMinDistanceF property in NCL) would be nice. Maybe it would return a dataset with the same dimensions as the original, but with nans in places where we don't want to draw arrows in plt.quiver()?

add_major_minor_ticks() incorrectly places minor ticks on log scales

add_major_minor_ticks() currently misplaces minor ticks on log scales. This was first noticed in the PR for NCL_axes_3.py in GeoCAT-examples when the singular minor tick was being places at 5.5e1 instead of 5e1.

The contrived example below shows the current behavior of this function. For a singular minor tick on a base 10 log scale, it's value should be 5, 50, 500, and so on. For two minor ticks on the same scale, their values should be 3.34, 33.34, 333.34,... and 6.67, 66.67, 666.67,... respectively. This is not the case.
Figure_1

Unpin xarray from v2023.02.0

Checks are failing due to a change in the latest version of xarray. Pinning xarray will solve the issue temporarily so we can release new changes to geocat-viz, but we will need to address the underlying cause at a later date.

Streamlines for triangle meshes

Add support to integrate and display streamlines for data sampled on a triangle mesh. Currently the MPL streamline function only operates on structured grids.

Fix right hand axis ticks

Right hand axis ticks/labels (raxis_ticks) are only used to set limits, not the actual ticks. For example, when raxis_ticks=np.arange(4, 29, 4) for conOncon_1, 4 is set as the lower bound for the y-limit, which is not right. Also, the heights 4, 8, 12... don't show up on the plot.
rha_ticks

Refactor code base

Several functions have import statements within them instead of at the top of the module and their kwarg arguments are in random orders (tick related labels intermixed with title related labels, e.g.)

Plotting MPAS data

MPAS data represents one example of the use of unstructured grids. Plotting data on these grids can sometimes be done effectively with MatPlotLib's tripcolor function, or similar functions that automatically generate triangulated meshes from unstructured data.

However, plotting the MPAS data on the native grid has high value, which requires being able to plot values in "cells" that are non-triangular (hexagonal and pentagonal). The following repository demonstrates how to do this for MPAS atmospheric data in Python:

https://github.com/MiCurry/MPAS-Plotting

There are 3 things about this repository that, I believe, could be improved upon:

  1. It is slow. It constructs a matplotlib.collections.PatchCollection object to represent the unstructured MPAS grid (see get_mpas_patches), and the documentation in the code suggests that this can be very slow. I believe it can probably be sped up with Numba, Cython, or any other number of tools. Maybe even smart uses of NumPy.
  2. It uses basemap, which is old and no longer supported. I believe the example plotting script in the mpas_plot_pressure.py example can be reworked to use Cartopy. (And then it should probably be added as an example to GeoCAT-examples).
  3. It is specific to MPAS, but I think the logic can probably be generalized to any unstructured grid.

I encourage discussion about how to generalize this code, speed it up, and how to modernize it.

CC @NCAR/geocat @NCAR/xdev

problem installing Spyder IDE in geocat environment

I want to install the spyder IDE in my geocat environment. I've had no trouble with my other environments, but for some reason geocat is throwing an incompatibility error.

(base) smcc@Jaguar:/mnt/data/dynamic_data/projects/projects2022/recreational_fishing_GHRSST$ conda info --envs

conda environments:

base * /home/smcc/anaconda3
geo_env /home/smcc/anaconda3/envs/geo_env
geocat /home/smcc/anaconda3/envs/geocat
geocat-examples /home/smcc/anaconda3/envs/geocat-examples
ncl_stable /home/smcc/anaconda3/envs/ncl_stable
pythia_foundations_env /home/smcc/anaconda3/envs/pythia_foundations_env
rces /home/smcc/anaconda3/envs/rces
scientificProject /home/smcc/anaconda3/envs/scientificProject

(geocat) smcc@Jaguar:/mnt/data/dynamic_data/projects/projects2022/recreational_fishing_GHRSST$ conda install spyder

Collecting package metadata (current_repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.
Solving environment: failed with repodata from current_repodata.json, will retry with next repodata source.
Collecting package metadata (repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.
Solving environment: \
Found conflicts! Looking for incompatible packages.
This can take several minutes. Press CTRL-C to abort.
failed

UnsatisfiableError: The following specifications were found to be incompatible with each other:

Output in format: Requested package -> Available versionsThe following specifications were found to be incompatible with your system:

  • feature:/linux-64::__glibc==2.27=0
  • feature:|@/linux-64::__glibc==2.27=0

Your installed version is: 2.27

Any idea how to fix this, please?
Thanks,
Sam

Add issue template

Small template so anyone asking for user support supplies us with adequate information.

Addressing single character color deprecation

matplotlib will no longer be supporting using single character color names (i.e. 'r' instead of 'red'). This change will take effect in two minor releases from now as stated here. This means that we will need to go through all of geocat-viz and make sure that we switch from 'r' to 'red', 'k' to 'black', 'b' to 'blue', etc.

This relates to a similar issue in geocat-examples NCAR/geocat-examples#265

Add support to facilitate locating quivers on triangle meshes

When generating 2D hedgehog (quiver) plots users typically want to locate quiver glyphs on at 2D lattice.
The MPL quiver function operates on a list of 2D vectors specified along with their coordinates. Thus for regular grids it is easy to locate quivers along a lattice simply by locating them at grid nodes. For unstructured data locating the quivers at grid nodes will not result in a regular placement of glyph locations. To support placing quivers at regular intervals the unstructured mesh needs to be sampled at arbitrary locations. This feature request is for a mechanism to sample an MPL triangle mesh such that at regularized list of vectors and their coordinates can be generated and fed into the MPL quiver function.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.