Created
November 26, 2014 19:23
-
-
Save flamingbear/2a473e33748704f576a3 to your computer and use it in GitHub Desktop.
compare v2 and v3 area files with their text stuff
This file contains hidden or 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
{ | |
"metadata": { | |
"name": "" | |
}, | |
"nbformat": 3, | |
"nbformat_minor": 0, | |
"worksheets": [ | |
{ | |
"cells": [ | |
{ | |
"cell_type": "markdown", | |
"source": [ | |
"# compare v2 and v3 area files" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"collapsed": false, | |
"input": [ | |
"import pandas as pd\n", | |
"import numpy as np\n", | |
"import matplotlib.pyplot as plt\n", | |
"import os" | |
], | |
"language": "python", | |
"outputs": [], | |
"prompt_number": 47 | |
}, | |
{ | |
"cell_type": "code", | |
"collapsed": false, | |
"input": [ | |
"base = '/Users/savoie/projects/sii_migration/pm504/'\n", | |
"dira = 'v2area_rounded'\n", | |
"dirb = 'v3area_rounded'" | |
], | |
"language": "python", | |
"outputs": [], | |
"prompt_number": 48 | |
}, | |
{ | |
"cell_type": "code", | |
"collapsed": false, | |
"input": [ | |
"files = [\n", | |
" 'NH_seaice_extent_final.csv',\n", | |
" 'NH_seaice_extent_nrt.csv',\n", | |
" 'SH_seaice_extent_final.csv',\n", | |
" 'SH_seaice_extent_nrt.csv',\n", | |
"]\n", | |
"clims = ['N_climatology_1981-2010.txt',\n", | |
" 'S_climatology_1981-2010.txt']" | |
], | |
"language": "python", | |
"outputs": [], | |
"prompt_number": 49 | |
}, | |
{ | |
"cell_type": "code", | |
"collapsed": false, | |
"input": [ | |
"def show_compare(a_file, a_data, b_file, b_data):\n", | |
" print (\"Comparing\\n {0} \\n with {1}:\".format(a_file, b_file))\n", | |
" print (\"Differences min:{0}, max: {1}\".format(min(a_data.Extent[:] - b_data.Extent[:]), max(a_data.Extent[:] - b_data.Extent[:])))\n", | |
" print (\"\")\n" | |
], | |
"language": "python", | |
"outputs": [], | |
"prompt_number": 50 | |
}, | |
{ | |
"cell_type": "code", | |
"collapsed": false, | |
"input": [ | |
"for the_filename in files:\n", | |
" a_file = os.path.join(base, dira, the_filename)\n", | |
" b_file = os.path.join(base, dirb, the_filename)\n", | |
" a_data = pd.read_csv(a_file, header=None, skiprows=2, names=[\"Year\", \"Month\", \"Day\", \"Extent\", \"Missing\", \"Source\"])\n", | |
" b_data = pd.read_csv(b_file, header=None, skiprows=2, names=[\"Year\", \"Month\", \"Day\", \"Extent\", \"Missing\", \"Source\"])\n", | |
" show_compare(a_file, a_data, b_file, b_data)\n", | |
"\n", | |
"for clim in clims:\n", | |
" a_file = os.path.join(base, dira, clim)\n", | |
" b_file = os.path.join(base, dirb, clim)\n", | |
" a_clim = pd.read_csv(a_file, header=None, skiprows=2, names=[\"doy\", \"Extent\", \"stddev\"])\n", | |
" b_clim = pd.read_csv(b_file, header=None, skiprows=2, names=[\"doy\", \"Extent\", \"stddev\"])\n", | |
" show_compare(a_file, a_clim, b_file, b_clim)\n", | |
" locs = np.where(np.abs(b_clim.Extent - a_clim.Extent ) > .0011) \n", | |
" if len(locs[0]) > 0:\n", | |
" print(\"places where clim bigger than expected: {0}\".format(locs))\n", | |
" plt.plot(b_clim.Extent - a_clim.Extent)\n", | |
" plt.show()\n", | |
" " | |
], | |
"language": "python", | |
"outputs": [ | |
{ | |
"output_type": "stream", | |
"stream": "stdout", | |
"text": [ | |
"Comparing\n", | |
" /Users/savoie/projects/sii_migration/pm504/v2area_rounded/NH_seaice_extent_final.csv \n", | |
" with /Users/savoie/projects/sii_migration/pm504/v3area_rounded/NH_seaice_extent_final.csv:\n", | |
"Differences min:-0.001, max: 0.001\n", | |
"\n", | |
"Comparing\n", | |
" /Users/savoie/projects/sii_migration/pm504/v2area_rounded/NH_seaice_extent_nrt.csv \n", | |
" with /Users/savoie/projects/sii_migration/pm504/v3area_rounded/NH_seaice_extent_nrt.csv:\n", | |
"Differences min:-0.001, max: 0.001\n", | |
"\n", | |
"Comparing\n", | |
" /Users/savoie/projects/sii_migration/pm504/v2area_rounded/SH_seaice_extent_final.csv \n", | |
" with /Users/savoie/projects/sii_migration/pm504/v3area_rounded/SH_seaice_extent_final.csv:" | |
] | |
}, | |
{ | |
"output_type": "stream", | |
"stream": "stdout", | |
"text": [ | |
"\n", | |
"Differences min:-0.001, max: 0.001\n", | |
"\n", | |
"Comparing\n", | |
" /Users/savoie/projects/sii_migration/pm504/v2area_rounded/SH_seaice_extent_nrt.csv \n", | |
" with /Users/savoie/projects/sii_migration/pm504/v3area_rounded/SH_seaice_extent_nrt.csv:\n", | |
"Differences min:-0.001, max: 0.0\n", | |
"\n", | |
"Comparing\n", | |
" /Users/savoie/projects/sii_migration/pm504/v2area_rounded/N_climatology_1981-2010.txt \n", | |
" with /Users/savoie/projects/sii_migration/pm504/v3area_rounded/N_climatology_1981-2010.txt:\n", | |
"Differences min:-0.001, max: 0.001\n", | |
"\n", | |
"Comparing\n", | |
" /Users/savoie/projects/sii_migration/pm504/v2area_rounded/S_climatology_1981-2010.txt \n", | |
" with /Users/savoie/projects/sii_migration/pm504/v3area_rounded/S_climatology_1981-2010.txt:\n", | |
"Differences min:-0.001, max: 0.0\n", | |
"\n" | |
] | |
} | |
], | |
"prompt_number": 51 | |
}, | |
{ | |
"cell_type": "code", | |
"collapsed": false, | |
"input": [], | |
"language": "python", | |
"outputs": [] | |
} | |
] | |
} | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment