Skip to content

Commit

Permalink
Reorder arguments in bulk statistics functions to be consistent with …
Browse files Browse the repository at this point in the history
…other tobac functions, and rename statistics keyword in feature detection and segmentation to 'statistic' to match bulk_statistics functions
  • Loading branch information
w-k-jones committed Nov 28, 2023
1 parent 0b03dce commit d9808ba
Show file tree
Hide file tree
Showing 7 changed files with 292 additions and 88 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,14 @@
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"metadata": {
"execution": {
"iopub.execute_input": "2023-11-22T21:24:25.784126Z",
"iopub.status.busy": "2023-11-22T21:24:25.783038Z",
"iopub.status.idle": "2023-11-22T21:24:28.947172Z",
"shell.execute_reply": "2023-11-22T21:24:28.945998Z"
}
},
"outputs": [],
"source": [
"# Import libraries\n",
Expand All @@ -32,15 +39,38 @@
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"execution_count": 2,
"metadata": {
"execution": {
"iopub.execute_input": "2023-11-22T21:24:28.955365Z",
"iopub.status.busy": "2023-11-22T21:24:28.953404Z",
"iopub.status.idle": "2023-11-22T21:24:30.627015Z",
"shell.execute_reply": "2023-11-22T21:24:30.623829Z"
}
},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"/Users/jonesw/python/tobac/tobac/utils/internal/basic.py:467: UserWarning: Numba not able to be imported; periodic boundary calculations will be slower.Exception raised: ModuleNotFoundError(\"No module named 'numba'\")\n",
" warnings.warn(\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"using tobac version 1.5.1\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"/Users/jonesw/python/tobac/tobac/utils/internal/basic.py:467: UserWarning: Numba not able to be imported; periodic boundary calculations will be slower.Exception raised: ModuleNotFoundError(\"No module named 'numba'\")\n",
" warnings.warn(\n"
]
}
],
"source": [
Expand All @@ -51,8 +81,15 @@
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"execution_count": 3,
"metadata": {
"execution": {
"iopub.execute_input": "2023-11-22T21:24:30.635471Z",
"iopub.status.busy": "2023-11-22T21:24:30.635206Z",
"iopub.status.idle": "2023-11-22T21:24:30.640901Z",
"shell.execute_reply": "2023-11-22T21:24:30.639954Z"
}
},
"outputs": [],
"source": [
"# Disable a few warnings:\n",
Expand All @@ -74,17 +111,31 @@
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"execution_count": 4,
"metadata": {
"execution": {
"iopub.execute_input": "2023-11-22T21:24:30.645377Z",
"iopub.status.busy": "2023-11-22T21:24:30.645131Z",
"iopub.status.idle": "2023-11-22T21:24:30.649660Z",
"shell.execute_reply": "2023-11-22T21:24:30.647983Z"
}
},
"outputs": [],
"source": [
"data_out=Path('../')"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"execution_count": 5,
"metadata": {
"execution": {
"iopub.execute_input": "2023-11-22T21:24:30.653243Z",
"iopub.status.busy": "2023-11-22T21:24:30.652893Z",
"iopub.status.idle": "2023-11-22T21:24:30.660492Z",
"shell.execute_reply": "2023-11-22T21:24:30.657555Z"
}
},
"outputs": [],
"source": [
"# Download the data: This only has to be done once for all tobac examples and can take a while\n",
Expand All @@ -111,17 +162,31 @@
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"execution_count": 6,
"metadata": {
"execution": {
"iopub.execute_input": "2023-11-22T21:24:30.664194Z",
"iopub.status.busy": "2023-11-22T21:24:30.663560Z",
"iopub.status.idle": "2023-11-22T21:24:30.755221Z",
"shell.execute_reply": "2023-11-22T21:24:30.754342Z"
}
},
"outputs": [],
"source": [
"Precip=iris.load_cube(str(data_file[0]),'surface_precipitation_average')"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"execution_count": 7,
"metadata": {
"execution": {
"iopub.execute_input": "2023-11-22T21:24:30.760639Z",
"iopub.status.busy": "2023-11-22T21:24:30.760033Z",
"iopub.status.idle": "2023-11-22T21:24:30.797997Z",
"shell.execute_reply": "2023-11-22T21:24:30.795937Z"
}
},
"outputs": [
{
"data": {
Expand Down Expand Up @@ -174,7 +239,7 @@
" margin-top: 7px;\n",
" }\n",
"</style>\n",
"<table class=\"iris\" id=\"139681909088144\">\n",
"<table class=\"iris\" id=\"4904049552\">\n",
" <tr class=\"iris\">\n",
"<th class=\"iris iris-word-cell\">Surface Precipitation Average (mm h-1)</th>\n",
"<th class=\"iris iris-word-cell\">time</th>\n",
Expand Down Expand Up @@ -257,11 +322,7 @@
" <td class=\"iris-title iris-word-cell\">Attributes</td>\n",
" <td class=\"iris-title\"></td>\n",
" <td class=\"iris-title\"></td>\n",
" <td class=\"iris-title\"></td>\n",
"</tr>\n",
"<tr class=\"iris\">\n",
" <td class=\"iris-word-cell iris-subheading-cell\">\tConventions</td>\n",
" <td class=\"iris-word-cell\" colspan=\"3\">&#x27;CF-1.5&#x27;</td>\n",
" <td class=\"iris-title\"><br>Conventions CF-1.5</td>\n",
"</tr>\n",
"</table>\n",
" "
Expand All @@ -281,8 +342,15 @@
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"execution_count": 8,
"metadata": {
"execution": {
"iopub.execute_input": "2023-11-22T21:24:30.802464Z",
"iopub.status.busy": "2023-11-22T21:24:30.802233Z",
"iopub.status.idle": "2023-11-22T21:24:30.807735Z",
"shell.execute_reply": "2023-11-22T21:24:30.806866Z"
}
},
"outputs": [],
"source": [
"#Set up directory to save output:\n",
Expand Down Expand Up @@ -313,8 +381,15 @@
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"execution_count": 9,
"metadata": {
"execution": {
"iopub.execute_input": "2023-11-22T21:24:30.815250Z",
"iopub.status.busy": "2023-11-22T21:24:30.814464Z",
"iopub.status.idle": "2023-11-22T21:24:31.172956Z",
"shell.execute_reply": "2023-11-22T21:24:31.171587Z"
}
},
"outputs": [],
"source": [
"parameters_features={}\n",
Expand Down Expand Up @@ -346,8 +421,15 @@
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"execution_count": 10,
"metadata": {
"execution": {
"iopub.execute_input": "2023-11-22T21:24:31.178421Z",
"iopub.status.busy": "2023-11-22T21:24:31.178098Z",
"iopub.status.idle": "2023-11-22T21:24:31.185823Z",
"shell.execute_reply": "2023-11-22T21:24:31.184976Z"
}
},
"outputs": [],
"source": [
"statistics = {}\n",
Expand All @@ -365,17 +447,31 @@
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {},
"execution_count": 11,
"metadata": {
"execution": {
"iopub.execute_input": "2023-11-22T21:24:31.195121Z",
"iopub.status.busy": "2023-11-22T21:24:31.193021Z",
"iopub.status.idle": "2023-11-22T21:24:31.200453Z",
"shell.execute_reply": "2023-11-22T21:24:31.199744Z"
}
},
"outputs": [],
"source": [
"statistics['percentiles'] = (np.percentile, {'q': [95,99]})"
]
},
{
"cell_type": "code",
"execution_count": 13,
"metadata": {},
"execution_count": 12,
"metadata": {
"execution": {
"iopub.execute_input": "2023-11-22T21:24:31.203865Z",
"iopub.status.busy": "2023-11-22T21:24:31.203495Z",
"iopub.status.idle": "2023-11-22T21:24:54.212942Z",
"shell.execute_reply": "2023-11-22T21:24:54.212133Z"
}
},
"outputs": [
{
"name": "stdout",
Expand All @@ -390,7 +486,7 @@
"source": [
"# Feature detection based on based on surface precipitation field and a range of thresholds\n",
"print('starting feature detection based on multiple thresholds')\n",
"Features= tobac.feature_detection_multithreshold(Precip,dxy,**parameters_features, statistics = statistics) \n",
"Features= tobac.feature_detection_multithreshold(Precip,dxy,**parameters_features, statistic=statistics) \n",
"print('feature detection done')\n",
"Features.to_hdf(savedir / 'Features.h5','table')\n",
"print('features saved')"
Expand All @@ -405,8 +501,15 @@
},
{
"cell_type": "code",
"execution_count": 14,
"metadata": {},
"execution_count": 13,
"metadata": {
"execution": {
"iopub.execute_input": "2023-11-22T21:24:54.217232Z",
"iopub.status.busy": "2023-11-22T21:24:54.216952Z",
"iopub.status.idle": "2023-11-22T21:24:54.240498Z",
"shell.execute_reply": "2023-11-22T21:24:54.239787Z"
}
},
"outputs": [
{
"data": {
Expand Down Expand Up @@ -617,7 +720,7 @@
"[5 rows x 21 columns]"
]
},
"execution_count": 14,
"execution_count": 13,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -643,7 +746,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.13"
"version": "3.11.3"
}
},
"nbformat": 4,
Expand Down
Loading

0 comments on commit d9808ba

Please sign in to comment.