|
23 | 23 | "from unity_sds_client.resources.data_file import DataFile"
|
24 | 24 | ]
|
25 | 25 | },
|
| 26 | + { |
| 27 | + "cell_type": "markdown", |
| 28 | + "id": "5cb70c6e-a08b-49c4-bbef-13200a18bfda", |
| 29 | + "metadata": {}, |
| 30 | + "source": [ |
| 31 | + "## Parameters Cell\n", |
| 32 | + "\n", |
| 33 | + "The below cell is tagged as a 'paramter' cell. This enables us to overwrite the below values at runtime. There are some special values in the below cell.\n", |
| 34 | + "\n", |
| 35 | + "* `input` is a special name, and it also has the `# type: stage-in` annotation. This should be a directory, and at run time it will be populated with a STAC catalog that contains files that have been staged for your algorithm to reference.\n", |
| 36 | + "* `output` is a special name, and it also has the `# type: stage-out` annotation. This should be treated as a directory to which you write ALL of your output files along with a STAC catalog that references files you would like to persist outside of the algorithm run." |
| 37 | + ] |
| 38 | + }, |
26 | 39 | {
|
27 | 40 | "cell_type": "code",
|
28 | 41 | "execution_count": 2,
|
29 | 42 | "id": "04ac7f2d",
|
30 | 43 | "metadata": {
|
| 44 | + "editable": true, |
| 45 | + "slideshow": { |
| 46 | + "slide_type": "" |
| 47 | + }, |
31 | 48 | "tags": [
|
32 | 49 | "parameters"
|
33 | 50 | ]
|
34 | 51 | },
|
35 | 52 | "outputs": [],
|
36 | 53 | "source": [
|
37 |
| - "input_stac_collection_file = 'test/stage_in/stage_in_results.json' # type: stage-in\n", |
38 |
| - "output_stac_catalog_dir = 'test/process_results/' # type: stage-out\n", |
| 54 | + "input = 'test/stage_in/' # type: stage-in\n", |
| 55 | + "output = 'test/process_results/' # type: stage-out\n", |
39 | 56 | "\n",
|
40 | 57 | "# Filename written to the working directory\n",
|
41 | 58 | "summary_table_filename = \"summary_table.txt\"\n",
|
|
51 | 68 | "example_argument_empty = None # type: string Allow a null value or a string\n"
|
52 | 69 | ]
|
53 | 70 | },
|
| 71 | + { |
| 72 | + "cell_type": "code", |
| 73 | + "execution_count": 8, |
| 74 | + "id": "62471f5d-d898-46c1-89c1-b572851db551", |
| 75 | + "metadata": {}, |
| 76 | + "outputs": [ |
| 77 | + { |
| 78 | + "name": "stdout", |
| 79 | + "output_type": "stream", |
| 80 | + "text": [ |
| 81 | + "reading test/stage_in/catalog.json\n" |
| 82 | + ] |
| 83 | + } |
| 84 | + ], |
| 85 | + "source": [ |
| 86 | + "input_catalog = os.path.join(input, \"catalog.json\")\n", |
| 87 | + "print(\"reading {}\".format(input_catalog))" |
| 88 | + ] |
| 89 | + }, |
54 | 90 | {
|
55 | 91 | "cell_type": "markdown",
|
56 | 92 | "id": "7926d21b",
|
|
63 | 99 | },
|
64 | 100 | {
|
65 | 101 | "cell_type": "code",
|
66 |
| - "execution_count": 3, |
| 102 | + "execution_count": 10, |
67 | 103 | "id": "2eeaa5d4",
|
68 | 104 | "metadata": {},
|
69 | 105 | "outputs": [
|
|
87 | 123 | "'<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>'"
|
88 | 124 | ]
|
89 | 125 | },
|
90 |
| - "execution_count": 3, |
| 126 | + "execution_count": 10, |
91 | 127 | "metadata": {},
|
92 | 128 | "output_type": "execute_result"
|
93 | 129 | }
|
|
122 | 158 | },
|
123 | 159 | {
|
124 | 160 | "cell_type": "code",
|
125 |
| - "execution_count": 4, |
| 161 | + "execution_count": 11, |
126 | 162 | "id": "3a09d57c",
|
127 | 163 | "metadata": {},
|
128 | 164 | "outputs": [
|
129 | 165 | {
|
130 | 166 | "data": {
|
131 | 167 | "text/plain": [
|
132 |
| - "['/home/jovyan/unity-example-application/test/stage_in/./SNDR.SS1330.CHIRP.20160822T0005.m06.g001.L1_AQ.std.v02_48.G.200425095850.nc',\n", |
133 |
| - " '/home/jovyan/unity-example-application/test/stage_in/./SNDR.SS1330.CHIRP.20160822T0011.m06.g002.L1_AQ.std.v02_48.G.200425095901.nc']" |
| 168 | + "['/Users/gangl/dev/unity/unity-OGC-example-application/test/stage_in/./SNDR.SS1330.CHIRP.20160822T0005.m06.g001.L1_AQ.std.v02_48.G.200425095850.nc',\n", |
| 169 | + " '/Users/gangl/dev/unity/unity-OGC-example-application/test/stage_in/./SNDR.SS1330.CHIRP.20160822T0011.m06.g002.L1_AQ.std.v02_48.G.200425095901.nc']" |
134 | 170 | ]
|
135 | 171 | },
|
136 |
| - "execution_count": 4, |
| 172 | + "execution_count": 11, |
137 | 173 | "metadata": {},
|
138 | 174 | "output_type": "execute_result"
|
139 | 175 | }
|
140 | 176 | ],
|
141 | 177 | "source": [
|
142 |
| - "inp_collection = Collection.from_stac(input_stac_collection_file)\n", |
| 178 | + "inp_collection = Collection.from_stac(input_catalog)\n", |
143 | 179 | "data_filenames = inp_collection.data_locations()\n",
|
144 | 180 | "\n",
|
145 | 181 | "data_filenames"
|
|
157 | 193 | },
|
158 | 194 | {
|
159 | 195 | "cell_type": "code",
|
160 |
| - "execution_count": 5, |
| 196 | + "execution_count": 12, |
161 | 197 | "id": "9fbac209",
|
162 | 198 | "metadata": {},
|
163 | 199 | "outputs": [],
|
|
177 | 213 | },
|
178 | 214 | {
|
179 | 215 | "cell_type": "code",
|
180 |
| - "execution_count": 6, |
| 216 | + "execution_count": 13, |
181 | 217 | "id": "d22c8670",
|
182 | 218 | "metadata": {},
|
183 | 219 | "outputs": [],
|
|
194 | 230 | },
|
195 | 231 | {
|
196 | 232 | "cell_type": "code",
|
197 |
| - "execution_count": 7, |
| 233 | + "execution_count": 14, |
198 | 234 | "id": "3344bd15",
|
199 | 235 | "metadata": {},
|
200 | 236 | "outputs": [
|
|
215 | 251 | "'<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 | 252 | ]
|
217 | 253 | },
|
218 |
| - "execution_count": 7, |
| 254 | + "execution_count": 14, |
219 | 255 | "metadata": {},
|
220 | 256 | "output_type": "execute_result"
|
221 | 257 | }
|
|
227 | 263 | },
|
228 | 264 | {
|
229 | 265 | "cell_type": "code",
|
230 |
| - "execution_count": 8, |
| 266 | + "execution_count": 16, |
231 | 267 | "id": "014257f3",
|
232 | 268 | "metadata": {},
|
233 | 269 | "outputs": [],
|
234 | 270 | "source": [
|
235 | 271 | "# Write the table in text format\n",
|
236 |
| - "pathlib.Path(output_stac_catalog_dir).mkdir(parents=True, exist_ok=True)\n", |
237 |
| - "output_filename = os.path.join(output_stac_catalog_dir, summary_table_filename)\n", |
| 272 | + "pathlib.Path(output).mkdir(parents=True, exist_ok=True)\n", |
| 273 | + "output_filename = os.path.join(output, summary_table_filename)\n", |
238 | 274 | "with open(output_filename, \"w\") as summary_file:\n",
|
239 | 275 | " summary_file.write(tabulate(table_data, headers=column_names))"
|
240 | 276 | ]
|
|
249 | 285 | },
|
250 | 286 | {
|
251 | 287 | "cell_type": "code",
|
252 |
| - "execution_count": 9, |
| 288 | + "execution_count": 18, |
253 | 289 | "id": "b4aa5d3b",
|
254 |
| - "metadata": {}, |
| 290 | + "metadata": { |
| 291 | + "editable": true, |
| 292 | + "slideshow": { |
| 293 | + "slide_type": "" |
| 294 | + }, |
| 295 | + "tags": [] |
| 296 | + }, |
255 | 297 | "outputs": [],
|
256 | 298 | "source": [
|
257 | 299 | "# Create a collection\n",
|
|
270 | 312 | "dataset.add_data_file(DataFile(\"csv\", summary_table_filename, [\"data\"]))\n",
|
271 | 313 | "\n",
|
272 | 314 | "#when we run \"to_stac\" below, this file will be generated. this needs to be added to the stac file itself for future reference.\n",
|
273 |
| - "dataset.add_data_file(DataFile(\"json\", output_stac_catalog_dir + \"/\" + summary_table_filename +'.json', [\"metadata\"] ))\n", |
| 315 | + "dataset.add_data_file(DataFile(\"json\", output + \"/\" + summary_table_filename +'.json', [\"metadata\"] ))\n", |
274 | 316 | "\n",
|
275 | 317 | "\n",
|
276 | 318 | "# Add the dataset to the collection\n",
|
277 | 319 | "#out_collection.add_dataset(dataset)\n",
|
278 | 320 | "out_collection._datasets.append(dataset)\n",
|
279 | 321 | "\n",
|
280 |
| - "Collection.to_stac(out_collection, output_stac_catalog_dir)" |
| 322 | + "Collection.to_stac(out_collection, output)" |
281 | 323 | ]
|
282 | 324 | },
|
283 | 325 | {
|
|
306 | 348 | "name": "python",
|
307 | 349 | "nbconvert_exporter": "python",
|
308 | 350 | "pygments_lexer": "ipython3",
|
309 |
| - "version": "3.8.18" |
| 351 | + "version": "3.10.8" |
310 | 352 | }
|
311 | 353 | },
|
312 | 354 | "nbformat": 4,
|
|
0 commit comments