Giter VIP home page Giter VIP logo

psy-transect's Introduction

The psyplot interactive visualization framework

CI Code coverage Latest Release PyPI version Code style: black Imports: isort PEP8 REUSE status

Welcome! psyplot is an open source python project that mainly combines the plotting utilities of matplotlib and the data management of the xarray package. The main purpose is to have a framework that allows a fast, attractive, flexible, easily applicable, easily reproducible and especially an interactive visualization of your data.

The ultimate goal is to help scientists and especially climate model developers in their daily work by providing a flexible visualization tool that can be enhanced by their own visualization scripts. psyplot can be used through the python command line and through the psyplot-gui module which provides a graphical user interface for an easier interactive usage.

The package is very new and there are many features that will be included in the future. So we are very pleased for feedback! Please simply raise an issue on GitHub (see also How to contribute in the docs).

You can see the full documentation on psyplot.github.io/psyplot.

Get in touch

Any quesions? Do not hessitate to get in touch with the psyplot developers.

See also the code of conduct, and our contribution guide for more information and a guide about good bug reports.

How to cite psyplot

When using psyplot, you should at least cite the publication in the Journal of Open Source Software:

Journal of Open Source Software

Sommer, P. S.: The psyplot interactive visualization framework, The Journal of Open Source Software, 2, doi:10.21105/joss.00363, https://doi.org/10.21105/joss.00363, 2017.

Furthermore, each release of psyplot and it's subprojects is associated with a DOI using zenodo.org. If you want to cite a specific version or plugin, please refer to the releases page of psyplot or the releases page of the corresponding subproject.

Acknowledgment

This package is being developed by Philipp S. Sommer at the Helmholtz Coastal Data Center (HCDC) of the Helmholtz-Zentrum Hereon.

I want to thank the developers of the matplotlib, xarray and cartopy packages for their great packages and of course the python developers for their fascinating work on this beautiful language.

A special thanks to Stefan Hagemann and Tobias Stacke from the Max-Planck-Institute of Meteorology in Hamburg, Germany for the motivation on this project and to the people of the Not yet visible agency for their advice in designing the logo and webpage.

Finally the author thanks the Swiss National Science Foundation (SNF) for their support. Funding for the author came from the ACACIA grant (CR10I2_146314) and the HORNET grant (200021_169598).

Note

Commits on github prior to version 1.0 were moved into another repository, the psyplot_old repository. This has been done because prior to version 1.0, the github repository contained all the reference figures used for testing which made the size of the repository too large.

Copyright © 2021 Helmholtz-Zentrum Hereon, 2020-2021 Helmholtz-Zentrum Geesthacht, 2016-2021 University of Lausanne

psyplot is released under the GNU LGPL-3.O license. See COPYING and COPYING.LESSER in the root of the repository for full licensing details.

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 3.0 as published by the Free Software Foundation.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU LGPL-3.0 license for more details.

You should have received a copy of the GNU LGPL-3.0 license along with this program. If not, see https://www.gnu.org/licenses/.

psy-transect's People

Contributors

chilipp avatar

Watchers

 avatar  avatar  avatar

psy-transect's Issues

AttributeError: module 'xarray' has no attribute 'ufuncs'

I get this AttributeError in psy_transect/utils.py (line 524), in select_level selection = xr.ufuncs.fabs(coord - level).argmin(dim) when running ds.psy.plot.horizontal_maptransect(...).

I think it is connected to the change Xarray’s ufuncs have been removed, now that they can be replaced by numpy’s ufuncs in all supported versions of numpy. By [Maximilian Roos](https://github.com/max-sixty). in xarray v2022.06.0rc0, see https://docs.xarray.dev/en/stable/whats-new.html.

I hope this can easily be resolved!

Decoder KeyError 'ncells'

Running the following code from icon-vis with the environment file environment.yml:

from pathlib import Path
import matplotlib.pyplot as plt
import numpy as np
import psyplot.project as psy
from psy_transect import utils
import iconarray

iconarray.get_example_data()
data_dir = "data/example_data/nc"
icon_ds = psy.open_dataset(Path(data_dir, "icon_19790101T000000Z.nc"))
orography = psy.open_dataset(Path(data_dir, "icon_19790101T000000Zc.nc")).psy.HHL

new_ds = utils.mesh_to_cf_bounds(orography, "height", "height_2", icon_ds)
new_ds["clon"] = new_ds.clon.copy(data=np.rad2deg(new_ds.clon))                                                                                                                        
new_ds["clat"] = new_ds.clat.copy(data=np.rad2deg(new_ds.clat))                                                                                                                        
new_ds["clon"].attrs["units"] = "degrees_east"                                                                                                                                         
new_ds["clat"].attrs["units"] = "degrees_north"                                                                                                                                        
new_ds["clat_bnds"] = new_ds.clat_bnds.copy(data=np.rad2deg(new_ds.clat_bnds))                                                                                                         
new_ds["clon_bnds"] = new_ds.clon_bnds.copy(data=np.rad2deg(new_ds.clon_bnds))
encodings = {v: var.encoding for v, var in new_ds.variables.items()}                                                                                                                   
attrs = {v: var.attrs for v, var in new_ds.variables.items()}                                                                                                                          
new_ds = new_ds.where(new_ds.HHL.notnull().any("height_2"), drop=True)
for v, enc in encodings.items():                                                                                                                                                       
    new_ds[v].encoding.update(enc)
for v, att in attrs.items():                                                                                                                                                           
    new_ds[v].attrs.update(att)

new_ds.psy.plot.vertical_maptransect(                                                                                                                                                
    name="temp",
    background="0.5",
    transect_resolution=0.1,                                                                                                                                                                    
    cmap="Reds",                                                                                                                                                                       
    decoder={"z": {"HHL"}},                                                                                                                                                            
    clabel="Temperature (K)",
    ylim=(0,6000),
    yticks=np.linspace(0,6000,7),
)

produces the following error:

Traceback (most recent call last):
  File "/scratch/snx3000/alauber/icon-vis/transect/plot_icon_transects.py", line 40, in <module>
    sp = new_ds.psy.plot.vertical_maptransect(
  File "/project/g110/alauber/envs/psyplot-transect/lib/python3.9/site-packages/psyplot/project.py", line 2180, in __call__
    return super(DatasetPlotterInterface, self).__call__(*args, **kwargs)
  File "/project/g110/alauber/envs/psyplot-transect/lib/python3.9/site-packages/psyplot/project.py", line 1983, in __call__
    return self._project_plotter._add_data(
  File "/project/g110/alauber/envs/psyplot-transect/lib/python3.9/site-packages/psyplot/project.py", line 2222, in _add_data
    return super(DatasetPlotter, self)._add_data(plotter_cls, self._ds,
  File "/project/g110/alauber/envs/psyplot-transect/lib/python3.9/site-packages/psyplot/project.py", line 1772, in _add_data
    return self.project._add_data(*args, **kwargs)
  File "/project/g110/alauber/envs/psyplot-transect/lib/python3.9/site-packages/psyplot/project.py", line 180, in wrapper
    return func(self, *args, **kwargs)
  File "/project/g110/alauber/envs/psyplot-transect/lib/python3.9/site-packages/psyplot/project.py", line 801, in _add_data
    plotter_cls(arr, make_plot=(not bool(share) and make_plot),
  File "/project/g110/alauber/envs/psyplot-transect/lib/python3.9/site-packages/psy_transect/plotters.py", line 319, in __init__
    super().__init__(*args, **kwargs)
  File "/project/g110/alauber/envs/psyplot-transect/lib/python3.9/site-packages/psyplot/plotter.py", line 1260, in __init__
    self.initialize_plot(data, ax=ax, draw=draw, clear=clear,
  File "/project/g110/alauber/envs/psyplot-transect/lib/python3.9/site-packages/psyplot/plotter.py", line 1418, in initialize_plot
    self._plot_by_priority(fmto_priority, grouper,
  File "/project/g110/alauber/envs/psyplot-transect/lib/python3.9/site-packages/psyplot/plotter.py", line 1623, in _plot_by_priority
    self._make_plot()
  File "/project/g110/alauber/envs/psyplot-transect/lib/python3.9/site-packages/psyplot/plotter.py", line 2466, in _make_plot
    fmto.make_plot()
  File "/project/g110/alauber/envs/psyplot-transect/lib/python3.9/site-packages/psy_simple/plotters.py", line 3317, in make_plot
    self._plot_funcs[self.value]()
  File "/project/g110/alauber/envs/psyplot-transect/lib/python3.9/site-packages/psy_simple/plotters.py", line 3324, in _pcolormesh
    return self._polycolor()
  File "/project/g110/alauber/envs/psyplot-transect/lib/python3.9/site-packages/psy_simple/plotters.py", line 3407, in _polycolor
    ybounds = self.cell_nodes_y
  File "/project/g110/alauber/envs/psyplot-transect/lib/python3.9/site-packages/psy_simple/plotters.py", line 3740, in cell_nodes_y
    return super(SimplePlot2D, self).cell_nodes_y
  File "/project/g110/alauber/envs/psyplot-transect/lib/python3.9/site-packages/psy_simple/plotters.py", line 3398, in cell_nodes_y
    ybounds = decoder.get_cell_node_coord(
  File "/project/g110/alauber/envs/psyplot-transect/lib/python3.9/site-packages/psyplot/data.py", line 757, in get_cell_node_coord
    bounds = self._get_coord_cell_node_coord(coord, coords, nans,
  File "/project/g110/alauber/envs/psyplot-transect/lib/python3.9/site-packages/psyplot/data.py", line 831, in _get_coord_cell_node_coord
    bounds = bounds.sel(**{
  File "/project/g110/alauber/envs/psyplot-transect/lib/python3.9/site-packages/xarray/core/dataarray.py", line 1549, in sel
    ds = self._to_temp_dataset().sel(
  File "/project/g110/alauber/envs/psyplot-transect/lib/python3.9/site-packages/xarray/core/dataset.py", line 2656, in sel
    result = self.isel(indexers=query_results.dim_indexers, drop=drop)
  File "/project/g110/alauber/envs/psyplot-transect/lib/python3.9/site-packages/xarray/core/dataset.py", line 2496, in isel
    return self._isel_fancy(indexers, drop=drop, missing_dims=missing_dims)
  File "/project/g110/alauber/envs/psyplot-transect/lib/python3.9/site-packages/xarray/core/dataset.py", line 2542, in _isel_fancy
    indexes, index_variables = isel_indexes(self.xindexes, valid_indexers)
  File "/project/g110/alauber/envs/psyplot-transect/lib/python3.9/site-packages/xarray/core/indexes.py", line 1478, in isel_indexes
    return _apply_indexes(indexes, indexers, "isel")
  File "/project/g110/alauber/envs/psyplot-transect/lib/python3.9/site-packages/xarray/core/indexes.py", line 1462, in _apply_indexes
    new_index = getattr(index, func)(index_args)
  File "/project/g110/alauber/envs/psyplot-transect/lib/python3.9/site-packages/xarray/core/indexes.py", line 429, in isel
    indxr = indexers[self.dim]
KeyError: 'ncells'

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.