cmip6_catalog_builder.ipynb 46.5 KB
Newer Older
Anderson Banihirwe's avatar
Anderson Banihirwe committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "import fnmatch\n",
    "import dask.dataframe as dd\n",
    "from intake.source.utils import reverse_format\n",
    "import os\n",
    "import re\n",
    "import subprocess\n",
    "from tqdm.auto import tqdm\n",
    "from pathlib import Path\n",
Anderson Banihirwe's avatar
Anderson Banihirwe committed
18 19
    "import shutil\n",
    "import numpy as np"
Anderson Banihirwe's avatar
Anderson Banihirwe committed
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Create text file containing all files available"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "def get_file_list(persist_path):\n",
Anderson Banihirwe's avatar
Anderson Banihirwe committed
36 37
    "    persist_path = Path(persist_path)\n",
    "    persist_path.mkdir(exist_ok=True)\n",
Anderson Banihirwe's avatar
Anderson Banihirwe committed
38 39 40 41 42 43 44 45 46 47 48 49 50 51
    "    root = Path(\"/glade/collections/cmip/CMIP6\")\n",
    "    dirs = [x for x in root.iterdir() if x.is_dir()]\n",
    "    for directory in tqdm(dirs):\n",
    "        print(directory)\n",
    "        stem = directory.stem\n",
    "        f = open(f\"{persist_path}/{stem}.txt\", \"w\")\n",
    "        cmd = [\"find\", \"-L\", directory.as_posix(), \"-name\", \"*.nc\"]\n",
    "        p = subprocess.Popen(cmd, stderr=subprocess.PIPE, stdout=f)\n",
    "        p.wait()\n",
    "        "
   ]
  },
  {
   "cell_type": "code",
Anderson Banihirwe's avatar
Anderson Banihirwe committed
52
   "execution_count": 6,
Anderson Banihirwe's avatar
Anderson Banihirwe committed
53
   "metadata": {},
Anderson Banihirwe's avatar
Anderson Banihirwe committed
54
   "outputs": [],
Anderson Banihirwe's avatar
Anderson Banihirwe committed
55 56
   "source": [
    "persist_path = \"./CMIP6_filelist\"\n",
Anderson Banihirwe's avatar
Anderson Banihirwe committed
57
    "#get_file_list(persist_path)"
Anderson Banihirwe's avatar
Anderson Banihirwe committed
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "\n",
    "## Extract attributes of a file using information from CMI6 DRS.\n",
    "\n",
    "\n",
    "References\n",
    " 1. CMIP6 DRS: http://goo.gl/v1drZl\n",
    " 2. Controlled Vocabularies (CVs) for use in CMIP6:\n",
    "    https://github.com/WCRP-CMIP/CMIP6_CVs\n",
    "    \n",
    "    \n",
    "Directory structure =\n",
    "```<mip_era>/\n",
    "    <activity_id>/\n",
    "        <institution_id>/\n",
    "            <source_id>/\n",
    "                <experiment_id>/\n",
    "                    <member_id>/\n",
    "                        <table_id>/\n",
    "                            <variable_id>/\n",
    "                                <grid_label>/\n",
    "                                    <version>\n",
    "```\n",
    "file name =\n",
    "```<variable_id>_<table_id>_<source_id>_<experiment_id >_<member_id>_<grid_label>[_<time_range>].nc```\n",
    "For time-invariant fields, the last segment (time_range) above is omitted.\n",
    "Example when there is no sub-experiment: `tas_Amon_GFDL-CM4_historical_r1i1p1f1_gn_196001-199912.nc`\n",
    "Example with a sub-experiment:   `pr_day_CNRM-CM6-1_dcppA-hindcast_s1960-r2i1p1f1_gn_198001-198412.nc`\n"
   ]
  },
  {
   "cell_type": "code",
Anderson Banihirwe's avatar
Anderson Banihirwe committed
95
   "execution_count": 7,
Anderson Banihirwe's avatar
Anderson Banihirwe committed
96
   "metadata": {},
97 98 99 100 101 102 103
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['CFMIP',\n",
       " 'CMIP',\n",
       " 'LUMIP',\n",
Anderson Banihirwe's avatar
Anderson Banihirwe committed
104
       " 'C4MIP',\n",
105 106 107 108 109
       " 'LS3MIP',\n",
       " 'OMIP',\n",
       " 'HighResMIP',\n",
       " 'DCPP',\n",
       " 'AerChemMIP',\n",
Anderson Banihirwe's avatar
Anderson Banihirwe committed
110
       " 'PMIP',\n",
Anderson Banihirwe's avatar
Anderson Banihirwe committed
111
       " 'DAMIP',\n",
112 113 114 115
       " 'PAMIP',\n",
       " 'ScenarioMIP']"
      ]
     },
Anderson Banihirwe's avatar
Anderson Banihirwe committed
116
     "execution_count": 7,
117 118 119 120 121 122 123 124 125 126 127 128
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "activity_ids = list(Path(persist_path).rglob(\"*.txt\"))\n",
    "activity_ids = [activity_id.stem for activity_id in activity_ids]\n",
    "activity_ids"
   ]
  },
  {
   "cell_type": "code",
Anderson Banihirwe's avatar
Anderson Banihirwe committed
129
   "execution_count": 8,
130
   "metadata": {},
Anderson Banihirwe's avatar
Anderson Banihirwe committed
131 132
   "outputs": [
    {
Anderson Banihirwe's avatar
Anderson Banihirwe committed
133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>path</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <td>0</td>\n",
       "      <td>/glade/collections/cmip/CMIP6/AerChemMIP/BCC/B...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>1</td>\n",
       "      <td>/glade/collections/cmip/CMIP6/AerChemMIP/BCC/B...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>2</td>\n",
       "      <td>/glade/collections/cmip/CMIP6/AerChemMIP/BCC/B...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>3</td>\n",
       "      <td>/glade/collections/cmip/CMIP6/AerChemMIP/BCC/B...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>4</td>\n",
       "      <td>/glade/collections/cmip/CMIP6/AerChemMIP/BCC/B...</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                                                path\n",
       "0  /glade/collections/cmip/CMIP6/AerChemMIP/BCC/B...\n",
       "1  /glade/collections/cmip/CMIP6/AerChemMIP/BCC/B...\n",
       "2  /glade/collections/cmip/CMIP6/AerChemMIP/BCC/B...\n",
       "3  /glade/collections/cmip/CMIP6/AerChemMIP/BCC/B...\n",
       "4  /glade/collections/cmip/CMIP6/AerChemMIP/BCC/B..."
      ]
     },
Anderson Banihirwe's avatar
Anderson Banihirwe committed
190
     "execution_count": 8,
Anderson Banihirwe's avatar
Anderson Banihirwe committed
191 192
     "metadata": {},
     "output_type": "execute_result"
Anderson Banihirwe's avatar
Anderson Banihirwe committed
193 194 195 196 197 198 199 200
    }
   ],
   "source": [
    "df = dd.read_csv(f\"{persist_path}/*.txt\", header=None).compute()\n",
    "df.columns = [\"path\"]\n",
    "df.head()"
   ]
  },
Anderson Banihirwe's avatar
Anderson Banihirwe committed
201 202 203 204 205 206 207
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "\n",
    "- 10/13/2019: 1,027,617 \n",
    "- 10/15/2019: 1,113,227\n",
Anderson Banihirwe's avatar
Anderson Banihirwe committed
208 209
    "- 10/16/2019: 1,129,214\n",
    "- 10/16/2019: 1,138,743"
Anderson Banihirwe's avatar
Anderson Banihirwe committed
210 211
   ]
  },
