{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 46,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<TarInfo 'depo_data_0.npy' at 0x7f8bf0e71e58>\n",
      "(1967261,)\n",
      "<TarInfo 'depo_info_0.npy' at 0x7f8bf1171750>\n"
     ]
    }
   ],
   "source": [
    "import numpy as np\n",
    "import tarfile\n",
    "import matplotlib.pyplot as plt\n",
    "%matplotlib qt\n",
    "\n",
    "tar = tarfile.open(\"depos-set.tar.bz2\", \"r:bz2\")\n",
    "for member in tar.getmembers():\n",
    "    print(member)\n",
    "    if \"data\" not in member.name :\n",
    "        continue\n",
    "    f = tar.extractfile(member)\n",
    "    if f is not None:\n",
    "        content = f.read()\n",
    "        # print(content)\n",
    "        depo = np.frombuffer(content)\n",
    "        # depo = depo[2:]\n",
    "        # depo = np.reshape(depo, (7, -1))\n",
    "        print(depo.shape)\n",
    "        # plt.scatter(depo[3],depo[2])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 45,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<TarInfo 'frame_orig_100.npy' at 0x7f8bf1171750>\n",
      "(7680016,)\n",
      "<TarInfo 'channels_orig_100.npy' at 0x7f8bf1171a70>\n",
      "<TarInfo 'tickinfo_orig_100.npy' at 0x7f8bd1885688>\n"
     ]
    }
   ],
   "source": [
    "tar = tarfile.open(\"frames.tar.bz2\", \"r:bz2\")\n",
    "for member in tar.getmembers():\n",
    "    print(member)\n",
    "    if \"frame\" not in member.name :\n",
    "        continue\n",
    "    f = tar.extractfile(member)\n",
    "    if f is not None:\n",
    "        content = f.read()\n",
    "        # print(content)\n",
    "        frame = np.frombuffer(content)\n",
    "        print(frame.shape)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 49,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.image.AxesImage at 0x7f8bb846d550>"
      ]
     },
     "execution_count": 49,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "frame = np.load(\"frame_orig_100.npy\")\n",
    "plt.imshow(frame)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 66,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(15698,)"
      ]
     },
     "execution_count": 66,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "f = np.frombuffer(content.split(b'\\n')[1])\n",
    "f.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "interpreter": {
   "hash": "b9483a4dd587476b98dd17ef78944d87a21a22a78f2af06dcfca96da16a6273c"
  },
  "kernelspec": {
   "display_name": "Python 3.6.10 ('pt13')",
   "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.6.10"
  },
  "orig_nbformat": 4
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
