Skip to content

Instantly share code, notes, and snippets.

@rsignell-usgs
Created January 30, 2024 18:11
Show Gist options
  • Save rsignell-usgs/441d6be11104fe173dbec317926174ef to your computer and use it in GitHub Desktop.
Save rsignell-usgs/441d6be11104fe173dbec317926174ef to your computer and use it in GitHub Desktop.
coiled_drift_test.ipynb
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "markdown",
"id": "4b6a0c24-dc55-4a0f-a7aa-10e6d1f70c6d",
"metadata": {},
"source": [
"# OpenDrift horizontal scaling using Coiled"
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "e6f54e92-04fc-4451-86b7-168d196d7364",
"metadata": {},
"outputs": [],
"source": [
"import os\n",
"import tempfile\n",
"import coiled\n",
"import numpy as np\n",
"import xarray as xr\n",
"\n",
"import pandas as pd\n",
"import intake\n",
"from opendrift.readers import reader_ROMS_native\n",
"from opendrift.models.oceandrift import OceanDrift\n",
"import datetime "
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "1f5e89c7-4a8a-4f3a-a782-55c14f65cde4",
"metadata": {},
"outputs": [],
"source": [
"# Step 1: Get a list of all start_dates\n",
"granules = pd.date_range(start='2012-01', end='2012-02', freq='28D').to_pydatetime()"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "0b092106-b00a-4c69-9410-0e123b090202",
"metadata": {
"tags": []
},
"outputs": [
{
"data": {
"text/plain": [
"array([datetime.datetime(2012, 1, 1, 0, 0),\n",
" datetime.datetime(2012, 1, 29, 0, 0)], dtype=object)"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"granules"
]
},
{
"cell_type": "code",
"execution_count": 16,
"id": "72909cd7-9134-40bb-8bf9-6d9411561cb4",
"metadata": {},
"outputs": [],
"source": [
"# Step 2: Create a function to process each file.\n",
"# Load and subset each data granule / file.\n",
"@coiled.function(\n",
" region=\"us-east-1\", # Run in the same region as data\n",
" account='fathom-mgray',\n",
" spot_policy=\"spot_with_fallback\", # Use spot instances when available\n",
" memory=\"16GB\",\n",
" keepalive='5 minutes',\n",
" software='odrift-d7')\n",
"def process(start_time):\n",
" intake_catalog = 'https://mghp.osn.xsede.org/rsignellbucket1/rsignell/CNAPS/cnaps_intake.yml'\n",
" cat = intake.open_catalog(intake_catalog)\n",
" dataset = 'CNAPS_Forecast_Archive_cache' # all years, read from OSN\n",
" dset = cat[dataset]\n",
" dset.kwargs['decode_times'] = False\n",
" ds = dset.read_chunked()\n",
" cnaps = reader_ROMS_native.Reader(ds) \n",
" \n",
" with tempfile.TemporaryDirectory() as tmpdir:\n",
" ncfile = f'{tmpdir}/opendrift_{start_time.strftime(\"%Y%m%d\")}.nc'\n",
" o = OceanDrift(loglevel=50) # Set loglevel to 0 for debug information\n",
" o.add_reader(cnaps)\n",
" o.seed_elements(lon=-70.462, lat=42.807, radius=1000, number=10, \n",
" z=np.linspace(0, -150, 10), time=start_time) \n",
" o.run(time_step=3600, duration=datetime.timedelta(days=7), outfile=ncfile)\n",
" ds = xr.open_dataset(ncfile).load()\n",
" return ds"
]
},
{
"cell_type": "code",
"execution_count": 17,
"id": "6ce27e14-5801-468c-a09b-5ffa04cf0801",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"# run with Distributed locally\n",
"#from dask.distributed import Client\n",
"#client = Client(n_workers=2) # 2 workers @ 8GB on \"large nebari environment\"\n",
"\n",
"#futures = client.map(process, granules)\n",
"#results = client.gather(futures)"
]
},
{
"cell_type": "code",
"execution_count": 25,
"id": "be4dbc93-1358-486e-a763-e7d0f9581888",
"metadata": {},
"outputs": [],
"source": [
"# Step 3: Run Coiled function on each file in parallel\n",
"results = process.map(granules) # This runs on the cloud in parallel"
]
},
{
"cell_type": "code",
"execution_count": 26,
"id": "fcee4615-34f8-497e-a975-34084c6307fe",
"metadata": {},
"outputs": [],
"source": [
"# Step 4: Combine and plot results\n",
"x = list(results)"
]
},
{
"cell_type": "code",
"execution_count": 27,
"id": "63371e28-cb76-4681-9b60-66b339305741",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div><svg style=\"position: absolute; width: 0; height: 0; overflow: hidden\">\n",
"<defs>\n",
"<symbol id=\"icon-database\" viewBox=\"0 0 32 32\">\n",
"<path d=\"M16 0c-8.837 0-16 2.239-16 5v4c0 2.761 7.163 5 16 5s16-2.239 16-5v-4c0-2.761-7.163-5-16-5z\"></path>\n",
"<path d=\"M16 17c-8.837 0-16-2.239-16-5v6c0 2.761 7.163 5 16 5s16-2.239 16-5v-6c0 2.761-7.163 5-16 5z\"></path>\n",
"<path d=\"M16 26c-8.837 0-16-2.239-16-5v6c0 2.761 7.163 5 16 5s16-2.239 16-5v-6c0 2.761-7.163 5-16 5z\"></path>\n",
"</symbol>\n",
"<symbol id=\"icon-file-text2\" viewBox=\"0 0 32 32\">\n",
"<path d=\"M28.681 7.159c-0.694-0.947-1.662-2.053-2.724-3.116s-2.169-2.030-3.116-2.724c-1.612-1.182-2.393-1.319-2.841-1.319h-15.5c-1.378 0-2.5 1.121-2.5 2.5v27c0 1.378 1.122 2.5 2.5 2.5h23c1.378 0 2.5-1.122 2.5-2.5v-19.5c0-0.448-0.137-1.23-1.319-2.841zM24.543 5.457c0.959 0.959 1.712 1.825 2.268 2.543h-4.811v-4.811c0.718 0.556 1.584 1.309 2.543 2.268zM28 29.5c0 0.271-0.229 0.5-0.5 0.5h-23c-0.271 0-0.5-0.229-0.5-0.5v-27c0-0.271 0.229-0.5 0.5-0.5 0 0 15.499-0 15.5 0v7c0 0.552 0.448 1 1 1h7v19.5z\"></path>\n",
"<path d=\"M23 26h-14c-0.552 0-1-0.448-1-1s0.448-1 1-1h14c0.552 0 1 0.448 1 1s-0.448 1-1 1z\"></path>\n",
"<path d=\"M23 22h-14c-0.552 0-1-0.448-1-1s0.448-1 1-1h14c0.552 0 1 0.448 1 1s-0.448 1-1 1z\"></path>\n",
"<path d=\"M23 18h-14c-0.552 0-1-0.448-1-1s0.448-1 1-1h14c0.552 0 1 0.448 1 1s-0.448 1-1 1z\"></path>\n",
"</symbol>\n",
"</defs>\n",
"</svg>\n",
"<style>/* CSS stylesheet for displaying xarray objects in jupyterlab.\n",
" *\n",
" */\n",
"\n",
":root {\n",
" --xr-font-color0: var(--jp-content-font-color0, rgba(0, 0, 0, 1));\n",
" --xr-font-color2: var(--jp-content-font-color2, rgba(0, 0, 0, 0.54));\n",
" --xr-font-color3: var(--jp-content-font-color3, rgba(0, 0, 0, 0.38));\n",
" --xr-border-color: var(--jp-border-color2, #e0e0e0);\n",
" --xr-disabled-color: var(--jp-layout-color3, #bdbdbd);\n",
" --xr-background-color: var(--jp-layout-color0, white);\n",
" --xr-background-color-row-even: var(--jp-layout-color1, white);\n",
" --xr-background-color-row-odd: var(--jp-layout-color2, #eeeeee);\n",
"}\n",
"\n",
"html[theme=dark],\n",
"body[data-theme=dark],\n",
"body.vscode-dark {\n",
" --xr-font-color0: rgba(255, 255, 255, 1);\n",
" --xr-font-color2: rgba(255, 255, 255, 0.54);\n",
" --xr-font-color3: rgba(255, 255, 255, 0.38);\n",
" --xr-border-color: #1F1F1F;\n",
" --xr-disabled-color: #515151;\n",
" --xr-background-color: #111111;\n",
" --xr-background-color-row-even: #111111;\n",
" --xr-background-color-row-odd: #313131;\n",
"}\n",
"\n",
".xr-wrap {\n",
" display: block !important;\n",
" min-width: 300px;\n",
" max-width: 700px;\n",
"}\n",
"\n",
".xr-text-repr-fallback {\n",
" /* fallback to plain text repr when CSS is not injected (untrusted notebook) */\n",
" display: none;\n",
"}\n",
"\n",
".xr-header {\n",
" padding-top: 6px;\n",
" padding-bottom: 6px;\n",
" margin-bottom: 4px;\n",
" border-bottom: solid 1px var(--xr-border-color);\n",
"}\n",
"\n",
".xr-header > div,\n",
".xr-header > ul {\n",
" display: inline;\n",
" margin-top: 0;\n",
" margin-bottom: 0;\n",
"}\n",
"\n",
".xr-obj-type,\n",
".xr-array-name {\n",
" margin-left: 2px;\n",
" margin-right: 10px;\n",
"}\n",
"\n",
".xr-obj-type {\n",
" color: var(--xr-font-color2);\n",
"}\n",
"\n",
".xr-sections {\n",
" padding-left: 0 !important;\n",
" display: grid;\n",
" grid-template-columns: 150px auto auto 1fr 20px 20px;\n",
"}\n",
"\n",
".xr-section-item {\n",
" display: contents;\n",
"}\n",
"\n",
".xr-section-item input {\n",
" display: none;\n",
"}\n",
"\n",
".xr-section-item input + label {\n",
" color: var(--xr-disabled-color);\n",
"}\n",
"\n",
".xr-section-item input:enabled + label {\n",
" cursor: pointer;\n",
" color: var(--xr-font-color2);\n",
"}\n",
"\n",
".xr-section-item input:enabled + label:hover {\n",
" color: var(--xr-font-color0);\n",
"}\n",
"\n",
".xr-section-summary {\n",
" grid-column: 1;\n",
" color: var(--xr-font-color2);\n",
" font-weight: 500;\n",
"}\n",
"\n",
".xr-section-summary > span {\n",
" display: inline-block;\n",
" padding-left: 0.5em;\n",
"}\n",
"\n",
".xr-section-summary-in:disabled + label {\n",
" color: var(--xr-font-color2);\n",
"}\n",
"\n",
".xr-section-summary-in + label:before {\n",
" display: inline-block;\n",
" content: '►';\n",
" font-size: 11px;\n",
" width: 15px;\n",
" text-align: center;\n",
"}\n",
"\n",
".xr-section-summary-in:disabled + label:before {\n",
" color: var(--xr-disabled-color);\n",
"}\n",
"\n",
".xr-section-summary-in:checked + label:before {\n",
" content: '▼';\n",
"}\n",
"\n",
".xr-section-summary-in:checked + label > span {\n",
" display: none;\n",
"}\n",
"\n",
".xr-section-summary,\n",
".xr-section-inline-details {\n",
" padding-top: 4px;\n",
" padding-bottom: 4px;\n",
"}\n",
"\n",
".xr-section-inline-details {\n",
" grid-column: 2 / -1;\n",
"}\n",
"\n",
".xr-section-details {\n",
" display: none;\n",
" grid-column: 1 / -1;\n",
" margin-bottom: 5px;\n",
"}\n",
"\n",
".xr-section-summary-in:checked ~ .xr-section-details {\n",
" display: contents;\n",
"}\n",
"\n",
".xr-array-wrap {\n",
" grid-column: 1 / -1;\n",
" display: grid;\n",
" grid-template-columns: 20px auto;\n",
"}\n",
"\n",
".xr-array-wrap > label {\n",
" grid-column: 1;\n",
" vertical-align: top;\n",
"}\n",
"\n",
".xr-preview {\n",
" color: var(--xr-font-color3);\n",
"}\n",
"\n",
".xr-array-preview,\n",
".xr-array-data {\n",
" padding: 0 5px !important;\n",
" grid-column: 2;\n",
"}\n",
"\n",
".xr-array-data,\n",
".xr-array-in:checked ~ .xr-array-preview {\n",
" display: none;\n",
"}\n",
"\n",
".xr-array-in:checked ~ .xr-array-data,\n",
".xr-array-preview {\n",
" display: inline-block;\n",
"}\n",
"\n",
".xr-dim-list {\n",
" display: inline-block !important;\n",
" list-style: none;\n",
" padding: 0 !important;\n",
" margin: 0;\n",
"}\n",
"\n",
".xr-dim-list li {\n",
" display: inline-block;\n",
" padding: 0;\n",
" margin: 0;\n",
"}\n",
"\n",
".xr-dim-list:before {\n",
" content: '(';\n",
"}\n",
"\n",
".xr-dim-list:after {\n",
" content: ')';\n",
"}\n",
"\n",
".xr-dim-list li:not(:last-child):after {\n",
" content: ',';\n",
" padding-right: 5px;\n",
"}\n",
"\n",
".xr-has-index {\n",
" font-weight: bold;\n",
"}\n",
"\n",
".xr-var-list,\n",
".xr-var-item {\n",
" display: contents;\n",
"}\n",
"\n",
".xr-var-item > div,\n",
".xr-var-item label,\n",
".xr-var-item > .xr-var-name span {\n",
" background-color: var(--xr-background-color-row-even);\n",
" margin-bottom: 0;\n",
"}\n",
"\n",
".xr-var-item > .xr-var-name:hover span {\n",
" padding-right: 5px;\n",
"}\n",
"\n",
".xr-var-list > li:nth-child(odd) > div,\n",
".xr-var-list > li:nth-child(odd) > label,\n",
".xr-var-list > li:nth-child(odd) > .xr-var-name span {\n",
" background-color: var(--xr-background-color-row-odd);\n",
"}\n",
"\n",
".xr-var-name {\n",
" grid-column: 1;\n",
"}\n",
"\n",
".xr-var-dims {\n",
" grid-column: 2;\n",
"}\n",
"\n",
".xr-var-dtype {\n",
" grid-column: 3;\n",
" text-align: right;\n",
" color: var(--xr-font-color2);\n",
"}\n",
"\n",
".xr-var-preview {\n",
" grid-column: 4;\n",
"}\n",
"\n",
".xr-index-preview {\n",
" grid-column: 2 / 5;\n",
" color: var(--xr-font-color2);\n",
"}\n",
"\n",
".xr-var-name,\n",
".xr-var-dims,\n",
".xr-var-dtype,\n",
".xr-preview,\n",
".xr-attrs dt {\n",
" white-space: nowrap;\n",
" overflow: hidden;\n",
" text-overflow: ellipsis;\n",
" padding-right: 10px;\n",
"}\n",
"\n",
".xr-var-name:hover,\n",
".xr-var-dims:hover,\n",
".xr-var-dtype:hover,\n",
".xr-attrs dt:hover {\n",
" overflow: visible;\n",
" width: auto;\n",
" z-index: 1;\n",
"}\n",
"\n",
".xr-var-attrs,\n",
".xr-var-data,\n",
".xr-index-data {\n",
" display: none;\n",
" background-color: var(--xr-background-color) !important;\n",
" padding-bottom: 5px !important;\n",
"}\n",
"\n",
".xr-var-attrs-in:checked ~ .xr-var-attrs,\n",
".xr-var-data-in:checked ~ .xr-var-data,\n",
".xr-index-data-in:checked ~ .xr-index-data {\n",
" display: block;\n",
"}\n",
"\n",
".xr-var-data > table {\n",
" float: right;\n",
"}\n",
"\n",
".xr-var-name span,\n",
".xr-var-data,\n",
".xr-index-name div,\n",
".xr-index-data,\n",
".xr-attrs {\n",
" padding-left: 25px !important;\n",
"}\n",
"\n",
".xr-attrs,\n",
".xr-var-attrs,\n",
".xr-var-data,\n",
".xr-index-data {\n",
" grid-column: 1 / -1;\n",
"}\n",
"\n",
"dl.xr-attrs {\n",
" padding: 0;\n",
" margin: 0;\n",
" display: grid;\n",
" grid-template-columns: 125px auto;\n",
"}\n",
"\n",
".xr-attrs dt,\n",
".xr-attrs dd {\n",
" padding: 0;\n",
" margin: 0;\n",
" float: left;\n",
" padding-right: 10px;\n",
" width: auto;\n",
"}\n",
"\n",
".xr-attrs dt {\n",
" font-weight: normal;\n",
" grid-column: 1;\n",
"}\n",
"\n",
".xr-attrs dt:hover span {\n",
" display: inline-block;\n",
" background: var(--xr-background-color);\n",
" padding-right: 10px;\n",
"}\n",
"\n",
".xr-attrs dd {\n",
" grid-column: 2;\n",
" white-space: pre-wrap;\n",
" word-break: break-all;\n",
"}\n",
"\n",
".xr-icon-database,\n",
".xr-icon-file-text2,\n",
".xr-no-icon {\n",
" display: inline-block;\n",
" vertical-align: middle;\n",
" width: 1em;\n",
" height: 1.5em !important;\n",
" stroke-width: 0;\n",
" stroke: currentColor;\n",
" fill: currentColor;\n",
"}\n",
"</style><pre class='xr-text-repr-fallback'>&lt;xarray.DataArray &#x27;lon&#x27; (trajectory: 10, time: 169)&gt;\n",
"array([[-70.44043 , -70.43675 , -70.43298 , ..., -70.06403 , -70.06316 ,\n",
" -70.062355],\n",
" [-70.45711 , -70.45687 , -70.4566 , ..., -70.28879 , -70.28684 ,\n",
" -70.28488 ],\n",
" [-70.450035, -70.45089 , -70.45173 , ..., -70.32512 , -70.3252 ,\n",
" -70.32532 ],\n",
" ...,\n",
" [-70.46385 , -70.46406 , -70.464294, ..., -70.50577 , -70.50623 ,\n",
" -70.50671 ],\n",
" [-70.463264, -70.46353 , -70.46381 , ..., -70.50462 , -70.50507 ,\n",
" -70.50553 ],\n",
" [-70.45698 , -70.45713 , -70.45731 , ..., -70.49809 , -70.498535,\n",
" -70.498985]], dtype=float32)\n",
"Coordinates:\n",
" * trajectory (trajectory) int32 1 2 3 4 5 6 7 8 9 10\n",
" * time (time) datetime64[ns] 2012-01-29 ... 2012-02-05\n",
"Attributes:\n",
" units: degrees_east\n",
" standard_name: longitude\n",
" long_name: longitude\n",
" minval: -70.5201\n",
" maxval: -70.062355</pre><div class='xr-wrap' style='display:none'><div class='xr-header'><div class='xr-obj-type'>xarray.DataArray</div><div class='xr-array-name'>'lon'</div><ul class='xr-dim-list'><li><span class='xr-has-index'>trajectory</span>: 10</li><li><span class='xr-has-index'>time</span>: 169</li></ul></div><ul class='xr-sections'><li class='xr-section-item'><div class='xr-array-wrap'><input id='section-08e71065-f450-4d45-b835-0bb1191957a1' class='xr-array-in' type='checkbox' checked><label for='section-08e71065-f450-4d45-b835-0bb1191957a1' title='Show/hide data repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-array-preview xr-preview'><span>-70.44 -70.44 -70.43 -70.43 -70.43 ... -70.5 -70.5 -70.5 -70.5 -70.5</span></div><div class='xr-array-data'><pre>array([[-70.44043 , -70.43675 , -70.43298 , ..., -70.06403 , -70.06316 ,\n",
" -70.062355],\n",
" [-70.45711 , -70.45687 , -70.4566 , ..., -70.28879 , -70.28684 ,\n",
" -70.28488 ],\n",
" [-70.450035, -70.45089 , -70.45173 , ..., -70.32512 , -70.3252 ,\n",
" -70.32532 ],\n",
" ...,\n",
" [-70.46385 , -70.46406 , -70.464294, ..., -70.50577 , -70.50623 ,\n",
" -70.50671 ],\n",
" [-70.463264, -70.46353 , -70.46381 , ..., -70.50462 , -70.50507 ,\n",
" -70.50553 ],\n",
" [-70.45698 , -70.45713 , -70.45731 , ..., -70.49809 , -70.498535,\n",
" -70.498985]], dtype=float32)</pre></div></div></li><li class='xr-section-item'><input id='section-f4b8b3f2-a4e0-495d-a784-bb867d7fcd0c' class='xr-section-summary-in' type='checkbox' checked><label for='section-f4b8b3f2-a4e0-495d-a784-bb867d7fcd0c' class='xr-section-summary' >Coordinates: <span>(2)</span></label><div class='xr-section-inline-details'></div><div class='xr-section-details'><ul class='xr-var-list'><li class='xr-var-item'><div class='xr-var-name'><span class='xr-has-index'>trajectory</span></div><div class='xr-var-dims'>(trajectory)</div><div class='xr-var-dtype'>int32</div><div class='xr-var-preview xr-preview'>1 2 3 4 5 6 7 8 9 10</div><input id='attrs-08a76203-040a-421b-b285-2e77ffa9c101' class='xr-var-attrs-in' type='checkbox' ><label for='attrs-08a76203-040a-421b-b285-2e77ffa9c101' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-9f1e8b21-2754-41c9-87ee-0befae8534de' class='xr-var-data-in' type='checkbox'><label for='data-9f1e8b21-2754-41c9-87ee-0befae8534de' title='Show/Hide data repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-var-attrs'><dl class='xr-attrs'><dt><span>cf_role :</span></dt><dd>trajectory_id</dd><dt><span>units :</span></dt><dd>1</dd></dl></div><div class='xr-var-data'><pre>array([ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10], dtype=int32)</pre></div></li><li class='xr-var-item'><div class='xr-var-name'><span class='xr-has-index'>time</span></div><div class='xr-var-dims'>(time)</div><div class='xr-var-dtype'>datetime64[ns]</div><div class='xr-var-preview xr-preview'>2012-01-29 ... 2012-02-05</div><input id='attrs-688cc7ac-abd4-4e28-8fcb-6655a2c96870' class='xr-var-attrs-in' type='checkbox' ><label for='attrs-688cc7ac-abd4-4e28-8fcb-6655a2c96870' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-086840f2-f8cd-4295-b191-d9dc7cb57c35' class='xr-var-data-in' type='checkbox'><label for='data-086840f2-f8cd-4295-b191-d9dc7cb57c35' title='Show/Hide data repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-var-attrs'><dl class='xr-attrs'><dt><span>standard_name :</span></dt><dd>time</dd><dt><span>long_name :</span></dt><dd>time</dd></dl></div><div class='xr-var-data'><pre>array([&#x27;2012-01-29T00:00:00.000000000&#x27;, &#x27;2012-01-29T01:00:00.000000000&#x27;,\n",
" &#x27;2012-01-29T02:00:00.000000000&#x27;, &#x27;2012-01-29T03:00:00.000000000&#x27;,\n",
" &#x27;2012-01-29T04:00:00.000000000&#x27;, &#x27;2012-01-29T05:00:00.000000000&#x27;,\n",
" &#x27;2012-01-29T06:00:00.000000000&#x27;, &#x27;2012-01-29T07:00:00.000000000&#x27;,\n",
" &#x27;2012-01-29T08:00:00.000000000&#x27;, &#x27;2012-01-29T09:00:00.000000000&#x27;,\n",
" &#x27;2012-01-29T10:00:00.000000000&#x27;, &#x27;2012-01-29T11:00:00.000000000&#x27;,\n",
" &#x27;2012-01-29T12:00:00.000000000&#x27;, &#x27;2012-01-29T13:00:00.000000000&#x27;,\n",
" &#x27;2012-01-29T14:00:00.000000000&#x27;, &#x27;2012-01-29T15:00:00.000000000&#x27;,\n",
" &#x27;2012-01-29T16:00:00.000000000&#x27;, &#x27;2012-01-29T17:00:00.000000000&#x27;,\n",
" &#x27;2012-01-29T18:00:00.000000000&#x27;, &#x27;2012-01-29T19:00:00.000000000&#x27;,\n",
" &#x27;2012-01-29T20:00:00.000000000&#x27;, &#x27;2012-01-29T21:00:00.000000000&#x27;,\n",
" &#x27;2012-01-29T22:00:00.000000000&#x27;, &#x27;2012-01-29T23:00:00.000000000&#x27;,\n",
" &#x27;2012-01-30T00:00:00.000000000&#x27;, &#x27;2012-01-30T01:00:00.000000000&#x27;,\n",
" &#x27;2012-01-30T02:00:00.000000000&#x27;, &#x27;2012-01-30T03:00:00.000000000&#x27;,\n",
" &#x27;2012-01-30T04:00:00.000000000&#x27;, &#x27;2012-01-30T05:00:00.000000000&#x27;,\n",
" &#x27;2012-01-30T06:00:00.000000000&#x27;, &#x27;2012-01-30T07:00:00.000000000&#x27;,\n",
" &#x27;2012-01-30T08:00:00.000000000&#x27;, &#x27;2012-01-30T09:00:00.000000000&#x27;,\n",
" &#x27;2012-01-30T10:00:00.000000000&#x27;, &#x27;2012-01-30T11:00:00.000000000&#x27;,\n",
" &#x27;2012-01-30T12:00:00.000000000&#x27;, &#x27;2012-01-30T13:00:00.000000000&#x27;,\n",
" &#x27;2012-01-30T14:00:00.000000000&#x27;, &#x27;2012-01-30T15:00:00.000000000&#x27;,\n",
" &#x27;2012-01-30T16:00:00.000000000&#x27;, &#x27;2012-01-30T17:00:00.000000000&#x27;,\n",
" &#x27;2012-01-30T18:00:00.000000000&#x27;, &#x27;2012-01-30T19:00:00.000000000&#x27;,\n",
" &#x27;2012-01-30T20:00:00.000000000&#x27;, &#x27;2012-01-30T21:00:00.000000000&#x27;,\n",
" &#x27;2012-01-30T22:00:00.000000000&#x27;, &#x27;2012-01-30T23:00:00.000000000&#x27;,\n",
" &#x27;2012-01-31T00:00:00.000000000&#x27;, &#x27;2012-01-31T01:00:00.000000000&#x27;,\n",
" &#x27;2012-01-31T02:00:00.000000000&#x27;, &#x27;2012-01-31T03:00:00.000000000&#x27;,\n",
" &#x27;2012-01-31T04:00:00.000000000&#x27;, &#x27;2012-01-31T05:00:00.000000000&#x27;,\n",
" &#x27;2012-01-31T06:00:00.000000000&#x27;, &#x27;2012-01-31T07:00:00.000000000&#x27;,\n",
" &#x27;2012-01-31T08:00:00.000000000&#x27;, &#x27;2012-01-31T09:00:00.000000000&#x27;,\n",
" &#x27;2012-01-31T10:00:00.000000000&#x27;, &#x27;2012-01-31T11:00:00.000000000&#x27;,\n",
" &#x27;2012-01-31T12:00:00.000000000&#x27;, &#x27;2012-01-31T13:00:00.000000000&#x27;,\n",
" &#x27;2012-01-31T14:00:00.000000000&#x27;, &#x27;2012-01-31T15:00:00.000000000&#x27;,\n",
" &#x27;2012-01-31T16:00:00.000000000&#x27;, &#x27;2012-01-31T17:00:00.000000000&#x27;,\n",
" &#x27;2012-01-31T18:00:00.000000000&#x27;, &#x27;2012-01-31T19:00:00.000000000&#x27;,\n",
" &#x27;2012-01-31T20:00:00.000000000&#x27;, &#x27;2012-01-31T21:00:00.000000000&#x27;,\n",
" &#x27;2012-01-31T22:00:00.000000000&#x27;, &#x27;2012-01-31T23:00:00.000000000&#x27;,\n",
" &#x27;2012-02-01T00:00:00.000000000&#x27;, &#x27;2012-02-01T01:00:00.000000000&#x27;,\n",
" &#x27;2012-02-01T02:00:00.000000000&#x27;, &#x27;2012-02-01T03:00:00.000000000&#x27;,\n",
" &#x27;2012-02-01T04:00:00.000000000&#x27;, &#x27;2012-02-01T05:00:00.000000000&#x27;,\n",
" &#x27;2012-02-01T06:00:00.000000000&#x27;, &#x27;2012-02-01T07:00:00.000000000&#x27;,\n",
" &#x27;2012-02-01T08:00:00.000000000&#x27;, &#x27;2012-02-01T09:00:00.000000000&#x27;,\n",
" &#x27;2012-02-01T10:00:00.000000000&#x27;, &#x27;2012-02-01T11:00:00.000000000&#x27;,\n",
" &#x27;2012-02-01T12:00:00.000000000&#x27;, &#x27;2012-02-01T13:00:00.000000000&#x27;,\n",
" &#x27;2012-02-01T14:00:00.000000000&#x27;, &#x27;2012-02-01T15:00:00.000000000&#x27;,\n",
" &#x27;2012-02-01T16:00:00.000000000&#x27;, &#x27;2012-02-01T17:00:00.000000000&#x27;,\n",
" &#x27;2012-02-01T18:00:00.000000000&#x27;, &#x27;2012-02-01T19:00:00.000000000&#x27;,\n",
" &#x27;2012-02-01T20:00:00.000000000&#x27;, &#x27;2012-02-01T21:00:00.000000000&#x27;,\n",
" &#x27;2012-02-01T22:00:00.000000000&#x27;, &#x27;2012-02-01T23:00:00.000000000&#x27;,\n",
" &#x27;2012-02-02T00:00:00.000000000&#x27;, &#x27;2012-02-02T01:00:00.000000000&#x27;,\n",
" &#x27;2012-02-02T02:00:00.000000000&#x27;, &#x27;2012-02-02T03:00:00.000000000&#x27;,\n",
" &#x27;2012-02-02T04:00:00.000000000&#x27;, &#x27;2012-02-02T05:00:00.000000000&#x27;,\n",
" &#x27;2012-02-02T06:00:00.000000000&#x27;, &#x27;2012-02-02T07:00:00.000000000&#x27;,\n",
" &#x27;2012-02-02T08:00:00.000000000&#x27;, &#x27;2012-02-02T09:00:00.000000000&#x27;,\n",
" &#x27;2012-02-02T10:00:00.000000000&#x27;, &#x27;2012-02-02T11:00:00.000000000&#x27;,\n",
" &#x27;2012-02-02T12:00:00.000000000&#x27;, &#x27;2012-02-02T13:00:00.000000000&#x27;,\n",
" &#x27;2012-02-02T14:00:00.000000000&#x27;, &#x27;2012-02-02T15:00:00.000000000&#x27;,\n",
" &#x27;2012-02-02T16:00:00.000000000&#x27;, &#x27;2012-02-02T17:00:00.000000000&#x27;,\n",
" &#x27;2012-02-02T18:00:00.000000000&#x27;, &#x27;2012-02-02T19:00:00.000000000&#x27;,\n",
" &#x27;2012-02-02T20:00:00.000000000&#x27;, &#x27;2012-02-02T21:00:00.000000000&#x27;,\n",
" &#x27;2012-02-02T22:00:00.000000000&#x27;, &#x27;2012-02-02T23:00:00.000000000&#x27;,\n",
" &#x27;2012-02-03T00:00:00.000000000&#x27;, &#x27;2012-02-03T01:00:00.000000000&#x27;,\n",
" &#x27;2012-02-03T02:00:00.000000000&#x27;, &#x27;2012-02-03T03:00:00.000000000&#x27;,\n",
" &#x27;2012-02-03T04:00:00.000000000&#x27;, &#x27;2012-02-03T05:00:00.000000000&#x27;,\n",
" &#x27;2012-02-03T06:00:00.000000000&#x27;, &#x27;2012-02-03T07:00:00.000000000&#x27;,\n",
" &#x27;2012-02-03T08:00:00.000000000&#x27;, &#x27;2012-02-03T09:00:00.000000000&#x27;,\n",
" &#x27;2012-02-03T10:00:00.000000000&#x27;, &#x27;2012-02-03T11:00:00.000000000&#x27;,\n",
" &#x27;2012-02-03T12:00:00.000000000&#x27;, &#x27;2012-02-03T13:00:00.000000000&#x27;,\n",
" &#x27;2012-02-03T14:00:00.000000000&#x27;, &#x27;2012-02-03T15:00:00.000000000&#x27;,\n",
" &#x27;2012-02-03T16:00:00.000000000&#x27;, &#x27;2012-02-03T17:00:00.000000000&#x27;,\n",
" &#x27;2012-02-03T18:00:00.000000000&#x27;, &#x27;2012-02-03T19:00:00.000000000&#x27;,\n",
" &#x27;2012-02-03T20:00:00.000000000&#x27;, &#x27;2012-02-03T21:00:00.000000000&#x27;,\n",
" &#x27;2012-02-03T22:00:00.000000000&#x27;, &#x27;2012-02-03T23:00:00.000000000&#x27;,\n",
" &#x27;2012-02-04T00:00:00.000000000&#x27;, &#x27;2012-02-04T01:00:00.000000000&#x27;,\n",
" &#x27;2012-02-04T02:00:00.000000000&#x27;, &#x27;2012-02-04T03:00:00.000000000&#x27;,\n",
" &#x27;2012-02-04T04:00:00.000000000&#x27;, &#x27;2012-02-04T05:00:00.000000000&#x27;,\n",
" &#x27;2012-02-04T06:00:00.000000000&#x27;, &#x27;2012-02-04T07:00:00.000000000&#x27;,\n",
" &#x27;2012-02-04T08:00:00.000000000&#x27;, &#x27;2012-02-04T09:00:00.000000000&#x27;,\n",
" &#x27;2012-02-04T10:00:00.000000000&#x27;, &#x27;2012-02-04T11:00:00.000000000&#x27;,\n",
" &#x27;2012-02-04T12:00:00.000000000&#x27;, &#x27;2012-02-04T13:00:00.000000000&#x27;,\n",
" &#x27;2012-02-04T14:00:00.000000000&#x27;, &#x27;2012-02-04T15:00:00.000000000&#x27;,\n",
" &#x27;2012-02-04T16:00:00.000000000&#x27;, &#x27;2012-02-04T17:00:00.000000000&#x27;,\n",
" &#x27;2012-02-04T18:00:00.000000000&#x27;, &#x27;2012-02-04T19:00:00.000000000&#x27;,\n",
" &#x27;2012-02-04T20:00:00.000000000&#x27;, &#x27;2012-02-04T21:00:00.000000000&#x27;,\n",
" &#x27;2012-02-04T22:00:00.000000000&#x27;, &#x27;2012-02-04T23:00:00.000000000&#x27;,\n",
" &#x27;2012-02-05T00:00:00.000000000&#x27;], dtype=&#x27;datetime64[ns]&#x27;)</pre></div></li></ul></div></li><li class='xr-section-item'><input id='section-4c72a84c-b2b1-4a65-ab1f-3af7555b953f' class='xr-section-summary-in' type='checkbox' ><label for='section-4c72a84c-b2b1-4a65-ab1f-3af7555b953f' class='xr-section-summary' >Indexes: <span>(2)</span></label><div class='xr-section-inline-details'></div><div class='xr-section-details'><ul class='xr-var-list'><li class='xr-var-item'><div class='xr-index-name'><div>trajectory</div></div><div class='xr-index-preview'>PandasIndex</div><div></div><input id='index-3b4a43cb-24bf-41f4-9d80-ddebadc38893' class='xr-index-data-in' type='checkbox'/><label for='index-3b4a43cb-24bf-41f4-9d80-ddebadc38893' title='Show/Hide index repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-index-data'><pre>PandasIndex(Int64Index([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], dtype=&#x27;int64&#x27;, name=&#x27;trajectory&#x27;))</pre></div></li><li class='xr-var-item'><div class='xr-index-name'><div>time</div></div><div class='xr-index-preview'>PandasIndex</div><div></div><input id='index-700f27ee-1798-40a3-9a73-318832ae1d8b' class='xr-index-data-in' type='checkbox'/><label for='index-700f27ee-1798-40a3-9a73-318832ae1d8b' title='Show/Hide index repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-index-data'><pre>PandasIndex(DatetimeIndex([&#x27;2012-01-29 00:00:00&#x27;, &#x27;2012-01-29 01:00:00&#x27;,\n",
" &#x27;2012-01-29 02:00:00&#x27;, &#x27;2012-01-29 03:00:00&#x27;,\n",
" &#x27;2012-01-29 04:00:00&#x27;, &#x27;2012-01-29 05:00:00&#x27;,\n",
" &#x27;2012-01-29 06:00:00&#x27;, &#x27;2012-01-29 07:00:00&#x27;,\n",
" &#x27;2012-01-29 08:00:00&#x27;, &#x27;2012-01-29 09:00:00&#x27;,\n",
" ...\n",
" &#x27;2012-02-04 15:00:00&#x27;, &#x27;2012-02-04 16:00:00&#x27;,\n",
" &#x27;2012-02-04 17:00:00&#x27;, &#x27;2012-02-04 18:00:00&#x27;,\n",
" &#x27;2012-02-04 19:00:00&#x27;, &#x27;2012-02-04 20:00:00&#x27;,\n",
" &#x27;2012-02-04 21:00:00&#x27;, &#x27;2012-02-04 22:00:00&#x27;,\n",
" &#x27;2012-02-04 23:00:00&#x27;, &#x27;2012-02-05 00:00:00&#x27;],\n",
" dtype=&#x27;datetime64[ns]&#x27;, name=&#x27;time&#x27;, length=169, freq=None))</pre></div></li></ul></div></li><li class='xr-section-item'><input id='section-6f1c41d7-742a-4bf0-8a6d-a9679fe52a12' class='xr-section-summary-in' type='checkbox' checked><label for='section-6f1c41d7-742a-4bf0-8a6d-a9679fe52a12' class='xr-section-summary' >Attributes: <span>(5)</span></label><div class='xr-section-inline-details'></div><div class='xr-section-details'><dl class='xr-attrs'><dt><span>units :</span></dt><dd>degrees_east</dd><dt><span>standard_name :</span></dt><dd>longitude</dd><dt><span>long_name :</span></dt><dd>longitude</dd><dt><span>minval :</span></dt><dd>-70.5201</dd><dt><span>maxval :</span></dt><dd>-70.062355</dd></dl></div></li></ul></div></div>"
],
"text/plain": [
"<xarray.DataArray 'lon' (trajectory: 10, time: 169)>\n",
"array([[-70.44043 , -70.43675 , -70.43298 , ..., -70.06403 , -70.06316 ,\n",
" -70.062355],\n",
" [-70.45711 , -70.45687 , -70.4566 , ..., -70.28879 , -70.28684 ,\n",
" -70.28488 ],\n",
" [-70.450035, -70.45089 , -70.45173 , ..., -70.32512 , -70.3252 ,\n",
" -70.32532 ],\n",
" ...,\n",
" [-70.46385 , -70.46406 , -70.464294, ..., -70.50577 , -70.50623 ,\n",
" -70.50671 ],\n",
" [-70.463264, -70.46353 , -70.46381 , ..., -70.50462 , -70.50507 ,\n",
" -70.50553 ],\n",
" [-70.45698 , -70.45713 , -70.45731 , ..., -70.49809 , -70.498535,\n",
" -70.498985]], dtype=float32)\n",
"Coordinates:\n",
" * trajectory (trajectory) int32 1 2 3 4 5 6 7 8 9 10\n",
" * time (time) datetime64[ns] 2012-01-29 ... 2012-02-05\n",
"Attributes:\n",
" units: degrees_east\n",
" standard_name: longitude\n",
" long_name: longitude\n",
" minval: -70.5201\n",
" maxval: -70.062355"
]
},
"execution_count": 27,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"x[1].lon"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "22396d80-0c8b-46f5-9433-a61e36410271",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "nebari-git-nebari-git-opendrift",
"language": "python",
"name": "conda-env-nebari-git-nebari-git-opendrift-py"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.6"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment