{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Upload data files\n", "

This Jupyter notebook\n", "shows how to upload data files to be converted\n", "to [Photon-HDF5](http://photon-hdf5.org) format.

\n", "\n", "Please send feedback and report any problems to the \n", "[Photon-HDF5 google group](https://groups.google.com/forum/#!forum/photon-hdf5).\n", "\n", "
\n", "
\n", "NOTE Uploading data files is only necessary when running the notebook online.\n", "
\n", "\n", "## Files under 35 MB\n", "\n", "Data files up to 35 MB you can be directly uploaded from the dashboard.\n", "Just go back to the Home Tab and click on the **Upload** button on the \n", "top right. Or, alternatively, you can use the method below even with small files.\n", "\n", "## Files over 35 MB\n", "\n", "For large files (>35 MB) the upload button will not work.\n", "In this case you have to upload the file somewhere on the internet first,\n", "and then copy the file URL in the cell below to download it:" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "url = 'https://ndownloader.figshare.com/files/3350672'" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "For example, the previous URL will download one of our example files, \n", "specifically a PicoQuant HT3 file (which you can then convert with the HT3 notebook). \n", "Other example data files are available [on figshare](https://figshare.com/articles/Examples_data_files_for_phconvert/1455963)." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Download\n", "\n", "Once you have copied the URL in the previous cell, you can download \n", "the file by running this notebook:\n", "go to menu *Cell* -> *Run All*, then follow the download progress \n", "at the end of this notebook." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "import sys\n", "def download(url):\n", " \"\"\"Download a file from `url` saving it to disk.\"\"\"\n", " from future.standard_library import install_aliases\n", " install_aliases()\n", " import urllib.request\n", "\n", " # Check if the URL is valid\n", " print('URL: %s' % url)\n", " try:\n", " response = urllib.request.urlopen(url)\n", " except urllib.error.URLError as e:\n", " print('Wrong URL.\\n\\nError:\\n%s\\n' % e)\n", " return\n", " \n", " # Download the file\n", " filename = response.geturl().split('/')[-1]\n", " print('File name: %s' % filename)\n", " def _report(blocknr, blocksize, size):\n", " current = (blocknr + 1) * blocksize / 2**20\n", " sys.stdout.write(\n", " \"\\rDownloaded {0:4.1f} / {1:4.1f} MB\".format(current, size/2**20))\n", " urllib.request.urlretrieve(url, filename, _report)\n", " print('\\nDownload completed, file saved as \"%s\".' % filename)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false, "scrolled": true }, "outputs": [], "source": [ "download(url)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Once the file is downloaded, you can go back to the dashboard (\"Home\" tab) \n", "and open the notebook for the file type you want to convert." ] } ], "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.5.1" } }, "nbformat": 4, "nbformat_minor": 0 }