Delete example_raw/load_ssl4eo_s.ipynb
Browse files- example_raw/load_ssl4eo_s.ipynb +0 -218
example_raw/load_ssl4eo_s.ipynb
DELETED
|
@@ -1,218 +0,0 @@
|
|
| 1 |
-
{
|
| 2 |
-
"cells": [
|
| 3 |
-
{
|
| 4 |
-
"cell_type": "markdown",
|
| 5 |
-
"metadata": {},
|
| 6 |
-
"source": [
|
| 7 |
-
"### Load from raw data (geotif)"
|
| 8 |
-
]
|
| 9 |
-
},
|
| 10 |
-
{
|
| 11 |
-
"cell_type": "code",
|
| 12 |
-
"execution_count": 1,
|
| 13 |
-
"metadata": {},
|
| 14 |
-
"outputs": [],
|
| 15 |
-
"source": [
|
| 16 |
-
"import torch\n",
|
| 17 |
-
"import kornia\n",
|
| 18 |
-
"import numpy as np\n",
|
| 19 |
-
"from kornia.augmentation import AugmentationSequential\n",
|
| 20 |
-
"from torch.utils.data import Dataset, DataLoader\n",
|
| 21 |
-
"from ssl4eo_s_dataset import SSL4EO_S\n",
|
| 22 |
-
"import time"
|
| 23 |
-
]
|
| 24 |
-
},
|
| 25 |
-
{
|
| 26 |
-
"cell_type": "code",
|
| 27 |
-
"execution_count": 2,
|
| 28 |
-
"metadata": {},
|
| 29 |
-
"outputs": [],
|
| 30 |
-
"source": [
|
| 31 |
-
"fnames_path = '../data/example_100_grids_cleaned/fnames_sampled_cleaned.json.gz'\n",
|
| 32 |
-
"root_dir = '../data/example_100_grids_cleaned/'"
|
| 33 |
-
]
|
| 34 |
-
},
|
| 35 |
-
{
|
| 36 |
-
"cell_type": "code",
|
| 37 |
-
"execution_count": 4,
|
| 38 |
-
"metadata": {},
|
| 39 |
-
"outputs": [
|
| 40 |
-
{
|
| 41 |
-
"name": "stdout",
|
| 42 |
-
"output_type": "stream",
|
| 43 |
-
"text": [
|
| 44 |
-
"Grid ID: 0685159_109.75_28.75\n",
|
| 45 |
-
"Grid ID: 0661743_15.75_24.75\n",
|
| 46 |
-
"Grid ID: 0644832_108.00_21.75\n",
|
| 47 |
-
"Grid ID: 0818849_52.25_52.00\n",
|
| 48 |
-
"Grid ID: 0351810_-67.50_-29.00\n",
|
| 49 |
-
"Grid ID: 0602947_76.75_14.50\n",
|
| 50 |
-
"Grid ID: 0906994_128.50_67.25\n",
|
| 51 |
-
"Grid ID: 0436848_-48.00_-14.25\n",
|
| 52 |
-
"Grid ID: 0774040_10.00_44.25\n",
|
| 53 |
-
"Grid ID: 0452591_-72.25_-11.50\n",
|
| 54 |
-
"Grid ID: 0653390_87.50_23.25\n",
|
| 55 |
-
"Grid ID: 0485853_-36.75_-5.75\n",
|
| 56 |
-
"Grid ID: 0421706_126.50_-17.00\n",
|
| 57 |
-
"Grid ID: 0846377_94.25_56.75\n",
|
| 58 |
-
"Grid ID: 0828442_-69.50_53.75\n",
|
| 59 |
-
"Grid ID: 0458494_-36.50_-10.50\n",
|
| 60 |
-
"Grid ID: 0726869_97.25_36.00\n",
|
| 61 |
-
"Grid ID: 0419942_45.50_-17.25\n",
|
| 62 |
-
"Grid ID: 0757070_87.50_41.25\n",
|
| 63 |
-
"Grid ID: 0536127_-68.25_3.00\n",
|
| 64 |
-
"Grid ID: 0366272_-52.00_-26.50\n",
|
| 65 |
-
"Grid ID: 0442952_38.00_-13.25\n",
|
| 66 |
-
"Grid ID: 0388675_148.75_-22.75\n",
|
| 67 |
-
"Grid ID: 0711658_-105.50_33.50\n",
|
| 68 |
-
"Grid ID: 0852399_159.75_57.75\n",
|
| 69 |
-
"Grid ID: 0786984_6.00_46.50\n",
|
| 70 |
-
"Grid ID: 0609868_7.00_15.75\n",
|
| 71 |
-
"Grid ID: 0639046_101.50_20.75\n",
|
| 72 |
-
"Grid ID: 0693560_50.00_30.25\n",
|
| 73 |
-
"Grid ID: 0806728_-98.00_50.00\n",
|
| 74 |
-
"Grid ID: 0747025_96.25_39.50\n",
|
| 75 |
-
"Grid ID: 0715237_69.25_34.00\n",
|
| 76 |
-
"Grid ID: 0404465_136.25_-20.00\n",
|
| 77 |
-
"Grid ID: 0765751_97.75_42.75\n",
|
| 78 |
-
"Grid ID: 0666369_92.25_25.50\n",
|
| 79 |
-
"Grid ID: 0442523_-69.25_-13.25\n",
|
| 80 |
-
"Grid ID: 0557752_-62.00_6.75\n",
|
| 81 |
-
"Grid ID: 0483681_140.25_-6.25\n",
|
| 82 |
-
"Grid ID: 0864309_-102.75_60.00\n",
|
| 83 |
-
"Grid ID: 0726037_-110.75_36.00\n",
|
| 84 |
-
"Grid ID: 0813333_113.25_51.00\n",
|
| 85 |
-
"Grid ID: 0634355_8.75_20.00\n",
|
| 86 |
-
"Grid ID: 0664887_81.75_25.25\n",
|
| 87 |
-
"Grid ID: 0710978_84.50_33.25\n",
|
| 88 |
-
"Grid ID: 0686399_59.75_29.00\n",
|
| 89 |
-
"Grid ID: 0723777_44.25_35.50\n",
|
| 90 |
-
"Grid ID: 0857128_-98.00_58.75\n",
|
| 91 |
-
"Grid ID: 0494484_-39.00_-4.25\n",
|
| 92 |
-
"Grid ID: 0894362_-149.50_65.25\n",
|
| 93 |
-
"Grid ID: 0483549_107.25_-6.25\n",
|
| 94 |
-
"Grid ID: 0295191_177.75_-39.00\n",
|
| 95 |
-
"Grid ID: 0706643_80.75_32.50\n",
|
| 96 |
-
"Grid ID: 0653323_70.75_23.25\n",
|
| 97 |
-
"Grid ID: 0535351_97.75_2.75\n",
|
| 98 |
-
"Grid ID: 0847024_-104.00_57.00\n",
|
| 99 |
-
"Grid ID: 0472887_-38.25_-8.00\n",
|
| 100 |
-
"Grid ID: 0729643_70.75_36.50\n",
|
| 101 |
-
"Grid ID: 0772176_-96.00_44.00\n",
|
| 102 |
-
"Grid ID: 0745484_71.00_39.25\n",
|
| 103 |
-
"Grid ID: 0881585_-103.75_63.00\n",
|
| 104 |
-
"Grid ID: 0819002_90.50_52.00\n",
|
| 105 |
-
"Grid ID: 0679995_-101.25_28.00\n",
|
| 106 |
-
"Grid ID: 0784419_84.75_46.00\n",
|
| 107 |
-
"Grid ID: 0572425_6.25_9.25\n",
|
| 108 |
-
"Grid ID: 0697807_31.75_31.00\n",
|
| 109 |
-
"Grid ID: 0546588_27.00_4.75\n",
|
| 110 |
-
"Grid ID: 0772634_18.50_44.00\n",
|
| 111 |
-
"Grid ID: 0414141_35.25_-18.25\n",
|
| 112 |
-
"Grid ID: 0680382_-4.50_28.00\n",
|
| 113 |
-
"Grid ID: 0730483_-79.25_36.75\n",
|
| 114 |
-
"Grid ID: 0817701_125.25_51.75\n",
|
| 115 |
-
"Grid ID: 0648708_-3.00_22.50\n",
|
| 116 |
-
"Grid ID: 0911614_-156.50_68.25\n",
|
| 117 |
-
"Grid ID: 0734741_-94.75_37.50\n",
|
| 118 |
-
"Grid ID: 0849078_49.50_57.25\n",
|
| 119 |
-
"Grid ID: 0445380_-75.00_-12.75\n",
|
| 120 |
-
"Grid ID: 0805860_45.00_49.75\n",
|
| 121 |
-
"Grid ID: 0902681_130.25_66.50\n",
|
| 122 |
-
"Grid ID: 0533572_13.00_2.50\n",
|
| 123 |
-
"Grid ID: 0680734_83.50_28.00\n",
|
| 124 |
-
"Grid ID: 0684932_53.00_28.75\n",
|
| 125 |
-
"Grid ID: 0438282_-49.50_-14.00\n",
|
| 126 |
-
"Grid ID: 0784237_39.25_46.00\n",
|
| 127 |
-
"Grid ID: 0320991_147.75_-34.50\n",
|
| 128 |
-
"Grid ID: 0618779_74.75_17.25\n",
|
| 129 |
-
"Time: 85.03972792625427\n"
|
| 130 |
-
]
|
| 131 |
-
}
|
| 132 |
-
],
|
| 133 |
-
"source": [
|
| 134 |
-
"transform_s1 = AugmentationSequential(\n",
|
| 135 |
-
" #kornia.augmentation.SmallestMaxSize(264),\n",
|
| 136 |
-
" kornia.augmentation.CenterCrop(224),\n",
|
| 137 |
-
")\n",
|
| 138 |
-
"transform_s2 = AugmentationSequential(\n",
|
| 139 |
-
" #kornia.augmentation.SmallestMaxSize(264),\n",
|
| 140 |
-
" kornia.augmentation.CenterCrop(224),\n",
|
| 141 |
-
")\n",
|
| 142 |
-
"transform_s3 = AugmentationSequential(\n",
|
| 143 |
-
" kornia.augmentation.SmallestMaxSize(96),\n",
|
| 144 |
-
" kornia.augmentation.CenterCrop(96),\n",
|
| 145 |
-
")\n",
|
| 146 |
-
"transform_s5p = AugmentationSequential(\n",
|
| 147 |
-
" kornia.augmentation.SmallestMaxSize(28),\n",
|
| 148 |
-
" kornia.augmentation.CenterCrop(28),\n",
|
| 149 |
-
")\n",
|
| 150 |
-
"transform_dem = AugmentationSequential(\n",
|
| 151 |
-
" kornia.augmentation.SmallestMaxSize(960),\n",
|
| 152 |
-
" kornia.augmentation.CenterCrop(960),\n",
|
| 153 |
-
")\n",
|
| 154 |
-
"\n",
|
| 155 |
-
"ssl4eo_s = SSL4EO_S(fnames_path, root_dir, transform_s1=transform_s1, transform_s2=transform_s2, transform_s3=transform_s3, transform_s5p=transform_s5p, transform_dem=transform_dem)\n",
|
| 156 |
-
"dataloader = DataLoader(ssl4eo_s, batch_size=1, shuffle=True, num_workers=4) # batch size can only be 1 because of varying number of images per grid\n",
|
| 157 |
-
"\n",
|
| 158 |
-
"start_time = time.time()\n",
|
| 159 |
-
"\n",
|
| 160 |
-
"for i, (sample, meta_data) in enumerate(dataloader):\n",
|
| 161 |
-
" pass\n",
|
| 162 |
-
" #print('Grid ID:', meta_data['dem'][0])\n",
|
| 163 |
-
" # print(sample.keys())\n",
|
| 164 |
-
" # print(meta_data.keys())\n",
|
| 165 |
-
"\n",
|
| 166 |
-
" \n",
|
| 167 |
-
" # print('### S1 GRD ###')\n",
|
| 168 |
-
" # print('Number of s1 local patches:', len(meta_data['s1_grd']), ' ', 'Number of time stamps for first local patch:', len(meta_data['s1_grd'][0]))\n",
|
| 169 |
-
" # print('Example for one image:', sample['s1_grd'][0][0].shape, meta_data['s1_grd'][0][0])\n",
|
| 170 |
-
" # print('### S2 TOA ###')\n",
|
| 171 |
-
" # print('Number of s2 local patches:', len(meta_data['s2_toa']), ' ', 'Number of time stamps for first local patch:', len(meta_data['s2_toa'][0]))\n",
|
| 172 |
-
" # print('Example for one image:', sample['s2_toa'][0][0].shape, meta_data['s2_toa'][0][0])\n",
|
| 173 |
-
" # print('### S3 OLCI ###')\n",
|
| 174 |
-
" # print('Number of s3 time stamps:', len(meta_data['s3_olci']))\n",
|
| 175 |
-
" # print('Example for one image:', sample['s3_olci'][0].shape, meta_data['s3_olci'][0])\n",
|
| 176 |
-
" # print('### S5P ###')\n",
|
| 177 |
-
" # print('Number of s5p time stamps for CO/NO2/O3/SO2:', len(meta_data['s5p_co']), len(meta_data['s5p_no2']), len(meta_data['s5p_o3']), len(meta_data['s5p_so2']))\n",
|
| 178 |
-
" # print('Example for one CO image:', sample['s5p_co'][0].shape, meta_data['s5p_co'][0])\n",
|
| 179 |
-
" # print('Example for one NO2 image:', sample['s5p_no2'][0].shape, meta_data['s5p_no2'][0])\n",
|
| 180 |
-
" # print('Example for one O3 image:', sample['s5p_o3'][0].shape, meta_data['s5p_o3'][0])\n",
|
| 181 |
-
" # print('Example for one SO2 image:', sample['s5p_so2'][0].shape, meta_data['s5p_so2'][0])\n",
|
| 182 |
-
" # print('### DEM ###')\n",
|
| 183 |
-
" # print('One DEM image for the grid:', sample['dem'].shape, meta_data['dem'][0])\n",
|
| 184 |
-
" # break\n",
|
| 185 |
-
"\n",
|
| 186 |
-
"print('Time:', time.time()-start_time)"
|
| 187 |
-
]
|
| 188 |
-
},
|
| 189 |
-
{
|
| 190 |
-
"cell_type": "code",
|
| 191 |
-
"execution_count": null,
|
| 192 |
-
"metadata": {},
|
| 193 |
-
"outputs": [],
|
| 194 |
-
"source": []
|
| 195 |
-
}
|
| 196 |
-
],
|
| 197 |
-
"metadata": {
|
| 198 |
-
"kernelspec": {
|
| 199 |
-
"display_name": "pytorch",
|
| 200 |
-
"language": "python",
|
| 201 |
-
"name": "python3"
|
| 202 |
-
},
|
| 203 |
-
"language_info": {
|
| 204 |
-
"codemirror_mode": {
|
| 205 |
-
"name": "ipython",
|
| 206 |
-
"version": 3
|
| 207 |
-
},
|
| 208 |
-
"file_extension": ".py",
|
| 209 |
-
"mimetype": "text/x-python",
|
| 210 |
-
"name": "python",
|
| 211 |
-
"nbconvert_exporter": "python",
|
| 212 |
-
"pygments_lexer": "ipython3",
|
| 213 |
-
"version": "3.10.13"
|
| 214 |
-
}
|
| 215 |
-
},
|
| 216 |
-
"nbformat": 4,
|
| 217 |
-
"nbformat_minor": 2
|
| 218 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|