Anderson Banihirwe's avatar
Anderson Banihirwe committed
212 213
  {
   "cell_type": "code",
Anderson Banihirwe's avatar
Anderson Banihirwe committed
214
   "execution_count": 10,
Anderson Banihirwe's avatar
Anderson Banihirwe committed
215
   "metadata": {},
Anderson Banihirwe's avatar
Anderson Banihirwe committed
216 217 218 219
   "outputs": [
    {
     "data": {
      "text/plain": [
Anderson Banihirwe's avatar
Anderson Banihirwe committed
220
       "1138743"
Anderson Banihirwe's avatar
Anderson Banihirwe committed
221 222
      ]
     },
Anderson Banihirwe's avatar
Anderson Banihirwe committed
223
     "execution_count": 10,
Anderson Banihirwe's avatar
Anderson Banihirwe committed
224 225 226 227
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
Anderson Banihirwe's avatar
Anderson Banihirwe committed
228 229 230 231 232 233
   "source": [
    "len(df)"
   ]
  },
  {
   "cell_type": "code",
Anderson Banihirwe's avatar
Anderson Banihirwe committed
234
   "execution_count": 11,
Anderson Banihirwe's avatar
Anderson Banihirwe committed
235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281
   "metadata": {},
   "outputs": [],
   "source": [
    "def _reverse_filename_format(file_basename, filename_template=None, gridspec_template=None):\n",
    "    \"\"\"\n",
    "    Uses intake's ``reverse_format`` utility to reverse the string method format.\n",
    "    Given format_string and resolved_string, find arguments\n",
    "    that would give format_string.format(arguments) == resolved_string\n",
    "    \"\"\"\n",
    "    try:\n",
    "        return reverse_format(filename_template, file_basename)\n",
    "    except ValueError:\n",
    "        try:\n",
    "            return reverse_format(gridspec_template, file_basename)\n",
    "        except:\n",
    "            print(\n",
    "                f'Failed to parse file: {file_basename} using patterns: {filename_template} and {gridspec_template}'\n",
    "            )\n",
    "            return {}\n",
    "            \n",
    "def _extract_attr_with_regex(input_str, regex, strip_chars=None):\n",
    "    pattern = re.compile(regex, re.IGNORECASE)\n",
    "    match = re.findall(pattern, input_str)\n",
    "    if match:\n",
    "        match = max(match, key=len)\n",
    "        if strip_chars:\n",
    "            match = match.strip(strip_chars)\n",
    "\n",
    "        else:\n",
    "            match = match.strip()\n",
    "\n",
    "        return match\n",
    "\n",
    "    else:\n",
    "        return None\n",
    "    \n",
    "\n",
    "exclude_patterns = ['*/files/*', '*/latest/*']\n",
    "def _filter_func(path):\n",
    "    return not any(\n",
    "        fnmatch.fnmatch(path, pat=exclude_pattern) for exclude_pattern in exclude_patterns\n",
    "    )\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
Anderson Banihirwe's avatar
Anderson Banihirwe committed
282 283 284 285 286 287 288
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
Anderson Banihirwe's avatar
Anderson Banihirwe committed
289
   "execution_count": 12,
Anderson Banihirwe's avatar
Anderson Banihirwe committed
290
   "metadata": {},
Anderson Banihirwe's avatar
Anderson Banihirwe committed
291 292 293 294 295
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
Anderson Banihirwe's avatar
Anderson Banihirwe committed
296 297
      "CPU times: user 3.72 s, sys: 0 ns, total: 3.72 s\n",
      "Wall time: 3.71 s\n"
Anderson Banihirwe's avatar
Anderson Banihirwe committed
298 299 300
     ]
    }
   ],
Anderson Banihirwe's avatar
Anderson Banihirwe committed
301 302 303 304 305 306 307 308
   "source": [
    "%%time\n",
    "files = df.path.tolist()\n",
    "filelist = list(filter(_filter_func, files))"
   ]
  },
  {
   "cell_type": "code",
Anderson Banihirwe's avatar
Anderson Banihirwe committed
309
   "execution_count": 13,
Anderson Banihirwe's avatar
Anderson Banihirwe committed
310
   "metadata": {},
Anderson Banihirwe's avatar
Anderson Banihirwe committed
311 312 313 314
   "outputs": [
    {
     "data": {
      "text/plain": [
Anderson Banihirwe's avatar
Anderson Banihirwe committed
315
       "722392"
Anderson Banihirwe's avatar
Anderson Banihirwe committed
316 317
      ]
     },
Anderson Banihirwe's avatar
Anderson Banihirwe committed
318
     "execution_count": 13,
Anderson Banihirwe's avatar
Anderson Banihirwe committed
319 320 321 322
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
Anderson Banihirwe's avatar
Anderson Banihirwe committed
323 324 325 326 327 328
   "source": [
    "len(filelist)"
   ]
  },
  {
   "cell_type": "code",
Anderson Banihirwe's avatar
Anderson Banihirwe committed
329
   "execution_count": 14,
Anderson Banihirwe's avatar
Anderson Banihirwe committed
330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363
   "metadata": {},
   "outputs": [],
   "source": [
    "def get_attrs(filepath):\n",
    "    basename = os.path.basename(filepath)\n",
    "    dirname = os.path.dirname(filepath)\n",
    "    filename_template = '{variable_id}_{table_id}_{source_id}_{experiment_id}_{member_id}_{grid_label}_{time_range}.nc'\n",
    "\n",
    "    gridspec_template = (\n",
    "                '{variable_id}_{table_id}_{source_id}_{experiment_id}_{member_id}_{grid_label}.nc'\n",
    "            )\n",
    "    \n",
    "    f = _reverse_filename_format(\n",
    "            basename, filename_template=filename_template, gridspec_template=gridspec_template\n",
    "        )\n",
    "\n",
    "    fileparts = {}\n",
    "    fileparts.update(f)\n",
    "    parent = os.path.dirname(filepath).strip('/')\n",
    "    parent_split = parent.split(f\"/{fileparts['source_id']}/\")\n",
    "    part_1 = parent_split[0].strip('/').split('/')\n",
    "    grid_label = parent.split(f\"/{fileparts['variable_id']}/\")[1].strip('/').split('/')[0]\n",
    "    fileparts['grid_label'] = grid_label\n",
    "    fileparts['activity_id'] = part_1[-2]\n",
    "    fileparts['institution_id'] = part_1[-1]\n",
    "    version_regex = r'v\\d{4}\\d{2}\\d{2}|v\\d{1}'\n",
    "    version = _extract_attr_with_regex(parent, regex=version_regex) or 'v0'\n",
    "    fileparts['version'] = version\n",
    "    fileparts['path'] = filepath\n",
    "    return fileparts "
   ]
  },
  {
   "cell_type": "code",
Anderson Banihirwe's avatar
Anderson Banihirwe committed
364
   "execution_count": 15,
Anderson Banihirwe's avatar
Anderson Banihirwe committed
365
   "metadata": {},
Anderson Banihirwe's avatar
Anderson Banihirwe committed
366 367 368 369 370
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
Anderson Banihirwe's avatar
Anderson Banihirwe committed
371 372
      "CPU times: user 18 s, sys: 851 ms, total: 18.8 s\n",
      "Wall time: 18.8 s\n"
Anderson Banihirwe's avatar
Anderson Banihirwe committed
373 374 375
     ]
    }
   ],
