{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "fileName = 'VIR_IR_1A_1_362681634_1_isis3.cub'\n",
    "\n",
    "import os\n",
    "os.environ[\"ISISDATA\"] = \"isisdata/isis_data\"\"\n",
    "os.environ[\"ISISTESTDATA\"] = \"/isisdata/isis_testData\"\n",
    "os.environ[\"ISISROOT\"] = \"/ISIS3/build\"\n",
    "\n",
    "import ale \n",
    "from ale.drivers.dawn_drivers import DawnVirIsisNaifSpiceDriver\n",
    "from ale.formatters.formatter import to_isd\n",
    "import spiceypy as spice\n",
    "from ale.drivers import AleJsonEncoder"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from ale.util import generate_kernels_from_cube\n",
    "kernels = generate_kernels_from_cube(fileName, expand=True, format_as='list')\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "kernels"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "scrolled": false
   },
   "outputs": [],
   "source": [
    "with DawnVirIsisNaifSpiceDriver(fileName, props = {\"kernels\": kernels}) as driver:\n",
    "    isisString = to_isd(driver)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "isisString"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import json\n",
    "\n",
    "isis_dict = isisString\n",
    "\n",
    "json_file = os.path.splitext(fileName)[0] + '.json'\n",
    "\n",
    "with open(json_file, 'w') as fp:\n",
    "    json.dump(isis_dict, fp, cls = AleJsonEncoder)\n",
    "    \n",
    "with open(json_file, 'r') as fp:\n",
    "    isis_dict = json.load(fp)\n",
    "    \n",
    "isis_dict.keys()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "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.10.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
