-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Substantial improvement to append * Add data and test notebooks for append * Get data_vars_mapping from data model * Add another test notebook * Update readme to reflect new functionality * Rebase, and post-rebase tidy
- Loading branch information
Showing
22 changed files
with
1,200 additions
and
117 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -79,4 +79,7 @@ venv.bak/ | |
# PyCharm | ||
/shelf/ | ||
/workspace.xml | ||
.idea | ||
.idea | ||
|
||
# VSCode | ||
.vscode/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
158 changes: 158 additions & 0 deletions
158
nctotdb/tests/integration/append/test_basic_append.ipynb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,158 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"id": "68f0e08e-ad4b-4eac-8f1d-66faeb2db68e", | ||
"metadata": {}, | ||
"source": [ | ||
"# Test basic append\n", | ||
"\n", | ||
"Test basic append operation between two NetCDF datasets with a single append dimension and no scalar coordinates." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "eec8e236-439d-43d5-89aa-bd19b668824b", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"import os\n", | ||
"import tempfile\n", | ||
"\n", | ||
"import nctotdb" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "36bcfde3-6c7a-4d15-b8af-f994fbde6744", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"data_path = os.path.join(os.path.dirname(os.path.abspath(\".\")), \"data\")" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "71d1134b-760a-494d-abb7-ee9076014814", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"base_dataset = os.path.join(data_path, \"xy_t0.nc\")\n", | ||
"append_dataset = os.path.join(data_path, \"xy_t1.nc\")" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "ad501500-1114-455e-b18c-85c65cc05b7c", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"ncdm = nctotdb.NCDataModel(base_dataset)\n", | ||
"ncdm.populate()" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "69fcd77e-cae3-48ca-a669-47bd2c8dc5e1", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"fp = tempfile.TemporaryDirectory()\n", | ||
"array_filepath = fp.name\n", | ||
"array_filepath" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "eb3c3ef9-c354-47de-b8a7-28a48d1aed67", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"tiledb_name = \"basic_append\"\n", | ||
"append_dim = \"time\"\n", | ||
"data_array_name = \"data\"\n", | ||
"\n", | ||
"writer = nctotdb.TileDBWriter(ncdm,\n", | ||
" array_filepath=array_filepath,\n", | ||
" array_name=tiledb_name,\n", | ||
" unlimited_dims=append_dim)\n", | ||
"writer.create_domains()" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "0054013c-bbd1-4550-9bca-51395e19d239", | ||
"metadata": {}, | ||
"source": [ | ||
"## Test 1. Append" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "68e69f75-4621-4c46-ac46-56ec6a0d4dbc", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"writer.append([append_dataset], append_dim, data_array_name, verbose=False)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "ea593a04-b1b9-4881-85e4-32b461bb045a", | ||
"metadata": {}, | ||
"source": [ | ||
"## Test 2. Load appended array as Iris cube" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "adb1d462-9fef-44c9-a370-c03cef3715ad", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"reader = nctotdb.TileDBReader(tiledb_name,\n", | ||
" array_filepath=array_filepath)\n", | ||
"reader.to_iris()" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "364d71de-7c35-40e8-8df1-6aa93d258740", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"fp.cleanup()" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"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.8.10" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 5 | ||
} |
Oops, something went wrong.