{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "fa0c8c8a",
   "metadata": {},
   "source": [
    "### How to read .csv stars ICL data"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "a7938be2",
   "metadata": {},
   "source": [
    "First import relevant modules"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "2d1d946b",
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import pandas as pd\n",
    "import matplotlib.pyplot as plt"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "c4c1dc64",
   "metadata": {},
   "source": [
    "Open .csv file using pandas"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "970b7b74",
   "metadata": {},
   "outputs": [],
   "source": [
    "P = pd.read_csv('ThreeHundred_Gadget-X_C001_snap128_starsICL.csv', sep='\\s+')"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "c665dc1a",
   "metadata": {},
   "source": [
    "Now display first 5 rows of the data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "337a38c9",
   "metadata": {
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "P.head()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "53f352d1",
   "metadata": {},
   "source": [
    "Check number of particles and rows"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "b27f9cd8",
   "metadata": {},
   "outputs": [],
   "source": [
    "P.shape"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "1a90319a",
   "metadata": {},
   "source": [
    "You can access the data in the same way as in dictrionaries"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "776fef3e",
   "metadata": {},
   "outputs": [],
   "source": [
    "plt.scatter(P['PosX'], P['PosY'], c='k', s=0.01, alpha=0.1)\n",
    "plt.axis('equal')"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "53600045",
   "metadata": {},
   "source": [
    "Particles in galaxies have GalID greater than zero, ICL stars have GalID = 0"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "01919060",
   "metadata": {
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "Gals = P[P['GalID'] != 0]\n",
    "Gals.head()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "f11fe4ff",
   "metadata": {},
   "source": [
    "Lets look at particles of galaxy with 2295"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "f14548e7",
   "metadata": {},
   "outputs": [],
   "source": [
    "gal = Gals[Gals['GalID']==2295]\n",
    "plt.scatter(gal['PosX'], gal['PosY'], c='k', s=0.01, alpha=0.1)\n",
    "plt.axis('equal')"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "66508708",
   "metadata": {},
   "source": [
    "Now, plot all the ICL stars"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "df9f964c",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "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.5.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
