Skip to content

Instantly share code, notes, and snippets.

@pelson
Created April 14, 2015 08:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pelson/e98e142b8a935142746b to your computer and use it in GitHub Desktop.
Save pelson/e98e142b8a935142746b to your computer and use it in GitHub Desktop.
um_packing performance.ipynb
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"import iris.fileformats.pp_packing as old_packing\n",
"import iris.fileformats.um.packing as um_packing\n",
"import numpy as np"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"np.random.seed(0)\n",
"data = np.random.randn(800, 500).astype(np.float32)"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"packed = um_packing.pack_wgdos(data, -6.0, missing_data_indicator=-10)"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"old = old_packing.wgdos_unpack(packed, 800, 500, -10)"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"new = um_packing.unpack_wgdos(packed, 800, 500, -10)"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"True"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"np.all(old == new)"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"1 loops, best of 3: 247 ms per loop\n"
]
}
],
"source": [
"%timeit old_packing.wgdos_unpack(packed, 800, 500, -10)"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"1 loops, best of 3: 246 ms per loop\n"
]
}
],
"source": [
"%timeit um_packing.unpack_wgdos(packed, 800, 500, -10)"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "ENV: dev_iris",
"language": "python",
"name": "env_dev_iris"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 2
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.9"
}
},
"nbformat": 4,
"nbformat_minor": 0
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment