CMIP6 storage#

with panel, pandas and hvplot

The primary publication of national Earth System Model data at DKRZ takes the largest part of the CMIP Data Pool (CDP). Most of the data have been produced within the national CMIP Project DICAD and in the compute project RZ988.

DKRZ supports modeling groups in all steps of the data wokflow from preparation to publication. In order to track and display the effort for this data workflow, we run automated scripts (cronjobs) which capture the extent of the final product: the disk space usage of these groups in the data pool and update it daily. The resulting statistics are uploaded into a public and freely available swift storage.

In the following, we create responsive bar plots with pandas, pandas and hvplot for statistical Key Performance Indicators of the CDP.

German contribution and publication#

Here we present you statistics of DICAD contributions to the CDP. Datasets which were

  • created as part of DICAD and

  • have been primarily published at the DKRZ ESGF Node

are considered.

The statisctis are computed by grouping the measures by:

  • source_id: Earth System Models (ESM)s which have contributed to the CDP.

  • institution_id: Institutions which have conducted and submitted model simulations to the CDP.

  • publication type: How much data has been published and replicated at DKRZ ESGF node.

[1]:
import warnings
warnings.filterwarnings('ignore')
kpis=["size [TB]", "filenumber","datasets"]
[2]:
import panel as pn
pn.extension("tabulator")
import pandas as pd
sourcesumdf = pd.read_csv("https://swift.dkrz.de/v1/dkrz_a44962e3ba914c309a7421573a6949a6/Pool-Statistics/mistral-cmip6-allocation-by-source.csv.gz").sort_values("size", ascending=False)
allinstdf = pd.read_csv("https://swift.dkrz.de/v1/dkrz_a44962e3ba914c309a7421573a6949a6/Pool-Statistics/mistral-cmip6-allocation-by-dicad-institutes.csv.gz").sort_values("size", ascending=False)
allreplicadf = pd.read_csv("https://swift.dkrz.de/v1/dkrz_a44962e3ba914c309a7421573a6949a6/Pool-Statistics/mistral-cmip6-allocation-by-publicationType.csv.gz").sort_values("size", ascending=False)
[3]:
import intake
from pathlib import Path
import hvplot.pandas
from bokeh.models import NumeralTickFormatter
import pandas as pd
sourcesumdf["Group"]="By source_id"
sourcesumdf["Key"]="source_id"
sourcesumdf["Legend"]=sourcesumdf["source_id"]
allinstdf["Group"]="By institution_id"
allinstdf["Key"]="institution_id"
allinstdf["Legend"]=allinstdf["institution_id"]
allreplicadf["Group"]="By Publication Status"
allreplicadf["Key"]="publicationType"
allreplicadf["Legend"]=allreplicadf["publicationType"]

sourcesumdf=sourcesumdf.set_index("Group")
allinstdf=allinstdf.set_index("Group")
allreplicadf=allreplicadf.set_index("Group")
#
#plotdf=sourcesumrz.append(allinstdf).append(sourcesum).append(allreplica) #.append(expdf)
plotdf=pd.concat([sourcesumdf,allinstdf,allreplicadf])
[4]:
plotdf=plotdf.rename(columns={"size":"size [TB]"})
grouped_df=plotdf.groupby(["Key"])
[5]:
plot_group=grouped_df.get_group("institution_id").sort_values("filenumber", ascending=False)
---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
Cell In[5], line 1
----> 1 plot_group=grouped_df.get_group("institution_id").sort_values("filenumber", ascending=False)

File /builds/data-infrastructure-services/cmip-data-pool/.cache/mamba/envs/datapoolservices/lib/python3.13/site-packages/pandas/core/groupby/groupby.py:885, in BaseGroupBy.get_group(self, name)
    883         name = name[0]
    884     else:
--> 885         raise KeyError(name)
    887 inds = self._get_index(name)
    888 if not len(inds):

KeyError: 'institution_id'
[6]:
plot_group
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
Cell In[6], line 1
----> 1 plot_group

