{"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":"Published on May 10, 2023. By Marília Prata, mpwolke","metadata":{}},{"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\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 read-only \"../input/\" directory\n# For example, running this (by clicking run or pressing Shift+Enter) will list all files under the input directory\n\nimport os\nfor dirname, _, filenames in os.walk('/kaggle/input'):\n    for filename in filenames:\n        print(os.path.join(dirname, filename))\n\n# You can write up to 20GB to the current directory (/kaggle/working/) that gets preserved as output when you create a version using \"Save & Run All\" \n# You can also write temporary files to /kaggle/temp/, but they won't be saved outside of the current session","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","_kg_hide-input":true,"_kg_hide-output":true,"execution":{"iopub.status.busy":"2023-05-10T23:02:09.793613Z","iopub.execute_input":"2023-05-10T23:02:09.795338Z"},"collapsed":true,"jupyter":{"outputs_hidden":true},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#Competition Citation:\n\n@misc{google-research-identify-contrails-reduce-global-warming,\n\n    author = {Aaron Sarna, Carl Elkin, HCL-Jevster, HCL-Rantig, inversion, Joe Ng, Maggie, Walter Reade},\n    \n    title = {Google Research - Identify Contrails to Reduce Global Warming},\n    \n    publisher = {Kaggle},\n    \n    year = {2023},\n    \n    url = {https://kaggle.com/competitions/google-research-identify-contrails-reduce-global-warming}","metadata":{}},{"cell_type":"markdown","source":"#Software to prevent Contrails from being created.\n\n\"A British company is working on technology which would reduce the number of contrails produced by airplanes in a bid to cut the environmental impact of air travel.\"\n\n\"A computer system built by Cambridge-based Satavia will reroute flights to avoid areas where contrails form.\" \n\n\"This process, it claims, will prevent contrails from being created and therefore eradicate the detrimental environmental impact they have.\"\n\n![](https://i.dailymail.co.uk/1s/2021/04/12/10/41644720-0-image-a-2_1618219697399.jpg)\n\nhttps://www.dailymail.co.uk/sciencetech/article-9461243/British-company-building-software-eradicate-contrails.html","metadata":{}},{"cell_type":"markdown","source":"#Contrails and their Impact on Global Warming\n\nContrails are human-made cirrus clouds that create a green-house effect and impact global warming.\n\n\nOn average 15% of flights generate contrails in the U.S.\n\n\nIncreasing cruise flight levels by 2000' to 4000' decreases Net Radiative Forcing by - 92%.\n\n\nFuel burn and CO2 emissions are lower at the higher altitude, so no penalty.\n\nhttps://www.sciencedirect.com/science/article/pii/S2590198219300338","metadata":{}},{"cell_type":"code","source":"import numpy as np # linear algebra\nimport pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\n\nimport tensorflow as tf","metadata":{"execution":{"iopub.status.busy":"2023-05-10T23:07:42.577334Z","iopub.execute_input":"2023-05-10T23:07:42.577742Z","iopub.status.idle":"2023-05-10T23:07:50.757474Z","shell.execute_reply.started":"2023-05-10T23:07:42.577713Z","shell.execute_reply":"2023-05-10T23:07:50.756289Z"},"_kg_hide-output":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"\"High thin clouds are generated by airliners when hot exhaust gases and water vapor from the jet engines mix with cold, humid air to form high thin clouds. These anthropogenic (human made) condensation trails, or “contrails,” create a green-house effect by absorbing or directing back to Earth approximately 33% of emitted outgoing longwave radiation.\"\n\nhttps://www.sciencedirect.com/science/article/pii/S2590198219300338","metadata":{}},{"cell_type":"code","source":"#by Alien https://www.kaggle.com/h053473666/use-tensorflow-tpu-to-decode-npy-files/notebook\n\nimg = np.load('../input/google-research-identify-contrails-reduce-global-warming/train/1000216489776414077/band_13.npy')","metadata":{"execution":{"iopub.status.busy":"2023-05-10T23:10:10.494036Z","iopub.execute_input":"2023-05-10T23:10:10.494846Z","iopub.status.idle":"2023-05-10T23:10:10.585441Z","shell.execute_reply.started":"2023-05-10T23:10:10.494809Z","shell.execute_reply":"2023-05-10T23:10:10.584327Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"img.dtype","metadata":{"execution":{"iopub.status.busy":"2023-05-10T23:10:26.501818Z","iopub.execute_input":"2023-05-10T23:10:26.502642Z","iopub.status.idle":"2023-05-10T23:10:26.510273Z","shell.execute_reply.started":"2023-05-10T23:10:26.502603Z","shell.execute_reply":"2023-05-10T23:10:26.509184Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(img.shape)\nprint(3 * 4096)\nnpshape = 3 * 4096","metadata":{"execution":{"iopub.status.busy":"2023-05-10T23:10:44.452338Z","iopub.execute_input":"2023-05-10T23:10:44.452748Z","iopub.status.idle":"2023-05-10T23:10:44.458601Z","shell.execute_reply.started":"2023-05-10T23:10:44.452709Z","shell.execute_reply":"2023-05-10T23:10:44.457435Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#Airplane ‘Contrails’ Add To Climate Change; Global Warming To Triple By 2050\n\n<iframe width=\"885\" height=\"498\" src=\"https://www.youtube.com/embed/R6UM-M1JGSc\" title=\"Airplane ‘Contrails’ Add To Climate Change; Global Warming To Triple By 2050  #shorts\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" allowfullscreen></iframe>\n\nhttps://www.youtube.com/watch?v=R6UM-M1JGSc","metadata":{}},{"cell_type":"code","source":"img = tf.io.read_file('../input/google-research-identify-contrails-reduce-global-warming/train/1000216489776414077/band_13.npy')","metadata":{"execution":{"iopub.status.busy":"2023-05-10T23:12:10.642905Z","iopub.execute_input":"2023-05-10T23:12:10.644046Z","iopub.status.idle":"2023-05-10T23:12:10.739445Z","shell.execute_reply.started":"2023-05-10T23:12:10.644012Z","shell.execute_reply":"2023-05-10T23:12:10.738616Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#by Alien https://www.kaggle.com/h053473666/use-tensorflow-tpu-to-decode-npy-files/notebook\n\nimg = tf.io.decode_raw(img, tf.float64)","metadata":{"execution":{"iopub.status.busy":"2023-05-10T23:12:38.523217Z","iopub.execute_input":"2023-05-10T23:12:38.523618Z","iopub.status.idle":"2023-05-10T23:12:38.53235Z","shell.execute_reply.started":"2023-05-10T23:12:38.523587Z","shell.execute_reply":"2023-05-10T23:12:38.531389Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"\"The climate impact of air traffic is to a large degree caused by changes in cirrus cloudiness resulting from the formation of contrails. Contrail cirrus radiative forcing is expected to increase significantly over time due to the large projected increases in air traffic. It was taken into account the predicted increase in air traffic volume, changes in propulsion efficiency and emissions, in particular soot emissions, and the modification of the contrail cirrus climate impact due to anthropogenic climate change.\"\n\nhttps://acp.copernicus.org/articles/19/8163/2019/","metadata":{}},{"cell_type":"code","source":"tensorshape = img.shape[0]","metadata":{"execution":{"iopub.status.busy":"2023-05-10T23:12:57.330046Z","iopub.execute_input":"2023-05-10T23:12:57.330443Z","iopub.status.idle":"2023-05-10T23:12:57.335875Z","shell.execute_reply.started":"2023-05-10T23:12:57.330414Z","shell.execute_reply":"2023-05-10T23:12:57.334667Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(img[16:]) # npy value","metadata":{"execution":{"iopub.status.busy":"2023-05-10T23:13:16.315067Z","iopub.execute_input":"2023-05-10T23:13:16.316149Z","iopub.status.idle":"2023-05-10T23:13:16.339244Z","shell.execute_reply.started":"2023-05-10T23:13:16.316117Z","shell.execute_reply":"2023-05-10T23:13:16.338002Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"dtype=32\nremove_len = 1024//dtype\nimg = img[remove_len:]","metadata":{"execution":{"iopub.status.busy":"2023-05-10T23:13:37.989712Z","iopub.execute_input":"2023-05-10T23:13:37.990108Z","iopub.status.idle":"2023-05-10T23:13:37.995391Z","shell.execute_reply.started":"2023-05-10T23:13:37.990075Z","shell.execute_reply":"2023-05-10T23:13:37.994535Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#Code by Nayu. T.S.https://www.kaggle.com/nayuts/let-s-visualize-data-to-understand\n\nimport glob\n\nimport matplotlib.pyplot as plt\nimport numpy as np # linear algebra\nimport pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\nimport plotly.express as px\nimport seaborn as sns\n\n%matplotlib inline  ","metadata":{"_kg_hide-output":true,"execution":{"iopub.status.busy":"2023-05-10T23:46:29.310786Z","iopub.execute_input":"2023-05-10T23:46:29.311192Z","iopub.status.idle":"2023-05-10T23:46:30.427109Z","shell.execute_reply.started":"2023-05-10T23:46:29.31116Z","shell.execute_reply":"2023-05-10T23:46:30.425896Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"!ls ../input/google-research-identify-contrails-reduce-global-warming","metadata":{"execution":{"iopub.status.busy":"2023-05-10T23:49:56.444032Z","iopub.execute_input":"2023-05-10T23:49:56.445056Z","iopub.status.idle":"2023-05-10T23:49:57.557184Z","shell.execute_reply.started":"2023-05-10T23:49:56.445022Z","shell.execute_reply":"2023-05-10T23:49:57.555941Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sub = pd.read_csv(\"../input/google-research-identify-contrails-reduce-global-warming/sample_submission.csv\")\n\nsub.head()","metadata":{"execution":{"iopub.status.busy":"2023-05-10T23:51:48.880199Z","iopub.execute_input":"2023-05-10T23:51:48.880598Z","iopub.status.idle":"2023-05-10T23:51:48.92383Z","shell.execute_reply.started":"2023-05-10T23:51:48.880566Z","shell.execute_reply":"2023-05-10T23:51:48.922713Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#Code by Nayu. T.S.https://www.kaggle.com/nayuts/let-s-visualize-data-to-understand\n\ntrain_id = \"band_13\"\nsignal_array = np.load(f\"../input/google-research-identify-contrails-reduce-global-warming/train/1000216489776414077/{train_id}.npy\")","metadata":{"execution":{"iopub.status.busy":"2023-05-11T00:01:12.215051Z","iopub.execute_input":"2023-05-11T00:01:12.215586Z","iopub.status.idle":"2023-05-11T00:01:12.226365Z","shell.execute_reply.started":"2023-05-11T00:01:12.215555Z","shell.execute_reply":"2023-05-11T00:01:12.225417Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#Code by Dom de Jonge https://www.kaggle.com/domdejonge/sample-code\n\nplot = np.load(\"../input/google-research-identify-contrails-reduce-global-warming/train/1000216489776414077/band_13.npy\")\nplt.plot(plot[0])\nplt.title('band_13.npy');","metadata":{"execution":{"iopub.status.busy":"2023-05-11T00:02:49.778094Z","iopub.execute_input":"2023-05-11T00:02:49.779051Z","iopub.status.idle":"2023-05-11T00:02:50.083654Z","shell.execute_reply.started":"2023-05-11T00:02:49.779018Z","shell.execute_reply":"2023-05-11T00:02:50.082597Z"},"_kg_hide-output":false,"_kg_hide-input":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#Code by Dom de Jonge https://www.kaggle.com/domdejonge/sample-code\n\nplot = np.load(\"../input/google-research-identify-contrails-reduce-global-warming/train/1000216489776414077/band_13.npy\")\nplt.plot(plot[0], color='red')\nplt.title('band_13.npy');","metadata":{"execution":{"iopub.status.busy":"2023-05-11T00:07:51.456613Z","iopub.execute_input":"2023-05-11T00:07:51.45704Z","iopub.status.idle":"2023-05-11T00:07:51.752695Z","shell.execute_reply.started":"2023-05-11T00:07:51.457007Z","shell.execute_reply":"2023-05-11T00:07:51.751772Z"},"_kg_hide-output":false,"_kg_hide-input":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#Code by Dom de Jonge https://www.kaggle.com/domdejonge/sample-code\n\nplot = np.load(\"../input/google-research-identify-contrails-reduce-global-warming/train/1001436206602675989/band_10.npy\")\nplt.plot(plot[0], color='green')\nplt.title('band_10.npy');","metadata":{"execution":{"iopub.status.busy":"2023-05-11T00:10:08.144066Z","iopub.execute_input":"2023-05-11T00:10:08.144502Z","iopub.status.idle":"2023-05-11T00:10:08.529845Z","shell.execute_reply.started":"2023-05-11T00:10:08.144471Z","shell.execute_reply":"2023-05-11T00:10:08.528957Z"},"_kg_hide-output":false,"_kg_hide-input":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#Code by Dom de Jonge https://www.kaggle.com/domdejonge/sample-code\n\nplot = np.load(\"../input/google-research-identify-contrails-reduce-global-warming/train/1000660467359258186/band_12.npy\")\nplt.plot(plot[0], color='purple')\nplt.title('band_12.npy');","metadata":{"execution":{"iopub.status.busy":"2023-05-11T00:11:42.817969Z","iopub.execute_input":"2023-05-11T00:11:42.818383Z","iopub.status.idle":"2023-05-11T00:11:43.196698Z","shell.execute_reply.started":"2023-05-11T00:11:42.81835Z","shell.execute_reply":"2023-05-11T00:11:43.195555Z"},"_kg_hide-output":false,"_kg_hide-input":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#Acknowledgements:\n\nDom de Jonge https://www.kaggle.com/domdejonge/sample-code\n\nNayu. T.S.https://www.kaggle.com/nayuts/let-s-visualize-data-to-understand\n\nAlien https://www.kaggle.com/h053473666/use-tensorflow-tpu-to-decode-npy-files/notebook","metadata":{}}]}