Copernicus dataset render slow

Hello,
I am trying to plot temperature dataset from copernicusmarine. When I run script in jupyter notebook it works fine and I mean when I move de slider the plot update de picture smothly. But when I try to deploy locally with

panel serve panel_app.py --autoreload

when I move the slider it tooks several seconds to update the plot, is very slow.
Here is my simple code:

import panel as pn
import copernicusmarine

@pn.cache
def get_data():
  DS = copernicusmarine.open_dataset(
    dataset_id="cmems_mod_glo_phy-thetao_anfc_0.083deg_P1D-m",
    variables=["thetao"],
    minimum_longitude=-74,
    maximum_longitude=-70,
    minimum_latitude=-26,
    maximum_latitude=-18,
    start_datetime="2023-01-01",
    end_datetime="2023-01-31",
    minimum_depth=0,
    maximum_depth=1,
  )
  return DS

DS = get_data()
plot = DS.thetao.hvplot(
    x='longitude',
    y = 'latitude',
)

pn.extension()

pn.template.MaterialTemplate(
    site="Panel",
    title="Getting Started App",
    main=[plot],
).servable();

output

Can you try profiling your app to see where the bottleneck is?
https://panel.holoviz.org/how_to/profiling/profile.html

1 Like

Hi, thank for reply.
It seems that every time I move the slider, Panel call get_data function.
is there a way to avoid it? I mean call get_data once and store dataset on memory

Maybe use
pn.state.cache["key"] = ... instead of pn.cache