NameError: name 'plot_group' is not defined
[7]:
def create_plot(group, kpi):
    global grouped_df
    plot_group=grouped_df.get_group(group).sort_values(kpi, ascending=False)
    a=plot_group.hvplot.bar(y=kpi,
                         ylabel=f"Sum of {kpi} in the CMIP6 Data Pool",
                         xlabel="Group",
                         by="Legend",
                         stacked=False,
                         #grid=True,
                         yformatter=NumeralTickFormatter(format='0,0'),
                         title="",
                         #  legend="top_left",
                           fontsize={'legend': "10%"},
                          width=650,
                          height=500,
                          muted_alpha=0,
                           fontscale=1.2
                          )
    b=plot_group.hvplot.bar(y=kpi,
                         ylabel="",
                         xlabel="Group",
                         by="Legend",
                         stacked=True,
                         #grid=True,
                         yformatter=NumeralTickFormatter(format='0,0'),
                         title="",
                         legend=False,
                           fontsize={'legend': "10%"},
                          width=150,
                          height=500,
                          muted_alpha=0,
                           fontscale=1.2
                          )
    return a+b
[8]:
interact = pn.interact(create_plot, group=list(grouped_df.groups.keys()), kpi=kpis)
pn.Column(pn.Card(interact[0], title="Plots for different <i>groups and kpis</i>", styles=dict(background='WhiteSmoke')),
          interact[1]
         ).embed()
---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
Cell In[8], line 1
----> 1 interact = pn.interact(create_plot, group=list(grouped_df.groups.keys()), kpi=kpis)
      2 pn.Column(pn.Card(interact[0], title="Plots for different <i>groups and kpis</i>", styles=dict(background='WhiteSmoke')),
      3           interact[1]
      4          ).embed()

File /builds/data-infrastructure-services/cmip-data-pool/.cache/mamba/envs/datapoolservices/lib/python3.13/site-packages/panel/interact.py:347, in _InteractFactory.__call__(self, _InteractFactory__interact_f, **kwargs)
    339     raise ValueError('A function cannot have "throttled" as an argument')
    341 # positional arg support in: https://gist.github.com/8851331
    342 # Handle the cases 1 and 2
    343 # 1. interact(f, **kwargs)
    344 # 2. @interact
    345 #    def f(*args, **kwargs):
    346 #        ...
--> 347 w = self.widget(f)
    348 try:
    349     f.widget = w

File /builds/data-infrastructure-services/cmip-data-pool/.cache/mamba/envs/datapoolservices/lib/python3.13/site-packages/panel/interact.py:270, in _InteractFactory.widget(self, f)
    257 def widget(self, f):
    258     """
    259     Return an interactive function widget for the given function.
    260     The widget is only constructed, not displayed nor attached to
   (...)    268         The function to which the interactive widgets are tied.
    269     """
--> 270     return self.cls(f, self.opts, **self.kwargs)

File /builds/data-infrastructure-services/cmip-data-pool/.cache/mamba/envs/datapoolservices/lib/python3.13/site-packages/panel/interact.py:104, in interactive.__init__(self, object, params, **kwargs)
    102     widgets.append(('manual', Button(name=self.manual_name)))
    103 self._widgets = dict(widgets)
--> 104 pane = self.object(**self.kwargs)
    105 if isinstance(pane, Viewable):
    106     self._pane = pane

Cell In[7], line 3, in create_plot(group, kpi)
      1 def create_plot(group, kpi):
      2     global grouped_df
----> 3     plot_group=grouped_df.get_group(group).sort_values(kpi, ascending=False)
      4     a=plot_group.hvplot.bar(y=kpi,
      5                          ylabel=f"Sum of {kpi} in the CMIP6 Data Pool",
      6                          xlabel="Group",
   (...)     17                            fontscale=1.2
     18                           )
     19     b=plot_group.hvplot.bar(y=kpi,
     20                          ylabel="",
     21                          xlabel="Group",
   (...)     32                            fontscale=1.2
     33                           )

File /builds/data-infrastructure-services/cmip-data-pool/.cache/mamba/envs/datapoolservices/lib/python3.13/site-packages/pandas/core/groupby/groupby.py:885, in BaseGroupBy.get_group(self, name)
    883         name = name[0]
    884     else:
