Skip to content

Commit

Permalink
Merge pull request #144 from tobac-project/dev
Browse files Browse the repository at this point in the history
Merge `dev` into `main` for 1.3.1 release
  • Loading branch information
freemansw1 committed Jun 27, 2022
2 parents 0d098ac + fee0208 commit e6e8fc3
Show file tree
Hide file tree
Showing 8 changed files with 260 additions and 246 deletions.
12 changes: 12 additions & 0 deletions .github/pull_request_template.md
@@ -0,0 +1,12 @@
* [ ] Have you followed our guidelines in CONTRIBUTING.md?
* [ ] Have you self-reviewed your code and corrected any misspellings?
* [ ] Have you written documentation that is easy to understand?
* [ ] Have you written descriptive commit messages?
* [ ] Have you added NumPy docstrings for newly added functions?
* [ ] Have you formatted your code using black?
* [ ] If you have introduced a new functionality, have you added adequate unit tests?
* [ ] Have all tests passed in your local clone?
* [ ] If you have introduced a new functionality, have you added an example notebook?
* [ ] Have you kept your pull request small and limited so that it is easy to review?
* [ ] Have the newest changes from this branch been merged?

14 changes: 14 additions & 0 deletions CHANGELOG.md
@@ -1,5 +1,19 @@
### Tobac Changelog

_**Version 1.3.1:**_

**Enhancements**

- Added auto-downloading of files in the example notebooks if data isn't already present [#113](https://github.com/tobac-project/tobac/pull/113)

**Bug fixes**

