{"cells":[{"metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","trusted":true},"cell_type":"code","source":"# This Python 3 environment comes with many helpful analytics libraries installed\n# It is defined by the kaggle/python docker image: https://github.com/kaggle/docker-python\n# For example, here's several helpful packages to load in \n\nimport numpy as np # linear algebra\nimport pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\n\n# Input data files are available in the \"../input/\" directory.\n# For example, running this (by clicking run or pressing Shift+Enter) will list the files in the input directory\n\nimport os\nprint(os.listdir(\"../input\"))\n\n# Any results you write to the current directory are saved as output.","execution_count":null,"outputs":[]},{"metadata":{"_cell_guid":"79c7e3d0-c299-4dcb-8224-4455121ee9b0","collapsed":true,"_uuid":"d629ff2d2480ee46fbb7e2d37f6b5fab8052498a","trusted":false},"cell_type":"markdown","source":"Let's import some packages."},{"metadata":{"trusted":true,"_uuid":"db1e6fa0f55df18b4eaee4dee4d034e8855249aa"},"cell_type":"code","source":"from matplotlib import pyplot as plt\n%matplotlib inline\n\nimport seaborn as sns","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"a277404bc2ea7f28ba5f3abd40545a32be038379"},"cell_type":"markdown","source":"Let's read data."},{"metadata":{"trusted":true,"_uuid":"ce1779e6695d938d5d06fad2912b4728618c2447"},"cell_type":"code","source":"train = pd.read_csv('../input/training_set.csv')\ntrain_meta = pd.read_csv('../input/training_set_metadata.csv')","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"ec03bf735231d525501e7ca252c54c2fbe7ea078"},"cell_type":"markdown","source":"The telescope only works during the night.  \n\nWhen is the night in term of mjd?"},{"metadata":{"trusted":true,"_uuid":"6eb613f881cd959bba90c8f72f7a450fcc36e4a7"},"cell_type":"code","source":"train['mjd_frac'] = np.modf(train.mjd)[0]\n\n_ = plt.hist(train.mjd_frac, bins=100)","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"df2d64fc2b3c0e62966abdcbf72b983333ad1f4f"},"cell_type":"markdown","source":"Seems the night starts around 0.95 and ends around 0.45.  Let's shift time to have night in a consecutive integer part."},{"metadata":{"trusted":true,"_uuid":"8195415550896c2296d3f5c3d3a4c1813ad3b01c"},"cell_type":"code","source":"train['mjd_frac'] = np.modf(train.mjd + 0.3)[0]\n\n_ = plt.hist(train.mjd_frac, bins=100)","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"ba138ab1aa1d76b140b07620cc2161bf86571c76"},"cell_type":"markdown","source":"Now the night starts at around 0.25 and ends around 0.75. We can define the night oindex accordingly."},{"metadata":{"trusted":true,"_uuid":"bffa577cbe1f0908bd572abe95a03ee41a5d6162"},"cell_type":"code","source":"train['mjd_night'] = np.modf(train.mjd + 0.3)[1]","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"325470a153828616e799789a9ead6b9565176a28"},"cell_type":"markdown","source":"Let's now look at wich passbands are used on every night."},{"metadata":{"trusted":true,"_uuid":"ee91dda315d427d84cdb14d8a5241b2f4a352945"},"cell_type":"code","source":"train = train.groupby(['object_id', 'mjd_night', 'passband']).mjd.mean().to_frame()\ntrain = train.reset_index()\ntrain.head()","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"c31fde949bcc67dcf29fc253a141d8f77fd66350"},"cell_type":"markdown","source":"Let's look at the ddf trainings set."},{"metadata":{"trusted":true,"_uuid":"6ebd9d3db960e854c1672ac8857b19df39b367a4"},"cell_type":"code","source":"train_ddf = train.merge(train_meta, how='left', on='object_id')\ntrain_ddf = train_ddf[train_ddf.ddf == 1]","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"e2313a864606949fffbbef0a4a73bda99ac39f07"},"cell_type":"markdown","source":"Let's look at which nights passband 0 is used and which nights the other passbands are used.[](http://)"},{"metadata":{"trusted":true,"_uuid":"1d00ba9540ff3d34d6bcd331f249926ee27bf8c5"},"cell_type":"code","source":"passband_0 = set(train_ddf[train_ddf.passband == 0].mjd_night.unique())\npassband_1_to_5 = set(train_ddf[train_ddf.passband > 0].mjd_night.unique())\nlen(passband_0), len(passband_1_to_5)","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"bd215676c61d2d262de915d6e4c175bce8dc0075"},"cell_type":"markdown","source":"Ddf set is photographied quite a lot.  \n\nHere is the peculiar thing.  Passband 0 is never used the same nigh as the other ones for sources in the ddf set:"},{"metadata":{"trusted":true,"_uuid":"65bc8511d108d4f4ef0db30592fd46ef835fffd1"},"cell_type":"code","source":"passband_0 & passband_1_to_5","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"157ea847ba592d9c312acf399b206b00e14cd650"},"cell_type":"markdown","source":"We don't have the same dichotomy for the non ddf sources.  "},{"metadata":{"_uuid":"b02a8a7dda87b7733b4cba77871954916998c7aa"},"cell_type":"markdown","source":"I have not found a way to leverage the above, but Im' interested to hear about any useful use of it.  This is whay I am sharing it here!"},{"metadata":{"trusted":true,"_uuid":"7c7216aa960f883faee39deb1a1a8a35105730af"},"cell_type":"code","source":"","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}