Anderson Banihirwe's avatar
Anderson Banihirwe committed
376 377 378 379 380 381 382
   "source": [
    "%%time\n",
    "entries = list(map(get_attrs, filelist))"
   ]
  },
  {
   "cell_type": "code",
Anderson Banihirwe's avatar
Anderson Banihirwe committed
383
   "execution_count": 16,
Anderson Banihirwe's avatar
Anderson Banihirwe committed
384
   "metadata": {},
Anderson Banihirwe's avatar
Anderson Banihirwe committed
385 386 387 388
   "outputs": [
    {
     "data": {
      "text/plain": [
Anderson Banihirwe's avatar
Anderson Banihirwe committed
389 390
       "{'variable_id': 'pr',\n",
       " 'table_id': 'day',\n",
Anderson Banihirwe's avatar
Anderson Banihirwe committed
391 392 393 394
       " 'source_id': 'BCC-ESM1',\n",
       " 'experiment_id': 'ssp370',\n",
       " 'member_id': 'r2i1p1f1',\n",
       " 'grid_label': 'gn',\n",
Anderson Banihirwe's avatar
Anderson Banihirwe committed
395
       " 'time_range': '20150101-20551231',\n",
Anderson Banihirwe's avatar
Anderson Banihirwe committed
396 397
       " 'activity_id': 'AerChemMIP',\n",
       " 'institution_id': 'BCC',\n",
Anderson Banihirwe's avatar
Anderson Banihirwe committed
398 399
       " 'version': 'v20190702',\n",
       " 'path': '/glade/collections/cmip/CMIP6/AerChemMIP/BCC/BCC-ESM1/ssp370/r2i1p1f1/day/pr/gn/v20190702/pr/pr_day_BCC-ESM1_ssp370_r2i1p1f1_gn_20150101-20551231.nc'}"
Anderson Banihirwe's avatar
Anderson Banihirwe committed
400 401
      ]
     },
Anderson Banihirwe's avatar
Anderson Banihirwe committed
402
     "execution_count": 16,
Anderson Banihirwe's avatar
Anderson Banihirwe committed
403 404 405 406
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
Anderson Banihirwe's avatar
Anderson Banihirwe committed
407 408 409 410 411 412
   "source": [
    "entries[0]"
   ]
  },
  {
   "cell_type": "code",
Anderson Banihirwe's avatar
Anderson Banihirwe committed
413
   "execution_count": 17,
Anderson Banihirwe's avatar
Anderson Banihirwe committed
414
   "metadata": {},
Anderson Banihirwe's avatar
Anderson Banihirwe committed
415 416 417 418
   "outputs": [
    {
     "data": {
      "text/plain": [
Anderson Banihirwe's avatar
Anderson Banihirwe committed
419
       "722392"
Anderson Banihirwe's avatar
Anderson Banihirwe committed
420 421
      ]
     },
Anderson Banihirwe's avatar
Anderson Banihirwe committed
422
     "execution_count": 17,
Anderson Banihirwe's avatar
Anderson Banihirwe committed
423 424 425 426
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
Anderson Banihirwe's avatar
Anderson Banihirwe committed
427 428 429 430 431 432
   "source": [
    "len(entries)"
   ]
  },
  {
   "cell_type": "code",
Anderson Banihirwe's avatar
Anderson Banihirwe committed
433
   "execution_count": 18,
Anderson Banihirwe's avatar
Anderson Banihirwe committed
434
   "metadata": {},
Anderson Banihirwe's avatar
Anderson Banihirwe committed
435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>variable_id</th>\n",
       "      <th>table_id</th>\n",
       "      <th>source_id</th>\n",
       "      <th>experiment_id</th>\n",
       "      <th>member_id</th>\n",
       "      <th>grid_label</th>\n",
       "      <th>time_range</th>\n",
       "      <th>activity_id</th>\n",
       "      <th>institution_id</th>\n",
       "      <th>version</th>\n",
       "      <th>path</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <td>0</td>\n",
Anderson Banihirwe's avatar
Anderson Banihirwe committed
473 474
       "      <td>pr</td>\n",
       "      <td>day</td>\n",
Anderson Banihirwe's avatar
Anderson Banihirwe committed
475 476 477 478
       "      <td>BCC-ESM1</td>\n",
       "      <td>ssp370</td>\n",
       "      <td>r2i1p1f1</td>\n",
       "      <td>gn</td>\n",
Anderson Banihirwe's avatar
Anderson Banihirwe committed
479
       "      <td>20150101-20551231</td>\n",
Anderson Banihirwe's avatar
Anderson Banihirwe committed
480 481
       "      <td>AerChemMIP</td>\n",
       "      <td>BCC</td>\n",
Anderson Banihirwe's avatar
Anderson Banihirwe committed
482
       "      <td>v20190702</td>\n",
Anderson Banihirwe's avatar
Anderson Banihirwe committed
483 484 485 486
       "      <td>/glade/collections/cmip/CMIP6/AerChemMIP/BCC/B...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>1</td>\n",
Anderson Banihirwe's avatar
Anderson Banihirwe committed
487
       "      <td>hfls</td>\n",
Anderson Banihirwe's avatar
Anderson Banihirwe committed
488 489 490 491 492 493 494 495 496 497 498 499 500
       "      <td>Amon</td>\n",
       "      <td>BCC-ESM1</td>\n",
       "      <td>ssp370</td>\n",
       "      <td>r2i1p1f1</td>\n",
       "      <td>gn</td>\n",
       "      <td>201501-205512</td>\n",
       "      <td>AerChemMIP</td>\n",
       "      <td>BCC</td>\n",
       "      <td>v20190624</td>\n",
       "      <td>/glade/collections/cmip/CMIP6/AerChemMIP/BCC/B...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>2</td>\n",
Anderson Banihirwe's avatar
Anderson Banihirwe committed
501
       "      <td>prsn</td>\n",
Anderson Banihirwe's avatar
Anderson Banihirwe committed
502 503 504 505 506 507 508 509 510 511 512 513 514
       "      <td>Amon</td>\n",
       "      <td>BCC-ESM1</td>\n",
       "      <td>ssp370</td>\n",
       "      <td>r2i1p1f1</td>\n",
       "      <td>gn</td>\n",
       "      <td>201501-205512</td>\n",
       "      <td>AerChemMIP</td>\n",
       "      <td>BCC</td>\n",
       "      <td>v20190624</td>\n",
       "      <td>/glade/collections/cmip/CMIP6/AerChemMIP/BCC/B...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>3</td>\n",
Anderson Banihirwe's avatar
Anderson Banihirwe committed
515
       "      <td>va</td>\n",
Anderson Banihirwe's avatar
Anderson Banihirwe committed
516 517 518 519 520 521 522 523 524 525 526 527 528
       "      <td>Amon</td>\n",
       "      <td>BCC-ESM1</td>\n",
       "      <td>ssp370</td>\n",
       "      <td>r2i1p1f1</td>\n",
       "      <td>gn</td>\n",
       "      <td>201501-205512</td>\n",
       "      <td>AerChemMIP</td>\n",
       "      <td>BCC</td>\n",
       "      <td>v20190624</td>\n",
       "      <td>/glade/collections/cmip/CMIP6/AerChemMIP/BCC/B...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>4</td>\n",
Anderson Banihirwe's avatar
Anderson Banihirwe committed
529
       "      <td>tas</td>\n",
Anderson Banihirwe's avatar
Anderson Banihirwe committed
530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546
       "      <td>Amon</td>\n",
       "      <td>BCC-ESM1</td>\n",
       "      <td>ssp370</td>\n",
       "      <td>r2i1p1f1</td>\n",
       "      <td>gn</td>\n",
       "      <td>201501-205512</td>\n",
       "      <td>AerChemMIP</td>\n",
       "      <td>BCC</td>\n",
       "      <td>v20190624</td>\n",
       "      <td>/glade/collections/cmip/CMIP6/AerChemMIP/BCC/B...</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "  variable_id table_id source_id experiment_id member_id grid_label  \\\n",
Anderson Banihirwe's avatar
Anderson Banihirwe committed
547 548 549 550 551
       "0          pr      day  BCC-ESM1        ssp370  r2i1p1f1         gn   \n",
       "1        hfls     Amon  BCC-ESM1        ssp370  r2i1p1f1         gn   \n",
       "2        prsn     Amon  BCC-ESM1        ssp370  r2i1p1f1         gn   \n",
       "3          va     Amon  BCC-ESM1        ssp370  r2i1p1f1         gn   \n",
       "4         tas     Amon  BCC-ESM1        ssp370  r2i1p1f1         gn   \n",
Anderson Banihirwe's avatar
Anderson Banihirwe committed
552
       "\n",
Anderson Banihirwe's avatar
Anderson Banihirwe committed
553 554 555 556 557 558
       "          time_range activity_id institution_id    version  \\\n",
       "0  20150101-20551231  AerChemMIP            BCC  v20190702   \n",
       "1      201501-205512  AerChemMIP            BCC  v20190624   \n",
       "2      201501-205512  AerChemMIP            BCC  v20190624   \n",
       "3      201501-205512  AerChemMIP            BCC  v20190624   \n",
       "4      201501-205512  AerChemMIP            BCC  v20190624   \n",
Anderson Banihirwe's avatar
Anderson Banihirwe committed
559 560 561 562 563 564 565 566 567
       "\n",
       "                                                path  \n",
       "0  /glade/collections/cmip/CMIP6/AerChemMIP/BCC/B...  \n",
       "1  /glade/collections/cmip/CMIP6/AerChemMIP/BCC/B...  \n",
       "2  /glade/collections/cmip/CMIP6/AerChemMIP/BCC/B...  \n",
       "3  /glade/collections/cmip/CMIP6/AerChemMIP/BCC/B...  \n",
       "4  /glade/collections/cmip/CMIP6/AerChemMIP/BCC/B...  "
      ]
     },
Anderson Banihirwe's avatar
Anderson Banihirwe committed
568
     "execution_count": 18,
Anderson Banihirwe's avatar
Anderson Banihirwe committed
569 570 571 572
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
Anderson Banihirwe's avatar
Anderson Banihirwe committed
573
   "source": [
574 575
    "df1 = pd.DataFrame(entries)\n",
    "df1.head()"
Anderson Banihirwe's avatar
Anderson Banihirwe committed
576 577 578 579
   ]
  },
  {
   "cell_type": "code",
Anderson Banihirwe's avatar
Anderson Banihirwe committed
580
   "execution_count": 19,
581 582 583 584 585
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
Anderson Banihirwe's avatar
Anderson Banihirwe committed
586
       "722392"
587 588
      ]
     },
Anderson Banihirwe's avatar
Anderson Banihirwe committed
589
     "execution_count": 19,
590 591 592 593 594 595
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "len(df1)"
596 597 598 599
   ]
  },
  {
   "cell_type": "code",
Anderson Banihirwe's avatar
Anderson Banihirwe committed
600
   "execution_count": 20,
601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>variable_id</th>\n",
       "      <th>table_id</th>\n",
       "      <th>source_id</th>\n",
       "      <th>experiment_id</th>\n",
       "      <th>member_id</th>\n",
       "      <th>grid_label</th>\n",
       "      <th>time_range</th>\n",
       "      <th>activity_id</th>\n",
       "      <th>institution_id</th>\n",
       "      <th>version</th>\n",
       "      <th>path</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
Anderson Banihirwe's avatar
Anderson Banihirwe committed
639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709
       "      <td>583241</td>\n",
       "      <td>basin</td>\n",
       "      <td>Ofx</td>\n",
       "      <td>abrupt-4xCO2</td>\n",
       "      <td>NorESM2-LM</td>\n",
       "      <td>r1i1p1f1</td>\n",
       "      <td>gn</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NCC</td>\n",
       "      <td>NorESM2-LM</td>\n",
       "      <td>v20190815</td>\n",
       "      <td>/glade/collections/cmip/CMIP6/CMIP/NCC/NorESM2...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>583243</td>\n",
       "      <td>deptho</td>\n",
       "      <td>Ofx</td>\n",
       "      <td>abrupt-4xCO2</td>\n",
       "      <td>NorESM2-LM</td>\n",
       "      <td>r1i1p1f1</td>\n",
       "      <td>gn</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NCC</td>\n",
       "      <td>NorESM2-LM</td>\n",
       "      <td>v20190815</td>\n",
       "      <td>/glade/collections/cmip/CMIP6/CMIP/NCC/NorESM2...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>583244</td>\n",
       "      <td>volcello</td>\n",
       "      <td>Ofx</td>\n",
       "      <td>abrupt-4xCO2</td>\n",
       "      <td>NorESM2-LM</td>\n",
       "      <td>r1i1p1f1</td>\n",
       "      <td>gr</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NCC</td>\n",
       "      <td>NorESM2-LM</td>\n",
       "      <td>v20190815</td>\n",
       "      <td>/glade/collections/cmip/CMIP6/CMIP/NCC/NorESM2...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>583531</td>\n",
       "      <td>deptho</td>\n",
       "      <td>Ofx</td>\n",
       "      <td>historical</td>\n",
       "      <td>NorESM2-LM</td>\n",
       "      <td>r1i1p1f1</td>\n",
       "      <td>gn</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NCC</td>\n",
       "      <td>NorESM2-LM</td>\n",
       "      <td>v20190815</td>\n",
       "      <td>/glade/collections/cmip/CMIP6/CMIP/NCC/NorESM2...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>584584</td>\n",
       "      <td>sftof</td>\n",
       "      <td>Ofx</td>\n",
       "      <td>piControl</td>\n",
       "      <td>NorESM2-LM</td>\n",
       "      <td>r1i1p1f1</td>\n",
       "      <td>gn</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NCC</td>\n",
       "      <td>NorESM2-LM</td>\n",
       "      <td>v20190815</td>\n",
       "      <td>/glade/collections/cmip/CMIP6/CMIP/NCC/NorESM2...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>584587</td>\n",
Anderson Banihirwe's avatar
Anderson Banihirwe committed
710
       "      <td>deptho</td>\n",
711 712 713 714 715 716 717 718 719 720 721 722
       "      <td>Ofx</td>\n",
       "      <td>piControl</td>\n",
       "      <td>NorESM2-LM</td>\n",
       "      <td>r1i1p1f1</td>\n",
       "      <td>gn</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NCC</td>\n",
       "      <td>NorESM2-LM</td>\n",
       "      <td>v20190815</td>\n",
       "      <td>/glade/collections/cmip/CMIP6/CMIP/NCC/NorESM2...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
Anderson Banihirwe's avatar
Anderson Banihirwe committed
723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779
       "      <td>586036</td>\n",
       "      <td>sftof</td>\n",
       "      <td>Ofx</td>\n",
       "      <td>1pctCO2</td>\n",
       "      <td>NorESM2-LM</td>\n",
       "      <td>r1i1p1f1</td>\n",
       "      <td>gn</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NCC</td>\n",
       "      <td>NorESM2-LM</td>\n",
       "      <td>v20190815</td>\n",
       "      <td>/glade/collections/cmip/CMIP6/CMIP/NCC/NorESM2...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>586039</td>\n",
       "      <td>basin</td>\n",
       "      <td>Ofx</td>\n",
       "      <td>1pctCO2</td>\n",
       "      <td>NorESM2-LM</td>\n",
       "      <td>r1i1p1f1</td>\n",
       "      <td>gn</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NCC</td>\n",
       "      <td>NorESM2-LM</td>\n",
       "      <td>v20190815</td>\n",
       "      <td>/glade/collections/cmip/CMIP6/CMIP/NCC/NorESM2...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>586041</td>\n",
       "      <td>deptho</td>\n",
       "      <td>Ofx</td>\n",
       "      <td>1pctCO2</td>\n",
       "      <td>NorESM2-LM</td>\n",
       "      <td>r1i1p1f1</td>\n",
       "      <td>gn</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NCC</td>\n",
       "      <td>NorESM2-LM</td>\n",
       "      <td>v20190815</td>\n",
       "      <td>/glade/collections/cmip/CMIP6/CMIP/NCC/NorESM2...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>586042</td>\n",
       "      <td>volcello</td>\n",
       "      <td>Ofx</td>\n",
       "      <td>1pctCO2</td>\n",
       "      <td>NorESM2-LM</td>\n",
       "      <td>r1i1p1f1</td>\n",
       "      <td>gr</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NCC</td>\n",
       "      <td>NorESM2-LM</td>\n",
       "      <td>v20190815</td>\n",
       "      <td>/glade/collections/cmip/CMIP6/CMIP/NCC/NorESM2...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>586189</td>\n",
780 781 782 783 784 785 786 787 788 789 790 791
       "      <td>thetao</td>\n",
       "      <td>Omon</td>\n",
       "      <td>PCMDI-test-1-0</td>\n",
       "      <td>piControl-withism</td>\n",
       "      <td>r3i1p1f1</td>\n",
       "      <td>gn</td>\n",
       "      <td>016201-016201</td>\n",
       "      <td>v20190926</td>\n",
       "      <td>thetao</td>\n",
       "      <td>v20190926</td>\n",
       "      <td>/glade/collections/cmip/CMIP6/CMIP/FIO-QLNM/FI...</td>\n",
       "    </tr>\n",
Anderson Banihirwe's avatar
Anderson Banihirwe committed
792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847
       "    <tr>\n",
       "      <td>588176</td>\n",
       "      <td>sftof</td>\n",
       "      <td>Ofx</td>\n",
       "      <td>hist-GHG</td>\n",
       "      <td>NorESM2-LM</td>\n",
       "      <td>r1i1p1f1</td>\n",
       "      <td>gn</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NCC</td>\n",
       "      <td>NorESM2-LM</td>\n",
       "      <td>v20190815</td>\n",
       "      <td>/glade/collections/cmip/CMIP6/DAMIP/NCC/NorESM...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>588177</td>\n",
       "      <td>areacello</td>\n",
       "      <td>Ofx</td>\n",
       "      <td>hist-GHG</td>\n",
       "      <td>NorESM2-LM</td>\n",
       "      <td>r1i1p1f1</td>\n",
       "      <td>gn</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NCC</td>\n",
       "      <td>NorESM2-LM</td>\n",
       "      <td>v20190815</td>\n",
       "      <td>/glade/collections/cmip/CMIP6/DAMIP/NCC/NorESM...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>588179</td>\n",
       "      <td>deptho</td>\n",
       "      <td>Ofx</td>\n",
       "      <td>hist-GHG</td>\n",
       "      <td>NorESM2-LM</td>\n",
       "      <td>r1i1p1f1</td>\n",
       "      <td>gn</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NCC</td>\n",
       "      <td>NorESM2-LM</td>\n",
       "      <td>v20190815</td>\n",
       "      <td>/glade/collections/cmip/CMIP6/DAMIP/NCC/NorESM...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>588181</td>\n",
       "      <td>volcello</td>\n",
       "      <td>Ofx</td>\n",
       "      <td>hist-GHG</td>\n",
       "      <td>NorESM2-LM</td>\n",
       "      <td>r1i1p1f1</td>\n",
       "      <td>gr</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NCC</td>\n",
       "      <td>NorESM2-LM</td>\n",
       "      <td>v20190815</td>\n",
       "      <td>/glade/collections/cmip/CMIP6/DAMIP/NCC/NorESM...</td>\n",
       "    </tr>\n",
848 849 850 851 852 853
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "       variable_id table_id       source_id      experiment_id member_id  \\\n",
Anderson Banihirwe's avatar
Anderson Banihirwe committed
854 855 856 857 858 859 860 861 862 863 864 865 866 867 868
       "583241       basin      Ofx    abrupt-4xCO2         NorESM2-LM  r1i1p1f1   \n",
       "583243      deptho      Ofx    abrupt-4xCO2         NorESM2-LM  r1i1p1f1   \n",
       "583244    volcello      Ofx    abrupt-4xCO2         NorESM2-LM  r1i1p1f1   \n",
       "583531      deptho      Ofx      historical         NorESM2-LM  r1i1p1f1   \n",
       "584584       sftof      Ofx       piControl         NorESM2-LM  r1i1p1f1   \n",
       "584587      deptho      Ofx       piControl         NorESM2-LM  r1i1p1f1   \n",
       "586036       sftof      Ofx         1pctCO2         NorESM2-LM  r1i1p1f1   \n",
       "586039       basin      Ofx         1pctCO2         NorESM2-LM  r1i1p1f1   \n",
       "586041      deptho      Ofx         1pctCO2         NorESM2-LM  r1i1p1f1   \n",
       "586042    volcello      Ofx         1pctCO2         NorESM2-LM  r1i1p1f1   \n",
       "586189      thetao     Omon  PCMDI-test-1-0  piControl-withism  r3i1p1f1   \n",
       "588176       sftof      Ofx        hist-GHG         NorESM2-LM  r1i1p1f1   \n",
       "588177   areacello      Ofx        hist-GHG         NorESM2-LM  r1i1p1f1   \n",
       "588179      deptho      Ofx        hist-GHG         NorESM2-LM  r1i1p1f1   \n",
       "588181    volcello      Ofx        hist-GHG         NorESM2-LM  r1i1p1f1   \n",
869 870
       "\n",
       "       grid_label     time_range activity_id institution_id    version  \\\n",
Anderson Banihirwe's avatar
Anderson Banihirwe committed
871 872 873 874 875 876 877 878 879 880 881 882 883 884 885
       "583241         gn            NaN         NCC     NorESM2-LM  v20190815   \n",
       "583243         gn            NaN         NCC     NorESM2-LM  v20190815   \n",
       "583244         gr            NaN         NCC     NorESM2-LM  v20190815   \n",
       "583531         gn            NaN         NCC     NorESM2-LM  v20190815   \n",
       "584584         gn            NaN         NCC     NorESM2-LM  v20190815   \n",
       "584587         gn            NaN         NCC     NorESM2-LM  v20190815   \n",
       "586036         gn            NaN         NCC     NorESM2-LM  v20190815   \n",
       "586039         gn            NaN         NCC     NorESM2-LM  v20190815   \n",
       "586041         gn            NaN         NCC     NorESM2-LM  v20190815   \n",
       "586042         gr            NaN         NCC     NorESM2-LM  v20190815   \n",
       "586189         gn  016201-016201   v20190926         thetao  v20190926   \n",
       "588176         gn            NaN         NCC     NorESM2-LM  v20190815   \n",
       "588177         gn            NaN         NCC     NorESM2-LM  v20190815   \n",
       "588179         gn            NaN         NCC     NorESM2-LM  v20190815   \n",
       "588181         gr            NaN         NCC     NorESM2-LM  v20190815   \n",
886 887
       "\n",
       "                                                     path  \n",
Anderson Banihirwe's avatar
Anderson Banihirwe committed
888 889 890 891 892 893 894 895 896 897 898 899 900 901 902
       "583241  /glade/collections/cmip/CMIP6/CMIP/NCC/NorESM2...  \n",
       "583243  /glade/collections/cmip/CMIP6/CMIP/NCC/NorESM2...  \n",
       "583244  /glade/collections/cmip/CMIP6/CMIP/NCC/NorESM2...  \n",
       "583531  /glade/collections/cmip/CMIP6/CMIP/NCC/NorESM2...  \n",
       "584584  /glade/collections/cmip/CMIP6/CMIP/NCC/NorESM2...  \n",
       "584587  /glade/collections/cmip/CMIP6/CMIP/NCC/NorESM2...  \n",
       "586036  /glade/collections/cmip/CMIP6/CMIP/NCC/NorESM2...  \n",
       "586039  /glade/collections/cmip/CMIP6/CMIP/NCC/NorESM2...  \n",
       "586041  /glade/collections/cmip/CMIP6/CMIP/NCC/NorESM2...  \n",
       "586042  /glade/collections/cmip/CMIP6/CMIP/NCC/NorESM2...  \n",
       "586189  /glade/collections/cmip/CMIP6/CMIP/FIO-QLNM/FI...  \n",
       "588176  /glade/collections/cmip/CMIP6/DAMIP/NCC/NorESM...  \n",
       "588177  /glade/collections/cmip/CMIP6/DAMIP/NCC/NorESM...  \n",
       "588179  /glade/collections/cmip/CMIP6/DAMIP/NCC/NorESM...  \n",
       "588181  /glade/collections/cmip/CMIP6/DAMIP/NCC/NorESM...  "
903 904
      ]
     },