- Fixed a bug with `map_tracks` that had it plot untracked cells caused by the switch to `-1` for untracked cells [#130](https://github.com/tobac-project/tobac/pull/130)

**Repository enhancements**

- New pull request template for the repository, including a checklist to be completed for each pull request [#120](https://github.com/tobac-project/tobac/pull/120)

_**Version 1.3:**_

**Enhancements**
Expand Down
110 changes: 55 additions & 55 deletions examples/Example_OLR_Tracking_model/Example_OLR_Tracking_model.ipynb
Expand Up @@ -30,14 +30,13 @@
"import iris\n",
"import numpy as np\n",
"import pandas as pd\n",
"import os,sys\n",
"import matplotlib.pyplot as plt\n",
"import iris.plot as iplt\n",
"import iris.quickplot as qplt\n",
"import zipfile, shutil\n",
"import shutil\n",
"import datetime\n",
"from six.moves import urllib\n",
"from glob import glob\n",
"from pathlib import Path\n",
"%matplotlib inline"
]
},
Expand All @@ -62,7 +61,7 @@
"warnings.filterwarnings('ignore', category=UserWarning, append=True)\n",
"warnings.filterwarnings('ignore', category=RuntimeWarning, append=True)\n",
"warnings.filterwarnings('ignore', category=FutureWarning, append=True)\n",
"warnings.filterwarnings('ignore',category=pd.io.pytables.PerformanceWarning)\n"
"warnings.filterwarnings('ignore',category=pd.io.pytables.PerformanceWarning)"
]
},
{
Expand All @@ -79,62 +78,63 @@
"metadata": {},
"outputs": [],
"source": [
"data_out='../'"
"data_out=Path('../')"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"start downloading data\n",
"start extracting data\n",
"data extracted\n"
]
}
],
"source": [
"# # Download the data: This only has to be done once for all tobac examples and can take a while\n",
"# file_path='https://zenodo.org/record/3195910/files/climate-processes/tobac_example_data-v1.0.1.zip'\n",
"# #file_path='http://zenodo..'\n",
"# tempfile='temp.zip'\n",
"# print('start downloading data')\n",
"# request=urllib.request.urlretrieve(file_path,tempfile)\n",
"# print('start extracting data')\n",
"# shutil.unpack_archive(tempfile,data_out)\n",
"# #zf = zipfile.ZipFile(tempfile)\n",
"# #zf.extractall(data_out)\n",
"# os.remove(tempfile)\n",
"# print('data extracted')\n"
"# Download the data: This only has to be done once for all tobac examples and can take a while\n",
"data_file = list(data_out.rglob('data/Example_input_OLR_model.nc'))\n",
"if len(data_file) == 0:\n",
" file_path='https://zenodo.org/record/3195910/files/climate-processes/tobac_example_data-v1.0.1.zip'\n",
" #file_path='http://zenodo..'\n",
" tempfile=Path('temp.zip')\n",
" print('start downloading data')\n",
" request=urllib.request.urlretrieve(file_path, tempfile)\n",
" print('start extracting data')\n",
" shutil.unpack_archive(tempfile, data_out)\n",
" tempfile.unlink()\n",
" print('data extracted')\n",
" data_file = list(data_out.rglob('data/Example_input_OLR_model.nc'))"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [],
"source": [
"data_file=os.path.join(data_out,'*','data','Example_input_OLR_model.nc')\n",
"data_file = glob(data_file)[0]"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [],
"source": [
"#Load Data from downloaded file:\n",
"OLR=iris.load_cube(data_file,'OLR')"
"OLR=iris.load_cube(data_file[0],'OLR')"
]
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": 7,
"metadata": {},
"outputs": [],
"source": [
"#Set up directory to save output and plots:\n",
"savedir='Save'\n",
"if not os.path.exists(savedir):\n",
" os.makedirs(savedir)\n",
"plot_dir=\"Plot\"\n",
"if not os.path.exists(plot_dir):\n",
" os.makedirs(plot_dir)"
"savedir=Path(\"Save\")\n",
"if not savedir.is_dir():\n",
" savedir.mkdir()\n",
"plot_dir=Path(\"Plot\")\n",
"if not plot_dir.is_dir():\n",
" plot_dir.mkdir()"
]
},
{
Expand All @@ -147,7 +147,7 @@
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": 8,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -157,7 +157,7 @@
},
{
"cell_type": "code",
"execution_count": 10,
"execution_count": 9,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -172,7 +172,7 @@
},
{
"cell_type": "code",
"execution_count": 11,
"execution_count": 10,
"metadata": {},
"outputs": [
{
Expand All @@ -187,9 +187,9 @@
"source": [
"# Perform feature detection:\n",
"print('starting feature detection')\n",
"Features=tobac.feature_detection_multithreshold(OLR,dxy,**parameters_features)\n",
"Features.to_hdf(os.path.join(savedir,'Features.h5'),'table')\n",
"print('feature detection performed and saved')\n"
"Features=tobac.feature_detection_multithreshold(OLR,dxy, **parameters_features)\n",
"Features.to_hdf(savedir / 'Features.h5', 'table')\n",
"print('feature detection performed and saved')"
]
},
{
Expand All @@ -202,7 +202,7 @@
},
{
"cell_type": "code",
"execution_count": 12,
"execution_count": 11,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -215,7 +215,7 @@
},
{
"cell_type": "code",
"execution_count": 13,
"execution_count": 12,
"metadata": {},
"outputs": [
{
Expand All @@ -233,8 +233,8 @@
"print('Starting segmentation based on OLR.')\n",
"Mask_OLR,Features_OLR=tobac.segmentation_2D(Features,OLR,dxy,**parameters_segmentation)\n",
"print('segmentation OLR performed, start saving results to files')\n",
"iris.save([Mask_OLR],os.path.join(savedir,'Mask_Segmentation_OLR.nc'),zlib=True,complevel=4) \n",
"Features_OLR.to_hdf(os.path.join(savedir,'Features_OLR.h5'),'table')\n",
"iris.save([Mask_OLR], savedir / 'Mask_Segmentation_OLR.nc', zlib=True, complevel=4) \n",
"Features_OLR.to_hdf(savedir / 'Features_OLR.h5', 'table')\n",
"print('segmentation OLR performed and saved')"
]
},
Expand All @@ -248,7 +248,7 @@
},
{
"cell_type": "code",
"execution_count": 14,
"execution_count": 13,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -267,21 +267,21 @@
},
{
"cell_type": "code",
"execution_count": 15,
"execution_count": 14,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Frame 95: 18 trajectories present.\n"
"Frame 95: 12 trajectories present.\n"
]
}
],
"source": [
"# Perform linking and save results to file:\n",
"Track=tobac.linking_trackpy(Features,OLR,dt=dt,dxy=dxy,**parameters_linking)\n",
"Track.to_hdf(os.path.join(savedir,'Track.h5'),'table')"
"Track=tobac.linking_trackpy(Features, OLR, dt=dt, dxy=dxy, **parameters_linking)\n",
"Track.to_hdf(savedir / 'Track.h5', 'table')"
]
},
{
Expand All @@ -298,7 +298,7 @@
"outputs": [],
"source": [
"# Set extent of maps created in the following cells:\n",
"axis_extent=[-95,-89,28,32] "
"axis_extent = [-95, -89, 28, 32] "
]
},
{
Expand All @@ -322,8 +322,8 @@
"source": [
"# Plot map with all individual tracks:\n",
"import cartopy.crs as ccrs\n",
"fig_map,ax_map=plt.subplots(figsize=(10,10),subplot_kw={'projection': ccrs.PlateCarree()})\n",
"ax_map=tobac.map_tracks(Track,axis_extent=axis_extent,axes=ax_map)"
"fig_map, ax_map = plt.subplots(figsize=(10,10), subplot_kw={'projection': ccrs.PlateCarree()})\n",
"ax_map = tobac.map_tracks(Track, axis_extent=axis_extent, axes=ax_map)"
]
},
{
Expand Down Expand Up @@ -357,7 +357,7 @@
"outputs": [],
"source": [
"# # Save animation to file:\n",
"# savefile_animation=os.path.join(plot_dir,'Animation.mp4')\n",
"# savefile_animation = plot_dir /'Animation.mp4'\n",
"# animation_test_tobac.save(savefile_animation,dpi=200)\n",
"# print(f'animation saved to {savefile_animation}')"
]
Expand Down

0 comments on commit e6e8fc3

Please sign in to comment.