{"cells":[{"metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","trusted":true},"cell_type":"code","source":"import numpy as np\nimport pandas as pd\nimport matplotlib.pyplot as plt\n","execution_count":null,"outputs":[]},{"metadata":{"_cell_guid":"79c7e3d0-c299-4dcb-8224-4455121ee9b0","_uuid":"d629ff2d2480ee46fbb7e2d37f6b5fab8052498a","trusted":true},"cell_type":"code","source":"# Read the data. Data are added with the \"+ Add Data\" button on the right hand panel.\n# Look for the LSST competition\nt = pd.read_csv(\"../input/training_set.csv\")\nm = pd.read_csv(\"../input/training_set_metadata.csv\")","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"2a43dc30d660f73004b331af74e6751e361915c6"},"cell_type":"code","source":"# Get the array of Object ID and length\nobjectid_list = np.unique(m['object_id'])\nobjectid_list_len = len(objectid_list)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"e8845ca23f509618dd38ca4aff554da14e155ca2"},"cell_type":"code","source":"# Loop 100 times\nfor j in range(100):\n\n    # Draw 10 random Object IDs from the list\n    objectid = objectid_list[np.int64(np.random.random() * objectid_list_len)]\n\n    # Get the rows with the objectid drawn above\n    lightcurve = t.loc[t['object_id']==objectid]\n\n    # Data\n    mjdstart = lightcurve['mjd'].iloc[0]\n    u = lightcurve.loc[lightcurve['passband']==0]\n    g = lightcurve.loc[lightcurve['passband']==1]\n    r = lightcurve.loc[lightcurve['passband']==2]\n    i = lightcurve.loc[lightcurve['passband']==3]\n    z = lightcurve.loc[lightcurve['passband']==4]\n    y = lightcurve.loc[lightcurve['passband']==5]\n\n    # More data\n    header = m.loc[m['object_id']==objectid]\n    objclass = header['target'].iloc[0]\n    specz = header['hostgal_specz'].iloc[0]\n    photz = header['hostgal_photoz'].iloc[0]\n    gallat = header['gal_b'].iloc[0]\n\n    # Preset the title of the plot\n    title = \"Object number: \" + str(objectid) + \", Object class: \" + str(objclass) + \"\\n\\n PhotZ = \" + str(photz) + \", SpecZ = \" + str(specz) + \", GalLat = \" + str(gallat) + \"deg\"\n\n    # Configure plot\n    f = plt.figure(figsize=(12,12))\n    plt.subplots_adjust(hspace=0)\n\n    # Adding a subplot to the 6th(third argument) plotting environment of size 6 (first) down 1 (second) across\n    ax1 = f.add_subplot(6,1,6)\n    plt.ylabel(\"Y\")\n    plt.errorbar(y['mjd']-mjdstart, y['flux'], yerr=y['flux_err'], fmt='o',color='brown')\n    plt.grid()\n\n    ax2 = f.add_subplot(6,1,5,sharex=ax1)\n    plt.ylabel(\"z\")\n    plt.errorbar(z['mjd']-mjdstart, z['flux'], yerr=z['flux_err'], fmt='o',color='red')\n    plt.grid()\n\n    ax3 = f.add_subplot(6,1,4,sharex=ax1)\n    plt.ylabel(\"i\")\n    plt.errorbar(i['mjd']-mjdstart, i['flux'], yerr=i['flux_err'], fmt='o',color='orange')\n    plt.grid()\n\n    ax4 = f.add_subplot(6,1,3,sharex=ax1)\n    plt.ylabel(\"r\")\n    plt.errorbar(r['mjd']-mjdstart, r['flux'], yerr=r['flux_err'], fmt='o',color='green')\n    plt.grid()\n\n    ax5 = f.add_subplot(6,1,2,sharex=ax1)\n    plt.ylabel(\"g\")\n    plt.errorbar(g['mjd']-mjdstart, g['flux'], yerr=g['flux_err'], fmt='o',color='blue')\n    plt.grid()\n\n    ax6 = f.add_subplot(6,1,1,sharex=ax1)\n    plt.ylabel(\"u\")\n    plt.errorbar(u['mjd']-mjdstart, u['flux'], yerr=u['flux_err'], fmt='o',color='purple')\n    plt.grid()\n\n    plt.title(title)\n    plt.xlabel(\"MJD\")\n","execution_count":null,"outputs":[]}],"metadata":{"kernelspec":{"display_name":"Python 3","language":"python","name":"python3"},"language_info":{"name":"python","version":"3.6.6","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"}},"nbformat":4,"nbformat_minor":1}