|
3 | 3 | {
|
4 | 4 | "cell_type": "code",
|
5 | 5 | "execution_count": 1,
|
6 |
| - "id": "075fe5a0", |
7 |
| - "metadata": {}, |
8 |
| - "outputs": [], |
9 |
| - "source": [ |
10 |
| - "import os\n", |
11 |
| - "from datetime import datetime \n", |
12 |
| - "from datetime import timezone" |
13 |
| - ] |
14 |
| - }, |
15 |
| - { |
16 |
| - "cell_type": "code", |
17 |
| - "execution_count": 2, |
18 | 6 | "id": "1251c9f4",
|
19 | 7 | "metadata": {},
|
20 | 8 | "outputs": [],
|
21 | 9 | "source": [
|
| 10 | + "# Application packages\n", |
22 | 11 | "from tabulate import tabulate\n",
|
23 | 12 | "import netCDF4\n",
|
| 13 | + "\n", |
| 14 | + "# stage_in packages\n", |
| 15 | + "from unity_py.resources.collection import Collection\n", |
| 16 | + "\n", |
| 17 | + "# stage_out packages\n", |
| 18 | + "import os\n", |
| 19 | + "import json\n", |
| 20 | + "from datetime import datetime, timezone\n", |
24 | 21 | "from pystac import ItemCollection, Item, Asset"
|
25 | 22 | ]
|
26 | 23 | },
|
27 | 24 | {
|
28 | 25 | "cell_type": "code",
|
29 |
| - "execution_count": 3, |
| 26 | + "execution_count": 2, |
30 | 27 | "id": "04ac7f2d",
|
31 | 28 | "metadata": {
|
32 | 29 | "tags": [
|
|
41 | 38 | "# Filename written to the working directory\n",
|
42 | 39 | "summary_table_filename = \"summary_table.txt\"\n",
|
43 | 40 | "\n",
|
44 |
| - "# Examples of arbitrary arguments of different data types\n", |
| 41 | + "# Examples of optional arbitrary arguments of different data types\n", |
45 | 42 | "example_argument_int = 1\n",
|
46 | 43 | "example_argument_float = 1.0\n",
|
47 | 44 | "example_argument_string = \"string\"\n",
|
|
61 | 58 | },
|
62 | 59 | {
|
63 | 60 | "cell_type": "code",
|
64 |
| - "execution_count": 4, |
| 61 | + "execution_count": 3, |
65 | 62 | "id": "2eeaa5d4",
|
66 | 63 | "metadata": {},
|
67 | 64 | "outputs": [
|
|
85 | 82 | "'<table>\\n<thead>\\n<tr><th>argument_name </th><th>type </th><th>value </th></tr>\\n</thead>\\n<tbody>\\n<tr><td>example_argument_int </td><td><class 'int'> </td><td>1 </td></tr>\\n<tr><td>example_argument_float </td><td><class 'float'> </td><td>1.0 </td></tr>\\n<tr><td>example_argument_string</td><td><class 'str'> </td><td>string </td></tr>\\n<tr><td>example_argument_bool </td><td><class 'bool'> </td><td>True </td></tr>\\n<tr><td>example_argument_empty </td><td><class 'NoneType'></td><td> </td></tr>\\n</tbody>\\n</table>'"
|
86 | 83 | ]
|
87 | 84 | },
|
88 |
| - "execution_count": 4, |
| 85 | + "execution_count": 3, |
89 | 86 | "metadata": {},
|
90 | 87 | "output_type": "execute_result"
|
91 | 88 | }
|
|
120 | 117 | },
|
121 | 118 | {
|
122 | 119 | "cell_type": "code",
|
123 |
| - "execution_count": 5, |
| 120 | + "execution_count": 4, |
124 | 121 | "id": "3a09d57c",
|
125 | 122 | "metadata": {},
|
126 | 123 | "outputs": [],
|
127 | 124 | "source": [
|
128 |
| - "import json\n", |
129 |
| - "\n", |
130 |
| - "with open(input_stac_collection, \"r\") as collection_file:\n", |
131 |
| - " collection = ItemCollection.from_dict(json.load(collection_file))" |
132 |
| - ] |
133 |
| - }, |
134 |
| - { |
135 |
| - "cell_type": "code", |
136 |
| - "execution_count": 6, |
137 |
| - "id": "72b03749", |
138 |
| - "metadata": {}, |
139 |
| - "outputs": [], |
140 |
| - "source": [ |
141 |
| - "data_filenames = []\n", |
142 |
| - "for item in collection.items:\n", |
143 |
| - " for asset_key in item.assets:\n", |
144 |
| - " asset = item.assets[asset_key]\n", |
145 |
| - " data_filenames.append(asset.href)" |
| 125 | + "inp_collection = Collection.from_stac(input_stac_collection)\n", |
| 126 | + "data_filenames = inp_collection.data_locations()" |
146 | 127 | ]
|
147 | 128 | },
|
148 | 129 | {
|
|
157 | 138 | },
|
158 | 139 | {
|
159 | 140 | "cell_type": "code",
|
160 |
| - "execution_count": 7, |
| 141 | + "execution_count": 5, |
161 | 142 | "id": "9fbac209",
|
162 | 143 | "metadata": {},
|
163 | 144 | "outputs": [],
|
|
177 | 158 | },
|
178 | 159 | {
|
179 | 160 | "cell_type": "code",
|
180 |
| - "execution_count": 8, |
| 161 | + "execution_count": 6, |
181 | 162 | "id": "d22c8670",
|
182 | 163 | "metadata": {},
|
183 | 164 | "outputs": [],
|
|
194 | 175 | },
|
195 | 176 | {
|
196 | 177 | "cell_type": "code",
|
197 |
| - "execution_count": 9, |
| 178 | + "execution_count": 7, |
198 | 179 | "id": "3344bd15",
|
199 | 180 | "metadata": {},
|
200 | 181 | "outputs": [
|
|
215 | 196 | "'<table>\\n<thead>\\n<tr><th>product_name </th><th>product_name_type_id </th><th>shortname </th><th>product_version </th><th>date_created </th><th>time_coverage_start </th><th>time_coverage_end </th><th style=\"text-align: right;\"> geospatial_lat_mid</th><th style=\"text-align: right;\"> geospatial_lon_mid</th></tr>\\n</thead>\\n<tbody>\\n<tr><td>SNDR.SS1330.CHIRP.20160822T0005.m06.g001.L1_AQ.std.v02_48.G.200425095850.nc</td><td>L1_AQ </td><td>SNDR13CHRP1</td><td>v02.48.00 </td><td>2021-04-25T05:59:08Z</td><td>2016-08-22T00:05:22Z </td><td>2016-08-22T00:11:22Z</td><td style=\"text-align: right;\"> -48.6062</td><td style=\"text-align: right;\"> 12.4563 </td></tr>\\n<tr><td>SNDR.SS1330.CHIRP.20160822T0011.m06.g002.L1_AQ.std.v02_48.G.200425095901.nc</td><td>L1_AQ </td><td>SNDR13CHRP1</td><td>v02.48.00 </td><td>2021-04-25T05:59:19Z</td><td>2016-08-22T00:11:22Z </td><td>2016-08-22T00:17:22Z</td><td style=\"text-align: right;\"> -69.3979</td><td style=\"text-align: right;\"> -1.98753</td></tr>\\n</tbody>\\n</table>'"
|
216 | 197 | ]
|
217 | 198 | },
|
218 |
| - "execution_count": 9, |
| 199 | + "execution_count": 7, |
219 | 200 | "metadata": {},
|
220 | 201 | "output_type": "execute_result"
|
221 | 202 | }
|
222 | 203 | ],
|
223 | 204 | "source": [
|
| 205 | + "# Output the table in html format\n", |
224 | 206 | "tabulate(table_data, headers=column_names, tablefmt='html')"
|
225 | 207 | ]
|
226 | 208 | },
|
227 | 209 | {
|
228 | 210 | "cell_type": "code",
|
229 |
| - "execution_count": 10, |
| 211 | + "execution_count": 8, |
230 | 212 | "id": "014257f3",
|
231 | 213 | "metadata": {},
|
232 | 214 | "outputs": [],
|
233 | 215 | "source": [
|
| 216 | + "# Write the table in text format\n", |
234 | 217 | "with open(summary_table_filename, \"w\") as summary_file:\n",
|
235 | 218 | " summary_file.write(tabulate(table_data, headers=column_names))"
|
236 | 219 | ]
|
|
245 | 228 | },
|
246 | 229 | {
|
247 | 230 | "cell_type": "code",
|
248 |
| - "execution_count": 11, |
249 |
| - "id": "b48d4ffd", |
| 231 | + "execution_count": 9, |
| 232 | + "id": "1029f88c", |
250 | 233 | "metadata": {},
|
251 | 234 | "outputs": [],
|
252 | 235 | "source": [
|
|
272 | 255 | },
|
273 | 256 | {
|
274 | 257 | "cell_type": "code",
|
275 |
| - "execution_count": 12, |
276 |
| - "id": "f63f5499", |
| 258 | + "execution_count": 10, |
| 259 | + "id": "504c9271", |
277 | 260 | "metadata": {},
|
278 | 261 | "outputs": [],
|
279 | 262 | "source": [
|
|
0 commit comments