|
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_stac_catalog_dir` has the `# type: stage-in` annotation. This variable tells your algorithm the name of the directory where to read inputs from. At run time it will be populated with a STAC catalog and the files it references. The application generator process will connect your variable name to the special `input` parameter in automatically generated CWL files.\n", |
| 36 | + "* `output_stac_catalog_dir` has the `# type: stage-out` annotation. This is a directory where 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. The application generator process will connect your variable name to the special `output` parameter in automatically generated CWL files." |
| 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_stac_catalog_dir = 'test/stage_in/' # type: stage-in\n", |
| 55 | + "output_stac_catalog_dir = '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": 3, |
| 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_stac_catalog_dir, \"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": 4, |
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": 4, |
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": 5, |
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 | + "['test/stage_in/SNDR.SS1330.CHIRP.20160822T0005.m06.g001.L1_AQ.std.v02_48.G.200425095850.nc',\n", |
| 169 | + " '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": 5, |
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 |
| - "data_filenames" |
| 181 | + "# Scrub base part of path so it is not displayed in Github with a home directory prefix\n", |
| 182 | + "[ os.path.relpath(fn, os.curdir) for fn in data_filenames ]" |
146 | 183 | ]
|
147 | 184 | },
|
148 | 185 | {
|
|
157 | 194 | },
|
158 | 195 | {
|
159 | 196 | "cell_type": "code",
|
160 |
| - "execution_count": 5, |
| 197 | + "execution_count": 6, |
161 | 198 | "id": "9fbac209",
|
162 | 199 | "metadata": {},
|
163 | 200 | "outputs": [],
|
|
177 | 214 | },
|
178 | 215 | {
|
179 | 216 | "cell_type": "code",
|
180 |
| - "execution_count": 6, |
| 217 | + "execution_count": 7, |
181 | 218 | "id": "d22c8670",
|
182 | 219 | "metadata": {},
|
183 | 220 | "outputs": [],
|
|
194 | 231 | },
|
195 | 232 | {
|
196 | 233 | "cell_type": "code",
|
197 |
| - "execution_count": 7, |
| 234 | + "execution_count": 8, |
198 | 235 | "id": "3344bd15",
|
199 | 236 | "metadata": {},
|
200 | 237 | "outputs": [
|
|
215 | 252 | "'<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 | 253 | ]
|
217 | 254 | },
|
218 |
| - "execution_count": 7, |
| 255 | + "execution_count": 8, |
219 | 256 | "metadata": {},
|
220 | 257 | "output_type": "execute_result"
|
221 | 258 | }
|
|
227 | 264 | },
|
228 | 265 | {
|
229 | 266 | "cell_type": "code",
|
230 |
| - "execution_count": 8, |
| 267 | + "execution_count": 9, |
231 | 268 | "id": "014257f3",
|
232 | 269 | "metadata": {},
|
233 | 270 | "outputs": [],
|
|
249 | 286 | },
|
250 | 287 | {
|
251 | 288 | "cell_type": "code",
|
252 |
| - "execution_count": 9, |
| 289 | + "execution_count": 10, |
253 | 290 | "id": "b4aa5d3b",
|
254 |
| - "metadata": {}, |
| 291 | + "metadata": { |
| 292 | + "editable": true, |
| 293 | + "slideshow": { |
| 294 | + "slide_type": "" |
| 295 | + }, |
| 296 | + "tags": [] |
| 297 | + }, |
255 | 298 | "outputs": [],
|
256 | 299 | "source": [
|
257 | 300 | "# Create a collection\n",
|
|
261 | 304 | "dataset = Dataset(\n",
|
262 | 305 | " name=summary_table_filename, \n",
|
263 | 306 | " collection_id=out_collection.collection_id, \n",
|
264 |
| - " start_time=datetime.utcnow().replace(tzinfo=timezone.utc).isoformat(), \n", |
265 |
| - " end_time=datetime.utcnow().replace(tzinfo=timezone.utc).isoformat(),\n", |
266 |
| - " creation_time=datetime.utcnow().replace(tzinfo=timezone.utc).isoformat(),\n", |
| 307 | + " start_time=datetime.now(timezone.utc).isoformat(), \n", |
| 308 | + " end_time=datetime.now(timezone.utc).isoformat(),\n", |
| 309 | + " creation_time=datetime.now(timezone.utc).isoformat(),\n", |
267 | 310 | ")\n",
|
268 | 311 | "\n",
|
269 | 312 | "# Add output file(s) to the dataset\n",
|
270 | 313 | "dataset.add_data_file(DataFile(\"csv\", summary_table_filename, [\"data\"]))\n",
|
271 | 314 | "\n",
|
272 | 315 | "#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", |
| 316 | + "dataset.add_data_file(DataFile(\"json\", os.path.join(output_stac_catalog_dir, summary_table_filename + '.json'), [\"metadata\"] ))\n", |
274 | 317 | "\n",
|
275 | 318 | "\n",
|
276 | 319 | "# Add the dataset to the collection\n",
|
|
279 | 322 | "\n",
|
280 | 323 | "Collection.to_stac(out_collection, output_stac_catalog_dir)"
|
281 | 324 | ]
|
282 |
| - }, |
283 |
| - { |
284 |
| - "cell_type": "code", |
285 |
| - "execution_count": null, |
286 |
| - "id": "14f240b6-b5ea-4bf8-8764-ecf12eee6c16", |
287 |
| - "metadata": {}, |
288 |
| - "outputs": [], |
289 |
| - "source": [] |
290 | 325 | }
|
291 | 326 | ],
|
292 | 327 | "metadata": {
|
293 | 328 | "celltoolbar": "Tags",
|
294 | 329 | "kernelspec": {
|
295 |
| - "display_name": "Python 3 (ipykernel)", |
| 330 | + "display_name": "Python 3", |
296 | 331 | "language": "python",
|
297 | 332 | "name": "python3"
|
298 | 333 | },
|
|
306 | 341 | "name": "python",
|
307 | 342 | "nbconvert_exporter": "python",
|
308 | 343 | "pygments_lexer": "ipython3",
|
309 |
| - "version": "3.8.18" |
| 344 | + "version": "3.12.4" |
310 | 345 | }
|
311 | 346 | },
|
312 | 347 | "nbformat": 4,
|
|
0 commit comments