--> 885         raise KeyError(name)
    887 inds = self._get_index(name)
    888 if not len(inds):

KeyError: 'institution_id'

The German contribution to CMIP6 by the five sources of MPI-M and AWI comprises

  • 1.6PB of data primary published at dkrz

  • more than 33% of the CMIP6 data pool

  • 2Mio files or 250 000 datasets

Statistics for different source_id#

The file mistral-cmip6-allocation-by-source.csv.gz contains the results per source with an additional classification by experiment.

* CV link to the registration in the official CMIP6 Controlled Vocabulay where all CMIP6 models had to register.

As soon as CMIP6 data from other ESMs like EMAC-2-53 is available, the lists will be expanded correspondingly.

[9]:
tabsource=pn.widgets.Tabulator(sourcesumdf, height=200)
filenamesource, buttonsource = tabsource.download_menu(
    text_kwargs={'name': 'Enter filename', 'value': 'mistral-cmip6-dicad-sources.csv.csv', 'width':100, 'height':60},
    button_kwargs={'name': 'Download table','width':100, 'height':60}
)
pn.Row(pn.Column(filenamesource,buttonsource),tabsource).embed()
[9]:

Statistics for different institution_ids#

The file mistral-cmip6-allocation-by-dicad-institutes.csv.gz contains statistics grouped by institutes that have contributed to DICAD.

[10]:
tabinst=pn.widgets.Tabulator(allinstdf, height=200)
filenameinst, buttoninst = tabinst.download_menu(
    text_kwargs={'name': 'Enter filename', 'value': 'mistral-cmip6-dicad-institutes.csv', 'width':100, 'height':60},
    button_kwargs={'name': 'Download table','width':100, 'height':60}
)
pn.Row(pn.Column(filenameinst, buttoninst),tabinst).embed()
[10]:

Statistics for different publication types#

The file mistral-cmip6-allocation-by-publicationType.csv.gz contains statistics grouped by institutes that have contributed to DICAD

  • published originals: Data which has been published first at the esgf-node at dkrz and is still valid and available.

  • retracted originals: Data which has been published first at the esgf-node at dkrz but has also been retracted afterwards.

  • published replicas: Data which has been copied to and published at dkrz and is still valid and available.

  • retracted replicas: Data which has been copied to and published at dkrz but has also been retracted afterwards.

[11]:
tabrepl=pn.widgets.Tabulator(allreplicadf, height=200)
filenamerepl, buttonrepl = tabrepl.download_menu(
    text_kwargs={'name': 'Enter filename', 'value': 'mistral-cmip6-replica.csv.csv', 'width':100, 'height':60},
    button_kwargs={'name': 'Download table','width':100, 'height':60}
)
pn.Row(pn.Column(filenamerepl, buttonrepl),tabrepl).embed()
[11]:
[12]:
timeseries=pd.read_csv("https://swift.dkrz.de/v1/dkrz_a44962e3ba914c309a7421573a6949a6/Pool-Statistics/mistral-cmip6-allocation-timeseries.csv.gz",
                       parse_dates=True,
                       index_col=0
                        )
tmplot= timeseries.hvplot.line(y=["Disk Allocation [GB]", "Number of Datasets", "Number of Files"],
                               shared_axes=False,
                               yformatter=NumeralTickFormatter(format='0,0'),
                               grid=True,
                               width=600,
                               height=500,
                               legend="top_left",
                              ).opts(axiswise=True)
hvplot.save(tmplot,"pool-timeseries-hvplot.html")
[13]:
tmplot
[13]:

Cloud upload#

We use the swiftclient for the upload.

[14]:
#from swiftclient import client
#from swiftenvbk0988 import *
#
#with open("pool-statistics-hvplot.html", 'rb') as f:
#    client.put_object(OS_STORAGE_URL, OS_AUTH_TOKEN, "Pool-Statistics", "pool-statistics-hvplot.html", f)
#with open("pool-timeseries-hvplot.html", 'rb') as f:
#    client.put_object(OS_STORAGE_URL, OS_AUTH_TOKEN, "Pool-Statistics", "pool-timeseries-hvplot.html", f)
[ ]: