{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "%load_ext autoreload\n",
    "%autoreload 2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "don't have phil's colormaps\n"
     ]
    }
   ],
   "source": [
    "import numpy as np\n",
    "import os\n",
    "\n",
    "import sys\n",
    "## ignore these lines, you do not need to add this if Firefly is pip installed into your PYTHONPATH\n",
    "sys.path.insert(0, '/Users/ageller/VISUALIZATIONS/Firefly')\n",
    "sys.path.insert(0,'/Users/agurvich/research/repos/firefly/src')\n",
    "from firefly.data_reader import FIREreader,SimpleFIREreader,TweenParams\n",
    "from abg_python.galaxy.gal_utils import Galaxy"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Convert FIRE data\n",
    "In this example notebook we demonstrate how to use the `firefly.data_reader.FIREreader` sub-class which creates specialized data files for FIRE formatted data. The details of how the `FIREreader` class is \"specialized\" see the <a href=\"https://alexbgurvi.ch/Firefly/docs/build/html/reference/api/api.html\">API documentation</a> and to see the example of this output visit <a href=\"https://alexbgurvi.ch/firefly/src/firefly/index.html\">the live demo version</a>."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Couldn't find a metadata file... for\n",
      " Metadata object at /Users/agurvich/scratch/data/metal_diffusion/m12b_res57000/metadata/meta_Galaxy_600.hdf5\n",
      "No rstar 1/2 in halo or metadata files, we will need to calculate it ourselves.\n",
      "Loading star particles of m12b_res57000 at 600 at /Users/agurvich/snaps/metal_diffusion/m12b_res57000/output\n",
      "Failed to open saved sub-snapshots AssertionError('Told not to use saved sub-snapshots')\n",
      "Loading gas particles of m12b_res57000 at 600 at /Users/agurvich/snaps/metal_diffusion/m12b_res57000/output\n",
      "Loading dark matter particles of m12b_res57000 at 600 at /Users/agurvich/snaps/metal_diffusion/m12b_res57000/output\n",
      "Reorienting...\n",
      "Done.\n",
      "extract_halo_inner(m12b_res57000 at 600,){'orient_stars': True, 'use_saved_subsnapshots': False} 19.53 s elapsed\n",
      "Snapshot memory free\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "(12.27201256901771,\n",
       " True,\n",
       " 13.610546783496492,\n",
       " -23.753615253930974,\n",
       " 331.60968,\n",
       " 2.454402513803542,\n",
       " 140.56429531755958)"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "galaxy = Galaxy('m12b_res57000',600)\n",
    "galaxy.extractMainHalo(use_saved_subsnapshots=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "thetas = np.linspace(0,360,1000)/180*np.pi\n",
    "coords = np.zeros((thetas.size,3))\n",
    "coords[:,0] = 0\n",
    "coords[:,1] = np.cos(thetas)\n",
    "coords[:,2] = np.sin(thetas)\n",
    "coords*=150\n",
    "my_tweenParams = TweenParams(coords,30) ## dt = 3000 ms between frames"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Loading ptype 2\n",
      "Loading ptype 1\n",
      "Loading ptype 4\n",
      "Loading ptype 0\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "array([Gas - 622573/6225729 particles - 4 tracked fields,\n",
       "       Stars - 326473/3264723 particles - 3 tracked fields,\n",
       "       HRDM - 186461/9323040 particles - 2 tracked fields,\n",
       "       LRDM - 60846/3042265 particles - 2 tracked fields], dtype=object)"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "## create a FIRE reader object\n",
    "reader = FIREreader(\n",
    "    ## path to directory containing (optionally multiple) .hdf5 files\n",
    "    snapdir = \"/Users/agurvich/research/snaps/metal_diffusion/m12b_res57000/output/\",\n",
    "    ## the snapshot number, best to provide separately in order to disambiguate\n",
    "    snapnum = 600,\n",
    "    ## particle types one would like to extract from .hdf5 files\n",
    "    ptypes=[0,4,1,2],\n",
    "    ## what to call them in the UI\n",
    "    UInames=['Gas','Stars','HRDM','LRDM'],\n",
    "    ## by what factor would we like to reduce the data for performance stability and disk space concerns\n",
    "    decimation_factors=[10,10,50,50],\n",
    "    ## what fields would we like to extract\n",
    "    fields=['Density','Temperature','AgeGyr','GCRadius'],\n",
    "    ## do we want to take the magnitude of any of these fields?\n",
    "    ## do we want to take the log? \n",
    "    logFlags=[True,True,False,False],\n",
    "    ## which fields do we want to be able to filter on?\n",
    "    filterFlags=[True,True,True,True],\n",
    "    ## which fields do we want to be able to colormap by?\n",
    "    colormapFlags=[True,True,True,True],\n",
    "    radiusFlags=[False,True,True,False],\n",
    "    ## where should the output .json files be saved to? \n",
    "    ##  if a relative path is given, like here, saves to $HOME/<JSONdir>\n",
    "    ##  and creates a soft-link to firefly/static/data\n",
    "    datadir=os.path.abspath(os.path.join(os.getcwd(),'..','static','data','FIRESampleData')),\n",
    "    ## overwrite the existing startup.json file\n",
    "    write_startup=True,\n",
    "    clean_datadir=True,\n",
    "    tweenParams=my_tweenParams)\n",
    "\n",
    "## fetch data from .hdf5 files\n",
    "reader.loadData(com=galaxy.scom,vcom=galaxy.sub_snap['vscom'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [],
   "source": [
    "## initialize the camera view\n",
    "camera = np.array([251,-117,82])\n",
    "camera = camera/np.linalg.norm(camera)*250\n",
    "reader.settings['camera'] = camera\n",
    "\n",
    "## set the initial colors of each of the particle groups\n",
    "reader.settings['color']['Gas']=[1,0,0,1]\n",
    "reader.settings['color']['Stars'] = [1,1,1,0.025]\n",
    "reader.settings['color']['HRDM'] = [0.5,0,0.5,1]\n",
    "reader.settings['color']['LRDM'] = [0.5,0,0.5,1]\n",
    "\n",
    "## set the sizes of each of the particle groups\n",
    "reader.settings['sizeMult']['Gas']=0.25\n",
    "reader.settings['sizeMult']['Stars']=0.03\n",
    "reader.settings['sizeMult']['HRDM']=1\n",
    "reader.settings['sizeMult']['LRDM']=1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [],
   "source": [
    "## initialize the gas with a colormap\n",
    "reader.settings['showColormap']['Gas'] = True\n",
    "reader.settings['blendingMode']['Gas'] = 'normal'\n",
    "reader.settings['depthTest']['Gas'] = True\n",
    "reader.settings['colormapVariable']['Gas'] = 3\n",
    "reader.settings['colormapLims']['Gas']['Velocity'] = [50,500]\n",
    "reader.settings['colormapVals']['Gas']['Velocity'] = [50,500]\n",
    "\n",
    "## initialize the gas with radius scaling (index 1 corresponds to Temperature, specified above)\n",
    "reader.settings['radiusVariable']['Gas'] = 1\n",
    "\n",
    "## initialize gas with velocity vectors\n",
    "reader.settings['showVel']['Gas'] = True\n",
    "reader.settings['velType']['Gas'] = 'arrow'\n",
    "\n",
    "## initialize HRDM with a filter excluding the center so as not to crowd the view\n",
    "reader.settings['filterVals']['HRDM']['GCRadius'] = [300,5000]\n",
    "reader.settings['filterLims']['HRDM']['GCRadius'] = [0,5000]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Gas - 622573/6225729 particles - 4 tracked fields\n",
      "Stars - 326473/3264723 particles - 3 tracked fields\n",
      "HRDM - 186461/9323040 particles - 2 tracked fields\n",
      "LRDM - 60846/3042265 particles - 2 tracked fields\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "''"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "## dump output to .ffly files\n",
    "reader.writeToDisk()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 46,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Gas - 3112865/6225729 particles - 4 tracked fields\n",
      "Stars - 1632362/3264723 particles - 3 tracked fields\n",
      "HRDM - 932304/9323040 particles - 2 tracked fields\n",
      "LRDM - 304227/3042265 particles - 2 tracked fields\n",
      "Initializing a new GitHub repository at /Users/agurvich/FIRE_lowres with\n",
      "\tGHREPONAME: FIRE_lowres\n",
      "\tGHUSER: agurvich\n",
      "\tGHOAUTHTOKENPATH: /Users/agurvich/.github.token\n",
      "\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current\n",
      "                                 Dload  Upload   Total   Spent    Left  Speed\n",
      "100  5766  100  5744  100    22   4401     16  0:00:01  0:00:01 --:--:--  4473\n",
      "To github.com:agurvich/FIRE_lowres.git\n",
      " * [new branch]      main -> main\n",
      "  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current\n",
      "                                 Dload  Upload   Total   Spent    Left  Speed\n",
      "100   626  100   587  100    39    930     61 --:--:-- --:--:-- --:--:--  1012\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "['{',\n",
       " '  \"id\": 516071472,',\n",
       " '  \"node_id\": \"R_kgDOHsKgMA\",',\n",
       " '  \"name\": \"FIRE_lowres\",',\n",
       " '  \"full_name\": \"agurvich/FIRE_lowres\",',\n",
       " '  \"private\": false,',\n",
       " '  \"owner\": {',\n",
       " '    \"login\": \"agurvich\",',\n",
       " '    \"id\": 7799423,',\n",
       " '    \"node_id\": \"MDQ6VXNlcjc3OTk0MjM=\",',\n",
       " '    \"avatar_url\": \"https://avatars.githubusercontent.com/u/7799423?v=4\",',\n",
       " '    \"gravatar_id\": \"\",',\n",
       " '    \"url\": \"https://api.github.com/users/agurvich\",',\n",
       " '    \"html_url\": \"https://github.com/agurvich\",',\n",
       " '    \"followers_url\": \"https://api.github.com/users/agurvich/followers\",',\n",
       " '    \"following_url\": \"https://api.github.com/users/agurvich/following{/other_user}\",',\n",
       " '    \"gists_url\": \"https://api.github.com/users/agurvich/gists{/gist_id}\",',\n",
       " '    \"starred_url\": \"https://api.github.com/users/agurvich/starred{/owner}{/repo}\",',\n",
       " '    \"subscriptions_url\": \"https://api.github.com/users/agurvich/subscriptions\",',\n",
       " '    \"organizations_url\": \"https://api.github.com/users/agurvich/orgs\",',\n",
       " '    \"repos_url\": \"https://api.github.com/users/agurvich/repos\",',\n",
       " '    \"events_url\": \"https://api.github.com/users/agurvich/events{/privacy}\",',\n",
       " '    \"received_events_url\": \"https://api.github.com/users/agurvich/received_events\",',\n",
       " '    \"type\": \"User\",',\n",
       " '    \"site_admin\": false',\n",
       " '  },',\n",
       " '  \"html_url\": \"https://github.com/agurvich/FIRE_lowres\",',\n",
       " '  \"description\": null,',\n",
       " '  \"fork\": false,',\n",
       " '  \"url\": \"https://api.github.com/repos/agurvich/FIRE_lowres\",',\n",
       " '  \"forks_url\": \"https://api.github.com/repos/agurvich/FIRE_lowres/forks\",',\n",
       " '  \"keys_url\": \"https://api.github.com/repos/agurvich/FIRE_lowres/keys{/key_id}\",',\n",
       " '  \"collaborators_url\": \"https://api.github.com/repos/agurvich/FIRE_lowres/collaborators{/collaborator}\",',\n",
       " '  \"teams_url\": \"https://api.github.com/repos/agurvich/FIRE_lowres/teams\",',\n",
       " '  \"hooks_url\": \"https://api.github.com/repos/agurvich/FIRE_lowres/hooks\",',\n",
       " '  \"issue_events_url\": \"https://api.github.com/repos/agurvich/FIRE_lowres/issues/events{/number}\",',\n",
       " '  \"events_url\": \"https://api.github.com/repos/agurvich/FIRE_lowres/events\",',\n",
       " '  \"assignees_url\": \"https://api.github.com/repos/agurvich/FIRE_lowres/assignees{/user}\",',\n",
       " '  \"branches_url\": \"https://api.github.com/repos/agurvich/FIRE_lowres/branches{/branch}\",',\n",
       " '  \"tags_url\": \"https://api.github.com/repos/agurvich/FIRE_lowres/tags\",',\n",
       " '  \"blobs_url\": \"https://api.github.com/repos/agurvich/FIRE_lowres/git/blobs{/sha}\",',\n",
       " '  \"git_tags_url\": \"https://api.github.com/repos/agurvich/FIRE_lowres/git/tags{/sha}\",',\n",
       " '  \"git_refs_url\": \"https://api.github.com/repos/agurvich/FIRE_lowres/git/refs{/sha}\",',\n",
       " '  \"trees_url\": \"https://api.github.com/repos/agurvich/FIRE_lowres/git/trees{/sha}\",',\n",
       " '  \"statuses_url\": \"https://api.github.com/repos/agurvich/FIRE_lowres/statuses/{sha}\",',\n",
       " '  \"languages_url\": \"https://api.github.com/repos/agurvich/FIRE_lowres/languages\",',\n",
       " '  \"stargazers_url\": \"https://api.github.com/repos/agurvich/FIRE_lowres/stargazers\",',\n",
       " '  \"contributors_url\": \"https://api.github.com/repos/agurvich/FIRE_lowres/contributors\",',\n",
       " '  \"subscribers_url\": \"https://api.github.com/repos/agurvich/FIRE_lowres/subscribers\",',\n",
       " '  \"subscription_url\": \"https://api.github.com/repos/agurvich/FIRE_lowres/subscription\",',\n",
       " '  \"commits_url\": \"https://api.github.com/repos/agurvich/FIRE_lowres/commits{/sha}\",',\n",
       " '  \"git_commits_url\": \"https://api.github.com/repos/agurvich/FIRE_lowres/git/commits{/sha}\",',\n",
       " '  \"comments_url\": \"https://api.github.com/repos/agurvich/FIRE_lowres/comments{/number}\",',\n",
       " '  \"issue_comment_url\": \"https://api.github.com/repos/agurvich/FIRE_lowres/issues/comments{/number}\",',\n",
       " '  \"contents_url\": \"https://api.github.com/repos/agurvich/FIRE_lowres/contents/{+path}\",',\n",
       " '  \"compare_url\": \"https://api.github.com/repos/agurvich/FIRE_lowres/compare/{base}...{head}\",',\n",
       " '  \"merges_url\": \"https://api.github.com/repos/agurvich/FIRE_lowres/merges\",',\n",
       " '  \"archive_url\": \"https://api.github.com/repos/agurvich/FIRE_lowres/{archive_format}{/ref}\",',\n",
       " '  \"downloads_url\": \"https://api.github.com/repos/agurvich/FIRE_lowres/downloads\",',\n",
       " '  \"issues_url\": \"https://api.github.com/repos/agurvich/FIRE_lowres/issues{/number}\",',\n",
       " '  \"pulls_url\": \"https://api.github.com/repos/agurvich/FIRE_lowres/pulls{/number}\",',\n",
       " '  \"milestones_url\": \"https://api.github.com/repos/agurvich/FIRE_lowres/milestones{/number}\",',\n",
       " '  \"notifications_url\": \"https://api.github.com/repos/agurvich/FIRE_lowres/notifications{?since,all,participating}\",',\n",
       " '  \"labels_url\": \"https://api.github.com/repos/agurvich/FIRE_lowres/labels{/name}\",',\n",
       " '  \"releases_url\": \"https://api.github.com/repos/agurvich/FIRE_lowres/releases{/id}\",',\n",
       " '  \"deployments_url\": \"https://api.github.com/repos/agurvich/FIRE_lowres/deployments\",',\n",
       " '  \"created_at\": \"2022-07-20T17:17:09Z\",',\n",
       " '  \"updated_at\": \"2022-07-20T17:17:09Z\",',\n",
       " '  \"pushed_at\": \"2022-07-20T17:17:09Z\",',\n",
       " '  \"git_url\": \"git://github.com/agurvich/FIRE_lowres.git\",',\n",
       " '  \"ssh_url\": \"git@github.com:agurvich/FIRE_lowres.git\",',\n",
       " '  \"clone_url\": \"https://github.com/agurvich/FIRE_lowres.git\",',\n",
       " '  \"svn_url\": \"https://github.com/agurvich/FIRE_lowres\",',\n",
       " '  \"homepage\": null,',\n",
       " '  \"size\": 0,',\n",
       " '  \"stargazers_count\": 0,',\n",
       " '  \"watchers_count\": 0,',\n",
       " '  \"language\": null,',\n",
       " '  \"has_issues\": true,',\n",
       " '  \"has_projects\": true,',\n",
       " '  \"has_downloads\": true,',\n",
       " '  \"has_wiki\": true,',\n",
       " '  \"has_pages\": false,',\n",
       " '  \"forks_count\": 0,',\n",
       " '  \"mirror_url\": null,',\n",
       " '  \"archived\": false,',\n",
       " '  \"disabled\": false,',\n",
       " '  \"open_issues_count\": 0,',\n",
       " '  \"license\": null,',\n",
       " '  \"allow_forking\": true,',\n",
       " '  \"is_template\": false,',\n",
       " '  \"web_commit_signoff_required\": false,',\n",
       " '  \"topics\": [',\n",
       " '',\n",
       " '  ],',\n",
       " '  \"visibility\": \"public\",',\n",
       " '  \"forks\": 0,',\n",
       " '  \"open_issues\": 0,',\n",
       " '  \"watchers\": 0,',\n",
       " '  \"default_branch\": \"main\",',\n",
       " '  \"permissions\": {',\n",
       " '    \"admin\": true,',\n",
       " '    \"maintain\": true,',\n",
       " '    \"push\": true,',\n",
       " '    \"triage\": true,',\n",
       " '    \"pull\": true',\n",
       " '  },',\n",
       " '  \"allow_squash_merge\": true,',\n",
       " '  \"allow_merge_commit\": true,',\n",
       " '  \"allow_rebase_merge\": true,',\n",
       " '  \"allow_auto_merge\": false,',\n",
       " '  \"delete_branch_on_merge\": false,',\n",
       " '  \"allow_update_branch\": false,',\n",
       " '  \"use_squash_pr_title_as_default\": false,',\n",
       " '  \"network_count\": 0,',\n",
       " '  \"subscribers_count\": 1',\n",
       " '}',\n",
       " 'Initialized empty Git repository in /Users/agurvich/FIRE_lowres/.git/',\n",
       " '[main (root-commit) ba2a742] initial commit',\n",
       " ' 139 files changed, 20846 insertions(+)',\n",
       " ' create mode 100644 README.md',\n",
       " ' create mode 100644 index.html',\n",
       " ' create mode 100644 static/css/UIStyles.css',\n",
       " ' create mode 100644 static/css/UIStyles2.css',\n",
       " ' create mode 100644 static/css/mainStyles.css',\n",
       " ' create mode 100644 static/data/FIRESampleData/DataGas000.ffly',\n",
       " ' create mode 100644 static/data/FIRESampleData/DataGas001.ffly',\n",
       " ' create mode 100644 static/data/FIRESampleData/DataGas002.ffly',\n",
       " ' create mode 100644 static/data/FIRESampleData/DataGas003.ffly',\n",
       " ' create mode 100644 static/data/FIRESampleData/DataGas004.ffly',\n",
       " ' create mode 100644 static/data/FIRESampleData/DataGas005.ffly',\n",
       " ' create mode 100644 static/data/FIRESampleData/DataGas006.ffly',\n",
       " ' create mode 100644 static/data/FIRESampleData/DataGas007.ffly',\n",
       " ' create mode 100644 static/data/FIRESampleData/DataGas008.ffly',\n",
       " ' create mode 100644 static/data/FIRESampleData/DataGas009.ffly',\n",
       " ' create mode 100644 static/data/FIRESampleData/DataGas010.ffly',\n",
       " ' create mode 100644 static/data/FIRESampleData/DataGas011.ffly',\n",
       " ' create mode 100644 static/data/FIRESampleData/DataGas012.ffly',\n",
       " ' create mode 100644 static/data/FIRESampleData/DataGas013.ffly',\n",
       " ' create mode 100644 static/data/FIRESampleData/DataGas014.ffly',\n",
       " ' create mode 100644 static/data/FIRESampleData/DataGas015.ffly',\n",
       " ' create mode 100644 static/data/FIRESampleData/DataGas016.ffly',\n",
       " ' create mode 100644 static/data/FIRESampleData/DataGas017.ffly',\n",
       " ' create mode 100644 static/data/FIRESampleData/DataGas018.ffly',\n",
       " ' create mode 100644 static/data/FIRESampleData/DataGas019.ffly',\n",
       " ' create mode 100644 static/data/FIRESampleData/DataGas020.ffly',\n",
       " ' create mode 100644 static/data/FIRESampleData/DataGas021.ffly',\n",
       " ' create mode 100644 static/data/FIRESampleData/DataGas022.ffly',\n",
       " ' create mode 100644 static/data/FIRESampleData/DataGas023.ffly',\n",
       " ' create mode 100644 static/data/FIRESampleData/DataGas024.ffly',\n",
       " ' create mode 100644 static/data/FIRESampleData/DataGas025.ffly',\n",
       " ' create mode 100644 static/data/FIRESampleData/DataGas026.ffly',\n",
       " ' create mode 100644 static/data/FIRESampleData/DataGas027.ffly',\n",
       " ' create mode 100644 static/data/FIRESampleData/DataGas028.ffly',\n",
       " ' create mode 100644 static/data/FIRESampleData/DataGas029.ffly',\n",
       " ' create mode 100644 static/data/FIRESampleData/DataGas030.ffly',\n",
       " ' create mode 100644 static/data/FIRESampleData/DataGas031.ffly',\n",
       " ' create mode 100644 static/data/FIRESampleData/DataHRDM000.ffly',\n",
       " ' create mode 100644 static/data/FIRESampleData/DataHRDM001.ffly',\n",
       " ' create mode 100644 static/data/FIRESampleData/DataHRDM002.ffly',\n",
       " ' create mode 100644 static/data/FIRESampleData/DataHRDM003.ffly',\n",
       " ' create mode 100644 static/data/FIRESampleData/DataHRDM004.ffly',\n",
       " ' create mode 100644 static/data/FIRESampleData/DataHRDM005.ffly',\n",
       " ' create mode 100644 static/data/FIRESampleData/DataHRDM006.ffly',\n",
       " ' create mode 100644 static/data/FIRESampleData/DataHRDM007.ffly',\n",
       " ' create mode 100644 static/data/FIRESampleData/DataHRDM008.ffly',\n",
       " ' create mode 100644 static/data/FIRESampleData/DataHRDM009.ffly',\n",
       " ' create mode 100644 static/data/FIRESampleData/DataLRDM000.ffly',\n",
       " ' create mode 100644 static/data/FIRESampleData/DataLRDM001.ffly',\n",
       " ' create mode 100644 static/data/FIRESampleData/DataLRDM002.ffly',\n",
       " ' create mode 100644 static/data/FIRESampleData/DataLRDM003.ffly',\n",
       " ' create mode 100644 static/data/FIRESampleData/DataSettings.json',\n",
       " ' create mode 100644 static/data/FIRESampleData/DataStars000.ffly',\n",
       " ' create mode 100644 static/data/FIRESampleData/DataStars001.ffly',\n",
       " ' create mode 100644 static/data/FIRESampleData/DataStars002.ffly',\n",
       " ' create mode 100644 static/data/FIRESampleData/DataStars003.ffly',\n",
       " ' create mode 100644 static/data/FIRESampleData/DataStars004.ffly',\n",
       " ' create mode 100644 static/data/FIRESampleData/DataStars005.ffly',\n",
       " ' create mode 100644 static/data/FIRESampleData/DataStars006.ffly',\n",
       " ' create mode 100644 static/data/FIRESampleData/DataStars007.ffly',\n",
       " ' create mode 100644 static/data/FIRESampleData/DataStars008.ffly',\n",
       " ' create mode 100644 static/data/FIRESampleData/DataStars009.ffly',\n",
       " ' create mode 100644 static/data/FIRESampleData/DataStars010.ffly',\n",
       " ' create mode 100644 static/data/FIRESampleData/DataStars011.ffly',\n",
       " ' create mode 100644 static/data/FIRESampleData/DataStars012.ffly',\n",
       " ' create mode 100644 static/data/FIRESampleData/DataStars013.ffly',\n",
       " ' create mode 100644 static/data/FIRESampleData/DataStars014.ffly',\n",
       " ' create mode 100644 static/data/FIRESampleData/DataStars015.ffly',\n",
       " ' create mode 100644 static/data/FIRESampleData/DataStars016.ffly',\n",
       " ' create mode 100644 static/data/FIRESampleData/TweenParams.json',\n",
       " ' create mode 100644 static/data/FIRESampleData/filenames.json',\n",
       " ' create mode 100644 static/data/startup.json',\n",
       " ' create mode 100644 static/docs/FIREFLY-02_trimmed.png',\n",
       " ' create mode 100644 static/docs/GUIicon.png',\n",
       " ' create mode 100644 static/docs/README.md',\n",
       " ' create mode 100644 static/docs/READMEcleanPack.md',\n",
       " ' create mode 100644 static/docs/UI.png',\n",
       " ' create mode 100644 static/docs/icon.png',\n",
       " ' create mode 100644 static/docs/jupyter_embed.png',\n",
       " ' create mode 100644 static/docs/screenGrab.png',\n",
       " ' create mode 100644 static/js/.DS_Store',\n",
       " ' create mode 100644 static/js/gui/GUIParams.js',\n",
       " ' create mode 100644 static/js/gui/GUIconstructors.js',\n",
       " ' create mode 100644 static/js/gui/GUIsocket.js',\n",
       " ' create mode 100644 static/js/gui/UI.js',\n",
       " ' create mode 100644 static/js/gui/colormap.js',\n",
       " ' create mode 100644 static/js/gui/initGUI.js',\n",
       " ' create mode 100644 static/js/gui/particles.js',\n",
       " ' create mode 100644 static/js/gui/sliders.js',\n",
       " ' create mode 100644 static/js/misc/FireflyFormat1.js',\n",
       " ' create mode 100644 static/js/misc/FireflyOctnodeSubstring.js',\n",
       " ' create mode 100644 static/js/misc/MyArrayBuffer.js',\n",
       " ' create mode 100644 static/js/misc/kaitai-struct/KaitaiStream.js',\n",
       " ' create mode 100644 static/js/misc/socketParams.js',\n",
       " ' create mode 100644 static/js/misc/utils.js',\n",
       " ' create mode 100644 static/js/misc/windowEvents.js',\n",
       " ' create mode 100644 static/js/octree/octreeCreatePartsMesh.js',\n",
       " ' create mode 100644 static/js/octree/octreeInit.js',\n",
       " ' create mode 100644 static/js/octree/octreeRenderLoop.js',\n",
       " ' create mode 100644 static/js/streamer/initStreamer.js',\n",
       " ' create mode 100644 static/js/viewer/applyUISelections.js',\n",
       " ' create mode 100644 static/js/viewer/createPartsMesh.js',\n",
       " ' create mode 100644 static/js/viewer/initViewer.js',\n",
       " ' create mode 100644 static/js/viewer/renderLoop.js',\n",
       " ' create mode 100644 static/js/viewer/runTweens.js',\n",
       " ' create mode 100644 static/js/viewer/viewerParams.js',\n",
       " ' create mode 100644 static/lib/Detector.js',\n",
       " ' create mode 100644 static/lib/DeviceOrientationControls.js',\n",
       " ' create mode 100644 static/lib/KeyboardState.js',\n",
       " ' create mode 100644 static/lib/StereoEffect.js',\n",
       " ' create mode 100644 static/lib/THREEx.FullScreen.js',\n",
       " ' create mode 100644 static/lib/THREEx.WindowResize.js',\n",
       " ' create mode 100644 static/lib/TrackballControls.js',\n",
       " ' create mode 100644 static/lib/Tween.js',\n",
       " ' create mode 100644 static/lib/VRButton.js',\n",
       " ' create mode 100644 static/lib/d3.v4.10.2.min.js',\n",
       " ' create mode 100644 static/lib/jquery-3.2.1.min.js',\n",
       " ' create mode 100644 static/lib/nouislider.min.css',\n",
       " ' create mode 100644 static/lib/nouislider.min.js',\n",
       " ' create mode 100644 static/lib/socket.io.min.js',\n",
       " ' create mode 100644 static/lib/socket.io.min.js.map',\n",
       " ' create mode 100644 static/lib/socket.io.min.js.org',\n",
       " ' create mode 100644 static/lib/spectrum.css',\n",
       " ' create mode 100644 static/lib/spectrum.js',\n",
       " ' create mode 100644 static/lib/three-fly-controls.js',\n",
       " ' create mode 100644 static/lib/three.min.js.old',\n",
       " ' create mode 100644 static/lib/three.min.r102.js',\n",
       " ' create mode 100644 static/lib/three.min.r137.js',\n",
       " ' create mode 100644 static/lib/threeoctree.min.js',\n",
       " ' create mode 100644 static/lib/wNumb.js',\n",
       " ' create mode 100644 static/shaders/fragment.glsl.js',\n",
       " ' create mode 100644 static/shaders/fragment_pass2.glsl.js',\n",
       " ' create mode 100644 static/shaders/vertex.glsl.js',\n",
       " ' create mode 100644 static/textures/.ipynb_checkpoints/createColormap-checkpoint.ipynb',\n",
       " ' create mode 100644 static/textures/bb.png',\n",
       " ' create mode 100644 static/textures/cmap.png',\n",
       " ' create mode 100644 static/textures/colormap.png',\n",
       " ' create mode 100644 static/textures/colormap_names.json',\n",
       " ' create mode 100644 static/textures/createColormap.ipynb',\n",
       " \"branch 'main' set up to track 'origin/main'.\",\n",
       " '{',\n",
       " '  \"url\": \"https://api.github.com/repos/agurvich/FIRE_lowres/pages\",',\n",
       " '  \"status\": null,',\n",
       " '  \"cname\": null,',\n",
       " '  \"custom_404\": false,',\n",
       " '  \"html_url\": \"http://www.alexbgurvi.ch/FIRE_lowres/\",',\n",
       " '  \"build_type\": \"legacy\",',\n",
       " '  \"source\": {',\n",
       " '    \"branch\": \"main\",',\n",
       " '    \"path\": \"/\"',\n",
       " '  },',\n",
       " '  \"public\": true,',\n",
       " '  \"protected_domain_state\": null,',\n",
       " '  \"pending_domain_unverified_at\": null,',\n",
       " '  \"https_certificate\": {',\n",
       " '    \"state\": \"approved\",',\n",
       " '    \"description\": \"The certificate has been approved.\",',\n",
       " '    \"domains\": [',\n",
       " '      null,',\n",
       " '      \"alexbgurvi.ch\"',\n",
       " '    ],',\n",
       " '    \"expires_at\": \"2022-08-27\"',\n",
       " '  },',\n",
       " '  \"https_enforced\": false',\n",
       " '}',\n",
       " 'Check the status of your new github pages site at: https://github.com/agurvich/FIRE_lowres/settings/pages or visit it at https://agurvich.github.io/FIRE_lowres',\n",
       " '']"
      ]
     },
     "execution_count": 46,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "reader.copyFireflySourceToTarget(\"FIRE_lowres\",init_gh_pages=True)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Using `firefly.data_reader.SimpleFIREreader`\n",
    "To simplify this process we have provided `firefly.data_reader.SimpleFIREreader` which takes a path to a FIRE snapshot and creates a basic iteration of Firefly showing the gas and stars given only a path to the data."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Loading ptype 4\n",
      "Loading ptype 0\n",
      "Outputting: Gas - 622573/6225729 particles - 3 tracked fields\n",
      "Outputting: Stars - 326473/3264723 particles - 3 tracked fields\n"
     ]
    }
   ],
   "source": [
    "reader = SimpleFIREreader(\n",
    "    ## path to directory containing (optionally multiple) .hdf5 files\n",
    "    path_to_snapshot = \"/Users/agurvich/research/snaps/metal_diffusion/m12b_res57000/output/snapdir_600\",\n",
    "    ## overwrite the existing startup.json file\n",
    "    write_startup=True, \n",
    "    ## pass absolute path to avoid symlink\n",
    "    JSONdir=os.path.abspath(os.path.join(os.getcwd(),'..','static','data','FIREData_50')))"
   ]
  }
 ],
 "metadata": {
  "anaconda-cloud": {},
  "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.9.7"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
