{"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":"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\n# import os\n# for 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","execution":{"iopub.status.busy":"2023-08-02T11:40:25.48895Z","iopub.execute_input":"2023-08-02T11:40:25.489321Z","iopub.status.idle":"2023-08-02T11:40:25.494565Z","shell.execute_reply.started":"2023-08-02T11:40:25.489293Z","shell.execute_reply":"2023-08-02T11:40:25.4937Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"/kaggle/input/google-research-identify-contrails-reduce-global-warming/validation_metadata.json\n/kaggle/input/google-research-identify-contrails-reduce-global-warming/train_metadata.json\n/kaggle/input/google-research-identify-contrails-reduce-global-warming/sample_submission.csv\n/kaggle/input/google-research-identify-contrails-reduce-global-warming/validation/3687499407028137410/band_10.npy\n/kaggle/input/google-research-identify-contrails-reduce-global-warming/validation/3687499407028137410/band_14.npy\n/kaggle/input/google-research-identify-contrails-reduce-global-warming/validation/3687499407028137410/band_15.npy\n/kaggle/input/google-research-identify-contrails-reduce-global-warming/validation/3687499407028137410/band_16.npy\n/kaggle/input/google-research-identify-contrails-reduce-global-warming/validation/3687499407028137410/band_08.npy\n/kaggle/input/google-research-identify-contrails-reduce-global-warming/validation/3687499407028137410/band_09.npy\n/kaggle/input/google-research-identify-contrails-reduce-global-warming/validation/3687499407028137410/band_13.npy\n/kaggle/input/google-research-identify-contrails-reduce-global-warming/validation/3687499407028137410/band_11.npy\n/kaggle/input/google-research-identify-contrails-reduce-global-warming/validation/3687499407028137410/human_pixel_masks.npy","metadata":{}},{"cell_type":"code","source":"import torch\nimport numpy as np\n\ndef load_npy(path):\n  \n  image = np.load(path)\n  image = torch.from_numpy(image)\n  image = image.float()\n  return image\n\ndef main():\n  \n  path = \"\"\n  image = load_npy(path)\n  print(image)","metadata":{"execution":{"iopub.status.busy":"2023-08-02T11:40:25.501472Z","iopub.execute_input":"2023-08-02T11:40:25.502772Z","iopub.status.idle":"2023-08-02T11:40:25.509182Z","shell.execute_reply.started":"2023-08-02T11:40:25.502734Z","shell.execute_reply":"2023-08-02T11:40:25.508202Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"load_npy(\"/kaggle/input/google-research-identify-contrails-reduce-global-warming/validation/3687499407028137410/band_10.npy\")","metadata":{"execution":{"iopub.status.busy":"2023-08-02T11:40:25.510953Z","iopub.execute_input":"2023-08-02T11:40:25.511866Z","iopub.status.idle":"2023-08-02T11:40:25.537449Z","shell.execute_reply.started":"2023-08-02T11:40:25.511834Z","shell.execute_reply":"2023-08-02T11:40:25.536248Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import torch\n\ndef load_npy(path):\n    \n    image = np.load(path)\n    image = torch.from_numpy(image)\n    image = image.float()\n    return image\n\ndef process_image(image):\n    \n    image = image / 255.0\n    image = image.unsqueeze(0)\n    return image\n\nif __name__ == \"__main__\":\n    image_path = \"/kaggle/input/google-research-identify-contrails-reduce-global-warming/validation/3687499407028137410/band_10.npy\"\n    image = load_npy(image_path)\n    image = process_image(image)\n    print(image)","metadata":{"execution":{"iopub.status.busy":"2023-08-02T11:40:25.539486Z","iopub.execute_input":"2023-08-02T11:40:25.539845Z","iopub.status.idle":"2023-08-02T11:40:25.557482Z","shell.execute_reply.started":"2023-08-02T11:40:25.539816Z","shell.execute_reply":"2023-08-02T11:40:25.556486Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# import numpy as np\n# import torch\n# import matplotlib.pyplot as plt\n\n# def plot_npy_image(path):\n#     image = np.load(path)\n#     image = torch.from_numpy(image)\n# #     image = np.reshape(256,256,3)\n#     image = np.squeeze(image, axis=2)\n#     image = image.cpu().detach().numpy()\n#     plt.imshow(image)\n#     plt.show()\n\n# plot_npy_image(\"/kaggle/input/google-research-identify-contrails-reduce-global-warming/validation/3687499407028137410/band_10.npy\")","metadata":{"execution":{"iopub.status.busy":"2023-08-02T11:40:25.558958Z","iopub.execute_input":"2023-08-02T11:40:25.55951Z","iopub.status.idle":"2023-08-02T11:40:25.56686Z","shell.execute_reply.started":"2023-08-02T11:40:25.559477Z","shell.execute_reply":"2023-08-02T11:40:25.565758Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import numpy as np\nimport json\n\ndef merge_files(npy_file, json_file) : \n\n  with open(npy_file, \"rb\") as f:\n    image = np.load(f)\n\n  with open(json_file, \"r\") as f:\n    data = json.load(f)\n\n  merged_data = {\"image\": image, \"data\": data}\n\n  return merged_data\n\nif __name__ == \"__main__\":\n  npy_file = \"/kaggle/input/google-research-identify-contrails-reduce-global-warming/validation/3687499407028137410/band_10.npy\"\n  json_file = \"/kaggle/input/google-research-identify-contrails-reduce-global-warming/validation_metadata.json\"\n\n  merged_data = merge_files(npy_file, json_file)\n\n#   print(merged_data)","metadata":{"execution":{"iopub.status.busy":"2023-08-02T11:40:25.569229Z","iopub.execute_input":"2023-08-02T11:40:25.569835Z","iopub.status.idle":"2023-08-02T11:40:25.6046Z","shell.execute_reply.started":"2023-08-02T11:40:25.569804Z","shell.execute_reply":"2023-08-02T11:40:25.603596Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def datatype(dict_):\n    print(type(dict_))\n\n\ndatatype(merged_data)\nprint(len(merged_data))","metadata":{"execution":{"iopub.status.busy":"2023-08-02T11:40:25.606109Z","iopub.execute_input":"2023-08-02T11:40:25.606707Z","iopub.status.idle":"2023-08-02T11:40:25.612717Z","shell.execute_reply.started":"2023-08-02T11:40:25.606673Z","shell.execute_reply":"2023-08-02T11:40:25.611575Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def key_names(dict_name):\n  \n  for key in dict_name.keys():\n    print(key)\n\n\nkey_names(merged_data)","metadata":{"execution":{"iopub.status.busy":"2023-08-02T11:40:25.614349Z","iopub.execute_input":"2023-08-02T11:40:25.614663Z","iopub.status.idle":"2023-08-02T11:40:25.626245Z","shell.execute_reply.started":"2023-08-02T11:40:25.614636Z","shell.execute_reply":"2023-08-02T11:40:25.62513Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import json\nimport matplotlib.pyplot as plt\n\nwith open('/kaggle/input/google-research-identify-contrails-reduce-global-warming/validation_metadata.json', 'r') as f:\n    data = json.load(f)","metadata":{"execution":{"iopub.status.busy":"2023-08-02T11:40:25.628041Z","iopub.execute_input":"2023-08-02T11:40:25.628475Z","iopub.status.idle":"2023-08-02T11:40:25.661771Z","shell.execute_reply.started":"2023-08-02T11:40:25.628435Z","shell.execute_reply":"2023-08-02T11:40:25.660021Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def datatype(dict_):\n    print(type(dict_))\n\ndatatype(data)\nprint(len(data))","metadata":{"execution":{"iopub.status.busy":"2023-08-02T11:40:25.664746Z","iopub.execute_input":"2023-08-02T11:40:25.665112Z","iopub.status.idle":"2023-08-02T11:40:25.671462Z","shell.execute_reply.started":"2023-08-02T11:40:25.665083Z","shell.execute_reply":"2023-08-02T11:40:25.670183Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"\ndef list_to_dataframe(list_data):\n  \n  column_names = list_data[0]\n  data = list_data[1:]\n  dataframe = pd.DataFrame(data, columns=column_names)\n  return dataframe\n\nif __name__ == '__main__':\n  dataframe = list_to_dataframe(data)\n  print(dataframe)","metadata":{"execution":{"iopub.status.busy":"2023-08-02T11:40:25.672965Z","iopub.execute_input":"2023-08-02T11:40:25.673828Z","iopub.status.idle":"2023-08-02T11:40:25.704568Z","shell.execute_reply.started":"2023-08-02T11:40:25.673785Z","shell.execute_reply":"2023-08-02T11:40:25.703667Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import matplotlib.pyplot as plt\n\ndef npy_image(npy_file):\n    band_images = np.load(npy_file)\n    fig, axes = plt.subplots(nrows=band_images.shape[0], ncols=1, figsize=(10, 10))\n    for i in range(band_images.shape[0]):\n        axes[i].imshow(band_images[i])\n        axes[i].set_title(f\"Band {i+1}\")\n    plt.show()\n\nif __name__ == \"__main__\":\n    npy_file = \"/kaggle/input/google-research-identify-contrails-reduce-global-warming/validation/3687499407028137410/band_11.npy\"\n    npy_image(npy_file)","metadata":{"execution":{"iopub.status.busy":"2023-08-02T11:40:25.705701Z","iopub.execute_input":"2023-08-02T11:40:25.707226Z","iopub.status.idle":"2023-08-02T11:40:59.983184Z","shell.execute_reply.started":"2023-08-02T11:40:25.707178Z","shell.execute_reply":"2023-08-02T11:40:59.981956Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"images = np.load('/kaggle/input/google-research-identify-contrails-reduce-global-warming/train/1013942970059727329/band_10.npy')\nimages.shape","metadata":{"execution":{"iopub.status.busy":"2023-08-02T11:40:59.984808Z","iopub.execute_input":"2023-08-02T11:40:59.985443Z","iopub.status.idle":"2023-08-02T11:40:59.996175Z","shell.execute_reply.started":"2023-08-02T11:40:59.985395Z","shell.execute_reply":"2023-08-02T11:40:59.995005Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import os\nfrom matplotlib import animation\nimport matplotlib.pyplot as plt\nfrom IPython import display","metadata":{"execution":{"iopub.status.busy":"2023-08-02T11:40:59.99779Z","iopub.execute_input":"2023-08-02T11:40:59.998144Z","iopub.status.idle":"2023-08-02T11:41:00.008879Z","shell.execute_reply.started":"2023-08-02T11:40:59.998113Z","shell.execute_reply":"2023-08-02T11:41:00.007493Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# https://www.kaggle.com/code/inversion/visualizing-contrails\n# https://matplotlib.org/stable/api/animation_api.html#animation\n\nBASE_DIR = '/kaggle/input/google-research-identify-contrails-reduce-global-warming/train'\nN_TIMES_BEFORE = 6\nrecord_id = '1704010292581573769'\n\nwith open(os.path.join(BASE_DIR, record_id, 'band_13.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-02T11:41:00.011438Z","iopub.execute_input":"2023-08-02T11:41:00.012092Z","iopub.status.idle":"2023-08-02T11:41:00.042636Z","shell.execute_reply.started":"2023-08-02T11:41:00.011955Z","shell.execute_reply":"2023-08-02T11:41:00.041393Z"},"trusted":true},"execution_count":null,"outputs":[]},{"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-02T11:41:00.046018Z","iopub.execute_input":"2023-08-02T11:41:00.046584Z","iopub.status.idle":"2023-08-02T11:41:00.070013Z","shell.execute_reply.started":"2023-08-02T11:41:00.046548Z","shell.execute_reply":"2023-08-02T11:41:00.068558Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"img = false_color[..., N_TIMES_BEFORE]\n\nplt.figure(figsize=(18, 6))\nax = plt.subplot(1, 3, 1)\nax.imshow(img)\nax.set_title('False color image')\n\nax = plt.subplot(1, 3, 2)\nax.imshow(human_pixel_mask, interpolation='none')\nax.set_title('Ground truth contrail mask')\n\nax = plt.subplot(1, 3, 3)\nax.imshow(img)\nax.imshow(human_pixel_mask, cmap='Reds', alpha=.4, interpolation='none')\nax.set_title('Contrail mask on false color image');","metadata":{"execution":{"iopub.status.busy":"2023-08-02T11:41:00.071677Z","iopub.execute_input":"2023-08-02T11:41:00.072174Z","iopub.status.idle":"2023-08-02T11:41:01.271601Z","shell.execute_reply.started":"2023-08-02T11:41:00.07213Z","shell.execute_reply":"2023-08-02T11:41:01.270157Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"img = false_color[..., N_TIMES_BEFORE]\nfig, ax = plt.subplots()\n# artistanimation object\nani = animation.ArtistAnimation(fig, [ax.imshow(img)], interval=200)\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2023-08-02T11:41:01.273485Z","iopub.execute_input":"2023-08-02T11:41:01.273853Z","iopub.status.idle":"2023-08-02T11:41:01.646239Z","shell.execute_reply.started":"2023-08-02T11:41:01.27382Z","shell.execute_reply":"2023-08-02T11:41:01.644953Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Animation\nfig = plt.figure(figsize=(6, 6))\nim = plt.imshow(false_color[..., 0])\ndef draw(i):\n    im.set_array(false_color[..., i])\n    return [im]\nanim = animation.FuncAnimation(\n    fig, draw, frames=false_color.shape[-1], interval=500, blit=True\n)\nplt.close()\ndisplay.HTML(anim.to_jshtml())","metadata":{"execution":{"iopub.status.busy":"2023-08-02T11:41:01.651294Z","iopub.execute_input":"2023-08-02T11:41:01.651702Z","iopub.status.idle":"2023-08-02T11:41:04.138551Z","shell.execute_reply.started":"2023-08-02T11:41:01.651669Z","shell.execute_reply":"2023-08-02T11:41:04.137585Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from matplotlib.animation import FuncAnimation\n\nfig = plt.figure(figsize=(6, 6))\nim = plt.imshow(false_color[..., 0])\n\ndef init():\n    ax.set_xlim(0, 2*np.pi)\n    ax.set_ylim(-1, 1)\n    return im,\n\ndef update(frame):\n    xdata.append(frame)\n    ydata.append(np.sin(frame))\n    ln.set_data(xdata, ydata)\n    return im,\n\nani = FuncAnimation(fig, update, frames=np.linspace(0, 2*np.pi, 128),\n                    init_func=init, blit=True)\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2023-08-02T11:41:04.139958Z","iopub.execute_input":"2023-08-02T11:41:04.140507Z","iopub.status.idle":"2023-08-02T11:41:04.65195Z","shell.execute_reply.started":"2023-08-02T11:41:04.140474Z","shell.execute_reply":"2023-08-02T11:41:04.650858Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def convert_numpy_to_torch(array):\n    return torch.from_numpy(array)\n\nif __name__ == \"__main__\":\n    img = false_color[..., N_TIMES_BEFORE]\n    tensor = convert_numpy_to_torch(img)\n    print(tensor)","metadata":{"execution":{"iopub.status.busy":"2023-08-02T11:41:04.653684Z","iopub.execute_input":"2023-08-02T11:41:04.654281Z","iopub.status.idle":"2023-08-02T11:41:04.663482Z","shell.execute_reply.started":"2023-08-02T11:41:04.654244Z","shell.execute_reply":"2023-08-02T11:41:04.662346Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# expand() function takes a tensor and a list of sizes, and it repeats the tensor along the dimensions that are not specified. \n# provide a size for the third dimension , do this by either:\n   # Adding a size to the list of sizes.\n   # Setting the size of the third dimension to 1.\ndef expand_tensor(tensor, sizes):\n    return tensor.expand(sizes)\n\nif __name__ == \"__main__\":\n    sizes = [256, 256, 3]\n    expanded_tensor = expand_tensor(tensor, sizes)\n    print(expanded_tensor.shape)","metadata":{"execution":{"iopub.status.busy":"2023-08-02T11:41:04.665283Z","iopub.execute_input":"2023-08-02T11:41:04.665775Z","iopub.status.idle":"2023-08-02T11:41:04.67725Z","shell.execute_reply.started":"2023-08-02T11:41:04.665731Z","shell.execute_reply":"2023-08-02T11:41:04.676312Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def reshape_and_process_image(image_file):\n    image = np.load(image_file)\n\n    # Reshape the image \n    image = image.reshape((1, image.shape[0], image.shape[1], image.shape[2]))\n\n    # Convert the numpy array to a torch tensor.\n    image = torch.from_numpy(image)\n\n    # Normalize pixel values\n    image = image / 255.0\n\n    return image\n\nif __name__ == \"__main__\":\n    # Reshape and process the image file.\n    image = reshape_and_process_image(\"/kaggle/input/google-research-identify-contrails-reduce-global-warming/validation/3687499407028137410/band_13.npy\")\n\n    # Print the shape of the image tensor.\n    print(image.shape)","metadata":{"execution":{"iopub.status.busy":"2023-08-02T11:41:04.678419Z","iopub.execute_input":"2023-08-02T11:41:04.679129Z","iopub.status.idle":"2023-08-02T11:41:04.700544Z","shell.execute_reply.started":"2023-08-02T11:41:04.679094Z","shell.execute_reply":"2023-08-02T11:41:04.699044Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"- Iterate through the files in the directory and check if each file ends with the .npy extension. If it does, the function will load the file as a NumPy array and then create an Image object from the array. Finally, the function will save the Image object as a PNG file in the same directory.","metadata":{}},{"cell_type":"code","source":"import numpy as np\nimport os\nfrom PIL import Image\n\ndef convert_npy_to_png(directory):\n    for file in os.listdir(directory):\n        if file.endswith(\".npy\"):\n            image = np.load(os.path.join(directory, file))\n            image = Image.fromarray(image)\n            image.save(os.path.join(directory, file.replace(\".npy\", \".png\")))\n\nif __name__ == \"__main__\":\n    convert_npy_to_png(\"/kaggle/input/google-research-identify-contrails-reduce-global-warming/train\")","metadata":{"execution":{"iopub.status.busy":"2023-08-02T11:41:04.702298Z","iopub.execute_input":"2023-08-02T11:41:04.702657Z","iopub.status.idle":"2023-08-02T11:41:04.725006Z","shell.execute_reply.started":"2023-08-02T11:41:04.702626Z","shell.execute_reply":"2023-08-02T11:41:04.723845Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"os.makedirs('/kaggle/working/Images')","metadata":{"execution":{"iopub.status.busy":"2023-08-02T11:49:47.596945Z","iopub.execute_input":"2023-08-02T11:49:47.597354Z","iopub.status.idle":"2023-08-02T11:49:47.602726Z","shell.execute_reply.started":"2023-08-02T11:49:47.597322Z","shell.execute_reply":"2023-08-02T11:49:47.601317Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import numpy as np\nimport os\nimport PIL.Image as Image\n\ndef convert_npy_to_png(input_dir, output_dir):\n    for file in os.listdir(input_dir):\n        if file.endswith(\".npy\"):\n            image = np.load(os.path.join(input_dir, file))\n            image = Image.fromarray(image)\n            image.save(os.path.join(output_dir, file.replace(\".npy\", \".png\")))\n\nif __name__ == \"__main__\":\n    input_dir = \"/kaggle/input/google-research-identify-contrails-reduce-global-warming/train\"\n    output_dir = \"/kaggle/working/Images\"\n    convert_npy_to_png(input_dir, output_dir)","metadata":{"execution":{"iopub.status.busy":"2023-08-02T11:49:37.45457Z","iopub.execute_input":"2023-08-02T11:49:37.454997Z","iopub.status.idle":"2023-08-02T11:49:37.478689Z","shell.execute_reply.started":"2023-08-02T11:49:37.454962Z","shell.execute_reply":"2023-08-02T11:49:37.477415Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Load the .npy file\ndata = np.load(\"/kaggle/input/google-research-identify-contrails-reduce-global-warming/train/1000216489776414077/band_11.npy\")\n\n# Process the data\nprocessed_data = data.astype(\"float32\")\nprocessed_data /= 255.0\n\n# Visualize the data\nplt.imshow(processed_data[0])\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2023-08-02T12:02:55.525642Z","iopub.execute_input":"2023-08-02T12:02:55.526386Z","iopub.status.idle":"2023-08-02T12:02:55.791932Z","shell.execute_reply.started":"2023-08-02T12:02:55.52635Z","shell.execute_reply":"2023-08-02T12:02:55.790652Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import json\nimport pandas as pd\nimport matplotlib.pyplot as plt\n\n# Read the JSON file into a Python object\nwith open('/kaggle/input/google-research-identify-contrails-reduce-global-warming/train_metadata.json', 'r') as f:\n    data = json.load(f)\n\n# Create a Pandas DataFrame from the JSON data\ndf = pd.DataFrame(data)\n\n# Plot the data\nplt.interactive(True)\nplt.plot(df[\"col_min\"], df[\"col_size\"])\nplt.plot(df[\"row_min\"], df[\"row_min\"])\nplt.legend()\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2023-08-02T12:20:03.926482Z","iopub.execute_input":"2023-08-02T12:20:03.927237Z","iopub.status.idle":"2023-08-02T12:20:04.437102Z","shell.execute_reply.started":"2023-08-02T12:20:03.927188Z","shell.execute_reply":"2023-08-02T12:20:04.435896Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}