psyplot / psy-maps

The psyplot plugin for visualizations on a map
https://psyplot.github.io/psy-maps
8 stars 5 forks source link

mapvector: lonlatbox and density don't work together #43

Closed victoria-cherkas closed 2 years ago

victoria-cherkas commented 2 years ago

Code Sample

mapvectors = ds.psy.plot.mapvector(time=0,
                                lonlatbox=[0.,17.,42.,50.],
                                name=[['U', 'V']],
                                density=10, 
                                arrowsize=400, 
                                title='Vector Plot on Regular Grid')

Problem description

I dont seem to be able to get lonlatbox and density to work simultaneously on a vector plot. map_extent does work with density, but not lonlatbox.

Expected Output

Expect lonlatbox to work as usual when specifying arrow density in vectorplot.

Output of psyplot -aV

``` psy_maps.plugin: requirements: cartopy: 0.20.2 version: 1.4.1 psy_reg.plugin: requirements: scipy: 1.8.0 statsmodels: 0.13.2 version: 1.4.0 psy_simple.plugin: version: 1.4.1 psy_transect.plugin: version: 0.0.1.dev0 psyplot: requirements: matplotlib: 3.4.3 numpy: 1.22.3 pandas: 1.4.1 python: 3.9.7 | packaged by conda-forge | (default, Sep 29 2021, 19:20:46) [GCC 9.4.0] xarray: 2022.3.0 version: 1.4.2 psyplot_gui: requirements: pyqt: 5.12.3 qt: 5.12.9 qtconsole: 5.3.0 version: 1.4.0 ```

NOTE

This is a bug report.

Chilipp commented 2 years ago

@victoria-cherkas could you please provide a netcdf file to reproduce this issue?

Chilipp commented 2 years ago

I tried with the test netcdf file in this repo and I think the problem is in the autoscaling of the axes which is the default option for map_extent.

as a workaround, you can set the map_extend value to "data" to stick to the lonlatbox, e.g.

sp = psy.plot.mapvector("test-t2m-u-v.nc", name=[["u", "v"]], density=10, lonlatbox="Europe", map_extent="data")

I need to have a closer look to see if that issue comes from psyplot or cartopy.

Chilipp commented 2 years ago

but just to be sure @victoria-cherkas

what you get is something like

image

and what you expect is something like

image

is this correct?

victoria-cherkas commented 2 years ago

Hi Philipp, Yes exactly that is what I'd expect, as in your images. I will try the map_extent=data as you suggest

victoria-cherkas commented 2 years ago

Your work around works, using map_extent= 'data' and lonlatbox, thanks. Equally I can just use map_extent.