Anderson Banihirwe's avatar
Anderson Banihirwe committed
905
     "execution_count": 20,
906 907 908 909 910
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
911
    "# Some entries are invalid\n",
Anderson Banihirwe's avatar
Anderson Banihirwe committed
912 913
    "invalids = df1[~df1.activity_id.isin(activity_ids)]\n",
    "df = df1[df1.activity_id.isin(activity_ids)]\n",
914 915 916 917 918
    "invalids"
   ]
  },
  {
   "cell_type": "code",
Anderson Banihirwe's avatar
Anderson Banihirwe committed
919
   "execution_count": 24,
Anderson Banihirwe's avatar
Anderson Banihirwe committed
920 921 922 923 924
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
Anderson Banihirwe's avatar
Anderson Banihirwe committed
925 926 927 928 929 930 931 932 933 934 935 936 937 938 939
       "['/glade/collections/cmip/CMIP6/CMIP/NCC/NorESM2-LM/abrupt-4xCO2/r1i1p1f1/Ofx/basin/gn/v20190815/basin/basin_Ofx_abrupt-4xCO2_NorESM2-LM_r1i1p1f1_gn.nc',\n",
       " '/glade/collections/cmip/CMIP6/CMIP/NCC/NorESM2-LM/abrupt-4xCO2/r1i1p1f1/Ofx/deptho/gn/v20190815/deptho/deptho_Ofx_abrupt-4xCO2_NorESM2-LM_r1i1p1f1_gn.nc',\n",
       " '/glade/collections/cmip/CMIP6/CMIP/NCC/NorESM2-LM/abrupt-4xCO2/r1i1p1f1/Ofx/volcello/gr/v20190815/volcello/volcello_Ofx_abrupt-4xCO2_NorESM2-LM_r1i1p1f1_gr.nc',\n",
       " '/glade/collections/cmip/CMIP6/CMIP/NCC/NorESM2-LM/historical/r1i1p1f1/Ofx/deptho/gn/v20190815/deptho/deptho_Ofx_historical_NorESM2-LM_r1i1p1f1_gn.nc',\n",
       " '/glade/collections/cmip/CMIP6/CMIP/NCC/NorESM2-LM/piControl/r1i1p1f1/Ofx/sftof/gn/v20190815/sftof/sftof_Ofx_piControl_NorESM2-LM_r1i1p1f1_gn.nc',\n",
       " '/glade/collections/cmip/CMIP6/CMIP/NCC/NorESM2-LM/piControl/r1i1p1f1/Ofx/deptho/gn/v20190815/deptho/deptho_Ofx_piControl_NorESM2-LM_r1i1p1f1_gn.nc',\n",
       " '/glade/collections/cmip/CMIP6/CMIP/NCC/NorESM2-LM/1pctCO2/r1i1p1f1/Ofx/sftof/gn/v20190815/sftof/sftof_Ofx_1pctCO2_NorESM2-LM_r1i1p1f1_gn.nc',\n",
       " '/glade/collections/cmip/CMIP6/CMIP/NCC/NorESM2-LM/1pctCO2/r1i1p1f1/Ofx/basin/gn/v20190815/basin/basin_Ofx_1pctCO2_NorESM2-LM_r1i1p1f1_gn.nc',\n",
       " '/glade/collections/cmip/CMIP6/CMIP/NCC/NorESM2-LM/1pctCO2/r1i1p1f1/Ofx/deptho/gn/v20190815/deptho/deptho_Ofx_1pctCO2_NorESM2-LM_r1i1p1f1_gn.nc',\n",
       " '/glade/collections/cmip/CMIP6/CMIP/NCC/NorESM2-LM/1pctCO2/r1i1p1f1/Ofx/volcello/gr/v20190815/volcello/volcello_Ofx_1pctCO2_NorESM2-LM_r1i1p1f1_gr.nc',\n",
       " '/glade/collections/cmip/CMIP6/CMIP/FIO-QLNM/FIO-ESM-2-0/piControl/r1i1p1f1/Omon/thetao/gn/v20190926/thetao/thetao_Omon_PCMDI-test-1-0_piControl-withism_r3i1p1f1_gn_016201-016201.nc',\n",
       " '/glade/collections/cmip/CMIP6/DAMIP/NCC/NorESM2-LM/hist-GHG/r1i1p1f1/Ofx/sftof/gn/v20190815/sftof/sftof_Ofx_hist-GHG_NorESM2-LM_r1i1p1f1_gn.nc',\n",
       " '/glade/collections/cmip/CMIP6/DAMIP/NCC/NorESM2-LM/hist-GHG/r1i1p1f1/Ofx/areacello/gn/v20190815/areacello/areacello_Ofx_hist-GHG_NorESM2-LM_r1i1p1f1_gn.nc',\n",
       " '/glade/collections/cmip/CMIP6/DAMIP/NCC/NorESM2-LM/hist-GHG/r1i1p1f1/Ofx/deptho/gn/v20190815/deptho/deptho_Ofx_hist-GHG_NorESM2-LM_r1i1p1f1_gn.nc',\n",
       " '/glade/collections/cmip/CMIP6/DAMIP/NCC/NorESM2-LM/hist-GHG/r1i1p1f1/Ofx/volcello/gr/v20190815/volcello/volcello_Ofx_hist-GHG_NorESM2-LM_r1i1p1f1_gr.nc']"
Anderson Banihirwe's avatar
Anderson Banihirwe committed
940 941
      ]
     },
Anderson Banihirwe's avatar
Anderson Banihirwe committed
942
     "execution_count": 24,
Anderson Banihirwe's avatar
Anderson Banihirwe committed
943 944 945 946 947
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
Anderson Banihirwe's avatar
Anderson Banihirwe committed
948 949
    "invalids.path.tolist()\n",
    "\n",
Anderson Banihirwe's avatar
Anderson Banihirwe committed
950 951 952 953 954
    "## Keep latest version"
   ]
  },
  {
   "cell_type": "code",
Anderson Banihirwe's avatar
Anderson Banihirwe committed
955
   "execution_count": 25,
Anderson Banihirwe's avatar
Anderson Banihirwe committed
956 957 958 959 960 961 962 963 964
   "metadata": {},
   "outputs": [],
   "source": [
    "grpby = list(set(df.columns.tolist()) - {'path', 'version'})\n",
    "groups = df.groupby(grpby)"
   ]
  },
  {
   "cell_type": "code",
Anderson Banihirwe's avatar
Anderson Banihirwe committed
965
   "execution_count": 26,
Anderson Banihirwe's avatar
Anderson Banihirwe committed
966 967 968 969 970 971
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
Anderson Banihirwe's avatar
Anderson Banihirwe committed
972 973
      "CPU times: user 3min 36s, sys: 2.86 s, total: 3min 39s\n",
      "Wall time: 3min 37s\n"
Anderson Banihirwe's avatar
Anderson Banihirwe committed
974 975 976 977 978 979 980 981 982 983 984 985 986
     ]
    }
   ],
   "source": [
    "%%time\n",
    "idx_to_remove = []\n",
    "for _, group in groups:\n",
    "    if group.version.nunique() > 1:\n",
    "        idx_to_remove.extend(group.sort_values(by=['version'], ascending=False).index[1:].values.tolist())"
   ]
  },
  {
   "cell_type": "code",
Anderson Banihirwe's avatar
Anderson Banihirwe committed
987
   "execution_count": 27,
Anderson Banihirwe's avatar
Anderson Banihirwe committed
988 989 990 991 992
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
Anderson Banihirwe's avatar
Anderson Banihirwe committed
993
       "23653"
Anderson Banihirwe's avatar
Anderson Banihirwe committed
994 995
      ]
     },
Anderson Banihirwe's avatar
Anderson Banihirwe committed
996
     "execution_count": 27,
Anderson Banihirwe's avatar
Anderson Banihirwe committed
997 998 999 1000 1001 1002 1003 1004 1005 1006
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "len(idx_to_remove)"
   ]
  },
  {
   "cell_type": "code",
Anderson Banihirwe's avatar
Anderson Banihirwe committed
1007
   "execution_count": 28,
Anderson Banihirwe's avatar
Anderson Banihirwe committed
1008 1009 1010 1011 1012
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
Anderson Banihirwe's avatar
Anderson Banihirwe committed
1013
       "722377"
Anderson Banihirwe's avatar
Anderson Banihirwe committed
1014 1015
      ]
     },
Anderson Banihirwe's avatar
Anderson Banihirwe committed
1016
     "execution_count": 28,
Anderson Banihirwe's avatar
Anderson Banihirwe committed
1017 1018 1019 1020 1021 1022 1023 1024 1025 1026
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "len(df)"
   ]
  },
  {
   "cell_type": "code",
Anderson Banihirwe's avatar
Anderson Banihirwe committed
1027
   "execution_count": 29,
Anderson Banihirwe's avatar
Anderson Banihirwe committed
1028 1029 1030 1031 1032
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
Anderson Banihirwe's avatar
Anderson Banihirwe committed
1033
       "698724"
Anderson Banihirwe's avatar
Anderson Banihirwe committed
1034 1035
      ]
     },
Anderson Banihirwe's avatar
Anderson Banihirwe committed
1036
     "execution_count": 29,
Anderson Banihirwe's avatar
Anderson Banihirwe committed
1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df = df.drop(index=idx_to_remove)\n",
    "len(df)"
   ]
  },
  {
   "cell_type": "code",
Anderson Banihirwe's avatar
Anderson Banihirwe committed
1048
   "execution_count": 30,
Anderson Banihirwe's avatar
Anderson Banihirwe committed
1049
   "metadata": {},
Anderson Banihirwe's avatar
Anderson Banihirwe committed
1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
1072 1073
       "      <th>variable_id</th>\n",
       "      <th>table_id</th>\n",
Anderson Banihirwe's avatar
Anderson Banihirwe committed
1074 1075 1076 1077 1078
       "      <th>source_id</th>\n",
       "      <th>experiment_id</th>\n",
       "      <th>member_id</th>\n",
       "      <th>grid_label</th>\n",
       "      <th>time_range</th>\n",
1079 1080 1081
       "      <th>activity_id</th>\n",
       "      <th>institution_id</th>\n",
       "      <th>version</th>\n",
Anderson Banihirwe's avatar
Anderson Banihirwe committed
1082
       "      <th>path</th>\n",
1083
       "      <th>dcpp_init_year</th>\n",
Anderson Banihirwe's avatar
Anderson Banihirwe committed
1084 1085 1086 1087 1088
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <td>0</td>\n",
Anderson Banihirwe's avatar
Anderson Banihirwe committed
1089 1090
       "      <td>pr</td>\n",
       "      <td>day</td>\n",
Anderson Banihirwe's avatar
Anderson Banihirwe committed
1091 1092 1093 1094
       "      <td>BCC-ESM1</td>\n",
       "      <td>ssp370</td>\n",
       "      <td>r2i1p1f1</td>\n",
       "      <td>gn</td>\n",
Anderson Banihirwe's avatar
Anderson Banihirwe committed
1095
       "      <td>20150101-20551231</td>\n",
1096 1097
       "      <td>AerChemMIP</td>\n",
       "      <td>BCC</td>\n",
Anderson Banihirwe's avatar
Anderson Banihirwe committed
1098
       "      <td>v20190702</td>\n",
Anderson Banihirwe's avatar
Anderson Banihirwe committed
1099
       "      <td>/glade/collections/cmip/CMIP6/AerChemMIP/BCC/B...</td>\n",
1100
       "      <td>NaN</td>\n",
Anderson Banihirwe's avatar
Anderson Banihirwe committed
1101 1102 1103
       "    </tr>\n",
       "    <tr>\n",
       "      <td>1</td>\n",
Anderson Banihirwe's avatar
Anderson Banihirwe committed
1104
       "      <td>hfls</td>\n",
1105
       "      <td>Amon</td>\n",
Anderson Banihirwe's avatar
Anderson Banihirwe committed
1106 1107 1108 1109 1110
       "      <td>BCC-ESM1</td>\n",
       "      <td>ssp370</td>\n",
       "      <td>r2i1p1f1</td>\n",
       "      <td>gn</td>\n",
       "      <td>201501-205512</td>\n",
1111 1112 1113
       "      <td>AerChemMIP</td>\n",
       "      <td>BCC</td>\n",
       "      <td>v20190624</td>\n",
Anderson Banihirwe's avatar
Anderson Banihirwe committed
1114
       "      <td>/glade/collections/cmip/CMIP6/AerChemMIP/BCC/B...</td>\n",
1115
       "      <td>NaN</td>\n",
Anderson Banihirwe's avatar
Anderson Banihirwe committed
1116 1117 1118
       "    </tr>\n",
       "    <tr>\n",
       "      <td>2</td>\n",
Anderson Banihirwe's avatar
Anderson Banihirwe committed
1119
       "      <td>prsn</td>\n",
1120
       "      <td>Amon</td>\n",
Anderson Banihirwe's avatar
Anderson Banihirwe committed
1121 1122 1123 1124 1125
       "      <td>BCC-ESM1</td>\n",
       "      <td>ssp370</td>\n",
       "      <td>r2i1p1f1</td>\n",
       "      <td>gn</td>\n",
       "      <td>201501-205512</td>\n",
1126 1127 1128
       "      <td>AerChemMIP</td>\n",
       "      <td>BCC</td>\n",
       "      <td>v20190624</td>\n",
Anderson Banihirwe's avatar
Anderson Banihirwe committed
1129
       "      <td>/glade/collections/cmip/CMIP6/AerChemMIP/BCC/B...</td>\n",
1130
       "      <td>NaN</td>\n",
Anderson Banihirwe's avatar
Anderson Banihirwe committed
1131 1132 1133
       "    </tr>\n",
       "    <tr>\n",
       "      <td>3</td>\n",
Anderson Banihirwe's avatar
Anderson Banihirwe committed
1134
       "      <td>va</td>\n",
1135
       "      <td>Amon</td>\n",
Anderson Banihirwe's avatar
Anderson Banihirwe committed
1136 1137 1138 1139 1140
       "      <td>BCC-ESM1</td>\n",
       "      <td>ssp370</td>\n",
       "      <td>r2i1p1f1</td>\n",
       "      <td>gn</td>\n",
       "      <td>201501-205512</td>\n",
1141 1142 1143
       "      <td>AerChemMIP</td>\n",
       "      <td>BCC</td>\n",
       "      <td>v20190624</td>\n",
Anderson Banihirwe's avatar
Anderson Banihirwe committed
1144
       "      <td>/glade/collections/cmip/CMIP6/AerChemMIP/BCC/B...</td>\n",
1145
       "      <td>NaN</td>\n",
Anderson Banihirwe's avatar
Anderson Banihirwe committed
1146 1147 1148
       "    </tr>\n",
       "    <tr>\n",
       "      <td>4</td>\n",
Anderson Banihirwe's avatar
Anderson Banihirwe committed
1149
       "      <td>tas</td>\n",
1150
       "      <td>Amon</td>\n",
Anderson Banihirwe's avatar
Anderson Banihirwe committed
1151 1152 1153 1154 1155
       "      <td>BCC-ESM1</td>\n",
       "      <td>ssp370</td>\n",
       "      <td>r2i1p1f1</td>\n",
       "      <td>gn</td>\n",
       "      <td>201501-205512</td>\n",
1156 1157 1158
       "      <td>AerChemMIP</td>\n",
       "      <td>BCC</td>\n",
       "      <td>v20190624</td>\n",
Anderson Banihirwe's avatar
Anderson Banihirwe committed
1159
       "      <td>/glade/collections/cmip/CMIP6/AerChemMIP/BCC/B...</td>\n",
1160
       "      <td>NaN</td>\n",
Anderson Banihirwe's avatar
Anderson Banihirwe committed
1161 1162 1163 1164 1165 1166
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
1167
       "  variable_id table_id source_id experiment_id member_id grid_label  \\\n",
Anderson Banihirwe's avatar
Anderson Banihirwe committed
1168 1169 1170 1171 1172
       "0          pr      day  BCC-ESM1        ssp370  r2i1p1f1         gn   \n",
       "1        hfls     Amon  BCC-ESM1        ssp370  r2i1p1f1         gn   \n",
       "2        prsn     Amon  BCC-ESM1        ssp370  r2i1p1f1         gn   \n",
       "3          va     Amon  BCC-ESM1        ssp370  r2i1p1f1         gn   \n",
       "4         tas     Amon  BCC-ESM1        ssp370  r2i1p1f1         gn   \n",
Anderson Banihirwe's avatar
Anderson Banihirwe committed
1173
       "\n",
Anderson Banihirwe's avatar
Anderson Banihirwe committed
1174 1175 1176 1177 1178 1179
       "          time_range activity_id institution_id    version  \\\n",
       "0  20150101-20551231  AerChemMIP            BCC  v20190702   \n",
       "1      201501-205512  AerChemMIP            BCC  v20190624   \n",
       "2      201501-205512  AerChemMIP            BCC  v20190624   \n",
       "3      201501-205512  AerChemMIP            BCC  v20190624   \n",
       "4      201501-205512  AerChemMIP            BCC  v20190624   \n",
Anderson Banihirwe's avatar
Anderson Banihirwe committed
1180
       "\n",
1181 1182 1183 1184 1185 1186
       "                                                path  dcpp_init_year  \n",
       "0  /glade/collections/cmip/CMIP6/AerChemMIP/BCC/B...             NaN  \n",
       "1  /glade/collections/cmip/CMIP6/AerChemMIP/BCC/B...             NaN  \n",
       "2  /glade/collections/cmip/CMIP6/AerChemMIP/BCC/B...             NaN  \n",
       "3  /glade/collections/cmip/CMIP6/AerChemMIP/BCC/B...             NaN  \n",
       "4  /glade/collections/cmip/CMIP6/AerChemMIP/BCC/B...             NaN  "
Anderson Banihirwe's avatar
Anderson Banihirwe committed
1187 1188
      ]
     },
Anderson Banihirwe's avatar
Anderson Banihirwe committed
1189
     "execution_count": 30,
