diff --git a/examples/symba_mars_disk/testnetcdf.ipynb b/examples/symba_mars_disk/testnetcdf.ipynb index 8c61f51a0..d98408178 100644 --- a/examples/symba_mars_disk/testnetcdf.ipynb +++ b/examples/symba_mars_disk/testnetcdf.ipynb @@ -4,14 +4,28 @@ "cell_type": "code", "execution_count": 1, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "'/home/daminton/git/swiftest/examples/symba_mars_disk'" + ] + }, + "execution_count": 1, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ - "import swiftest" + "import swiftest\n", + "import os\n", + "import xarray as xr\n", + "os.getcwd()" ] }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 12, "metadata": {}, "outputs": [ { @@ -30,7 +44,1494 @@ ], "source": [ "sim = swiftest.Simulation(param_file=\"param.in\")\n", - "sim.bin2xr()" + "sim.bin2xr()\n" + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "
<xarray.Dataset>\n",
+       "Dimensions:      (id: 1521, time: 11)\n",
+       "Coordinates:\n",
+       "  * id           (id) int64 1 2 3 4 5 6 7 ... 1515 1516 1517 1518 1519 1520 1521\n",
+       "  * time         (time) float64 0.0 600.0 1.2e+03 ... 4.8e+03 5.4e+03 6e+03\n",
+       "Data variables: (12/46)\n",
+       "    npl          (time) int32 1500 1500 1500 1500 1500 ... 1518 1518 1518 1518\n",
+       "    ntp          (time) int32 0 0 0 0 0 0 0 0 0 0 0\n",
+       "    xhx          (id, time) float64 0.0 0.0 0.0 ... 1.587e+06 2.838e+06\n",
+       "    xhy          (id, time) float64 0.0 0.0 0.0 ... -9.103e+06 -8.791e+06\n",
+       "    xhz          (id, time) float64 0.0 0.0 0.0 ... -3.433e+04 -3.905e+04\n",
+       "    vhx          (id, time) float64 0.0 0.0 0.0 ... 2.118e+03 2.045e+03\n",
+       "    ...           ...\n",
+       "    py_origin    (id) float64 0.0 -4.373e+06 ... -8.094e+06 -8.123e+06\n",
+       "    pz_origin    (id) float64 0.0 -9.627e+03 2.41e+04 ... 2.923e+03 -3.139e+03\n",
+       "    vhx_origin   (id) float64 0.0 988.0 1.016e+03 ... 1.881e+03 1.887e+03\n",
+       "    vhy_origin   (id) float64 0.0 -1.888e+03 ... -1.004e+03 -1.027e+03\n",
+       "    vhz_origin   (id) float64 0.0 10.69 -2.604 -1.465 ... 18.95 -9.448 -12.51\n",
+       "    origin_type  (id) <U32 'Central body' ... 'Supercatastrophic'
" + ], + "text/plain": [ + "\n", + "Dimensions: (id: 1521, time: 11)\n", + "Coordinates:\n", + " * id (id) int64 1 2 3 4 5 6 7 ... 1515 1516 1517 1518 1519 1520 1521\n", + " * time (time) float64 0.0 600.0 1.2e+03 ... 4.8e+03 5.4e+03 6e+03\n", + "Data variables: (12/46)\n", + " npl (time) int32 ...\n", + " ntp (time) int32 ...\n", + " xhx (id, time) float64 ...\n", + " xhy (id, time) float64 ...\n", + " xhz (id, time) float64 ...\n", + " vhx (id, time) float64 ...\n", + " ... ...\n", + " py_origin (id) float64 0.0 -4.373e+06 ... -8.094e+06 -8.123e+06\n", + " pz_origin (id) float64 0.0 -9.627e+03 2.41e+04 ... 2.923e+03 -3.139e+03\n", + " vhx_origin (id) float64 0.0 988.0 1.016e+03 ... 1.881e+03 1.887e+03\n", + " vhy_origin (id) float64 0.0 -1.888e+03 ... -1.004e+03 -1.027e+03\n", + " vhz_origin (id) float64 0.0 10.69 -2.604 -1.465 ... 18.95 -9.448 -12.51\n", + " origin_type (id) \n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "
<xarray.Dataset>\n",
+       "Dimensions:      (id: 1521)\n",
+       "Coordinates:\n",
+       "  * id           (id) int32 1 1130 216 1326 20 27 ... 1517 1518 1519 1520 1521\n",
+       "Data variables:\n",
+       "    time_origin  (id) float64 0.0 0.0 0.0 0.0 ... 2.4e+03 2.4e+03 2.4e+03\n",
+       "    xhx_origin   (id) float64 0.0 1.047e+07 -1.034e+07 ... -4.435e+06 -4.426e+06\n",
+       "    py_origin    (id) float64 0.0 3.395e+06 2.852e+05 ... -8.094e+06 -8.123e+06\n",
+       "    pz_origin    (id) float64 0.0 2.709e+04 -3.221e+04 ... 2.923e+03 -3.139e+03\n",
+       "    vhx_origin   (id) float64 0.0 -597.1 -50.0 ... 1.885e+03 1.881e+03 1.887e+03\n",
+       "    vhy_origin   (id) float64 0.0 1.881e+03 -2.018e+03 ... -1.004e+03 -1.027e+03\n",
+       "    vhz_origin   (id) float64 0.0 -6.96 11.61 3.592 ... 18.95 -9.448 -12.51\n",
+       "    origin_type  (id) <U32 'Central body' ... 'Supercatastrophic'
" + ], + "text/plain": [ + "\n", + "Dimensions: (id: 1521)\n", + "Coordinates:\n", + " * id (id) int32 1 1130 216 1326 20 27 ... 1517 1518 1519 1520 1521\n", + "Data variables:\n", + " time_origin (id) float64 0.0 0.0 0.0 0.0 ... 2.4e+03 2.4e+03 2.4e+03\n", + " xhx_origin (id) float64 0.0 1.047e+07 -1.034e+07 ... -4.435e+06 -4.426e+06\n", + " py_origin (id) float64 0.0 3.395e+06 2.852e+05 ... -8.094e+06 -8.123e+06\n", + " pz_origin (id) float64 0.0 2.709e+04 -3.221e+04 ... 2.923e+03 -3.139e+03\n", + " vhx_origin (id) float64 0.0 -597.1 -50.0 ... 1.885e+03 1.881e+03 1.887e+03\n", + " vhy_origin (id) float64 0.0 1.881e+03 -2.018e+03 ... -1.004e+03 -1.027e+03\n", + " vhz_origin (id) float64 0.0 -6.96 11.61 3.592 ... 18.95 -9.448 -12.51\n", + " origin_type (id) 0, drop=True)" + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "metadata": {}, + "outputs": [ + { + "ename": "KeyError", + "evalue": "216", + "output_type": "error", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mKeyError\u001b[0m Traceback (most recent call last)", + "\u001b[0;32m~/.conda/envs/cent7/2020.02-py37/swiftestOOF/lib/python3.7/site-packages/pandas/core/indexes/base.py\u001b[0m in \u001b[0;36mget_loc\u001b[0;34m(self, key, method, tolerance)\u001b[0m\n\u001b[1;32m 3079\u001b[0m \u001b[0;32mtry\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 3080\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_engine\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mget_loc\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mcasted_key\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 3081\u001b[0m \u001b[0;32mexcept\u001b[0m \u001b[0mKeyError\u001b[0m \u001b[0;32mas\u001b[0m \u001b[0merr\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;32mpandas/_libs/index.pyx\u001b[0m in \u001b[0;36mpandas._libs.index.IndexEngine.get_loc\u001b[0;34m()\u001b[0m\n", + "\u001b[0;32mpandas/_libs/index.pyx\u001b[0m in \u001b[0;36mpandas._libs.index.IndexEngine.get_loc\u001b[0;34m()\u001b[0m\n", + "\u001b[0;32mpandas/_libs/hashtable_class_helper.pxi\u001b[0m in \u001b[0;36mpandas._libs.hashtable.Int64HashTable.get_item\u001b[0;34m()\u001b[0m\n", + "\u001b[0;32mpandas/_libs/hashtable_class_helper.pxi\u001b[0m in \u001b[0;36mpandas._libs.hashtable.Int64HashTable.get_item\u001b[0;34m()\u001b[0m\n", + "\u001b[0;31mKeyError\u001b[0m: 216", + "\nThe above exception was the direct cause of the following exception:\n", + "\u001b[0;31mKeyError\u001b[0m Traceback (most recent call last)", + "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mnewp\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0msel\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mid\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;36m216\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", + "\u001b[0;32m~/.conda/envs/cent7/2020.02-py37/swiftestOOF/lib/python3.7/site-packages/xarray/core/dataset.py\u001b[0m in \u001b[0;36msel\u001b[0;34m(self, indexers, method, tolerance, drop, **indexers_kwargs)\u001b[0m\n\u001b[1;32m 2347\u001b[0m \u001b[0mindexers\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0meither_dict_or_kwargs\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mindexers\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mindexers_kwargs\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m\"sel\"\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 2348\u001b[0m pos_indexers, new_indexes = remap_label_indexers(\n\u001b[0;32m-> 2349\u001b[0;31m \u001b[0mself\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mindexers\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mindexers\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mmethod\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mmethod\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mtolerance\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mtolerance\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 2350\u001b[0m )\n\u001b[1;32m 2351\u001b[0m \u001b[0mresult\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0misel\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mindexers\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mpos_indexers\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mdrop\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mdrop\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;32m~/.conda/envs/cent7/2020.02-py37/swiftestOOF/lib/python3.7/site-packages/xarray/core/coordinates.py\u001b[0m in \u001b[0;36mremap_label_indexers\u001b[0;34m(obj, indexers, method, tolerance, **indexers_kwargs)\u001b[0m\n\u001b[1;32m 418\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 419\u001b[0m pos_indexers, new_indexes = indexing.remap_label_indexers(\n\u001b[0;32m--> 420\u001b[0;31m \u001b[0mobj\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mv_indexers\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mmethod\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mmethod\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mtolerance\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mtolerance\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 421\u001b[0m )\n\u001b[1;32m 422\u001b[0m \u001b[0;31m# attach indexer's coordinate to pos_indexers\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;32m~/.conda/envs/cent7/2020.02-py37/swiftestOOF/lib/python3.7/site-packages/xarray/core/indexing.py\u001b[0m in \u001b[0;36mremap_label_indexers\u001b[0;34m(data_obj, indexers, method, tolerance)\u001b[0m\n\u001b[1;32m 276\u001b[0m \u001b[0mcoords_dtype\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mdata_obj\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mcoords\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mdim\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mdtype\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 277\u001b[0m \u001b[0mlabel\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mmaybe_cast_to_coords_dtype\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mlabel\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mcoords_dtype\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 278\u001b[0;31m \u001b[0midxr\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mnew_idx\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mconvert_label_indexer\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mindex\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mlabel\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mdim\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mmethod\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mtolerance\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 279\u001b[0m \u001b[0mpos_indexers\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mdim\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0midxr\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 280\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mnew_idx\u001b[0m \u001b[0;32mis\u001b[0m \u001b[0;32mnot\u001b[0m \u001b[0;32mNone\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;32m~/.conda/envs/cent7/2020.02-py37/swiftestOOF/lib/python3.7/site-packages/xarray/core/indexing.py\u001b[0m in \u001b[0;36mconvert_label_indexer\u001b[0;34m(index, label, index_name, method, tolerance)\u001b[0m\n\u001b[1;32m 197\u001b[0m \u001b[0mindexer\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mindex\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mget_loc\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mlabel_value\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 198\u001b[0m \u001b[0;32melse\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 199\u001b[0;31m \u001b[0mindexer\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mindex\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mget_loc\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mlabel_value\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mmethod\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mmethod\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mtolerance\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mtolerance\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 200\u001b[0m \u001b[0;32melif\u001b[0m \u001b[0mlabel\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mdtype\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mkind\u001b[0m \u001b[0;34m==\u001b[0m \u001b[0;34m\"b\"\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 201\u001b[0m \u001b[0mindexer\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mlabel\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;32m~/.conda/envs/cent7/2020.02-py37/swiftestOOF/lib/python3.7/site-packages/pandas/core/indexes/base.py\u001b[0m in \u001b[0;36mget_loc\u001b[0;34m(self, key, method, tolerance)\u001b[0m\n\u001b[1;32m 3080\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_engine\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mget_loc\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mcasted_key\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 3081\u001b[0m \u001b[0;32mexcept\u001b[0m \u001b[0mKeyError\u001b[0m \u001b[0;32mas\u001b[0m \u001b[0merr\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 3082\u001b[0;31m \u001b[0;32mraise\u001b[0m \u001b[0mKeyError\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mkey\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;32mfrom\u001b[0m \u001b[0merr\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 3083\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 3084\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mtolerance\u001b[0m \u001b[0;32mis\u001b[0m \u001b[0;32mnot\u001b[0m \u001b[0;32mNone\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;31mKeyError\u001b[0m: 216" + ] + } + ], + "source": [] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "
<xarray.Dataset>\n",
+       "Dimensions:      ()\n",
+       "Coordinates:\n",
+       "    id           int32 216\n",
+       "Data variables:\n",
+       "    time_origin  float64 0.0\n",
+       "    xhx_origin   float64 -1.034e+07\n",
+       "    py_origin    float64 2.852e+05\n",
+       "    pz_origin    float64 -3.221e+04\n",
+       "    vhx_origin   float64 -50.0\n",
+       "    vhy_origin   float64 -2.018e+03\n",
+       "    vhz_origin   float64 11.61\n",
+       "    origin_type  <U32 'Initial conditions'
" + ], + "text/plain": [ + "\n", + "Dimensions: ()\n", + "Coordinates:\n", + " id int32 216\n", + "Data variables:\n", + " time_origin float64 0.0\n", + " xhx_origin float64 -1.034e+07\n", + " py_origin float64 2.852e+05\n", + " pz_origin float64 -3.221e+04\n", + " vhx_origin float64 -50.0\n", + " vhy_origin float64 -2.018e+03\n", + " vhz_origin float64 11.61\n", + " origin_type \n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "
<xarray.DataArray 'name' (str: 32)>\n",
+       "array([b'M', b'e', b'r', b'c', b'u', b'r', b'y', b'', b'', b'', b'', b'', b'',\n",
+       "       b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'',\n",
+       "       b'', b'', b'', b'', b''], dtype='|S1')\n",
+       "Coordinates:\n",
+       "    id       int32 1\n",
+       "Dimensions without coordinates: str
" + ], + "text/plain": [ + "\n", + "array([b'M', b'e', b'r', b'c', b'u', b'r', b'y', b'', b'', b'', b'', b'', b'',\n", + " b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'',\n", + " b'', b'', b'', b'', b''], dtype='|S1')\n", + "Coordinates:\n", + " id int32 1\n", + "Dimensions without coordinates: str" + ] + }, + "execution_count": 4, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "sim.ds.sel(id=1)['name']" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": {}, + "outputs": [], + "source": [ + "ds = sim.ds" + ] + }, + { + "cell_type": "code", + "execution_count": 15, + "metadata": {}, + "outputs": [ + { + "ename": "SyntaxError", + "evalue": "can't assign to function call (, line 2)", + "output_type": "error", + "traceback": [ + "\u001b[0;36m File \u001b[0;32m\"\"\u001b[0;36m, line \u001b[0;32m2\u001b[0m\n\u001b[0;31m ds['name'].sel(id=i) = 'test'\u001b[0m\n\u001b[0m ^\u001b[0m\n\u001b[0;31mSyntaxError\u001b[0m\u001b[0;31m:\u001b[0m can't assign to function call\n" + ] + } + ], + "source": [ + "for i in ds.id:\n", + " ds['name'].sel(id=i) = 'test'" + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "array('SMVEMJSUNueeaauarenrnrrptap\\x00cutsiunt\\x00ush\\x00truu\\x00r\\x00\\x00\\x00ensn\\x00y\\x00\\x00\\x00r\\x00\\x00e',\n", + " dtype='