Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rasterize=True flips image #59

Closed
ahuang11 opened this issue Jul 19, 2018 · 8 comments
Closed

rasterize=True flips image #59

ahuang11 opened this issue Jul 19, 2018 · 8 comments

Comments

@ahuang11
Copy link
Collaborator

image

@jbednar
Copy link
Member

jbednar commented Jul 20, 2018

I can reproduce this using holoviews.operation.datashader.rasterize(), so I think it's an issue with rasterize() itself rather than anything in hvplot:

image

It seems to be specific to QuadMesh objects, because the same data doesn't get flipped for Image objects:

image

@jbednar
Copy link
Member

jbednar commented Jul 20, 2018

I've made a possible fix for this problem on holoviews: holoviz/holoviews#2883

@ahuang11, could you try it out and see if it works for you? It definitely fixes it in the example I show above, but I don't know if this is the right fix, i.e., whether it will break some other case.

@ahuang11
Copy link
Collaborator Author

ahuang11 commented Jul 20, 2018

Looks good for this case too. Thanks for the quick support!

(Interestingly, quadmesh without rasterize=True before a fix was also flipped: #23)

image

@ahuang11
Copy link
Collaborator Author

ahuang11 commented Jul 20, 2018

Oh I explored other cases too to see if it broke anything; when I pass in crs=crs.PlateCarree() it crashes, but to use gv.operation.project_image() I need to specify the crs...

import os
import xarray as xr
import holoviews as hv
import geoviews as gv
import hvplot.xarray
hv.extension('bokeh')

os.system(
    'wget -nc '
    'ftp://ftp.cdc.noaa.gov/'
    'Datasets/ncep.reanalysis.dailyavgs/'
    'surface/'
    'air.sig995.2018.nc'
)

obs_ds = xr.open_dataset('air.sig995.2018.nc')
qm = obs_ds.hvplot.quadmesh(x='lon', y='lat', z='air', groupby='time',
                       rasterize=True, crs=crs.PlateCarree(central_longitude=360)))
gv.operation.project_image(qm, projection=ccrs.NorthPolarStereo())

but works if it's an Image

qm = obs_ds.hvplot.image(x='lon', y='lat', z='air', groupby='time',
                         rasterize=True, crs=crs.PlateCarree(central_longitude=360))
gv.operation.project_image(qm, projection=ccrs.NorthPolarStereo()).options(projection=ccrs.NorthPolarStereo())

and also works if I supply a projection...

obs_ds.hvplot.quadmesh(x='lon', y='lat', z='air', groupby='time',
                       crs=crs.PlateCarree(central_longitude=360),
                       projection=ccrs.NorthPolarStereo())

but if I add rasterize=True to the last bit, it gives an empty globe (until I interact by zooming out)

obs_ds.hvplot.quadmesh(x='lon', y='lat', z='air', groupby='time',
                       crs=crs.PlateCarree(central_longitude=360),
                       rasterize=True,
                       projection=ccrs.NorthPolarStereo())

@jbednar
Copy link
Member

jbednar commented Jul 20, 2018

Probably best to let @philippjfr review this, as he knows all the various ways this code can get used, whereas I can see only this specific case. Unfortunately, he may not be able to respond any time soon...

@ahuang11
Copy link
Collaborator Author

Not a problem at all; there's no rush! Thanks for all the help and making these amazing tools!

@philippjfr
Copy link
Member

Should be fixed in holoviz/holoviews#3017

@ahuang11
Copy link
Collaborator Author

ahuang11 commented Nov 7, 2018

Fixed.

@ahuang11 ahuang11 closed this as completed Nov 7, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants