Skip to content

Instantly share code, notes, and snippets.

Created February 7, 2016 14:33
Show Gist options
  • Save anonymous/613be985bcf0001ebd05 to your computer and use it in GitHub Desktop.
Save anonymous/613be985bcf0001ebd05 to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"import skrf as rf # scikit-rf\n",
"import xarray as xr"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"n = rf.data.ring_slot\n",
"\n",
"\n",
"s =xr.DataArray(n.s,\n",
" [('f',n.frequency.f_scaled),\n",
" ('m',range(n.nports)),\n",
" ('n',range(n.nports))])\n",
"\n",
"z0 =xr.DataArray(n.z0,\n",
" [('f',n.frequency.f_scaled),\n",
" ('m',range(n.nports))])\n",
"\n",
"ntwk = xr.Dataset({'s':s,\n",
" 'z0':z0},\n",
" attrs={'name':n.name})"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"<xarray.Dataset>\n",
"Dimensions: (f: 201, m: 2, n: 2)\n",
"Coordinates:\n",
" * f (f) float64 75.0 75.17 75.35 75.53 75.7 75.88 76.05 76.22 76.4 ...\n",
" * m (m) int64 0 1\n",
" * n (n) int64 0 1\n",
"Data variables:\n",
" s (f, m, n) complex128 (-0.503723180993+0.457844804761j) ...\n",
" z0 (f, m) complex128 (50+0j) (50+0j) (50+0j) (50+0j) (50+0j) ...\n",
"Attributes:\n",
" name: ring slot"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"ntwk"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"ntwk.to_netcdf('ring_slot.nc',engine='h5netcdf')"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"<xarray.Dataset>\n",
"Dimensions: (f: 201)\n",
"Coordinates:\n",
" * f (f) float64 75.0 75.17 75.35 75.53 75.7 75.88 76.05 76.22 76.4 ...\n",
"Data variables:\n",
" *empty*\n",
"Attributes:\n",
" name: ring slot"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"ntwk_opened = xr.open_dataset('ring_slot.nc')\n",
"ntwk_opened\n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"ntwk_opened.close()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "IPython (Python 2)",
"language": "python",
"name": "python2"
},
"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.10"
}
},
"nbformat": 4,
"nbformat_minor": 0
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment