{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "ad87eb09",
   "metadata": {},
   "outputs": [],
   "source": [
    "import re,json,glob,cmipld\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "8332153e",
   "metadata": {},
   "outputs": [],
   "source": [
    "files = glob.glob('*.json')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "d6f5a839",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[]\n",
      "[{'@id': 'agcm', 'is_required': True}, {'@id': 'aer', 'is_required': False}, {'@id': 'bgc', 'is_required': False}, {'@id': 'chem', 'is_required': False}]\n",
      "[{'@id': 'agcm', 'is_required': True}, {'@id': 'aer', 'is_required': False}, {'@id': 'bgc', 'is_required': False}, {'@id': 'chem', 'is_required': False}]\n",
      "[{'@id': 'agcm', 'is_required': True}, {'@id': 'aer', 'is_required': False}, {'@id': 'bgc', 'is_required': False}, {'@id': 'chem', 'is_required': False}]\n",
      "[{'@id': 'aogcm', 'is_required': True}]\n",
      "[{'@id': 'aogcm', 'is_required': True}, {'@id': 'bgc', 'is_required': True}, {'@id': 'aer', 'is_required': False}, {'@id': 'chem', 'is_required': False}]\n",
      "[{'@id': 'pending', 'is_required': True}]\n",
      "[{'@id': 'agcm', 'is_required': True}, {'@id': 'aer', 'is_required': False}, {'@id': 'bgc', 'is_required': False}, {'@id': 'chem', 'is_required': False}]\n",
      "[{'@id': 'agcm', 'is_required': True}, {'@id': 'chem', 'is_required': True}]\n",
      "[{'@id': 'aogcm', 'is_required': True}, {'@id': 'bgc', 'is_required': True}, {'@id': 'aer', 'is_required': False}, {'@id': 'chem', 'is_required': False}]\n",
      "[{'@id': 'aer', 'is_required': True}, {'@id': 'agcm', 'is_required': True}, {'@id': 'chem', 'is_required': False}]\n",
      "[{'@id': 'pending', 'is_required': True}]\n",
      "[]\n",
      "[{'@id': 'agcm', 'is_required': True}, {'@id': 'bgc', 'is_required': True}, {'@id': 'aer', 'is_required': False}, {'@id': 'chem', 'is_required': False}, {'@id': 'ism', 'is_required': False}]\n",
      "[]\n",
      "[{'@id': 'aer', 'is_required': True}, {'@id': 'agcm', 'is_required': True}, {'@id': 'chem', 'is_required': False}]\n",
      "[]\n",
      "[{'@id': 'pending', 'is_required': True}]\n",
      "[{'@id': 'pending', 'is_required': True}]\n",
      "[{'@id': 'agcm', 'is_required': True}, {'@id': 'aer', 'is_required': False}, {'@id': 'bgc', 'is_required': False}, {'@id': 'chem', 'is_required': False}]\n",
      "[{'@id': 'pending', 'is_required': True}]\n",
      "[{'@id': 'pending', 'is_required': True}]\n",
      "[{'@id': 'aogcm', 'is_required': True}, {'@id': 'bgc', 'is_required': False}, {'@id': 'chem', 'is_required': False}, {'@id': 'aer', 'is_required': False}]\n",
      "[{'@id': 'pending', 'is_required': True}]\n",
      "[{'@id': 'pending', 'is_required': True}]\n",
      "[]\n",
      "[{'@id': 'aogcm', 'is_required': True}, {'@id': 'aer', 'is_required': False}, {'@id': 'bgc', 'is_required': False}, {'@id': 'chem', 'is_required': False}]\n",
      "[{'@id': 'pending', 'is_required': True}]\n",
      "[{'@id': 'aogcm', 'is_required': True}]\n",
      "[{'@id': 'agcm', 'is_required': True}, {'@id': 'chem', 'is_required': True}]\n",
      "[{'@id': 'aogcm', 'is_required': True}, {'@id': 'aer', 'is_required': False}, {'@id': 'chem', 'is_required': False}, {'@id': 'bgc', 'is_required': False}]\n",
      "[{'@id': 'aogcm', 'is_required': True}, {'@id': 'aer', 'is_required': False}, {'@id': 'bgc', 'is_required': False}, {'@id': 'chem', 'is_required': False}, {'@id': 'ism', 'is_required': False}]\n",
      "[{'@id': 'aogcm', 'is_required': True}, {'@id': 'aer', 'is_required': False}, {'@id': 'bgc', 'is_required': False}, {'@id': 'chem', 'is_required': False}]\n",
      "[{'@id': 'aer', 'is_required': True}, {'@id': 'agcm', 'is_required': True}, {'@id': 'chem', 'is_required': False}]\n",
      "[{'@id': 'aogcm', 'is_required': True}, {'@id': 'bgc', 'is_required': True}, {'@id': 'aer', 'is_required': False}, {'@id': 'chem', 'is_required': False}, {'@id': 'ism', 'is_required': False}]\n",
      "[{'@id': 'pending', 'is_required': True}]\n",
      "[{'@id': 'pending', 'is_required': True}]\n",
      "[{'@id': 'land', 'is_required': True}, {'@id': 'bgc', 'is_required': False}]\n",
      "[]\n",
      "[{'@id': 'pending', 'is_required': True}]\n",
      "[{'@id': 'aogcm', 'is_required': True}, {'@id': 'land', 'is_required': True}, {'@id': 'bgc', 'is_required': True}]\n",
      "[{'@id': 'pending', 'is_required': True}]\n",
      "[{'@id': 'pending', 'is_required': True}]\n",
      "[{'@id': 'aer', 'is_required': True}, {'@id': 'agcm', 'is_required': True}, {'@id': 'chem', 'is_required': False}]\n",
      "[{'@id': 'pending', 'is_required': True}]\n",
      "[{'@id': 'pending', 'is_required': True}]\n",
      "[{'@id': 'aogcm', 'is_required': True}, {'@id': 'aer', 'is_required': False}, {'@id': 'chem', 'is_required': False}, {'@id': 'bgc', 'is_required': False}]\n",
      "[]\n",
      "[{'@id': 'pending', 'is_required': True}]\n",
      "[{'@id': 'pending', 'is_required': True}]\n",
      "[{'@id': 'aer', 'is_required': True}, {'@id': 'agcm', 'is_required': True}, {'@id': 'chem', 'is_required': False}]\n",
      "[{'@id': 'aogcm', 'is_required': True}, {'@id': 'aer', 'is_required': False}, {'@id': 'chem', 'is_required': False}, {'@id': 'bgc', 'is_required': False}]\n",
      "[{'@id': 'pending', 'is_required': True}]\n",
      "[{'@id': 'aogcm', 'is_required': True}, {'@id': 'bgc', 'is_required': True}, {'@id': 'aer', 'is_required': False}, {'@id': 'chem', 'is_required': False}]\n",
      "[{'@id': 'pending', 'is_required': True}]\n",
      "[{'@id': 'pending', 'is_required': True}]\n",
      "[{'@id': 'agcm', 'is_required': True}, {'@id': 'chem', 'is_required': True}]\n",
      "[{'@id': 'pending', 'is_required': True}]\n",
      "[{'@id': 'pending', 'is_required': True}]\n",
      "[{'@id': 'pending', 'is_required': True}]\n",
      "[{'@id': 'pending', 'is_required': True}]\n",
      "[{'@id': 'aogcm', 'is_required': True}, {'@id': 'land', 'is_required': True}, {'@id': 'bgc', 'is_required': True}]\n",
      "[{'@id': 'aogcm', 'is_required': True}, {'@id': 'bgc', 'is_required': True}, {'@id': 'aer', 'is_required': False}, {'@id': 'chem', 'is_required': False}, {'@id': 'ism', 'is_required': False}]\n",
      "[{'@id': 'aer', 'is_required': True}, {'@id': 'aogcm', 'is_required': True}, {'@id': 'chem', 'is_required': False}]\n",
      "[{'@id': 'aogcm', 'is_required': True}, {'@id': 'aer', 'is_required': False}, {'@id': 'chem', 'is_required': False}, {'@id': 'bgc', 'is_required': False}]\n",
      "[{'@id': 'pending', 'is_required': True}]\n",
      "[{'@id': 'pending', 'is_required': True}]\n",
      "[{'@id': 'pending', 'is_required': True}]\n",
      "[{'@id': 'aer', 'is_required': True}, {'@id': 'agcm', 'is_required': True}, {'@id': 'chem', 'is_required': False}]\n",
      "[{'@id': 'pending', 'is_required': True}]\n",
      "[{'@id': 'pending', 'is_required': True}]\n",
      "[{'@id': 'aer', 'is_required': True}, {'@id': 'agcm', 'is_required': True}, {'@id': 'chem', 'is_required': False}]\n",
      "[{'@id': 'agcm', 'is_required': True}, {'@id': 'chem', 'is_required': True}]\n",
      "[{'@id': 'pending', 'is_required': True}]\n",
      "[{'@id': 'aogcm', 'is_required': True}, {'@id': 'bgc', 'is_required': True}, {'@id': 'aer', 'is_required': False}, {'@id': 'chem', 'is_required': False}, {'@id': 'ism', 'is_required': False}]\n",
      "[{'@id': 'pending', 'is_required': True}]\n",
      "[{'@id': 'pending', 'is_required': True}]\n",
      "[{'@id': 'aer', 'is_required': True}, {'@id': 'agcm', 'is_required': True}, {'@id': 'chem', 'is_required': True}]\n",
      "[{'@id': 'agcm', 'is_required': True}, {'@id': 'aer', 'is_required': False}, {'@id': 'bgc', 'is_required': False}, {'@id': 'chem', 'is_required': False}]\n",
      "[{'@id': 'pending', 'is_required': True}]\n",
      "[{'@id': 'aogcm', 'is_required': True}, {'@id': 'aer', 'is_required': False}, {'@id': 'bgc', 'is_required': False}, {'@id': 'chem', 'is_required': False}]\n",
      "[{'@id': 'aogcm', 'is_required': True}]\n",
      "[{'@id': 'pending', 'is_required': True}]\n",
      "[{'@id': 'agcm', 'is_required': True}, {'@id': 'aer', 'is_required': False}, {'@id': 'bgc', 'is_required': False}, {'@id': 'chem', 'is_required': False}]\n",
      "[{'@id': 'aogcm', 'is_required': True}, {'@id': 'aer', 'is_required': False}, {'@id': 'bgc', 'is_required': False}, {'@id': 'chem', 'is_required': False}]\n",
      "[{'@id': 'pending', 'is_required': True}]\n",
      "[{'@id': 'aogcm', 'is_required': True}, {'@id': 'bgc', 'is_required': True}, {'@id': 'aer', 'is_required': False}, {'@id': 'chem', 'is_required': False}]\n",
      "[{'@id': 'aer', 'is_required': True}, {'@id': 'aogcm', 'is_required': True}, {'@id': 'chem', 'is_required': True}]\n",
      "[{'@id': 'agcm', 'is_required': True}, {'@id': 'chem', 'is_required': True}]\n",
      "[{'@id': 'pending', 'is_required': True}]\n",
      "[{'@id': 'agcm', 'is_required': True}, {'@id': 'aer', 'is_required': False}, {'@id': 'chem', 'is_required': False}, {'@id': 'bgc', 'is_required': False}]\n",
      "[{'@id': 'pending', 'is_required': True}]\n",
      "[]\n",
      "[{'@id': 'aogcm', 'is_required': True}, {'@id': 'bgc', 'is_required': True}, {'@id': 'aer', 'is_required': False}, {'@id': 'chem', 'is_required': False}, {'@id': 'ism', 'is_required': False}]\n",
      "[{'@id': 'agcm', 'is_required': True}, {'@id': 'aer', 'is_required': False}, {'@id': 'bgc', 'is_required': False}, {'@id': 'chem', 'is_required': False}]\n",
      "[{'@id': 'pending', 'is_required': True}]\n",
      "[{'@id': 'agcm', 'is_required': True}, {'@id': 'aer', 'is_required': False}, {'@id': 'bgc', 'is_required': False}, {'@id': 'chem', 'is_required': False}]\n",
      "[{'@id': 'agcm', 'is_required': True}, {'@id': 'aer', 'is_required': False}, {'@id': 'bgc', 'is_required': False}, {'@id': 'chem', 'is_required': False}]\n",
      "[{'@id': 'pending', 'is_required': True}]\n",
      "[{'@id': 'pending', 'is_required': True}]\n",
      "[{'@id': 'pending', 'is_required': True}]\n",
      "[{'@id': 'agcm', 'is_required': True}, {'@id': 'aer', 'is_required': False}, {'@id': 'bgc', 'is_required': False}, {'@id': 'chem', 'is_required': False}]\n",
      "[{'@id': 'aogcm', 'is_required': True}, {'@id': 'aer', 'is_required': False}, {'@id': 'bgc', 'is_required': False}, {'@id': 'chem', 'is_required': False}]\n",
      "[{'@id': 'agcm', 'is_required': True}, {'@id': 'chem', 'is_required': True}]\n",
      "[{'@id': 'aer', 'is_required': True}, {'@id': 'agcm', 'is_required': True}, {'@id': 'chem', 'is_required': False}]\n",
      "[{'@id': 'pending', 'is_required': True}]\n",
      "[]\n",
      "[{'@id': 'aogcm', 'is_required': True}, {'@id': 'aer', 'is_required': False}, {'@id': 'bgc', 'is_required': False}, {'@id': 'chem', 'is_required': False}]\n",
      "[{'@id': 'agcm', 'is_required': True}, {'@id': 'chem', 'is_required': True}]\n",
      "[{'@id': 'pending', 'is_required': True}]\n",
      "[]\n",
      "[{'@id': 'aogcm', 'is_required': True}, {'@id': 'bgc', 'is_required': True}, {'@id': 'aer', 'is_required': True}, {'@id': 'chem', 'is_required': False}]\n",
      "[{'@id': 'pending', 'is_required': True}]\n",
      "[{'@id': 'pending', 'is_required': True}]\n",
      "[]\n",
      "[{'@id': 'pending', 'is_required': True}]\n",
      "[{'@id': 'agcm', 'is_required': True}, {'@id': 'aer', 'is_required': False}, {'@id': 'bgc', 'is_required': False}, {'@id': 'chem', 'is_required': False}]\n",
      "[{'@id': 'agcm', 'is_required': True}, {'@id': 'aer', 'is_required': False}, {'@id': 'bgc', 'is_required': False}, {'@id': 'chem', 'is_required': False}]\n",
      "[{'@id': 'agcm', 'is_required': True}, {'@id': 'aer', 'is_required': True}, {'@id': 'chem', 'is_required': False}]\n",
      "[{'@id': 'pending', 'is_required': True}]\n"
     ]
    }
   ],
   "source": [
    "for f in files:\n",
    "    with open(f) as fp:\n",
    "        jd = json.load(fp)\n",
    "        \n",
    "    print(jd['model_realms'])\n",
    "    \n",
    "    \n",
    "    # jd['model_realms_required'] = sorted([r.get('@id',r) for r in jd.get('model_realms',[]) if r.get('is_required')])\n",
    "    \n",
    "    # jd['model_realms_additional_allowed'] = sorted([r.get('@id',r) for r in jd.get('model_realms',[]) if not r.get('is_required')])\n",
    "    \n",
    "    # del jd['model_realms']\n",
    "    \n",
    "    \n",
    "    \n",
    "    \n",
    "    \n",
    "    # doi = cmipld.utils.texttools.get_doi(str(jd))\n",
    "    \n",
    "    # jd['references'] = doi\n",
    "    \n",
    "    # with open(f, 'w') as fp:\n",
    "    #     json.dump(jd, fp, indent=2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "efaafc20",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "base2",
   "language": "python",
   "name": "python3"
  },
  "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.11.0"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
