{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"pygments_lexer":"ipython3","nbconvert_exporter":"python","version":"3.6.4","file_extension":".py","codemirror_mode":{"name":"ipython","version":3},"name":"python","mimetype":"text/x-python"}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"markdown","source":"# OpenContrails dataset documentation\n \nThe satellite images are originally obtained from the [GOES-16 Advanced Baseline Imager (ABI)](https://www.goes-r.gov/spacesegment/abi.html), which is publicly available on [Google Cloud Storage](https://console.cloud.google.com/storage/browser/gcp-public-data-goes-16/). The original full-disk images were reprojected using bilinear resampling to generate a local scene image. Because contrails are easier to identify with temporal context, a sequence of images at 10-minute intervals are provided. Each example contains exactly one labeled frame.\n\nLearn more about the dataset from our preprint: [OpenContrails: Benchmarking Contrail Detection on GOES-16 ABI](https://arxiv.org/abs/2304.02122).\n\n## Files\nIn each subdirectory named by `{record_id}`, binary files in numpy `.npy` format that corresponds to a single example are provided:\n\n* **`band_{08-16}.npy`**: array with size of `H x W x T`, where `T = n_times_before + n_times_after + 1`, representing the number of images in the sequence. There are `n_times_before` and `n_times_after` images before and after the labeled frame respectively. In our dataset all examples have  `n_times_before=4` and `n_times_after=3`. Each band represents an infrared channel at different wavelengths and is converted to brightness temperatures based on the calibration parameters. The number in the filename corresponds to the GOES-16 ABI band number. Details of the ABI bands can be found [here](https://www.goes-r.gov/mission/ABI-bands-quick-info.html).\n* **`human_individual_masks.npy`**: array with size of `H x W x 1 x R`. Each example is labeled by `R` individual human labelers. `R` is not the same for all samples. The labeled masks have value either 0 or 1 and correspond to the `(n_times_before+1)`-th image in `band_{08-16}.npy`. They are available only in the training set.\n* **`human_pixel_masks.npy`**: array with size of `H x W x 1` containing the  binary groundtruth. A pixel is regarded as contrail pixel in evaluation if it is labeled as contrail by more than half of the labelers. \n\n**`{train/validation}_metadata.json`**: contains the timestamps and the projection parameters to reproduce the satellite images.\n","metadata":{}},{"cell_type":"code","source":"import os\nimport numpy as np\nfrom matplotlib import animation\nimport matplotlib.pyplot as plt\nfrom IPython import display","metadata":{"_uuid":"3ddfdbda-6bea-47d1-ba9d-d4acaa379ad1","_cell_guid":"c7665dd4-f4e4-48e1-93c8-8d162f664b2c","collapsed":false,"jupyter":{"outputs_hidden":false},"execution":{"iopub.status.busy":"2023-08-20T12:13:30.498761Z","iopub.execute_input":"2023-08-20T12:13:30.499248Z","iopub.status.idle":"2023-08-20T12:13:30.510557Z","shell.execute_reply.started":"2023-08-20T12:13:30.499202Z","shell.execute_reply":"2023-08-20T12:13:30.509262Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"BASE_DIR = '/kaggle/input/google-research-identify-contrails-reduce-global-warming/train'\nN_TIMES_BEFORE = 4\nrecord_id = '1704010292581573769'\n\nwith open(os.path.join(BASE_DIR, record_id, 'band_11.npy'), 'rb') as f:\n    band11 = np.load(f)\nwith open(os.path.join(BASE_DIR, record_id, 'band_14.npy'), 'rb') as f:\n    band14 = np.load(f)\nwith open(os.path.join(BASE_DIR, record_id, 'band_15.npy'), 'rb') as f:\n    band15 = np.load(f)\nwith open(os.path.join(BASE_DIR, record_id, 'human_pixel_masks.npy'), 'rb') as f:\n    human_pixel_mask = np.load(f)\nwith open(os.path.join(BASE_DIR, record_id, 'human_individual_masks.npy'), 'rb') as f:\n    human_individual_mask = np.load(f)","metadata":{"execution":{"iopub.status.busy":"2023-08-20T12:13:30.517722Z","iopub.execute_input":"2023-08-20T12:13:30.518739Z","iopub.status.idle":"2023-08-20T12:13:30.762288Z","shell.execute_reply.started":"2023-08-20T12:13:30.518679Z","shell.execute_reply":"2023-08-20T12:13:30.75984Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"### Combine bands into a false color image\nIn order to view contrails in GOES, we use the \"ash\" color scheme. This color scheme was originally developed for viewing volcanic ash in the atmosphere but is also useful for viewing thin cirrus, including contrails. In this color scheme, contrails appear in the image as dark blue.\n\nNote that we use a modified version of the ash color scheme here, developed by Kulik et al., which uses slightly different bands and bounds tuned for contrails.\n\nReferences:\n - Ash Color Scheme (page 7): https://eumetrain.org/sites/default/files/2020-05/RGB_recipes.pdf","metadata":{}},{"cell_type":"code","source":"_T11_BOUNDS = (243, 303)\n_CLOUD_TOP_TDIFF_BOUNDS = (-4, 5)\n_TDIFF_BOUNDS = (-4, 2)\n\ndef normalize_range(data, bounds):\n    \"\"\"Maps data to the range [0, 1].\"\"\"\n    return (data - bounds[0]) / (bounds[1] - bounds[0])\n\nr = normalize_range(band15 - band14, _TDIFF_BOUNDS)\ng = normalize_range(band14 - band11, _CLOUD_TOP_TDIFF_BOUNDS)\nb = normalize_range(band14, _T11_BOUNDS)\nfalse_color = np.clip(np.stack([r, g, b], axis=2), 0, 1)","metadata":{"execution":{"iopub.status.busy":"2023-08-20T12:13:30.770274Z","iopub.execute_input":"2023-08-20T12:13:30.772686Z","iopub.status.idle":"2023-08-20T12:13:30.816738Z","shell.execute_reply.started":"2023-08-20T12:13:30.772615Z","shell.execute_reply":"2023-08-20T12:13:30.815298Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"## Visualize data","metadata":{}},{"cell_type":"code","source":"record_id_2 = '1000216489776414077'\n\nwith open(os.path.join(BASE_DIR, record_id_2, 'band_11.npy'), 'rb') as f:\n    band11 = np.load(f)\nwith open(os.path.join(BASE_DIR, record_id_2, 'band_14.npy'), 'rb') as f:\n    band14 = np.load(f)\nwith open(os.path.join(BASE_DIR, record_id_2, 'band_15.npy'), 'rb') as f:\n    band15 = np.load(f)\nwith open(os.path.join(BASE_DIR, record_id_2, 'human_pixel_masks.npy'), 'rb') as f:\n    human_pixel_mask = np.load(f)\nwith open(os.path.join(BASE_DIR, record_id_2, 'human_individual_masks.npy'), 'rb') as f:\n    human_individual_mask = np.load(f)\nr = normalize_range(band15 - band14, _TDIFF_BOUNDS)\ng = normalize_range(band14 - band11, _CLOUD_TOP_TDIFF_BOUNDS)\nb = normalize_range(band14, _T11_BOUNDS)\nfalse_color_2 = np.clip(np.stack([r, g, b], axis=2), 0, 1)\nimg = false_color_2[..., N_TIMES_BEFORE]\n\nplt.figure(figsize=(18, 6))\nplt.imshow(img)","metadata":{"execution":{"iopub.status.busy":"2023-08-20T12:13:30.81901Z","iopub.execute_input":"2023-08-20T12:13:30.820597Z","iopub.status.idle":"2023-08-20T12:13:31.5404Z","shell.execute_reply.started":"2023-08-20T12:13:30.820532Z","shell.execute_reply":"2023-08-20T12:13:31.539252Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"record_id_3 = '1000603527582775543'\n\nwith open(os.path.join(BASE_DIR, record_id_3, 'band_11.npy'), 'rb') as f:\n    band11 = np.load(f)\nwith open(os.path.join(BASE_DIR, record_id_3, 'band_14.npy'), 'rb') as f:\n    band14 = np.load(f)\nwith open(os.path.join(BASE_DIR, record_id_3, 'band_15.npy'), 'rb') as f:\n    band15 = np.load(f)\nwith open(os.path.join(BASE_DIR, record_id_3, 'human_pixel_masks.npy'), 'rb') as f:\n    human_pixel_mask = np.load(f)\nwith open(os.path.join(BASE_DIR, record_id_3, 'human_individual_masks.npy'), 'rb') as f:\n    human_individual_mask = np.load(f)\nr = normalize_range(band15 - band14, _TDIFF_BOUNDS)\ng = normalize_range(band14 - band11, _CLOUD_TOP_TDIFF_BOUNDS)\nb = normalize_range(band14, _T11_BOUNDS)\nfalse_color_3 = np.clip(np.stack([r, g, b], axis=2), 0, 1)\nimg = false_color_3[..., N_TIMES_BEFORE]\n\nplt.figure(figsize=(18, 6))\nplt.imshow(img)","metadata":{"execution":{"iopub.status.busy":"2023-08-20T12:13:31.544247Z","iopub.execute_input":"2023-08-20T12:13:31.545283Z","iopub.status.idle":"2023-08-20T12:13:32.147566Z","shell.execute_reply.started":"2023-08-20T12:13:31.54522Z","shell.execute_reply":"2023-08-20T12:13:32.146255Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"record_id_4 = '1000660467359258186'\n\nwith open(os.path.join(BASE_DIR, record_id_4, 'band_11.npy'), 'rb') as f:\n    band11 = np.load(f)\nwith open(os.path.join(BASE_DIR, record_id_4, 'band_14.npy'), 'rb') as f:\n    band14 = np.load(f)\nwith open(os.path.join(BASE_DIR, record_id_4, 'band_15.npy'), 'rb') as f:\n    band15 = np.load(f)\nwith open(os.path.join(BASE_DIR, record_id_4, 'human_pixel_masks.npy'), 'rb') as f:\n    human_pixel_mask = np.load(f)\nwith open(os.path.join(BASE_DIR, record_id_4, 'human_individual_masks.npy'), 'rb') as f:\n    human_individual_mask = np.load(f)\nr = normalize_range(band15 - band14, _TDIFF_BOUNDS)\ng = normalize_range(band14 - band11, _CLOUD_TOP_TDIFF_BOUNDS)\nb = normalize_range(band14, _T11_BOUNDS)\nfalse_color_4 = np.clip(np.stack([r, g, b], axis=2), 0, 1)\nimg = false_color_4[..., N_TIMES_BEFORE]\n\nplt.figure(figsize=(18, 6))\nplt.imshow(img)","metadata":{"execution":{"iopub.status.busy":"2023-08-20T12:13:32.148977Z","iopub.execute_input":"2023-08-20T12:13:32.149361Z","iopub.status.idle":"2023-08-20T12:13:32.823538Z","shell.execute_reply.started":"2023-08-20T12:13:32.149308Z","shell.execute_reply":"2023-08-20T12:13:32.822113Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"record_id_5 = '1000823728928031783'\n\nwith open(os.path.join(BASE_DIR, record_id_5, 'band_11.npy'), 'rb') as f:\n    band11 = np.load(f)\nwith open(os.path.join(BASE_DIR, record_id_5, 'band_14.npy'), 'rb') as f:\n    band14 = np.load(f)\nwith open(os.path.join(BASE_DIR, record_id_5, 'band_15.npy'), 'rb') as f:\n    band15 = np.load(f)\nwith open(os.path.join(BASE_DIR, record_id_5, 'human_pixel_masks.npy'), 'rb') as f:\n    human_pixel_mask = np.load(f)\nwith open(os.path.join(BASE_DIR, record_id_5, 'human_individual_masks.npy'), 'rb') as f:\n    human_individual_mask = np.load(f)\nr = normalize_range(band15 - band14, _TDIFF_BOUNDS)\ng = normalize_range(band14 - band11, _CLOUD_TOP_TDIFF_BOUNDS)\nb = normalize_range(band14, _T11_BOUNDS)\nfalse_color_5 = np.clip(np.stack([r, g, b], axis=2), 0, 1)\nimg = false_color_5[..., N_TIMES_BEFORE]\n\nplt.figure(figsize=(18, 6))\nplt.imshow(img)","metadata":{"execution":{"iopub.status.busy":"2023-08-20T12:13:32.825202Z","iopub.execute_input":"2023-08-20T12:13:32.825697Z","iopub.status.idle":"2023-08-20T12:13:33.488399Z","shell.execute_reply.started":"2023-08-20T12:13:32.825637Z","shell.execute_reply":"2023-08-20T12:13:33.4869Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"record_id_6 = '1001436206602675989'\n\nwith open(os.path.join(BASE_DIR, record_id_6, 'band_11.npy'), 'rb') as f:\n    band11 = np.load(f)\nwith open(os.path.join(BASE_DIR, record_id_6, 'band_14.npy'), 'rb') as f:\n    band14 = np.load(f)\nwith open(os.path.join(BASE_DIR, record_id_6, 'band_15.npy'), 'rb') as f:\n    band15 = np.load(f)\nwith open(os.path.join(BASE_DIR, record_id_6, 'human_pixel_masks.npy'), 'rb') as f:\n    human_pixel_mask = np.load(f)\nwith open(os.path.join(BASE_DIR, record_id_6, 'human_individual_masks.npy'), 'rb') as f:\n    human_individual_mask = np.load(f)\nr = normalize_range(band15 - band14, _TDIFF_BOUNDS)\ng = normalize_range(band14 - band11, _CLOUD_TOP_TDIFF_BOUNDS)\nb = normalize_range(band14, _T11_BOUNDS)\nfalse_color_6 = np.clip(np.stack([r, g, b], axis=2), 0, 1)\nimg = false_color_6[..., N_TIMES_BEFORE]\n\nplt.figure(figsize=(18, 6))\nplt.imshow(img)","metadata":{"execution":{"iopub.status.busy":"2023-08-20T12:13:33.490893Z","iopub.execute_input":"2023-08-20T12:13:33.491841Z","iopub.status.idle":"2023-08-20T12:13:34.292512Z","shell.execute_reply.started":"2023-08-20T12:13:33.491784Z","shell.execute_reply":"2023-08-20T12:13:34.291458Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"record_id_7 = '1004946886927737572'\n\nwith open(os.path.join(BASE_DIR, record_id_7, 'band_11.npy'), 'rb') as f:\n    band11 = np.load(f)\nwith open(os.path.join(BASE_DIR, record_id_7, 'band_14.npy'), 'rb') as f:\n    band14 = np.load(f)\nwith open(os.path.join(BASE_DIR, record_id_7, 'band_15.npy'), 'rb') as f:\n    band15 = np.load(f)\nwith open(os.path.join(BASE_DIR, record_id_7, 'human_pixel_masks.npy'), 'rb') as f:\n    human_pixel_mask = np.load(f)\nwith open(os.path.join(BASE_DIR, record_id_7, 'human_individual_masks.npy'), 'rb') as f:\n    human_individual_mask = np.load(f)\nr = normalize_range(band15 - band14, _TDIFF_BOUNDS)\ng = normalize_range(band14 - band11, _CLOUD_TOP_TDIFF_BOUNDS)\nb = normalize_range(band14, _T11_BOUNDS)\nfalse_color_7 = np.clip(np.stack([r, g, b], axis=2), 0, 1)\nimg = false_color_7[..., N_TIMES_BEFORE]\n\nplt.figure(figsize=(18, 6))\nplt.imshow(img)","metadata":{"execution":{"iopub.status.busy":"2023-08-20T12:13:34.293873Z","iopub.execute_input":"2023-08-20T12:13:34.294438Z","iopub.status.idle":"2023-08-20T12:13:34.911519Z","shell.execute_reply.started":"2023-08-20T12:13:34.294396Z","shell.execute_reply":"2023-08-20T12:13:34.910359Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"record_id_8 = '1008059333185464192'\n\nwith open(os.path.join(BASE_DIR, record_id_8, 'band_11.npy'), 'rb') as f:\n    band11 = np.load(f)\nwith open(os.path.join(BASE_DIR, record_id_8, 'band_14.npy'), 'rb') as f:\n    band14 = np.load(f)\nwith open(os.path.join(BASE_DIR, record_id_8, 'band_15.npy'), 'rb') as f:\n    band15 = np.load(f)\nwith open(os.path.join(BASE_DIR, record_id_8, 'human_pixel_masks.npy'), 'rb') as f:\n    human_pixel_mask = np.load(f)\nwith open(os.path.join(BASE_DIR, record_id_8, 'human_individual_masks.npy'), 'rb') as f:\n    human_individual_mask = np.load(f)\nr = normalize_range(band15 - band14, _TDIFF_BOUNDS)\ng = normalize_range(band14 - band11, _CLOUD_TOP_TDIFF_BOUNDS)\nb = normalize_range(band14, _T11_BOUNDS)\nfalse_color_8 = np.clip(np.stack([r, g, b], axis=2), 0, 1)\nimg = false_color_8[..., N_TIMES_BEFORE]\n\nplt.figure(figsize=(18, 6))\nplt.imshow(img)","metadata":{"execution":{"iopub.status.busy":"2023-08-20T12:13:34.913447Z","iopub.execute_input":"2023-08-20T12:13:34.913913Z","iopub.status.idle":"2023-08-20T12:13:35.589627Z","shell.execute_reply.started":"2023-08-20T12:13:34.913864Z","shell.execute_reply":"2023-08-20T12:13:35.587924Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"record_id_9 = '102251599132794748'\n\nwith open(os.path.join(BASE_DIR, record_id_9, 'band_11.npy'), 'rb') as f:\n    band11 = np.load(f)\nwith open(os.path.join(BASE_DIR, record_id_9, 'band_14.npy'), 'rb') as f:\n    band14 = np.load(f)\nwith open(os.path.join(BASE_DIR, record_id_9, 'band_15.npy'), 'rb') as f:\n    band15 = np.load(f)\nwith open(os.path.join(BASE_DIR, record_id_9, 'human_pixel_masks.npy'), 'rb') as f:\n    human_pixel_mask = np.load(f)\nwith open(os.path.join(BASE_DIR, record_id_9, 'human_individual_masks.npy'), 'rb') as f:\n    human_individual_mask = np.load(f)\nr = normalize_range(band15 - band14, _TDIFF_BOUNDS)\ng = normalize_range(band14 - band11, _CLOUD_TOP_TDIFF_BOUNDS)\nb = normalize_range(band14, _T11_BOUNDS)\nfalse_color_9 = np.clip(np.stack([r, g, b], axis=2), 0, 1)\nimg = false_color_9[..., N_TIMES_BEFORE]\n\nplt.figure(figsize=(18, 6))\nplt.imshow(img)","metadata":{"execution":{"iopub.status.busy":"2023-08-20T12:13:35.594913Z","iopub.execute_input":"2023-08-20T12:13:35.595424Z","iopub.status.idle":"2023-08-20T12:13:36.280609Z","shell.execute_reply.started":"2023-08-20T12:13:35.595373Z","shell.execute_reply":"2023-08-20T12:13:36.279398Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"record_id_10 = '1037509194786240155'\n\nwith open(os.path.join(BASE_DIR, record_id_10, 'band_11.npy'), 'rb') as f:\n    band11 = np.load(f)\nwith open(os.path.join(BASE_DIR, record_id_10, 'band_14.npy'), 'rb') as f:\n    band14 = np.load(f)\nwith open(os.path.join(BASE_DIR, record_id_10, 'band_15.npy'), 'rb') as f:\n    band15 = np.load(f)\nwith open(os.path.join(BASE_DIR, record_id_10, 'human_pixel_masks.npy'), 'rb') as f:\n    human_pixel_mask = np.load(f)\nwith open(os.path.join(BASE_DIR, record_id_10, 'human_individual_masks.npy'), 'rb') as f:\n    human_individual_mask = np.load(f)\nr = normalize_range(band15 - band14, _TDIFF_BOUNDS)\ng = normalize_range(band14 - band11, _CLOUD_TOP_TDIFF_BOUNDS)\nb = normalize_range(band14, _T11_BOUNDS)\nfalse_color_10 = np.clip(np.stack([r, g, b], axis=2), 0, 1)\nimg = false_color_10[..., N_TIMES_BEFORE]\n\nplt.figure(figsize=(18, 6))\nplt.imshow(img)","metadata":{"execution":{"iopub.status.busy":"2023-08-20T12:13:36.28229Z","iopub.execute_input":"2023-08-20T12:13:36.28336Z","iopub.status.idle":"2023-08-20T12:13:36.909643Z","shell.execute_reply.started":"2023-08-20T12:13:36.283313Z","shell.execute_reply":"2023-08-20T12:13:36.908427Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"record_id_11 = '1063024545451565686'\n\nwith open(os.path.join(BASE_DIR, record_id_11, 'band_11.npy'), 'rb') as f:\n    band11 = np.load(f)\nwith open(os.path.join(BASE_DIR, record_id_11, 'band_14.npy'), 'rb') as f:\n    band14 = np.load(f)\nwith open(os.path.join(BASE_DIR, record_id_11, 'band_15.npy'), 'rb') as f:\n    band15 = np.load(f)\nwith open(os.path.join(BASE_DIR, record_id_11, 'human_pixel_masks.npy'), 'rb') as f:\n    human_pixel_mask = np.load(f)\nwith open(os.path.join(BASE_DIR, record_id_11, 'human_individual_masks.npy'), 'rb') as f:\n    human_individual_mask = np.load(f)\nr = normalize_range(band15 - band14, _TDIFF_BOUNDS)\ng = normalize_range(band14 - band11, _CLOUD_TOP_TDIFF_BOUNDS)\nb = normalize_range(band14, _T11_BOUNDS)\nfalse_color_11 = np.clip(np.stack([r, g, b], axis=2), 0, 1)\nimg = false_color_11[..., N_TIMES_BEFORE]\n\nplt.figure(figsize=(18, 6))\nplt.imshow(img)","metadata":{"execution":{"iopub.status.busy":"2023-08-20T12:13:36.911557Z","iopub.execute_input":"2023-08-20T12:13:36.912298Z","iopub.status.idle":"2023-08-20T12:13:37.605354Z","shell.execute_reply.started":"2023-08-20T12:13:36.912249Z","shell.execute_reply":"2023-08-20T12:13:37.604029Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"record_id_12 = '1123139137613199345'\n\nwith open(os.path.join(BASE_DIR, record_id_12, 'band_11.npy'), 'rb') as f:\n    band11 = np.load(f)\nwith open(os.path.join(BASE_DIR, record_id_12, 'band_14.npy'), 'rb') as f:\n    band14 = np.load(f)\nwith open(os.path.join(BASE_DIR, record_id_12, 'band_15.npy'), 'rb') as f:\n    band15 = np.load(f)\nwith open(os.path.join(BASE_DIR, record_id_12, 'human_pixel_masks.npy'), 'rb') as f:\n    human_pixel_mask = np.load(f)\nwith open(os.path.join(BASE_DIR, record_id_12, 'human_individual_masks.npy'), 'rb') as f:\n    human_individual_mask = np.load(f)\nr = normalize_range(band15 - band14, _TDIFF_BOUNDS)\ng = normalize_range(band14 - band11, _CLOUD_TOP_TDIFF_BOUNDS)\nb = normalize_range(band14, _T11_BOUNDS)\nfalse_color_12 = np.clip(np.stack([r, g, b], axis=2), 0, 1)\nimg = false_color_12[..., N_TIMES_BEFORE]\n\nplt.figure(figsize=(18, 6))\nplt.imshow(img)","metadata":{"execution":{"iopub.status.busy":"2023-08-20T12:13:37.60735Z","iopub.execute_input":"2023-08-20T12:13:37.6082Z","iopub.status.idle":"2023-08-20T12:13:38.236661Z","shell.execute_reply.started":"2023-08-20T12:13:37.608127Z","shell.execute_reply":"2023-08-20T12:13:38.235245Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"false_color_list = [false_color_3, false_color_4, false_color_5, false_color_6, false_color_7, false_color_8, false_color_9, false_color_10, false_color_11, false_color_12]\n\nplt.figure(figsize=(27, 9))\n\nfor i in range(len(false_color_list)):\n    ax = plt.subplot(2, 5, i+1)\n    ax.imshow(false_color_list[i][..., N_TIMES_BEFORE])\n    #ax.axis('off')\n\nplt.subplots_adjust(wspace=0.01)\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2023-08-20T12:13:38.238315Z","iopub.execute_input":"2023-08-20T12:13:38.238658Z","iopub.status.idle":"2023-08-20T12:13:40.374864Z","shell.execute_reply.started":"2023-08-20T12:13:38.238625Z","shell.execute_reply":"2023-08-20T12:13:40.372655Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"record_id_3 = '1000603527582775543'\n\nwith open(os.path.join(BASE_DIR, record_id_3, 'band_11.npy'), 'rb') as f:\n    band11 = np.load(f)\nwith open(os.path.join(BASE_DIR, record_id_3, 'band_14.npy'), 'rb') as f:\n    band14 = np.load(f)\nwith open(os.path.join(BASE_DIR, record_id_3, 'band_15.npy'), 'rb') as f:\n    band15 = np.load(f)\nwith open(os.path.join(BASE_DIR, record_id_3, 'human_pixel_masks.npy'), 'rb') as f:\n    human_pixel_mask = np.load(f)\nwith open(os.path.join(BASE_DIR, record_id_3, 'human_individual_masks.npy'), 'rb') as f:\n    human_individual_mask = np.load(f)\nr = normalize_range(band15 - band14, _TDIFF_BOUNDS)\ng = normalize_range(band14 - band11, _CLOUD_TOP_TDIFF_BOUNDS)\nb = normalize_range(band14, _T11_BOUNDS)\nfalse_color_3 = np.clip(np.stack([r, g, b], axis=2), 0, 1)\nimg = false_color_3[..., N_TIMES_BEFORE]\n\nplt.figure(figsize=(18, 6))\nax = plt.subplot(1, 3, 1)\nax.imshow(img)\nax.axis('off')\n#ax.set_title('False color image')\n\nax = plt.subplot(1, 3, 2)\nax.axis('off')\nax.imshow(human_pixel_mask, interpolation='none')\n#ax.set_title('Ground truth contrail mask')\n\nax = plt.subplot(1, 3, 3)\nax.axis('off')\nax.imshow(img)\nax.imshow(human_pixel_mask, cmap='Reds', alpha=.4, interpolation='none')\n#ax.set_title('Contrail mask on false color image');\nplt.subplots_adjust(wspace=0)\nplt.tight_layout()\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2023-08-20T12:13:40.377257Z","iopub.execute_input":"2023-08-20T12:13:40.377697Z","iopub.status.idle":"2023-08-20T12:13:41.265014Z","shell.execute_reply.started":"2023-08-20T12:13:40.37766Z","shell.execute_reply":"2023-08-20T12:13:41.263651Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"record_id = '1704010292581573769'\n\nwith open(os.path.join(BASE_DIR, record_id, 'band_11.npy'), 'rb') as f:\n    band11 = np.load(f)\nwith open(os.path.join(BASE_DIR, record_id, 'band_14.npy'), 'rb') as f:\n    band14 = np.load(f)\nwith open(os.path.join(BASE_DIR, record_id, 'band_15.npy'), 'rb') as f:\n    band15 = np.load(f)\nwith open(os.path.join(BASE_DIR, record_id, 'human_pixel_masks.npy'), 'rb') as f:\n    human_pixel_mask = np.load(f)\nwith open(os.path.join(BASE_DIR, record_id, 'human_individual_masks.npy'), 'rb') as f:\n    human_individual_mask = np.load(f)\nr = normalize_range(band15 - band14, _TDIFF_BOUNDS)\ng = normalize_range(band14 - band11, _CLOUD_TOP_TDIFF_BOUNDS)\nb = normalize_range(band14, _T11_BOUNDS)\nfalse_color = np.clip(np.stack([r, g, b], axis=2), 0, 1)\nimg = false_color[..., N_TIMES_BEFORE]\n\nplt.figure(figsize=(18, 6))\nax = plt.subplot(1, 3, 1)\nax.imshow(img)\nax.axis('off')\n#ax.set_title('False color image')\n\nax = plt.subplot(1, 3, 2, sharey=ax)\nax.axis('off')\nax.imshow(human_pixel_mask, interpolation='none')\n#ax.set_title('Ground truth contrail mask')\n\nax = plt.subplot(1, 3, 3, sharey=ax)\nax.axis('off')\nax.imshow(img)\nax.imshow(human_pixel_mask, cmap='Reds', alpha=.4, interpolation='none')\n#ax.set_title('Contrail mask on false color image');\nplt.subplots_adjust(wspace=0)\nplt.tight_layout()\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2023-08-20T12:13:41.266884Z","iopub.execute_input":"2023-08-20T12:13:41.267303Z","iopub.status.idle":"2023-08-20T12:13:42.166426Z","shell.execute_reply.started":"2023-08-20T12:13:41.267265Z","shell.execute_reply":"2023-08-20T12:13:42.16469Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"record_id_9 = '102251599132794748'\n\nwith open(os.path.join(BASE_DIR, record_id_9, 'band_11.npy'), 'rb') as f:\n    band11 = np.load(f)\nwith open(os.path.join(BASE_DIR, record_id_9, 'band_14.npy'), 'rb') as f:\n    band14 = np.load(f)\nwith open(os.path.join(BASE_DIR, record_id_9, 'band_15.npy'), 'rb') as f:\n    band15 = np.load(f)\nwith open(os.path.join(BASE_DIR, record_id_9, 'human_pixel_masks.npy'), 'rb') as f:\n    human_pixel_mask = np.load(f)\nwith open(os.path.join(BASE_DIR, record_id_9, 'human_individual_masks.npy'), 'rb') as f:\n    human_individual_mask = np.load(f)\nr = normalize_range(band15 - band14, _TDIFF_BOUNDS)\ng = normalize_range(band14 - band11, _CLOUD_TOP_TDIFF_BOUNDS)\nb = normalize_range(band14, _T11_BOUNDS)\nfalse_color_9 = np.clip(np.stack([r, g, b], axis=2), 0, 1)\nimg = false_color_9[..., N_TIMES_BEFORE]\n\nplt.figure(figsize=(18, 6))\nax = plt.subplot(1, 3, 1)\nax.imshow(img)\nax.axis('off')\n#ax.set_title('False color image')\n\nax = plt.subplot(1, 3, 2, sharey=ax)\nax.axis('off')\nax.imshow(human_pixel_mask, interpolation='none')\n#ax.set_title('Ground truth contrail mask')\n\nax = plt.subplot(1, 3, 3, sharey=ax)\nax.axis('off')\nax.imshow(img)\nax.imshow(human_pixel_mask, cmap='Reds', alpha=.4, interpolation='none')\n#ax.set_title('Contrail mask on false color image');\nplt.subplots_adjust(wspace=0)\nplt.tight_layout()\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2023-08-20T12:13:42.168496Z","iopub.execute_input":"2023-08-20T12:13:42.169798Z","iopub.status.idle":"2023-08-20T12:13:43.265669Z","shell.execute_reply.started":"2023-08-20T12:13:42.169733Z","shell.execute_reply":"2023-08-20T12:13:43.264125Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"n = human_individual_mask.shape[-1]\nplt.figure(figsize=(16, 4))\nfor i in range(n):\n    plt.subplot(1, n, i+1)\n    plt.imshow(human_individual_mask[..., i], interpolation='none')","metadata":{"execution":{"iopub.status.busy":"2023-08-20T12:13:43.267407Z","iopub.execute_input":"2023-08-20T12:13:43.267794Z","iopub.status.idle":"2023-08-20T12:13:43.843487Z","shell.execute_reply.started":"2023-08-20T12:13:43.267758Z","shell.execute_reply":"2023-08-20T12:13:43.842288Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"fig = plt.figure(figsize=(6, 6))\nim = plt.imshow(false_color_3[..., 0])\ndef draw(i):\n    im.set_array(false_color_3[..., i])\n    return [im]\nanim = animation.FuncAnimation(\n    fig, draw, frames=false_color_3.shape[-1], interval=50, blit=True\n)\nax.axis('off')\nplt.close()\ndisplay.HTML(anim.to_jshtml())","metadata":{"execution":{"iopub.status.busy":"2023-08-20T12:32:21.990658Z","iopub.execute_input":"2023-08-20T12:32:21.991246Z","iopub.status.idle":"2023-08-20T12:32:24.25973Z","shell.execute_reply.started":"2023-08-20T12:32:21.991195Z","shell.execute_reply":"2023-08-20T12:32:24.25809Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"fig = plt.figure(figsize=(6, 6))\nim = plt.imshow(false_color_3[..., 0])\n\ndef draw(i):\n    im.set_array(false_color_3[..., i])\n    ax = plt.gca()  # Get the current Axes instance\n    ax.axis('off')  # Turn off the axes\n    return [im]\n\nanim = animation.FuncAnimation(\n    fig, draw, frames=false_color_3.shape[-1], interval=50, blit=True\n)\n\nplt.close()\ndisplay.HTML(anim.to_jshtml())","metadata":{"execution":{"iopub.status.busy":"2023-08-20T12:34:31.741761Z","iopub.execute_input":"2023-08-20T12:34:31.742683Z","iopub.status.idle":"2023-08-20T12:34:33.784388Z","shell.execute_reply.started":"2023-08-20T12:34:31.742637Z","shell.execute_reply":"2023-08-20T12:34:33.783072Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}