Ouranosinc / figanos

Outils pour produire des graphiques informatifs sur les impacts des changements climatiques.
Apache License 2.0
1 stars 0 forks source link

Issues with scatter map #237

Closed juliettelavoie closed 3 months ago

juliettelavoie commented 3 months ago

Setup Information

Description

I am having a few issues with scattermap.

  1. vmin, vmax not respected.

~2. Can't use markersize argument.~

Steps To Reproduce

  1. 
    url = 'https://pavics.ouranos.ca//twitcher/ows/proxy/thredds/dodsC/birdhouse/disk2/cccs_portal/indices/Final/BCCAQv2_CMIP6/tx_max/YS/ssp585/ensemble_percentiles/tx_max_ann_BCCAQ2v2+ANUSPLIN300_historical+ssp585_1950-2100_30ymean_percentiles.nc'
    opened = xr.open_dataset(url, decode_timedelta=False)
    ds_space = opened[['tx_max_p50']].isel(time=0).sel(lat=slice(40,65), lon=slice(-90,-55))

fg.gridmap(ds_space,plot_kw={'vmin': 0,'vmax': 25,}) #-> works, max is 25

ds_stat=ds_space.isel(lat=100,lon=100).expand_dims(station=['test']) fg.scattermap(ds_stat,plot_kw={'vmin': 0,'vmax': 25,}) #-> doesn't works, max is 30


~2~ [EDIT]: nevermind this. 

fg.scattermap(ds_stat,plot_kw={'vmin': 0,'vmax': 25,'markersize':10})


TypeError Traceback (most recent call last) Cell In[55], line 9 5 fg.gridmap(ds_space,plot_kw={'vmin': 0,'vmax': 25,}) #-> works, max is 25 8 ds_stat=ds_space.isel(lat=100,lon=100).expand_dims(station=['test']) ----> 9 fg.scattermap(ds_stat,plot_kw={'vmin': 0,'vmax': 25,'markersize':10}) #-> doesn't works, max is 30

File ~/Projets/figanos/src/figanos/matplotlib/plot.py:1729, in scattermap(data, ax, use_attrs, fig_kw, plot_kw, projection, transform, features, geometries_kw, sizes, size_range, cmap, levels, divergent, legend_kw, show_time, frame, enumerate_subplots) 1727 raise ValueError(f"{sizes} not found") 1728 else: -> 1729 raise TypeError("sizes must be a string or a bool") 1731 # nans sizes 1732 smask = ~np.isnan(sdata.values) & mask

TypeError: sizes must be a string or a bool



### Additional context

_No response_

### Contribution

- [X] I would be willing/able to open a Pull Request to address this bug.
juliettelavoie commented 3 months ago

for 1, I dont understand why we use custom_cmap_norm all the time (not what we do in gridmap) ?https://github.com/Ouranosinc/figanos/blob/be727b5c2d7eeefe92961b264c90b7f5a28bc3d9/src/figanos/matplotlib/plot.py#L1754

Is there a way to force the vmax and vmin, not make "make vmin and vmax prettier"

juliettelavoie commented 3 months ago
  1. My bad, I mixed up s and markersize. This is okay.
sarahclaude commented 3 months ago

I think its because of the way we deal with NaNs in scattermap (since they are not dealt with by xarray because of the markers). But we could test if it could be removed for the cmap