Anderson Banihirwe's avatar
Anderson Banihirwe committed
1190 1191 1192 1193
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
Anderson Banihirwe's avatar
Anderson Banihirwe committed
1194
   "source": [
1195 1196 1197
    "df[\"dcpp_init_year\"] = df.member_id.map(lambda x: float(x.split(\"-\")[0][1:] if x.startswith(\"s\") else np.nan))\n",
    "df[\"member_id\"] = df[\"member_id\"].map(lambda x: x.split(\"-\")[-1] if x.startswith(\"s\") else x)\n",
    "df.head()"
Anderson Banihirwe's avatar
Anderson Banihirwe committed
1198 1199 1200 1201
   ]
  },
  {
   "cell_type": "code",
Anderson Banihirwe's avatar
Anderson Banihirwe committed
1202
   "execution_count": 31,
Anderson Banihirwe's avatar
Anderson Banihirwe committed
1203
   "metadata": {},
Anderson Banihirwe's avatar
Anderson Banihirwe committed
1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>activity_id</th>\n",
       "      <th>institution_id</th>\n",
       "      <th>source_id</th>\n",
       "      <th>experiment_id</th>\n",
       "      <th>member_id</th>\n",
       "      <th>table_id</th>\n",
       "      <th>variable_id</th>\n",
       "      <th>grid_label</th>\n",
1234
       "      <th>dcpp_init_year</th>\n",
Anderson Banihirwe's avatar
Anderson Banihirwe committed
1235 1236 1237 1238 1239 1240 1241 1242
       "      <th>version</th>\n",
       "      <th>time_range</th>\n",
       "      <th>path</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <td>0</td>\n",
1243 1244 1245 1246 1247
       "      <td>AerChemMIP</td>\n",
       "      <td>BCC</td>\n",
       "      <td>BCC-ESM1</td>\n",
       "      <td>ssp370</td>\n",
       "      <td>r2i1p1f1</td>\n",
Anderson Banihirwe's avatar
Anderson Banihirwe committed
1248 1249
       "      <td>day</td>\n",
       "      <td>pr</td>\n",
Anderson Banihirwe's avatar
Anderson Banihirwe committed
1250
       "      <td>gn</td>\n",
1251
       "      <td>NaN</td>\n",
Anderson Banihirwe's avatar
Anderson Banihirwe committed
1252 1253
       "      <td>v20190702</td>\n",
       "      <td>20150101-20551231</td>\n",
1254
       "      <td>/glade/collections/cmip/CMIP6/AerChemMIP/BCC/B...</td>\n",
Anderson Banihirwe's avatar
Anderson Banihirwe committed
1255 1256 1257
       "    </tr>\n",
       "    <tr>\n",
       "      <td>1</td>\n",
1258 1259 1260 1261 1262 1263
       "      <td>AerChemMIP</td>\n",
       "      <td>BCC</td>\n",
       "      <td>BCC-ESM1</td>\n",
       "      <td>ssp370</td>\n",
       "      <td>r2i1p1f1</td>\n",
       "      <td>Amon</td>\n",
Anderson Banihirwe's avatar
Anderson Banihirwe committed
1264
       "      <td>hfls</td>\n",
Anderson Banihirwe's avatar
Anderson Banihirwe committed
1265
       "      <td>gn</td>\n",
1266 1267 1268 1269
       "      <td>NaN</td>\n",
       "      <td>v20190624</td>\n",
       "      <td>201501-205512</td>\n",
       "      <td>/glade/collections/cmip/CMIP6/AerChemMIP/BCC/B...</td>\n",
Anderson Banihirwe's avatar
Anderson Banihirwe committed
1270 1271 1272
       "    </tr>\n",
       "    <tr>\n",
       "      <td>2</td>\n",
1273 1274 1275 1276 1277
       "      <td>AerChemMIP</td>\n",
       "      <td>BCC</td>\n",
       "      <td>BCC-ESM1</td>\n",
       "      <td>ssp370</td>\n",
       "      <td>r2i1p1f1</td>\n",
Anderson Banihirwe's avatar
Anderson Banihirwe committed
1278
       "      <td>Amon</td>\n",
Anderson Banihirwe's avatar
Anderson Banihirwe committed
1279
       "      <td>prsn</td>\n",
Anderson Banihirwe's avatar
Anderson Banihirwe committed
1280
       "      <td>gn</td>\n",
1281 1282 1283 1284
       "      <td>NaN</td>\n",
       "      <td>v20190624</td>\n",
       "      <td>201501-205512</td>\n",
       "      <td>/glade/collections/cmip/CMIP6/AerChemMIP/BCC/B...</td>\n",
Anderson Banihirwe's avatar
Anderson Banihirwe committed
1285 1286 1287
       "    </tr>\n",
       "    <tr>\n",
       "      <td>3</td>\n",
1288 1289 1290 1291 1292 1293
       "      <td>AerChemMIP</td>\n",
       "      <td>BCC</td>\n",
       "      <td>BCC-ESM1</td>\n",
       "      <td>ssp370</td>\n",
       "      <td>r2i1p1f1</td>\n",
       "      <td>Amon</td>\n",
Anderson Banihirwe's avatar
Anderson Banihirwe committed
1294
       "      <td>va</td>\n",
Anderson Banihirwe's avatar
Anderson Banihirwe committed
1295
       "      <td>gn</td>\n",
1296 1297 1298 1299
       "      <td>NaN</td>\n",
       "      <td>v20190624</td>\n",
       "      <td>201501-205512</td>\n",
       "      <td>/glade/collections/cmip/CMIP6/AerChemMIP/BCC/B...</td>\n",
Anderson Banihirwe's avatar
Anderson Banihirwe committed
1300 1301 1302
       "    </tr>\n",
       "    <tr>\n",
       "      <td>4</td>\n",
1303 1304 1305 1306 1307
       "      <td>AerChemMIP</td>\n",
       "      <td>BCC</td>\n",
       "      <td>BCC-ESM1</td>\n",
       "      <td>ssp370</td>\n",
       "      <td>r2i1p1f1</td>\n",
Anderson Banihirwe's avatar
Anderson Banihirwe committed
1308
       "      <td>Amon</td>\n",
Anderson Banihirwe's avatar
Anderson Banihirwe committed
1309
       "      <td>tas</td>\n",
Anderson Banihirwe's avatar
Anderson Banihirwe committed
1310
       "      <td>gn</td>\n",
1311 1312 1313 1314
       "      <td>NaN</td>\n",
       "      <td>v20190624</td>\n",
       "      <td>201501-205512</td>\n",
       "      <td>/glade/collections/cmip/CMIP6/AerChemMIP/BCC/B...</td>\n",
Anderson Banihirwe's avatar
Anderson Banihirwe committed
1315 1316 1317 1318 1319 1320
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
1321
       "  activity_id institution_id source_id experiment_id member_id table_id  \\\n",
Anderson Banihirwe's avatar
Anderson Banihirwe committed
1322
       "0  AerChemMIP            BCC  BCC-ESM1        ssp370  r2i1p1f1      day   \n",
1323 1324 1325 1326
       "1  AerChemMIP            BCC  BCC-ESM1        ssp370  r2i1p1f1     Amon   \n",
       "2  AerChemMIP            BCC  BCC-ESM1        ssp370  r2i1p1f1     Amon   \n",
       "3  AerChemMIP            BCC  BCC-ESM1        ssp370  r2i1p1f1     Amon   \n",
       "4  AerChemMIP            BCC  BCC-ESM1        ssp370  r2i1p1f1     Amon   \n",
Anderson Banihirwe's avatar
Anderson Banihirwe committed
1327
       "\n",
Anderson Banihirwe's avatar
Anderson Banihirwe committed
1328 1329 1330 1331 1332 1333
       "  variable_id grid_label  dcpp_init_year    version         time_range  \\\n",
       "0          pr         gn             NaN  v20190702  20150101-20551231   \n",
       "1        hfls         gn             NaN  v20190624      201501-205512   \n",
       "2        prsn         gn             NaN  v20190624      201501-205512   \n",
       "3          va         gn             NaN  v20190624      201501-205512   \n",
       "4         tas         gn             NaN  v20190624      201501-205512   \n",
Anderson Banihirwe's avatar
Anderson Banihirwe committed
1334 1335
       "\n",
       "                                                path  \n",
1336 1337 1338 1339 1340
       "0  /glade/collections/cmip/CMIP6/AerChemMIP/BCC/B...  \n",
       "1  /glade/collections/cmip/CMIP6/AerChemMIP/BCC/B...  \n",
       "2  /glade/collections/cmip/CMIP6/AerChemMIP/BCC/B...  \n",
       "3  /glade/collections/cmip/CMIP6/AerChemMIP/BCC/B...  \n",
       "4  /glade/collections/cmip/CMIP6/AerChemMIP/BCC/B...  "
Anderson Banihirwe's avatar
Anderson Banihirwe committed
1341 1342
      ]
     },
Anderson Banihirwe's avatar
Anderson Banihirwe committed
1343
     "execution_count": 31,
Anderson Banihirwe's avatar
Anderson Banihirwe committed
1344 1345 1346 1347
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
Anderson Banihirwe's avatar
Anderson Banihirwe committed
1348
   "source": [
1349 1350 1351 1352
    "columns = [\"activity_id\", \"institution_id\", \"source_id\", \"experiment_id\", \"member_id\", \"table_id\", \"variable_id\",\n",
    "           \"grid_label\", \"dcpp_init_year\", \"version\", \"time_range\", \"path\"]\n",
    "df = df[columns]\n",
    "df.head()"
Anderson Banihirwe's avatar
Anderson Banihirwe committed
1353 1354 1355 1356
   ]
  },
  {
   "cell_type": "code",
Anderson Banihirwe's avatar
Anderson Banihirwe committed
1357
   "execution_count": 32,
Anderson Banihirwe's avatar
Anderson Banihirwe committed
1358 1359 1360
   "metadata": {},
   "outputs": [],
   "source": [
1361
    "df.to_csv(\"../catalogs/glade-cmip6.csv.gz\", compression=\"gzip\", index=False)"
Anderson Banihirwe's avatar
Anderson Banihirwe committed
1362
   ]
Anderson Banihirwe's avatar
Anderson Banihirwe committed
1363 1364 1365 1366 1367 1368 1369
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
Anderson Banihirwe's avatar
Anderson Banihirwe committed
1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399
  }
 ],
 "metadata": {
  "file_extension": ".py",
  "kernelspec": {
   "display_name": "Python [conda env:analysis]",
   "language": "python",
   "name": "conda-env-analysis-py"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.3"
  },
  "mimetype": "text/x-python",
  "name": "python",
  "npconvert_exporter": "python",
  "pygments_lexer": "ipython3",
  "version": 3
 },
 "nbformat": 4,
 "nbformat_minor": 4
}