Skip to content

Instantly share code, notes, and snippets.

@rhattersley
Last active August 29, 2015 14:11
Show Gist options
  • Save rhattersley/ec532c0d5059ad8c84b2 to your computer and use it in GitHub Desktop.
Save rhattersley/ec532c0d5059ad8c84b2 to your computer and use it in GitHub Desktop.
Curvilinear intersection fails
Display the source blob
Display the rendered blob
Raw
{
"metadata": {
"name": "",
"signature": "sha256:2aa1057764a1e880d2202b936495338fe9ee6beead522ae4171ac0de649ef4af"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
"cell_type": "code",
"collapsed": false,
"input": [
"import iris\n",
"print iris.__version__, iris.__file__"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
"1.8.0-DEV /home/richard/git/iris/lib/iris/__init__.pyc\n"
]
}
],
"prompt_number": 1
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"url = 'http://omgsrv1.meas.ncsu.edu:8080/thredds/dodsC/fmrc/'\n",
"url += 'sabgom/SABGOM_Forecast_Model_Run_Collection_best.ncd'"
],
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 2
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"cdl = !ncdump -h {url}\n",
"print '\\n'.join(cdl[:10] + ['...'])"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
"netcdf SABGOM_Forecast_Model_Run_Collection_best {\n",
"dimensions:\n",
"\tocean_time = UNLIMITED ; // (40 currently)\n",
"\tboundary = 4 ;\n",
"\teta_psi = 319 ;\n",
"\teta_rho = 320 ;\n",
"\teta_u = 320 ;\n",
"\teta_v = 319 ;\n",
"\tmaxStrlen64 = 64 ;\n",
"\ts_rho = 36 ;\n",
"...\n"
]
}
],
"prompt_number": 3
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"iris.FUTURE.netcdf_promote = True # Allow sea_surface_height to appear as a top-level Cube.\n",
"cube = iris.load_cube(url, 'sea_surface_height')\n",
"print cube"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stderr",
"text": [
"/home/richard/git/iris/lib/iris/fileformats/cf.py:1040: UserWarning: Ignoring formula terms variable u'h' referenced by data variable u'v' via variable u's_rho': Dimensions (u'eta_rho', u'xi_rho') do not span (u'time', u's_rho', u'eta_v', u'xi_v')\n",
" warnings.warn(msg)\n",
"/home/richard/git/iris/lib/iris/fileformats/cf.py:1040: UserWarning: Ignoring formula terms variable u'zeta' referenced by data variable u'v' via variable u's_rho': Dimensions (u'time', u'eta_rho', u'xi_rho') do not span (u'time', u's_rho', u'eta_v', u'xi_v')\n",
" warnings.warn(msg)\n",
"/home/richard/git/iris/lib/iris/fileformats/cf.py:1040: UserWarning: Ignoring formula terms variable u'h' referenced by data variable u'u' via variable u's_rho': Dimensions (u'eta_rho', u'xi_rho') do not span (u'time', u's_rho', u'eta_u', u'xi_u')\n",
" warnings.warn(msg)\n"
]
},
{
"output_type": "stream",
"stream": "stderr",
"text": [
"/home/richard/git/iris/lib/iris/fileformats/cf.py:1040: UserWarning: Ignoring formula terms variable u'zeta' referenced by data variable u'u' via variable u's_rho': Dimensions (u'time', u'eta_rho', u'xi_rho') do not span (u'time', u's_rho', u'eta_u', u'xi_u')\n",
" warnings.warn(msg)\n",
"/home/richard/git/iris/lib/iris/fileformats/_pyke_rules/compiled_krb/fc_rules_cf_fc.py:1200: UserWarning: Ignoring netCDF variable 'chlorophyll' invalid units 'milligrams_chlorophyll meter-3'\n",
" warnings.warn(msg.format(msg_name, msg_units))\n",
"/home/richard/git/iris/lib/iris/fileformats/_pyke_rules/compiled_krb/fc_rules_cf_fc.py:1295: UserWarning: Gracefully filling 'time' dimension coordinate masked points\n",
" warnings.warn(msg.format(str(cf_coord_var.cf_name)))\n",
"/home/richard/git/iris/lib/iris/fileformats/_pyke_rules/compiled_krb/fc_rules_cf_fc.py:1200: UserWarning: Ignoring netCDF variable 'phytoplankton' invalid units 'millimole_nitrogen meter-3'\n",
" warnings.warn(msg.format(msg_name, msg_units))\n",
"/home/richard/git/iris/lib/iris/fileformats/_pyke_rules/compiled_krb/fc_rules_cf_fc.py:1200: UserWarning: Ignoring netCDF variable 'NO3' invalid units 'millimole_N03 meter-3'\n",
" warnings.warn(msg.format(msg_name, msg_units))\n"
]
},
{
"output_type": "stream",
"stream": "stdout",
"text": [
"sea_surface_height / (meter) (time: 312; -- : 320; -- : 440)\n",
" Dimension coordinates:\n",
" time x - -\n",
" Auxiliary coordinates:\n",
" forecast_reference_time x - -\n",
" latitude - x x\n",
" longitude - x x\n",
" Attributes:\n",
" CPP_options: SABGOM, ADD_FSOBC, ADD_M2OBC, ANA_BPFLUX, ANA_BSFLUX, ANA_BTFLUX, ANA_SPFLUX,...\n",
" Conventions: CF-1.4, _Coordinates\n",
" _CoordSysBuilder: ucar.nc2.dataset.conv.CF1Convention\n",
" _DODS_Unlimited_Dimension: ocean_time\n",
" ana_file: ROMS/Functionals/ana_btflux.h, ROMS/Functionals/ana_nudgcoef.h, ROMS/F...\n",
" bio_file: ROMS/Nonlinear/Biology/fennel.h\n",
" bpar_file: /home/omg/autosabgom/bioFasham_038_Katja.in.U3C4\n",
" bry_file: /gpfs_share/omg/omg/autosabgom/in/ncoda_bry_20141204.nc\n",
" cdm_data_type: GRID\n",
" clm_file: /gpfs_share/omg/omg/autosabgom/in/ncoda_clm_20141204.nc\n",
" code_dir: /he_data/he/zxue/COAWST411\n",
" compiler_command: /usr/local/apps/mpich/x86_64/pgi105/mx127..7/bin/mpif90\n",
" compiler_flags: -fastsse -Kieee -fastsse -Mipa=fast -tp k8-64 -Mfree\n",
" compiler_system: pgi\n",
" cpu: x86_64\n",
" dia_file: /gpfs_share/omg/autosabgom/out/dia_20141204.nc\n",
" featureType: GRID\n",
" field: free-surface, scalar, series\n",
" file: /gpfs_share/omg/autosabgom/out/his_20141204_0002.nc\n",
" format: netCDF-3 classic file\n",
" frc_file_01: /gpfs_share/omg/omg/autosabgom/in/nomads_forc_20141204.nc\n",
" frc_file_02: /gpfs_share/omg/omg/autosabgom/in/SABGOM.OTIS.Ref18581117.8Cons\n",
" frc_file_03: /gpfs_share/omg/omg/autosabgom/in/sabgom_river_79_clm_2003_2010.nc\n",
" grd_file: /gpfs_share/omg/omg/autosabgom/in/sabgom_grd.nc.Etopo2.LP.r1_5.filled\n",
" header_dir: /he_data/he/zxue/Projects/SABGOM_BIO\n",
" header_file: mch_bio_nf.h\n",
" his_base: /gpfs_share/omg/autosabgom/out/his_20141204\n",
" history: ROMS/TOMS, Version 3.4, Thursday - December 4, 2014 - 11:53:33 PM ;\n",
"FMRC...\n",
" ini_file: /gpfs_share/omg/omg/autosabgom/in/ncoda_ini_20141204.nc\n",
" location: Proto fmrc:SABGOM Forecast Model Run Collection\n",
" os: Linux\n",
" rst_file: /gpfs_share/omg/autosabgom/out/rst_20141204.nc\n",
" script_file: /home/omg/autosabgom/sabgom_20141204.in\n",
" spos_file: /home/omg/autosabgom/stations.in\n",
" sta_file: /gpfs_share/omg/autosabgom/out/sta_20141204.nc\n",
" svn_rev: 412M\n",
" svn_url: https://www.myroms.org/svn/omlab/branches/jcwarner\n",
" tiling: 008x004\n",
" time: ocean_time\n",
" title: ROMS/TOMS 3.0 - South-Atlantic Bight and Gulf of Mexico\n",
" type: ROMS/TOMS history file\n"
]
},
{
"output_type": "stream",
"stream": "stderr",
"text": [
"/home/richard/git/iris/lib/iris/fileformats/_pyke_rules/compiled_krb/fc_rules_cf_fc.py:1200: UserWarning: Ignoring netCDF variable 'zooplankton' invalid units 'millimole_nitrogen meter-3'\n",
" warnings.warn(msg.format(msg_name, msg_units))\n",
"/home/richard/git/iris/lib/iris/fileformats/_pyke_rules/compiled_krb/fc_rules_cf_fc.py:1200: UserWarning: Ignoring netCDF variable 'NH4' invalid units 'millimole_NH4 meter-3'\n",
" warnings.warn(msg.format(msg_name, msg_units))\n"
]
}
],
"prompt_number": 4
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"lons = cube.coord('longitude').points\n",
"print lons.min(), lons.max()"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
"-100.432853579 -68.1901166374\n"
]
}
],
"prompt_number": 5
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"chunk = cube.intersection(longitude=(-87, -74))"
],
"language": "python",
"metadata": {},
"outputs": [
{
"ename": "CoordinateMultiDimError",
"evalue": "Multi-dimensional coordinate not supported: 'longitude'",
"output_type": "pyerr",
"traceback": [
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m\n\u001b[1;31mCoordinateMultiDimError\u001b[0m Traceback (most recent call last)",
"\u001b[1;32m<ipython-input-6-dfbb1c260c2b>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m()\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[0mchunk\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mcube\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mintersection\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mlongitude\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m-\u001b[0m\u001b[1;36m87\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;33m-\u001b[0m\u001b[1;36m74\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m",
"\u001b[1;32m/home/richard/git/iris/lib/iris/cube.pyc\u001b[0m in \u001b[0;36mintersection\u001b[1;34m(self, *args, **kwargs)\u001b[0m\n\u001b[0;32m 2085\u001b[0m \u001b[0mresult\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mresult\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_intersect\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m*\u001b[0m\u001b[0marg\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 2086\u001b[0m \u001b[1;32mfor\u001b[0m \u001b[0mname\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mvalue\u001b[0m \u001b[1;32min\u001b[0m \u001b[0mkwargs\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0miteritems\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m-> 2087\u001b[1;33m \u001b[0mresult\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mresult\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_intersect\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mname\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;33m*\u001b[0m\u001b[0mvalue\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 2088\u001b[0m \u001b[1;32mreturn\u001b[0m \u001b[0mresult\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 2089\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n",
"\u001b[1;32m/home/richard/git/iris/lib/iris/cube.pyc\u001b[0m in \u001b[0;36m_intersect\u001b[1;34m(self, name_or_coord, minimum, maximum, min_inclusive, max_inclusive)\u001b[0m\n\u001b[0;32m 2092\u001b[0m \u001b[0mcoord\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mcoord\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mname_or_coord\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 2093\u001b[0m \u001b[1;32mif\u001b[0m \u001b[0mcoord\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mndim\u001b[0m \u001b[1;33m!=\u001b[0m \u001b[1;36m1\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m-> 2094\u001b[1;33m \u001b[1;32mraise\u001b[0m \u001b[0miris\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mexceptions\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mCoordinateMultiDimError\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mcoord\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 2095\u001b[0m \u001b[1;32mif\u001b[0m \u001b[0mcoord\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mnbounds\u001b[0m \u001b[1;32mnot\u001b[0m \u001b[1;32min\u001b[0m \u001b[1;33m(\u001b[0m\u001b[1;36m0\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;36m2\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 2096\u001b[0m \u001b[1;32mraise\u001b[0m \u001b[0mValueError\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m'expected 0 or 2 bound values per cell'\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
"\u001b[1;31mCoordinateMultiDimError\u001b[0m: Multi-dimensional coordinate not supported: 'longitude'"
]
}
],
"prompt_number": 6
},
{
"cell_type": "code",
"collapsed": false,
"input": [],
"language": "python",
"metadata": {},
"outputs": []
}
],
"metadata": {}
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment