GithubHelp home page GithubHelp logo

psyplot / psy-transect Goto Github PK

View Code? Open in Web Editor NEW
0.0 3.0 0.0 5.97 MB

Visualize and explore transects with psyplot

Home Page: https://psyplot.github.io/psy-transect/

Python 96.03% Makefile 3.97%
data-analysis data-exploration data-science exploratory-data-analysis psyplot transects

psy-transect's Introduction

psy-transect

CI Code coverage Latest Release

Code style: black Imports: isort PEP8 Checked with mypy

Psyplot plugin for visualizing data along a transect for exploratory data analysis

Installation

Install this package in a dedicated python environment via

python -m venv venv
source venv/bin/activate
pip install psy-transect

To use this in a development setup, clone the source code from gitlab, start the development server and make your changes::

git clone https://codebase.helmholtz.cloud/psyplot/psy-transect
cd psy-transect
python -m venv venv
source venv/bin/activate
make dev-install

More detailed installation and usage instructions may be found in the docs.

Technical note

This package has been generated from the template https://codebase.helmholtz.cloud/psyplot/psyplot-plugin-template.git.

See the template repository for instructions on how to update the skeleton for this package.

License information

Copyright © 2021-2024 Helmholtz-Zentrum hereon GmbH

Code files in this repository are licensed under the LGPL-3.0-only, if not stated otherwise in the file.

Documentation files in this repository are licensed under CC-BY-4.0, if not stated otherwise in the file.

Supplementary and configuration files in this repository are licensed under CC0-1.0, if not stated otherwise in the file.

Please check the header of the individual files for more detailed information.

License management

License management is handled with reuse. If you have any questions on this, please have a look into the contributing guide or contact the maintainers of psy-transect.

psy-transect's People

Contributors

chilipp avatar

Watchers

 avatar  avatar  avatar

psy-transect's Issues

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'

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!

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.