2 | 2 |
<head>
|
3 | 3 |
<meta charset="utf-8">
|
4 | 4 |
<meta name="viewport" content="width=device-width, initial-scale=1">
|
5 | |
<meta name="generator" content="pdoc" />
|
|
5 |
<meta name="generator" content="pdoc 6.4.3" />
|
6 | 6 |
<title>netCDF4 API documentation</title>
|
7 | 7 |
<link rel="icon" type="image/svg+xml" href="data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A//www.w3.org/2000/svg%22%20width%3D%2264%22%20height%3D%2264%22%20viewBox%3D%2244.5%202.5%2015%2015%22%3E%3Cpath%20d%3D%22M49.351%2021.041c-.233-.721-.546-2.408-.772-4.076-.042-.09-.067-.187-.046-.288-.166-1.347-.277-2.625-.241-3.351-1.378-1.008-2.271-2.586-2.271-4.362%200-.976.272-1.935.788-2.774.057-.094.122-.18.184-.268-.033-.167-.052-.339-.052-.516%200-1.477%201.202-2.679%202.679-2.679.791%200%201.496.352%201.987.9a6.3%206.3%200%200%201%201.001.029c.492-.564%201.207-.929%202.012-.929%201.477%200%202.679%201.202%202.679%202.679a2.65%202.65%200%200%201-.269%201.148c.383.747.595%201.572.595%202.41%200%202.311-1.507%204.29-3.635%205.107.037.699.147%202.27.423%203.294l.137.461c.156%202.136-4.612%205.166-5.199%203.215zm.127-4.919a4.78%204.78%200%200%200%20.775-.584c-.172-.115-.505-.254-.88-.378zm.331%202.302l.828-.502c-.202-.143-.576-.328-.984-.49zm.45%202.157l.701-.403c-.214-.115-.536-.249-.891-.376l.19.779zM49.13%204.141c0%20.152.123.276.276.276s.275-.124.275-.276-.123-.276-.276-.276-.275.124-.275.276zm.735-.389a1.15%201.15%200%200%201%20.314.783%201.16%201.16%200%200%201-1.162%201.162c-.457%200-.842-.27-1.032-.653-.026.117-.042.238-.042.362a1.68%201.68%200%200%200%201.679%201.679%201.68%201.68%200%200%200%201.679-1.679c0-.843-.626-1.535-1.436-1.654zm3.076%201.654a1.68%201.68%200%200%200%201.679%201.679%201.68%201.68%200%200%200%201.679-1.679c0-.037-.009-.072-.011-.109-.21.3-.541.508-.935.508a1.16%201.16%200%200%201-1.162-1.162%201.14%201.14%200%200%201%20.474-.912c-.015%200-.03-.005-.045-.005-.926.001-1.679.754-1.679%201.68zm1.861-1.265c0%20.152.123.276.276.276s.275-.124.275-.276-.123-.276-.276-.276-.275.124-.275.276zm1.823%204.823c0-.52-.103-1.035-.288-1.52-.466.394-1.06.64-1.717.64-1.144%200-2.116-.725-2.499-1.738-.383%201.012-1.355%201.738-2.499%201.738-.867%200-1.631-.421-2.121-1.062-.307.605-.478%201.267-.478%201.942%200%202.486%202.153%204.51%204.801%204.51s4.801-2.023%204.801-4.51zm-3.032%209.156l-.146-.492c-.276-1.02-.395-2.457-.444-3.268a6.11%206.11%200%200%201-1.18.115%206.01%206.01%200%200%201-2.536-.562l.006.175c.802.215%201.848.612%202.021%201.25.079.295-.021.601-.274.837l-.598.501c.667.304%201.243.698%201.311%201.179.02.144.022.507-.393.787l-.564.365c1.285.521%201.361.96%201.381%201.126.018.142.011.496-.427.746l-.854.489c.064-1.19%201.985-2.585%202.697-3.248zM49.34%209.925c0-.667%201-.667%201%200%200%20.653.818%201.205%201.787%201.205s1.787-.552%201.787-1.205c0-.667%201-.667%201%200%200%201.216-1.25%202.205-2.787%202.205s-2.787-.989-2.787-2.205zm-.887-7.633c-.093.077-.205.114-.317.114a.5.5%200%200%201-.318-.886L49.183.397a.5.5%200%200%201%20.703.068.5.5%200%200%201-.069.703zm7.661-.065c-.086%200-.173-.022-.253-.068l-1.523-.893c-.575-.337-.069-1.2.506-.863l1.523.892a.5.5%200%200%201%20.179.685c-.094.158-.261.247-.432.247z%22%20fill%3D%22%233bb300%22/%3E%3C/svg%3E"/>
|
8 | 8 |
|
9 | 9 |
|
10 | 10 |
<style type="text/css">/*! * Bootstrap Reboot v5.0.0-beta1 (https://getbootstrap.com/) * Copyright 2011-2020 The Bootstrap Authors * Copyright 2011-2020 Twitter, Inc. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) * Forked from Normalize.css, licensed MIT (https://github.com/necolas/normalize.css/blob/master/LICENSE.md) */*,::after,::before{box-sizing:border-box}@media (prefers-reduced-motion:no-preference){:root{scroll-behavior:smooth}}body{margin:0;font-family:system-ui,-apple-system,"Segoe UI",Roboto,"Helvetica Neue",Arial,"Noto Sans","Liberation Sans",sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji";font-size:1rem;font-weight:400;line-height:1.5;color:#212529;background-color:#fff;-webkit-text-size-adjust:100%;-webkit-tap-highlight-color:transparent}[tabindex="-1"]:focus:not(:focus-visible){outline:0!important}hr{margin:1rem 0;color:inherit;background-color:currentColor;border:0;opacity:.25}hr:not([size]){height:1px}h1,h2,h3,h4,h5,h6{margin-top:0;margin-bottom:.5rem;font-weight:500;line-height:1.2}h1{font-size:calc(1.375rem + 1.5vw)}@media (min-width:1200px){h1{font-size:2.5rem}}h2{font-size:calc(1.325rem + .9vw)}@media (min-width:1200px){h2{font-size:2rem}}h3{font-size:calc(1.3rem + .6vw)}@media (min-width:1200px){h3{font-size:1.75rem}}h4{font-size:calc(1.275rem + .3vw)}@media (min-width:1200px){h4{font-size:1.5rem}}h5{font-size:1.25rem}h6{font-size:1rem}p{margin-top:0;margin-bottom:1rem}abbr[data-bs-original-title],abbr[title]{text-decoration:underline;-webkit-text-decoration:underline dotted;text-decoration:underline dotted;cursor:help;-webkit-text-decoration-skip-ink:none;text-decoration-skip-ink:none}address{margin-bottom:1rem;font-style:normal;line-height:inherit}ol,ul{padding-left:2rem}dl,ol,ul{margin-top:0;margin-bottom:1rem}ol ol,ol ul,ul ol,ul ul{margin-bottom:0}dt{font-weight:700}dd{margin-bottom:.5rem;margin-left:0}blockquote{margin:0 0 1rem}b,strong{font-weight:bolder}small{font-size:.875em}mark{padding:.2em;background-color:#fcf8e3}sub,sup{position:relative;font-size:.75em;line-height:0;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}a{color:#0d6efd;text-decoration:underline}a:hover{color:#0a58ca}a:not([href]):not([class]),a:not([href]):not([class]):hover{color:inherit;text-decoration:none}code,kbd,pre,samp{font-family:SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace;font-size:1em;direction:ltr;unicode-bidi:bidi-override}pre{display:block;margin-top:0;margin-bottom:1rem;overflow:auto;font-size:.875em}pre code{font-size:inherit;color:inherit;word-break:normal}code{font-size:.875em;color:#d63384;word-wrap:break-word}a>code{color:inherit}kbd{padding:.2rem .4rem;font-size:.875em;color:#fff;background-color:#212529;border-radius:.2rem}kbd kbd{padding:0;font-size:1em;font-weight:700}figure{margin:0 0 1rem}img,svg{vertical-align:middle}table{caption-side:bottom;border-collapse:collapse}caption{padding-top:.5rem;padding-bottom:.5rem;color:#6c757d;text-align:left}th{text-align:inherit;text-align:-webkit-match-parent}tbody,td,tfoot,th,thead,tr{border-color:inherit;border-style:solid;border-width:0}label{display:inline-block}button{border-radius:0}button:focus{outline:dotted 1px;outline:-webkit-focus-ring-color auto 5px}button,input,optgroup,select,textarea{margin:0;font-family:inherit;font-size:inherit;line-height:inherit}button,select{text-transform:none}[role=button]{cursor:pointer}select{word-wrap:normal}[list]::-webkit-calendar-picker-indicator{display:none}[type=button],[type=reset],[type=submit],button{-webkit-appearance:button}[type=button]:not(:disabled),[type=reset]:not(:disabled),[type=submit]:not(:disabled),button:not(:disabled){cursor:pointer}::-moz-focus-inner{padding:0;border-style:none}textarea{resize:vertical}fieldset{min-width:0;padding:0;margin:0;border:0}legend{float:left;width:100%;padding:0;margin-bottom:.5rem;font-size:calc(1.275rem + .3vw);line-height:inherit}@media (min-width:1200px){legend{font-size:1.5rem}}legend+*{clear:left}::-webkit-datetime-edit-day-field,::-webkit-datetime-edit-fields-wrapper,::-webkit-datetime-edit-hour-field,::-webkit-datetime-edit-minute,::-webkit-datetime-edit-month-field,::-webkit-datetime-edit-text,::-webkit-datetime-edit-year-field{padding:0}::-webkit-inner-spin-button{height:auto}[type=search]{outline-offset:-2px;-webkit-appearance:textfield}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-color-swatch-wrapper{padding:0}::file-selector-button{font:inherit}::-webkit-file-upload-button{font:inherit;-webkit-appearance:button}output{display:inline-block}iframe{border:0}summary{display:list-item;cursor:pointer}progress{vertical-align:baseline}[hidden]{display:none!important}</style>
|
11 | 11 |
<style type="text/css">/*! pygments syntax highlighting */pre{line-height:125%;}td.linenos pre{color:#000000; background-color:#f0f0f0; padding-left:5px; padding-right:5px;}span.linenos{color:#000000; background-color:#f0f0f0; padding-left:5px; padding-right:5px;}td.linenos pre.special{color:#000000; background-color:#ffffc0; padding-left:5px; padding-right:5px;}span.linenos.special{color:#000000; background-color:#ffffc0; padding-left:5px; padding-right:5px;}.pdoc .hll{background-color:#ffffcc}.pdoc{background:#f8f8f8;}.pdoc .c{color:#408080; font-style:italic}.pdoc .err{border:1px solid #FF0000}.pdoc .k{color:#008000; font-weight:bold}.pdoc .o{color:#666666}.pdoc .ch{color:#408080; font-style:italic}.pdoc .cm{color:#408080; font-style:italic}.pdoc .cp{color:#BC7A00}.pdoc .cpf{color:#408080; font-style:italic}.pdoc .c1{color:#408080; font-style:italic}.pdoc .cs{color:#408080; font-style:italic}.pdoc .gd{color:#A00000}.pdoc .ge{font-style:italic}.pdoc .gr{color:#FF0000}.pdoc .gh{color:#000080; font-weight:bold}.pdoc .gi{color:#00A000}.pdoc .go{color:#888888}.pdoc .gp{color:#000080; font-weight:bold}.pdoc .gs{font-weight:bold}.pdoc .gu{color:#800080; font-weight:bold}.pdoc .gt{color:#0044DD}.pdoc .kc{color:#008000; font-weight:bold}.pdoc .kd{color:#008000; font-weight:bold}.pdoc .kn{color:#008000; font-weight:bold}.pdoc .kp{color:#008000}.pdoc .kr{color:#008000; font-weight:bold}.pdoc .kt{color:#B00040}.pdoc .m{color:#666666}.pdoc .s{color:#BA2121}.pdoc .na{color:#7D9029}.pdoc .nb{color:#008000}.pdoc .nc{color:#0000FF; font-weight:bold}.pdoc .no{color:#880000}.pdoc .nd{color:#AA22FF}.pdoc .ni{color:#999999; font-weight:bold}.pdoc .ne{color:#D2413A; font-weight:bold}.pdoc .nf{color:#0000FF}.pdoc .nl{color:#A0A000}.pdoc .nn{color:#0000FF; font-weight:bold}.pdoc .nt{color:#008000; font-weight:bold}.pdoc .nv{color:#19177C}.pdoc .ow{color:#AA22FF; font-weight:bold}.pdoc .w{color:#bbbbbb}.pdoc .mb{color:#666666}.pdoc .mf{color:#666666}.pdoc .mh{color:#666666}.pdoc .mi{color:#666666}.pdoc .mo{color:#666666}.pdoc .sa{color:#BA2121}.pdoc .sb{color:#BA2121}.pdoc .sc{color:#BA2121}.pdoc .dl{color:#BA2121}.pdoc .sd{color:#BA2121; font-style:italic}.pdoc .s2{color:#BA2121}.pdoc .se{color:#BB6622; font-weight:bold}.pdoc .sh{color:#BA2121}.pdoc .si{color:#BB6688; font-weight:bold}.pdoc .sx{color:#008000}.pdoc .sr{color:#BB6688}.pdoc .s1{color:#BA2121}.pdoc .ss{color:#19177C}.pdoc .bp{color:#008000}.pdoc .fm{color:#0000FF}.pdoc .vc{color:#19177C}.pdoc .vg{color:#19177C}.pdoc .vi{color:#19177C}.pdoc .vm{color:#19177C}.pdoc .il{color:#666666}</style>
|
12 | |
<style type="text/css">/*! pdoc */:root{--pdoc-background:#fff;}.pdoc{--text:#212529;--muted:#6c757d;--link:#3660a5;--link-hover:#1659c5;--code:#f7f7f7;--active:#fff598;--accent:#eee;--accent2:#c1c1c1;--nav-hover:rgba(255, 255, 255, 0.5);--name:#0066BB;--def:#008800;--annotation:#007020;}body{background-color:var(--pdoc-background);}html, body{width:100%;height:100%;}@media (max-width:769px){#navtoggle{cursor:pointer;position:absolute;width:50px;height:40px;top:1rem;right:1rem;border-color:var(--text);color:var(--text);display:flex;opacity:0.8;}#navtoggle:hover{opacity:1;}#togglestate + div{display:none;}#togglestate:checked + div{display:inherit;}main{padding:2rem 3vw;}.git-button{display:none !important;}}@media (min-width:770px){:root{--sidebar-width:clamp(12.5rem, 28vw, 22rem);}nav{position:fixed;overflow:auto;height:100vh;width:var(--sidebar-width);}main{padding:3rem 2rem 3rem calc(var(--sidebar-width) + 3rem);width:calc(54rem + var(--sidebar-width));max-width:100%;}#navtoggle{display:none;}}#togglestate{display:none;}nav.pdoc{--pad:1.75rem;--indent:1.5rem;background-color:var(--accent);border-right:1px solid var(--accent2);box-shadow:0 0 20px rgba(50, 50, 50, .2) inset;padding:0 0 0 var(--pad);overflow-wrap:anywhere;scrollbar-width:thin; scrollbar-color:var(--accent2) transparent }nav.pdoc::-webkit-scrollbar{width:.4rem; }nav.pdoc::-webkit-scrollbar-thumb{background-color:var(--accent2); }nav.pdoc > div{padding:var(--pad) 0;}nav.pdoc .module-list-button{display:inline-flex;align-items:center;color:var(--text);border-color:var(--muted);margin-bottom:1rem;}nav.pdoc .module-list-button:hover{border-color:var(--text);}nav.pdoc ul{list-style:none;padding-left:0;}nav.pdoc li{display:block;margin:0;padding:.2rem 0 .2rem var(--indent);transition:all 100ms;}nav.pdoc > div > ul > li{padding-left:0;}nav.pdoc li:hover{background-color:var(--nav-hover);}nav.pdoc a, nav.pdoc a:hover{color:var(--text);}nav.pdoc a{display:block;}nav.pdoc > h2:first-of-type{margin-top:1.5rem;}nav.pdoc .class:before{content:"class ";color:var(--muted);}nav.pdoc .function:after{content:"()";color:var(--muted);}html, main{scroll-behavior:smooth;}.pdoc{color:var(--text);box-sizing:border-box;line-height:1.5;background:none;}.pdoc .pdoc-button{display:inline-block;border:solid black 1px;border-radius:2px;font-size:.75rem;padding:calc(0.5em - 1px) 1em;transition:100ms all;}.pdoc h1, .pdoc h2, .pdoc h3, .pdoc h4{font-weight:300;margin:.3em 0;padding:.2em 0;}.pdoc a{text-decoration:none;color:var(--link);}.pdoc a:hover{color:var(--link-hover);}.pdoc blockquote{margin-left:2rem;}.pdoc pre{background-color:var(--code);border-top:1px solid var(--accent2);border-bottom:1px solid var(--accent2);margin-bottom:1em;padding:.5rem 0 .5rem .5rem;overflow-x:auto;}.pdoc code{color:var(--text);padding:.2em .4em;margin:0;font-size:85%;background-color:var(--code);border-radius:6px;}.pdoc a > code{color:inherit;}.pdoc pre > code{display:inline-block;font-size:inherit;background:none;border:none;padding:0;}.pdoc .modulename{margin-top:0;font-weight:bold;}.pdoc .modulename a{color:var(--link);transition:100ms all;}.pdoc .git-button{float:right;border:solid var(--link) 1px;}.pdoc .git-button:hover{background-color:var(--link);color:var(--pdoc-background);}.pdoc details{--shift:-40px;text-align:right;margin-top:var(--shift);margin-bottom:calc(0px - var(--shift));clear:both;filter:opacity(1);}.pdoc details:not([open]){height:0;overflow:visible;}.pdoc details > summary{font-size:.75rem;cursor:pointer;color:var(--muted);border-width:0;padding:0 .7em;display:inline-block;display:inline list-item;user-select:none;}.pdoc details > summary:focus{outline:0;}.pdoc details > div{margin-top:calc(0px - var(--shift) / 2);text-align:left;}.pdoc .docstring{margin-bottom:1.5rem;}.pdoc > section:first-of-type > .docstring{margin-bottom:3rem;}.pdoc .docstring pre{margin-left:1em;margin-right:1em;}.pdoc h1:target,.pdoc h2:target,.pdoc h3:target,.pdoc h4:target,.pdoc h5:target,.pdoc h6:target{background-color:var(--active);box-shadow:-1rem 0 0 0 var(--active);}.pdoc div:target > .attr,.pdoc section:target > .attr,.pdoc dd:target > a{background-color:var(--active);}.pdoc .attr:hover{filter:contrast(0.95);}.pdoc .headerlink{position:absolute;width:0;margin-left:-1.5rem;line-height:1.4rem;font-size:1.5rem;font-weight:normal;transition:all 100ms ease-in-out;opacity:0;}.pdoc .attr > .headerlink{margin-left:-2.5rem;}.pdoc *:hover > .headerlink,.pdoc *:target > .attr > .headerlink{opacity:1;}.pdoc .attr{color:var(--text);margin:1rem 0 .5rem;padding:.4rem 5rem .4rem 1rem;background-color:var(--accent);}.pdoc .classattr{margin-left:2rem;}.pdoc .name{color:var(--name);font-weight:bold;}.pdoc .def{color:var(--def);font-weight:bold;}.pdoc .signature{white-space:pre-wrap;}.pdoc .annotation{color:var(--annotation);}.pdoc .inherited{margin-left:2rem;}.pdoc .inherited dt{font-weight:700;}.pdoc .inherited dt, .pdoc .inherited dd{display:inline;margin-left:0;margin-bottom:.5rem;}.pdoc .inherited dd:not(:last-child):after{content:", ";}.pdoc .inherited .class:before{content:"class ";}.pdoc .inherited .function a:after{content:"()";}.pdoc .attribution{margin-top:2rem;display:block;opacity:0.5;transition:all 200ms;filter:grayscale(100%);}.pdoc .attribution:hover{opacity:1;filter:grayscale(0%);}.pdoc .attribution img{margin-left:5px;height:35px;vertical-align:middle;width:70px;transition:all 200ms;}</style>
|
|
12 |
<style type="text/css">/*! pdoc */:root{--pdoc-background:#fff;}.pdoc{--text:#212529;--muted:#6c757d;--link:#3660a5;--link-hover:#1659c5;--code:#f7f7f7;--active:#fff598;--accent:#eee;--accent2:#c1c1c1;--nav-hover:rgba(255, 255, 255, 0.5);--name:#0066BB;--def:#008800;--annotation:#007020;}body{background-color:var(--pdoc-background);}html, body{width:100%;height:100%;}@media (max-width:769px){#navtoggle{cursor:pointer;position:absolute;width:50px;height:40px;top:1rem;right:1rem;border-color:var(--text);color:var(--text);display:flex;opacity:0.8;}#navtoggle:hover{opacity:1;}#togglestate + div{display:none;}#togglestate:checked + div{display:inherit;}main{padding:2rem 3vw;}.git-button{display:none !important;}}@media (min-width:770px){:root{--sidebar-width:clamp(12.5rem, 28vw, 22rem);}nav{position:fixed;overflow:auto;height:100vh;width:var(--sidebar-width);}main{padding:3rem 2rem 3rem calc(var(--sidebar-width) + 3rem);width:calc(54rem + var(--sidebar-width));max-width:100%;}#navtoggle{display:none;}}#togglestate{display:none;}nav.pdoc{--pad:1.75rem;--indent:1.5rem;background-color:var(--accent);border-right:1px solid var(--accent2);box-shadow:0 0 20px rgba(50, 50, 50, .2) inset;padding:0 0 0 var(--pad);overflow-wrap:anywhere;scrollbar-width:thin; scrollbar-color:var(--accent2) transparent }nav.pdoc::-webkit-scrollbar{width:.4rem; }nav.pdoc::-webkit-scrollbar-thumb{background-color:var(--accent2); }nav.pdoc > div{padding:var(--pad) 0;}nav.pdoc .module-list-button{display:inline-flex;align-items:center;color:var(--text);border-color:var(--muted);margin-bottom:1rem;}nav.pdoc .module-list-button:hover{border-color:var(--text);}nav.pdoc ul{list-style:none;padding-left:0;}nav.pdoc li{display:block;margin:0;padding:.2rem 0 .2rem var(--indent);transition:all 100ms;}nav.pdoc > div > ul > li{padding-left:0;}nav.pdoc li:hover{background-color:var(--nav-hover);}nav.pdoc a, nav.pdoc a:hover{color:var(--text);}nav.pdoc a{display:block;}nav.pdoc > h2:first-of-type{margin-top:1.5rem;}nav.pdoc .class:before{content:"class ";color:var(--muted);}nav.pdoc .function:after{content:"()";color:var(--muted);}html, main{scroll-behavior:smooth;}.pdoc{color:var(--text);box-sizing:border-box;line-height:1.5;background:none;}.pdoc .pdoc-button{display:inline-block;border:solid black 1px;border-radius:2px;font-size:.75rem;padding:calc(0.5em - 1px) 1em;transition:100ms all;}.pdoc .visually-hidden{position:absolute !important;width:1px !important;height:1px !important;padding:0 !important;margin:-1px !important;overflow:hidden !important;clip:rect(0, 0, 0, 0) !important;white-space:nowrap !important;border:0 !important;}.pdoc h1, .pdoc h2, .pdoc h3, .pdoc h4{font-weight:300;margin:.3em 0;padding:.2em 0;}.pdoc a{text-decoration:none;color:var(--link);}.pdoc a:hover{color:var(--link-hover);}.pdoc blockquote{margin-left:2rem;}.pdoc pre{background-color:var(--code);border-top:1px solid var(--accent2);border-bottom:1px solid var(--accent2);margin-bottom:1em;padding:.5rem 0 .5rem .5rem;overflow-x:auto;}.pdoc code{color:var(--text);padding:.2em .4em;margin:0;font-size:85%;background-color:var(--code);border-radius:6px;}.pdoc a > code{color:inherit;}.pdoc pre > code{display:inline-block;font-size:inherit;background:none;border:none;padding:0;}.pdoc .modulename{margin-top:0;font-weight:bold;}.pdoc .modulename a{color:var(--link);transition:100ms all;}.pdoc .git-button{float:right;border:solid var(--link) 1px;}.pdoc .git-button:hover{background-color:var(--link);color:var(--pdoc-background);}.pdoc details{--shift:-40px;text-align:right;margin-top:var(--shift);margin-bottom:calc(0px - var(--shift));clear:both;filter:opacity(1);}.pdoc details:not([open]){height:0;overflow:visible;}.pdoc details > summary{font-size:.75rem;cursor:pointer;color:var(--muted);border-width:0;padding:0 .7em;display:inline-block;display:inline list-item;user-select:none;}.pdoc details > summary:focus{outline:0;}.pdoc details > div{margin-top:calc(0px - var(--shift) / 2);text-align:left;}.pdoc .docstring{margin-bottom:1.5rem;}.pdoc > section:first-of-type > .docstring{margin-bottom:3rem;}.pdoc .docstring pre{margin-left:1em;margin-right:1em;}.pdoc h1:target,.pdoc h2:target,.pdoc h3:target,.pdoc h4:target,.pdoc h5:target,.pdoc h6:target{background-color:var(--active);box-shadow:-1rem 0 0 0 var(--active);}.pdoc div:target > .attr,.pdoc section:target > .attr,.pdoc dd:target > a{background-color:var(--active);}.pdoc .attr:hover{filter:contrast(0.95);}.pdoc .headerlink{position:absolute;width:0;margin-left:-1.5rem;line-height:1.4rem;font-size:1.5rem;font-weight:normal;transition:all 100ms ease-in-out;opacity:0;}.pdoc .attr > .headerlink{margin-left:-2.5rem;}.pdoc *:hover > .headerlink,.pdoc *:target > .attr > .headerlink{opacity:1;}.pdoc .attr{color:var(--text);margin:1rem 0 .5rem;padding:.4rem 5rem .4rem 1rem;background-color:var(--accent);}.pdoc .classattr{margin-left:2rem;}.pdoc .name{color:var(--name);font-weight:bold;}.pdoc .def{color:var(--def);font-weight:bold;}.pdoc .signature{white-space:pre-wrap;}.pdoc .annotation{color:var(--annotation);}.pdoc .inherited{margin-left:2rem;}.pdoc .inherited dt{font-weight:700;}.pdoc .inherited dt, .pdoc .inherited dd{display:inline;margin-left:0;margin-bottom:.5rem;}.pdoc .inherited dd:not(:last-child):after{content:", ";}.pdoc .inherited .class:before{content:"class ";}.pdoc .inherited .function a:after{content:"()";}.pdoc .attribution{margin-top:2rem;display:block;opacity:0.5;transition:all 200ms;filter:grayscale(100%);}.pdoc .attribution:hover{opacity:1;filter:grayscale(0%);}.pdoc .attribution img{margin-left:5px;height:35px;vertical-align:middle;width:70px;transition:all 200ms;}</style>
|
13 | 13 |
</head>
|
14 | 14 |
<body> <nav class="pdoc">
|
15 | 15 |
<label id="navtoggle" for="togglestate" class="pdoc-button"><svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'><path stroke-linecap='round' stroke="currentColor" stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/></svg></label>
|
16 | 16 |
<input id="togglestate" type="checkbox">
|
17 | 17 |
<div>
|
18 | |
<a class="pdoc-button module-list-button" href="./index.html">
|
19 | |
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-box-arrow-in-left" viewBox="0 0 16 16">
|
20 | |
<path fill-rule="evenodd" d="M10 3.5a.5.5 0 0 0-.5-.5h-8a.5.5 0 0 0-.5.5v9a.5.5 0 0 0 .5.5h8a.5.5 0 0 0 .5-.5v-2a.5.5 0 0 1 1 0v2A1.5 1.5 0 0 1 9.5 14h-8A1.5 1.5 0 0 1 0 12.5v-9A1.5 1.5 0 0 1 1.5 2h8A1.5 1.5 0 0 1 11 3.5v2a.5.5 0 0 1-1 0v-2z"/>
|
21 | |
<path fill-rule="evenodd" d="M4.146 8.354a.5.5 0 0 1 0-.708l3-3a.5.5 0 1 1 .708.708L5.707 7.5H14.5a.5.5 0 0 1 0 1H5.707l2.147 2.146a.5.5 0 0 1-.708.708l-3-3z"/>
|
22 | |
</svg> netCDF4</a>
|
23 | 18 |
|
24 | 19 |
|
25 | 20 |
<h2>Contents</h2>
|
26 | 21 |
<ul>
|
27 | |
<li><a href="#version-156">Version 1.5.6</a></li>
|
|
22 |
<li><a href="#version-157">Version 1.5.7</a></li>
|
28 | 23 |
</ul></li>
|
29 | 24 |
<li><a href="#introduction">Introduction</a>
|
30 | 25 |
<ul>
|
31 | |
<li><a href="#download">Download</a></li>
|
32 | |
<li><a href="#requires">Requires</a></li>
|
33 | |
<li><a href="#install">Install</a></li>
|
|
26 |
<li><a href="#quick-install">Quick Install</a></li>
|
|
27 |
<li><a href="#developer-install">Developer Install</a></li>
|
34 | 28 |
</ul></li>
|
35 | 29 |
<li><a href="#tutorial">Tutorial</a>
|
36 | 30 |
<ul>
|
|
197 | 191 |
|
198 | 192 |
</li>
|
199 | 193 |
<li>
|
200 | |
<a class="class" href="#Group">Group</a>
|
|
194 |
<a class="class" href="#Variable">Variable</a>
|
201 | 195 |
<ul class="memberlist">
|
202 | 196 |
<li>
|
203 | |
<a class="function" href="#Group.__init__">Group</a>
|
204 | |
</li>
|
205 | |
<li>
|
206 | |
<a class="function" href="#Group.close">close</a>
|
|
197 |
<a class="function" href="#Variable.__init__">Variable</a>
|
|
198 |
</li>
|
|
199 |
<li>
|
|
200 |
<a class="function" href="#Variable.group">group</a>
|
|
201 |
</li>
|
|
202 |
<li>
|
|
203 |
<a class="function" href="#Variable.ncattrs">ncattrs</a>
|
|
204 |
</li>
|
|
205 |
<li>
|
|
206 |
<a class="function" href="#Variable.setncattr">setncattr</a>
|
|
207 |
</li>
|
|
208 |
<li>
|
|
209 |
<a class="function" href="#Variable.setncattr_string">setncattr_string</a>
|
|
210 |
</li>
|
|
211 |
<li>
|
|
212 |
<a class="function" href="#Variable.setncatts">setncatts</a>
|
|
213 |
</li>
|
|
214 |
<li>
|
|
215 |
<a class="function" href="#Variable.getncattr">getncattr</a>
|
|
216 |
</li>
|
|
217 |
<li>
|
|
218 |
<a class="function" href="#Variable.delncattr">delncattr</a>
|
|
219 |
</li>
|
|
220 |
<li>
|
|
221 |
<a class="function" href="#Variable.filters">filters</a>
|
|
222 |
</li>
|
|
223 |
<li>
|
|
224 |
<a class="function" href="#Variable.endian">endian</a>
|
|
225 |
</li>
|
|
226 |
<li>
|
|
227 |
<a class="function" href="#Variable.chunking">chunking</a>
|
|
228 |
</li>
|
|
229 |
<li>
|
|
230 |
<a class="function" href="#Variable.get_var_chunk_cache">get_var_chunk_cache</a>
|
|
231 |
</li>
|
|
232 |
<li>
|
|
233 |
<a class="function" href="#Variable.set_var_chunk_cache">set_var_chunk_cache</a>
|
|
234 |
</li>
|
|
235 |
<li>
|
|
236 |
<a class="function" href="#Variable.renameAttribute">renameAttribute</a>
|
|
237 |
</li>
|
|
238 |
<li>
|
|
239 |
<a class="function" href="#Variable.assignValue">assignValue</a>
|
|
240 |
</li>
|
|
241 |
<li>
|
|
242 |
<a class="function" href="#Variable.getValue">getValue</a>
|
|
243 |
</li>
|
|
244 |
<li>
|
|
245 |
<a class="function" href="#Variable.set_auto_chartostring">set_auto_chartostring</a>
|
|
246 |
</li>
|
|
247 |
<li>
|
|
248 |
<a class="function" href="#Variable.use_nc_get_vars">use_nc_get_vars</a>
|
|
249 |
</li>
|
|
250 |
<li>
|
|
251 |
<a class="function" href="#Variable.set_auto_maskandscale">set_auto_maskandscale</a>
|
|
252 |
</li>
|
|
253 |
<li>
|
|
254 |
<a class="function" href="#Variable.set_auto_scale">set_auto_scale</a>
|
|
255 |
</li>
|
|
256 |
<li>
|
|
257 |
<a class="function" href="#Variable.set_auto_mask">set_auto_mask</a>
|
|
258 |
</li>
|
|
259 |
<li>
|
|
260 |
<a class="function" href="#Variable.set_always_mask">set_always_mask</a>
|
|
261 |
</li>
|
|
262 |
<li>
|
|
263 |
<a class="function" href="#Variable.set_ncstring_attrs">set_ncstring_attrs</a>
|
|
264 |
</li>
|
|
265 |
<li>
|
|
266 |
<a class="function" href="#Variable.set_collective">set_collective</a>
|
|
267 |
</li>
|
|
268 |
<li>
|
|
269 |
<a class="function" href="#Variable.get_dims">get_dims</a>
|
|
270 |
</li>
|
|
271 |
<li>
|
|
272 |
<a class="variable" href="#Variable.name">name</a>
|
|
273 |
</li>
|
|
274 |
<li>
|
|
275 |
<a class="variable" href="#Variable.datatype">datatype</a>
|
|
276 |
</li>
|
|
277 |
<li>
|
|
278 |
<a class="variable" href="#Variable.shape">shape</a>
|
|
279 |
</li>
|
|
280 |
<li>
|
|
281 |
<a class="variable" href="#Variable.size">size</a>
|
|
282 |
</li>
|
|
283 |
<li>
|
|
284 |
<a class="variable" href="#Variable.dimensions">dimensions</a>
|
|
285 |
</li>
|
|
286 |
<li>
|
|
287 |
<a class="variable" href="#Variable.ndim">ndim</a>
|
|
288 |
</li>
|
|
289 |
<li>
|
|
290 |
<a class="variable" href="#Variable.dtype">dtype</a>
|
|
291 |
</li>
|
|
292 |
<li>
|
|
293 |
<a class="variable" href="#Variable.mask">mask</a>
|
|
294 |
</li>
|
|
295 |
<li>
|
|
296 |
<a class="variable" href="#Variable.scale">scale</a>
|
|
297 |
</li>
|
|
298 |
<li>
|
|
299 |
<a class="variable" href="#Variable.always_mask">always_mask</a>
|
|
300 |
</li>
|
|
301 |
<li>
|
|
302 |
<a class="variable" href="#Variable.chartostring">chartostring</a>
|
207 | 303 |
</li>
|
208 | 304 |
</ul>
|
209 | 305 |
|
|
230 | 326 |
|
231 | 327 |
</li>
|
232 | 328 |
<li>
|
233 | |
<a class="class" href="#Variable">Variable</a>
|
|
329 |
<a class="class" href="#Group">Group</a>
|
234 | 330 |
<ul class="memberlist">
|
235 | 331 |
<li>
|
236 | |
<a class="function" href="#Variable.__init__">Variable</a>
|
237 | |
</li>
|
238 | |
<li>
|
239 | |
<a class="function" href="#Variable.group">group</a>
|
240 | |
</li>
|
241 | |
<li>
|
242 | |
<a class="function" href="#Variable.ncattrs">ncattrs</a>
|
243 | |
</li>
|
244 | |
<li>
|
245 | |
<a class="function" href="#Variable.setncattr">setncattr</a>
|
246 | |
</li>
|
247 | |
<li>
|
248 | |
<a class="function" href="#Variable.setncattr_string">setncattr_string</a>
|
249 | |
</li>
|
250 | |
<li>
|
251 | |
<a class="function" href="#Variable.setncatts">setncatts</a>
|
252 | |
</li>
|
253 | |
<li>
|
254 | |
<a class="function" href="#Variable.getncattr">getncattr</a>
|
255 | |
</li>
|
256 | |
<li>
|
257 | |
<a class="function" href="#Variable.delncattr">delncattr</a>
|
258 | |
</li>
|
259 | |
<li>
|
260 | |
<a class="function" href="#Variable.filters">filters</a>
|
261 | |
</li>
|
262 | |
<li>
|
263 | |
<a class="function" href="#Variable.endian">endian</a>
|
264 | |
</li>
|
265 | |
<li>
|
266 | |
<a class="function" href="#Variable.chunking">chunking</a>
|
267 | |
</li>
|
268 | |
<li>
|
269 | |
<a class="function" href="#Variable.get_var_chunk_cache">get_var_chunk_cache</a>
|
270 | |
</li>
|
271 | |
<li>
|
272 | |
<a class="function" href="#Variable.set_var_chunk_cache">set_var_chunk_cache</a>
|
273 | |
</li>
|
274 | |
<li>
|
275 | |
<a class="function" href="#Variable.renameAttribute">renameAttribute</a>
|
276 | |
</li>
|
277 | |
<li>
|
278 | |
<a class="function" href="#Variable.assignValue">assignValue</a>
|
279 | |
</li>
|
280 | |
<li>
|
281 | |
<a class="function" href="#Variable.getValue">getValue</a>
|
282 | |
</li>
|
283 | |
<li>
|
284 | |
<a class="function" href="#Variable.set_auto_chartostring">set_auto_chartostring</a>
|
285 | |
</li>
|
286 | |
<li>
|
287 | |
<a class="function" href="#Variable.use_nc_get_vars">use_nc_get_vars</a>
|
288 | |
</li>
|
289 | |
<li>
|
290 | |
<a class="function" href="#Variable.set_auto_maskandscale">set_auto_maskandscale</a>
|
291 | |
</li>
|
292 | |
<li>
|
293 | |
<a class="function" href="#Variable.set_auto_scale">set_auto_scale</a>
|
294 | |
</li>
|
295 | |
<li>
|
296 | |
<a class="function" href="#Variable.set_auto_mask">set_auto_mask</a>
|
297 | |
</li>
|
298 | |
<li>
|
299 | |
<a class="function" href="#Variable.set_always_mask">set_always_mask</a>
|
300 | |
</li>
|
301 | |
<li>
|
302 | |
<a class="function" href="#Variable.set_ncstring_attrs">set_ncstring_attrs</a>
|
303 | |
</li>
|
304 | |
<li>
|
305 | |
<a class="function" href="#Variable.set_collective">set_collective</a>
|
306 | |
</li>
|
307 | |
<li>
|
308 | |
<a class="function" href="#Variable.get_dims">get_dims</a>
|
309 | |
</li>
|
310 | |
<li>
|
311 | |
<a class="variable" href="#Variable.name">name</a>
|
312 | |
</li>
|
313 | |
<li>
|
314 | |
<a class="variable" href="#Variable.datatype">datatype</a>
|
315 | |
</li>
|
316 | |
<li>
|
317 | |
<a class="variable" href="#Variable.shape">shape</a>
|
318 | |
</li>
|
319 | |
<li>
|
320 | |
<a class="variable" href="#Variable.size">size</a>
|
321 | |
</li>
|
322 | |
<li>
|
323 | |
<a class="variable" href="#Variable.dimensions">dimensions</a>
|
324 | |
</li>
|
325 | |
<li>
|
326 | |
<a class="variable" href="#Variable.ndim">ndim</a>
|
327 | |
</li>
|
328 | |
<li>
|
329 | |
<a class="variable" href="#Variable.dtype">dtype</a>
|
330 | |
</li>
|
331 | |
<li>
|
332 | |
<a class="variable" href="#Variable.mask">mask</a>
|
333 | |
</li>
|
334 | |
<li>
|
335 | |
<a class="variable" href="#Variable.scale">scale</a>
|
336 | |
</li>
|
337 | |
<li>
|
338 | |
<a class="variable" href="#Variable.always_mask">always_mask</a>
|
339 | |
</li>
|
340 | |
<li>
|
341 | |
<a class="variable" href="#Variable.chartostring">chartostring</a>
|
|
332 |
<a class="function" href="#Group.__init__">Group</a>
|
|
333 |
</li>
|
|
334 |
<li>
|
|
335 |
<a class="function" href="#Group.close">close</a>
|
|
336 |
</li>
|
|
337 |
</ul>
|
|
338 |
|
|
339 |
</li>
|
|
340 |
<li>
|
|
341 |
<a class="class" href="#MFDataset">MFDataset</a>
|
|
342 |
<ul class="memberlist">
|
|
343 |
<li>
|
|
344 |
<a class="function" href="#MFDataset.__init__">MFDataset</a>
|
|
345 |
</li>
|
|
346 |
<li>
|
|
347 |
<a class="function" href="#MFDataset.ncattrs">ncattrs</a>
|
|
348 |
</li>
|
|
349 |
<li>
|
|
350 |
<a class="function" href="#MFDataset.close">close</a>
|
|
351 |
</li>
|
|
352 |
</ul>
|
|
353 |
|
|
354 |
</li>
|
|
355 |
<li>
|
|
356 |
<a class="class" href="#MFTime">MFTime</a>
|
|
357 |
<ul class="memberlist">
|
|
358 |
<li>
|
|
359 |
<a class="function" href="#MFTime.__init__">MFTime</a>
|
342 | 360 |
</li>
|
343 | 361 |
</ul>
|
344 | 362 |
|
|
377 | 395 |
|
378 | 396 |
</li>
|
379 | 397 |
<li>
|
380 | |
<a class="class" href="#EnumType">EnumType</a>
|
381 | |
<ul class="memberlist">
|
382 | |
<li>
|
383 | |
<a class="function" href="#EnumType.__init__">EnumType</a>
|
384 | |
</li>
|
385 | |
<li>
|
386 | |
<a class="variable" href="#EnumType.dtype">dtype</a>
|
387 | |
</li>
|
388 | |
<li>
|
389 | |
<a class="variable" href="#EnumType.name">name</a>
|
390 | |
</li>
|
391 | |
<li>
|
392 | |
<a class="variable" href="#EnumType.enum_dict">enum_dict</a>
|
393 | |
</li>
|
394 | |
</ul>
|
395 | |
|
|
398 |
<a class="function" href="#date2num">date2num</a>
|
396 | 399 |
</li>
|
397 | 400 |
<li>
|
398 | |
<a class="function" href="#getlibversion">getlibversion</a>
|
|
401 |
<a class="function" href="#num2date">num2date</a>
|
399 | 402 |
</li>
|
400 | 403 |
<li>
|
401 | |
<a class="function" href="#get_chunk_cache">get_chunk_cache</a>
|
402 | |
</li>
|
403 | |
<li>
|
404 | |
<a class="function" href="#set_chunk_cache">set_chunk_cache</a>
|
405 | |
</li>
|
406 | |
<li>
|
407 | |
<a class="function" href="#stringtoarr">stringtoarr</a>
|
|
404 |
<a class="function" href="#date2index">date2index</a>
|
408 | 405 |
</li>
|
409 | 406 |
<li>
|
410 | 407 |
<a class="function" href="#stringtochar">stringtochar</a>
|
|
413 | 410 |
<a class="function" href="#chartostring">chartostring</a>
|
414 | 411 |
</li>
|
415 | 412 |
<li>
|
416 | |
<a class="class" href="#MFDataset">MFDataset</a>
|
417 | |
<ul class="memberlist">
|
418 | |
<li>
|
419 | |
<a class="function" href="#MFDataset.__init__">MFDataset</a>
|
420 | |
</li>
|
421 | |
<li>
|
422 | |
<a class="function" href="#MFDataset.ncattrs">ncattrs</a>
|
423 | |
</li>
|
424 | |
<li>
|
425 | |
<a class="function" href="#MFDataset.close">close</a>
|
426 | |
</li>
|
427 | |
</ul>
|
428 | |
|
|
413 |
<a class="function" href="#stringtoarr">stringtoarr</a>
|
429 | 414 |
</li>
|
430 | 415 |
<li>
|
431 | |
<a class="class" href="#MFTime">MFTime</a>
|
|
416 |
<a class="function" href="#getlibversion">getlibversion</a>
|
|
417 |
</li>
|
|
418 |
<li>
|
|
419 |
<a class="class" href="#EnumType">EnumType</a>
|
432 | 420 |
<ul class="memberlist">
|
433 | 421 |
<li>
|
434 | |
<a class="function" href="#MFTime.__init__">MFTime</a>
|
|
422 |
<a class="function" href="#EnumType.__init__">EnumType</a>
|
|
423 |
</li>
|
|
424 |
<li>
|
|
425 |
<a class="variable" href="#EnumType.dtype">dtype</a>
|
|
426 |
</li>
|
|
427 |
<li>
|
|
428 |
<a class="variable" href="#EnumType.name">name</a>
|
|
429 |
</li>
|
|
430 |
<li>
|
|
431 |
<a class="variable" href="#EnumType.enum_dict">enum_dict</a>
|
435 | 432 |
</li>
|
436 | 433 |
</ul>
|
437 | 434 |
|
|
435 |
</li>
|
|
436 |
<li>
|
|
437 |
<a class="function" href="#get_chunk_cache">get_chunk_cache</a>
|
|
438 |
</li>
|
|
439 |
<li>
|
|
440 |
<a class="function" href="#set_chunk_cache">set_chunk_cache</a>
|
438 | 441 |
</li>
|
439 | 442 |
</ul>
|
440 | 443 |
|
441 | 444 |
|
442 | 445 |
<a class="attribution" title="pdoc: Python API documentation generator" href="https://pdoc.dev">
|
443 | |
built with <img
|
444 | |
alt="pdoc"
|
|
446 |
built with <span class="visually-hidden">pdoc</span><img
|
|
447 |
alt="pdoc logo"
|
445 | 448 |
src="data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A//www.w3.org/2000/svg%22%20role%3D%22img%22%20aria-label%3D%22pdoc%20logo%22%20width%3D%22300%22%20height%3D%22150%22%20viewBox%3D%22-1%200%2060%2030%22%3E%3Ctitle%3Epdoc%3C/title%3E%3Cpath%20d%3D%22M29.621%2021.293c-.011-.273-.214-.475-.511-.481a.5.5%200%200%200-.489.503l-.044%201.393c-.097.551-.695%201.215-1.566%201.704-.577.428-1.306.486-2.193.182-1.426-.617-2.467-1.654-3.304-2.487l-.173-.172a3.43%203.43%200%200%200-.365-.306.49.49%200%200%200-.286-.196c-1.718-1.06-4.931-1.47-7.353.191l-.219.15c-1.707%201.187-3.413%202.131-4.328%201.03-.02-.027-.49-.685-.141-1.763.233-.721.546-2.408.772-4.076.042-.09.067-.187.046-.288.166-1.347.277-2.625.241-3.351%201.378-1.008%202.271-2.586%202.271-4.362%200-.976-.272-1.935-.788-2.774-.057-.094-.122-.18-.184-.268.033-.167.052-.339.052-.516%200-1.477-1.202-2.679-2.679-2.679-.791%200-1.496.352-1.987.9a6.3%206.3%200%200%200-1.001.029c-.492-.564-1.207-.929-2.012-.929-1.477%200-2.679%201.202-2.679%202.679A2.65%202.65%200%200%200%20.97%206.554c-.383.747-.595%201.572-.595%202.41%200%202.311%201.507%204.29%203.635%205.107-.037.699-.147%202.27-.423%203.294l-.137.461c-.622%202.042-2.515%208.257%201.727%2010.643%201.614.908%203.06%201.248%204.317%201.248%202.665%200%204.492-1.524%205.322-2.401%201.476-1.559%202.886-1.854%206.491.82%201.877%201.393%203.514%201.753%204.861%201.068%202.223-1.713%202.811-3.867%203.399-6.374.077-.846.056-1.469.054-1.537zm-4.835%204.313c-.054.305-.156.586-.242.629-.034-.007-.131-.022-.307-.157-.145-.111-.314-.478-.456-.908.221.121.432.25.675.355.115.039.219.051.33.081zm-2.251-1.238c-.05.33-.158.648-.252.694-.022.001-.125-.018-.307-.157-.217-.166-.488-.906-.639-1.573.358.344.754.693%201.198%201.036zm-3.887-2.337c-.006-.116-.018-.231-.041-.342.635.145%201.189.368%201.599.625.097.231.166.481.174.642-.03.049-.055.101-.067.158-.046.013-.128.026-.298.004-.278-.037-.901-.57-1.367-1.087zm-1.127-.497c.116.306.176.625.12.71-.019.014-.117.045-.345.016-.206-.027-.604-.332-.986-.695.41-.051.816-.056%201.211-.031zm-4.535%201.535c.209.22.379.47.358.598-.006.041-.088.138-.351.234-.144.055-.539-.063-.979-.259a11.66%2011.66%200%200%200%20.972-.573zm.983-.664c.359-.237.738-.418%201.126-.554.25.237.479.548.457.694-.006.042-.087.138-.351.235-.174.064-.694-.105-1.232-.375zm-3.381%201.794c-.022.145-.061.29-.149.401-.133.166-.358.248-.69.251h-.002c-.133%200-.306-.26-.45-.621.417.091.854.07%201.291-.031zm-2.066-8.077a4.78%204.78%200%200%201-.775-.584c.172-.115.505-.254.88-.378l-.105.962zm-.331%202.302a10.32%2010.32%200%200%201-.828-.502c.202-.143.576-.328.984-.49l-.156.992zm-.45%202.157l-.701-.403c.214-.115.536-.249.891-.376a11.57%2011.57%200%200%201-.19.779zm-.181%201.716c.064.398.194.702.298.893-.194-.051-.435-.162-.736-.398.061-.119.224-.3.438-.495zM8.87%204.141c0%20.152-.123.276-.276.276s-.275-.124-.275-.276.123-.276.276-.276.275.124.275.276zm-.735-.389a1.15%201.15%200%200%200-.314.783%201.16%201.16%200%200%200%201.162%201.162c.457%200%20.842-.27%201.032-.653.026.117.042.238.042.362a1.68%201.68%200%200%201-1.679%201.679%201.68%201.68%200%200%201-1.679-1.679c0-.843.626-1.535%201.436-1.654zM5.059%205.406A1.68%201.68%200%200%201%203.38%207.085a1.68%201.68%200%200%201-1.679-1.679c0-.037.009-.072.011-.109.21.3.541.508.935.508a1.16%201.16%200%200%200%201.162-1.162%201.14%201.14%200%200%200-.474-.912c.015%200%20.03-.005.045-.005.926.001%201.679.754%201.679%201.68zM3.198%204.141c0%20.152-.123.276-.276.276s-.275-.124-.275-.276.123-.276.276-.276.275.124.275.276zM1.375%208.964c0-.52.103-1.035.288-1.52.466.394%201.06.64%201.717.64%201.144%200%202.116-.725%202.499-1.738.383%201.012%201.355%201.738%202.499%201.738.867%200%201.631-.421%202.121-1.062.307.605.478%201.267.478%201.942%200%202.486-2.153%204.51-4.801%204.51s-4.801-2.023-4.801-4.51zm24.342%2019.349c-.985.498-2.267.168-3.813-.979-3.073-2.281-5.453-3.199-7.813-.705-1.315%201.391-4.163%203.365-8.423.97-3.174-1.786-2.239-6.266-1.261-9.479l.146-.492c.276-1.02.395-2.457.444-3.268a6.11%206.11%200%200%200%201.18.115%206.01%206.01%200%200%200%202.536-.562l-.006.175c-.802.215-1.848.612-2.021%201.25-.079.295.021.601.274.837.219.203.415.364.598.501-.667.304-1.243.698-1.311%201.179-.02.144-.022.507.393.787.213.144.395.26.564.365-1.285.521-1.361.96-1.381%201.126-.018.142-.011.496.427.746l.854.489c-.473.389-.971.914-.999%201.429-.018.278.095.532.316.713.675.556%201.231.721%201.653.721.059%200%20.104-.014.158-.02.207.707.641%201.64%201.513%201.64h.013c.8-.008%201.236-.345%201.462-.626.173-.216.268-.457.325-.692.424.195.93.374%201.372.374.151%200%20.294-.021.423-.068.732-.27.944-.704.993-1.021.009-.061.003-.119.002-.179.266.086.538.147.789.147.15%200%20.294-.021.423-.069.542-.2.797-.489.914-.754.237.147.478.258.704.288.106.014.205.021.296.021.356%200%20.595-.101.767-.229.438.435%201.094.992%201.656%201.067.106.014.205.021.296.021a1.56%201.56%200%200%200%20.323-.035c.17.575.453%201.289.866%201.605.358.273.665.362.914.362a.99.99%200%200%200%20.421-.093%201.03%201.03%200%200%200%20.245-.164c.168.428.39.846.68%201.068.358.273.665.362.913.362a.99.99%200%200%200%20.421-.093c.317-.148.512-.448.639-.762.251.157.495.257.726.257.127%200%20.25-.024.37-.071.427-.17.706-.617.841-1.314.022-.015.047-.022.068-.038.067-.051.133-.104.196-.159-.443%201.486-1.107%202.761-2.086%203.257zM8.66%209.925a.5.5%200%201%200-1%200c0%20.653-.818%201.205-1.787%201.205s-1.787-.552-1.787-1.205a.5.5%200%201%200-1%200c0%201.216%201.25%202.205%202.787%202.205s2.787-.989%202.787-2.205zm4.4%2015.965l-.208.097c-2.661%201.258-4.708%201.436-6.086.527-1.542-1.017-1.88-3.19-1.844-4.198a.4.4%200%200%200-.385-.414c-.242-.029-.406.164-.414.385-.046%201.249.367%203.686%202.202%204.896.708.467%201.547.7%202.51.7%201.248%200%202.706-.392%204.362-1.174l.185-.086a.4.4%200%200%200%20.205-.527c-.089-.204-.326-.291-.527-.206zM9.547%202.292c.093.077.205.114.317.114a.5.5%200%200%200%20.318-.886L8.817.397a.5.5%200%200%200-.703.068.5.5%200%200%200%20.069.703l1.364%201.124zm-7.661-.065c.086%200%20.173-.022.253-.068l1.523-.893a.5.5%200%200%200-.506-.863l-1.523.892a.5.5%200%200%200-.179.685c.094.158.261.247.432.247z%22%20transform%3D%22matrix%28-1%200%200%201%2058%200%29%22%20fill%3D%22%233bb300%22/%3E%3Cpath%20d%3D%22M.3%2021.86V10.18q0-.46.02-.68.04-.22.18-.5.28-.54%201.34-.54%201.06%200%201.42.28.38.26.44.78.76-1.04%202.38-1.04%201.64%200%203.1%201.54%201.46%201.54%201.46%203.58%200%202.04-1.46%203.58-1.44%201.54-3.08%201.54-1.64%200-2.38-.92v4.04q0%20.46-.04.68-.02.22-.18.5-.14.3-.5.42-.36.12-.98.12-.62%200-1-.12-.36-.12-.52-.4-.14-.28-.18-.5-.02-.22-.02-.68zm3.96-9.42q-.46.54-.46%201.18%200%20.64.46%201.18.48.52%201.2.52.74%200%201.24-.52.52-.52.52-1.18%200-.66-.48-1.18-.48-.54-1.26-.54-.76%200-1.22.54zm14.741-8.36q.16-.3.54-.42.38-.12%201-.12.64%200%201.02.12.38.12.52.42.16.3.18.54.04.22.04.68v11.94q0%20.46-.04.7-.02.22-.18.5-.3.54-1.7.54-1.38%200-1.54-.98-.84.96-2.34.96-1.8%200-3.28-1.56-1.48-1.58-1.48-3.66%200-2.1%201.48-3.68%201.5-1.58%203.28-1.58%201.48%200%202.3%201v-4.2q0-.46.02-.68.04-.24.18-.52zm-3.24%2010.86q.52.54%201.26.54.74%200%201.22-.54.5-.54.5-1.18%200-.66-.48-1.22-.46-.56-1.26-.56-.8%200-1.28.56-.48.54-.48%201.2%200%20.66.52%201.2zm7.833-1.2q0-2.4%201.68-3.96%201.68-1.56%203.84-1.56%202.16%200%203.82%201.56%201.66%201.54%201.66%203.94%200%201.66-.86%202.96-.86%201.28-2.1%201.9-1.22.6-2.54.6-1.32%200-2.56-.64-1.24-.66-2.1-1.92-.84-1.28-.84-2.88zm4.18%201.44q.64.48%201.3.48.66%200%201.32-.5.66-.5.66-1.48%200-.98-.62-1.46-.62-.48-1.34-.48-.72%200-1.34.5-.62.5-.62%201.48%200%20.96.64%201.46zm11.412-1.44q0%20.84.56%201.32.56.46%201.18.46.64%200%201.18-.36.56-.38.9-.38.6%200%201.46%201.06.46.58.46%201.04%200%20.76-1.1%201.42-1.14.8-2.8.8-1.86%200-3.58-1.34-.82-.64-1.34-1.7-.52-1.08-.52-2.36%200-1.3.52-2.34.52-1.06%201.34-1.7%201.66-1.32%203.54-1.32.76%200%201.48.22.72.2%201.06.4l.32.2q.36.24.56.38.52.4.52.92%200%20.5-.42%201.14-.72%201.1-1.38%201.1-.38%200-1.08-.44-.36-.34-1.04-.34-.66%200-1.24.48-.58.48-.58%201.34z%22%20fill%3D%22green%22/%3E%3C/svg%3E"/>
|
446 | 449 |
</a>
|
447 | 450 |
</div>
|
|
449 | 452 |
<main class="pdoc">
|
450 | 453 |
<section>
|
451 | 454 |
<h1 class="modulename">
|
452 | |
<a href="./index.html">netCDF4</a>._netCDF4 </h1>
|
453 | |
|
454 | |
<div class="docstring"><h2 id="version-156">Version 1.5.6</h2>
|
|
455 |
netCDF4 </h1>
|
|
456 |
|
|
457 |
<div class="docstring"><h2 id="version-157">Version 1.5.7</h2>
|
455 | 458 |
|
456 | 459 |
<h1 id="introduction">Introduction</h1>
|
457 | 460 |
|
|
474 | 477 |
compound types containing enums, or vlens containing compound
|
475 | 478 |
types) are not supported.</p>
|
476 | 479 |
|
477 | |
<h2 id="download">Download</h2>
|
|
480 |
<h2 id="quick-install">Quick Install</h2>
|
478 | 481 |
|
479 | 482 |
<ul>
|
480 | |
<li>Latest bleeding-edge code from the
|
|
483 |
<li>the easiest way to get going is to install via <code>pip install netCDF4</code>.
|
|
484 |
(or if you use the <a href="http://conda.io">conda</a> package manager <code>conda install -c conda_forge netCDF4</code>).</li>
|
|
485 |
</ul>
|
|
486 |
|
|
487 |
<h2 id="developer-install">Developer Install</h2>
|
|
488 |
|
|
489 |
<ul>
|
|
490 |
<li>Clone the
|
481 | 491 |
<a href="http://github.com/Unidata/netcdf4-python">github repository</a>.</li>
|
482 | |
<li>Latest <a href="https://pypi.python.org/pypi/netCDF4">releases</a>
|
483 | |
(source code and binary installers).</li>
|
484 | |
</ul>
|
485 | |
|
486 | |
<h2 id="requires">Requires</h2>
|
487 | |
|
488 | |
<ul>
|
489 | |
<li>Python 3.6 or later.</li>
|
490 | |
<li><a href="http://numpy.scipy.org">numpy array module</a>, version 1.10.0 or later.</li>
|
491 | |
<li><a href="http://cython.org">Cython</a>, version 0.21 or later.</li>
|
492 | |
<li><a href="https://pypi.python.org/pypi/setuptools">setuptools</a>, version 18.0 or
|
493 | |
later.</li>
|
494 | |
<li>The HDF5 C library version 1.8.4-patch1 or higher
|
495 | |
from <a href="ftp://ftp.hdfgroup.org/HDF5/current/src"></a>.
|
496 | |
<strong><em>netCDF version 4.4.1 or higher is recommended if using HDF5 1.10.x -
|
497 | |
otherwise resulting files may be unreadable by clients using earlier
|
498 | |
versions of HDF5. For netCDF < 4.4.1, HDF5 version 1.8.x is recommended.</em></strong>
|
499 | |
Be sure to build with <code>--enable-hl --enable-shared</code>.</li>
|
500 | |
<li><a href="http://curl.haxx.se/libcurl">Libcurl</a>, if you want
|
501 | |
<a href="http://opendap.org">OPeNDAP</a> support.</li>
|
502 | |
<li><a href="http://www.hdfgroup.org/products/hdf4">HDF4</a>, if you want
|
503 | |
to be able to read HDF4 "Scientific Dataset" (SD) files.</li>
|
504 | |
<li>The netCDF-4 C library from the <a href="https://github.com/Unidata/netcdf-c/releases">github releases
|
505 | |
page</a>.
|
506 | |
Version 4.1.1 or higher is required (4.2 or higher recommended).
|
507 | |
Be sure to build with <code>--enable-netcdf-4 --enable-shared</code>, and set
|
508 | |
<code>CPPFLAGS="-I $HDF5_DIR/include"</code> and <code>LDFLAGS="-L $HDF5_DIR/lib"</code>,
|
509 | |
where <code>$HDF5_DIR</code> is the directory where HDF5 was installed.
|
510 | |
If you want <a href="http://opendap.org">OPeNDAP</a> support, add <code>--enable-dap</code>.
|
511 | |
If you want HDF4 SD support, add <code>--enable-hdf4</code> and add
|
512 | |
the location of the HDF4 headers and library to <code>$CPPFLAGS</code> and <code>$LDFLAGS</code>.</li>
|
513 | |
<li>for MPI parallel IO support, an MPI-enabled versions of the netcdf library
|
514 | |
is required, as is the <a href="http://mpi4py.scipy.org">mpi4py</a> python module.
|
|
492 |
<li>Make sure the dependencies are satisfied (Python 3.6 or later,
|
|
493 |
<a href="http://numpy.scipy.org">numpy</a>,
|
|
494 |
<a href="http://cython.org">Cython</a>,
|
|
495 |
<a href="https://github.com/Unidata/cftime">cftime</a>,
|
|
496 |
<a href="https://pypi.python.org/pypi/setuptools">setuptools</a>,
|
|
497 |
the <a href="https://www.hdfgroup.org/solutions/hdf5/">HDF5 C library</a>,
|
|
498 |
and the <a href="https://www.unidata.ucar.edu/software/netcdf/">netCDF C library</a>).
|
|
499 |
For MPI parallel IO support, an MPI-enabled versions of the netcdf library
|
|
500 |
is required, as is <a href="http://mpi4py.scipy.org">mpi4py</a>.
|
515 | 501 |
Parallel IO further depends on the existence of MPI-enabled HDF5 or the
|
516 | 502 |
<a href="https://parallel-netcdf.github.io/">PnetCDF</a> library.</li>
|
517 | |
<li><a href="https://github.com/Unidata/cftime">cftime</a> for
|
518 | |
time and date handling utility functions.</li>
|
519 | |
</ul>
|
520 | |
|
521 | |
<h2 id="install">Install</h2>
|
522 | |
|
523 | |
<ul>
|
524 | |
<li>install the requisite python modules and C libraries (see above). It's
|
525 | |
easiest if all the C libs are built as shared libraries.</li>
|
526 | |
<li>By default, the utility <code>nc-config</code>, installed with netcdf 4.1.2 or higher,
|
|
503 |
<li>By default, the utility <code>nc-config</code> (installed with netcdf-c)
|
527 | 504 |
will be run used to determine where all the dependencies live.</li>
|
528 | 505 |
<li>If <code>nc-config</code> is not in your default <code>PATH</code>, you can set the <code>NETCDF4_DIR</code>
|
529 | 506 |
environment variable and <code>setup.py</code> will look in <code>$NETCDF4_DIR/bin</code>.
|
|
535 | 512 |
As a last resort, the library and include paths can be set via environment variables.
|
536 | 513 |
If you go this route, set <code>USE_NCCONFIG</code> and <code>USE_SETUPCFG</code> to 0, and specify
|
537 | 514 |
<code>NETCDF4_LIBDIR</code>, <code>NETCDF4_INCDIR</code>, <code>HDF5_LIBDIR</code> and <code>HDF5_INCDIR</code>.
|
538 | |
Similarly, environment variables
|
539 | |
(all capitalized) can be used to set the include and library paths for
|
540 | |
<code>hdf4</code>, <code>szip</code>, <code>jpeg</code>, <code>curl</code> and <code>zlib</code>. If the dependencies are not found
|
|
515 |
If the dependencies are not found
|
541 | 516 |
in any of the paths specified by environment variables, then standard locations
|
542 | 517 |
(such as <code>/usr</code> and <code>/usr/local</code>) are searched.</li>
|
543 | 518 |
<li>run <code>python setup.py build</code>, then <code>python setup.py install</code> (as root if
|
544 | |
necessary). <code>pip install</code> can be used to install pre-compiled binary wheels from
|
545 | |
<a href="https://pypi.org/project/netCDF4">pypi</a>.</li>
|
|
519 |
necessary).</li>
|
546 | 520 |
<li>run the tests in the 'test' directory by running <code>python run_all.py</code>.</li>
|
547 | 521 |
</ul>
|
548 | 522 |
|
|
568 | 542 |
|
569 | 543 |
<h2 id="creatingopeningclosing-a-netcdf-file">Creating/Opening/Closing a netCDF file</h2>
|
570 | 544 |
|
571 | |
<p>To create a netCDF file from python, you simply call the <a href="#Dataset">Dataset</a>
|
|
545 |
<p>To create a netCDF file from python, you simply call the <code><a href="#Dataset">Dataset</a></code>
|
572 | 546 |
constructor. This is also the method used to open an existing netCDF
|
573 | 547 |
file. If the file is open for write access (<code>mode='w', 'r+'</code> or <code>'a'</code>), you may
|
574 | 548 |
write any type of data including new dimensions, groups, variables and
|
|
592 | 566 |
keyword in the <code><a href="#Dataset">Dataset</a></code> constructor. The default format is
|
593 | 567 |
<code>NETCDF4</code>. To see how a given file is formatted, you can examine the
|
594 | 568 |
<code>data_model</code> attribute. Closing the netCDF file is
|
595 | |
accomplished via the <a href="#<a href="#Dataset.close">Dataset.close</a>"><a href="#Dataset.close">Dataset.close</a></a> method of the <a href="#Dataset">Dataset</a>
|
|
569 |
accomplished via the <code><a href="#Dataset.close">Dataset.close</a></code> method of the <code><a href="#Dataset">Dataset</a></code>
|
596 | 570 |
instance.</p>
|
597 | 571 |
|
598 | 572 |
<p>Here's an example:</p>
|
|
605 | 579 |
</code></pre></div>
|
606 | 580 |
|
607 | 581 |
<p>Remote <a href="http://opendap.org">OPeNDAP</a>-hosted datasets can be accessed for
|
608 | |
reading over http if a URL is provided to the <a href="#Dataset">Dataset</a> constructor instead of a
|
|
582 |
reading over http if a URL is provided to the <code><a href="#Dataset">Dataset</a></code> constructor instead of a
|
609 | 583 |
filename. However, this requires that the netCDF library be built with
|
610 | 584 |
OPenDAP support, via the <code>--enable-dap</code> configure option (added in
|
611 | 585 |
version 4.0.1).</p>
|
|
615 | 589 |
<p>netCDF version 4 added support for organizing data in hierarchical
|
616 | 590 |
groups, which are analogous to directories in a filesystem. Groups serve
|
617 | 591 |
as containers for variables, dimensions and attributes, as well as other
|
618 | |
groups. A <a href="#Dataset">Dataset</a> creates a special group, called
|
|
592 |
groups. A <code><a href="#Dataset">Dataset</a></code> creates a special group, called
|
619 | 593 |
the 'root group', which is similar to the root directory in a unix
|
620 | |
filesystem. To create <a href="#Group">Group</a> instances, use the
|
621 | |
<a href="#<a href="#Dataset.createGroup">Dataset.createGroup</a>"><a href="#Dataset.createGroup">Dataset.createGroup</a></a> method of a <a href="#Dataset">Dataset</a> or <a href="#Group">Group</a>
|
622 | |
instance. <a href="#<a href="#Dataset.createGroup">Dataset.createGroup</a>"><a href="#Dataset.createGroup">Dataset.createGroup</a></a> takes a single argument, a
|
623 | |
python string containing the name of the new group. The new <a href="#Group">Group</a>
|
|
594 |
filesystem. To create <code><a href="#Group">Group</a></code> instances, use the
|
|
595 |
<code><a href="#Dataset.createGroup">Dataset.createGroup</a></code> method of a <code><a href="#Dataset">Dataset</a></code> or <code><a href="#Group">Group</a></code>
|
|
596 |
instance. <code><a href="#Dataset.createGroup">Dataset.createGroup</a></code> takes a single argument, a
|
|
597 |
python string containing the name of the new group. The new <code><a href="#Group">Group</a></code>
|
624 | 598 |
instances contained within the root group can be accessed by name using
|
625 | |
the <code>groups</code> dictionary attribute of the <a href="#Dataset">Dataset</a> instance. Only
|
|
599 |
the <code>groups</code> dictionary attribute of the <code><a href="#Dataset">Dataset</a></code> instance. Only
|
626 | 600 |
<code>NETCDF4</code> formatted files support Groups, if you try to create a Group
|
627 | 601 |
in a netCDF 3 file you will get an error message.</p>
|
628 | 602 |
|
|
642 | 616 |
<span class="o">>>></span>
|
643 | 617 |
</code></pre></div>
|
644 | 618 |
|
645 | |
<p>Groups can exist within groups in a <a href="#Dataset">Dataset</a>, just as directories
|
646 | |
exist within directories in a unix filesystem. Each <a href="#Group">Group</a> instance
|
|
619 |
<p>Groups can exist within groups in a <code><a href="#Dataset">Dataset</a></code>, just as directories
|
|
620 |
exist within directories in a unix filesystem. Each <code><a href="#Group">Group</a></code> instance
|
647 | 621 |
has a <code>groups</code> attribute dictionary containing all of the group
|
648 | |
instances contained within that group. Each <a href="#Group">Group</a> instance also has a
|
|
622 |
instances contained within that group. Each <code><a href="#Group">Group</a></code> instance also has a
|
649 | 623 |
<code>path</code> attribute that contains a simulated unix directory path to
|
650 | 624 |
that group. To simplify the creation of nested groups, you can
|
651 | |
use a unix-like path as an argument to <a href="#<a href="#Dataset.createGroup">Dataset.createGroup</a>"><a href="#Dataset.createGroup">Dataset.createGroup</a></a>.</p>
|
|
625 |
use a unix-like path as an argument to <code><a href="#Dataset.createGroup">Dataset.createGroup</a></code>.</p>
|
652 | 626 |
|
653 | 627 |
<div class="codehilite"><pre><span></span><code><span class="o">>>></span> <span class="n">fcstgrp1</span> <span class="o">=</span> <span class="n">rootgrp</span><span class="o">.</span><span class="n">createGroup</span><span class="p">(</span><span class="s2">"/forecasts/model1"</span><span class="p">)</span>
|
654 | 628 |
<span class="o">>>></span> <span class="n">fcstgrp2</span> <span class="o">=</span> <span class="n">rootgrp</span><span class="o">.</span><span class="n">createGroup</span><span class="p">(</span><span class="s2">"/forecasts/model2"</span><span class="p">)</span>
|
|
660 | 634 |
returned.</p>
|
661 | 635 |
|
662 | 636 |
<p>Here's an example that shows how to navigate all the groups in a
|
663 | |
<a href="#Dataset">Dataset</a>. The function <code>walktree</code> is a Python generator that is used
|
664 | |
to walk the directory tree. Note that printing the <a href="#Dataset">Dataset</a> or <a href="#Group">Group</a>
|
|
637 |
<code><a href="#Dataset">Dataset</a></code>. The function <code>walktree</code> is a Python generator that is used
|
|
638 |
to walk the directory tree. Note that printing the <code><a href="#Dataset">Dataset</a></code> or <code><a href="#Group">Group</a></code>
|
665 | 639 |
object yields summary information about it's contents.</p>
|
666 | 640 |
|
667 | 641 |
<div class="codehilite"><pre><span></span><code><span class="o">>>></span> <span class="k">def</span> <span class="nf">walktree</span><span class="p">(</span><span class="n">top</span><span class="p">):</span>
|
|
707 | 681 |
before any variables can be created the dimensions they use must be
|
708 | 682 |
created first. A special case, not often used in practice, is that of a
|
709 | 683 |
scalar variable, which has no dimensions. A dimension is created using
|
710 | |
the <a href="#<a href="#Dataset.createDimension">Dataset.createDimension</a>"><a href="#Dataset.createDimension">Dataset.createDimension</a></a> method of a <a href="#Dataset">Dataset</a>
|
711 | |
or <a href="#Group">Group</a> instance. A Python string is used to set the name of the
|
|
684 |
the <code><a href="#Dataset.createDimension">Dataset.createDimension</a></code> method of a <code><a href="#Dataset">Dataset</a></code>
|
|
685 |
or <code><a href="#Group">Group</a></code> instance. A Python string is used to set the name of the
|
712 | 686 |
dimension, and an integer value is used to set the size. To create an
|
713 | 687 |
unlimited dimension (a dimension that can be appended to), the size
|
714 | 688 |
value is set to <code>None</code> or 0. In this example, there both the <code>time</code> and
|
|
722 | 696 |
<span class="o">>>></span> <span class="n">lon</span> <span class="o">=</span> <span class="n">rootgrp</span><span class="o">.</span><span class="n">createDimension</span><span class="p">(</span><span class="s2">"lon"</span><span class="p">,</span> <span class="mi">144</span><span class="p">)</span>
|
723 | 697 |
</code></pre></div>
|
724 | 698 |
|
725 | |
<p>All of the <a href="#Dimension">Dimension</a> instances are stored in a python dictionary.</p>
|
|
699 |
<p>All of the <code><a href="#Dimension">Dimension</a></code> instances are stored in a python dictionary.</p>
|
726 | 700 |
|
727 | 701 |
<div class="codehilite"><pre><span></span><code><span class="o">>>></span> <span class="nb">print</span><span class="p">(</span><span class="n">rootgrp</span><span class="o">.</span><span class="n">dimensions</span><span class="p">)</span>
|
728 | 702 |
<span class="p">{</span><span class="s1">'level'</span><span class="p">:</span> <span class="o"><</span><span class="k">class</span> <span class="err">'</span><span class="nc">netCDF4</span><span class="o">.</span><span class="n">_netCDF4</span><span class="o">.</span><span class="n">Dimension</span><span class="s1">'> (unlimited): name = '</span><span class="n">level</span><span class="s1">', size = 0, '</span><span class="n">time</span><span class="s1">': <class '</span><span class="n">netCDF4</span><span class="o">.</span><span class="n">_netCDF4</span><span class="o">.</span><span class="n">Dimension</span><span class="s1">'> (unlimited): name = '</span><span class="n">time</span><span class="s1">', size = 0, '</span><span class="n">lat</span><span class="s1">': <class '</span><span class="n">netCDF4</span><span class="o">.</span><span class="n">_netCDF4</span><span class="o">.</span><span class="n">Dimension</span><span class="s1">'>: name = '</span><span class="n">lat</span><span class="s1">', size = 73, '</span><span class="n">lon</span><span class="s1">': <class '</span><span class="n">netCDF4</span><span class="o">.</span><span class="n">_netCDF4</span><span class="o">.</span><span class="n">Dimension</span><span class="s1">'>: name = '</span><span class="n">lon</span><span class="s1">', size = 144}</span>
|
729 | 703 |
</code></pre></div>
|
730 | 704 |
|
731 | |
<p>Using the python <code>len</code> function with a <a href="#Dimension">Dimension</a> instance returns
|
|
705 |
<p>Using the python <code>len</code> function with a <code><a href="#Dimension">Dimension</a></code> instance returns
|
732 | 706 |
current size of that dimension.
|
733 | |
<a href="#<a href="#Dimension.isunlimited">Dimension.isunlimited</a>"><a href="#Dimension.isunlimited">Dimension.isunlimited</a></a> method of a <a href="#Dimension">Dimension</a> instance
|
|
707 |
<code><a href="#Dimension.isunlimited">Dimension.isunlimited</a></code> method of a <code><a href="#Dimension">Dimension</a></code> instance
|
734 | 708 |
be used to determine if the dimensions is unlimited, or appendable.</p>
|
735 | 709 |
|
736 | 710 |
<div class="codehilite"><pre><span></span><code><span class="o">>>></span> <span class="nb">print</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">lon</span><span class="p">))</span>
|
|
741 | 715 |
<span class="kc">True</span>
|
742 | 716 |
</code></pre></div>
|
743 | 717 |
|
744 | |
<p>Printing the <a href="#Dimension">Dimension</a> object
|
|
718 |
<p>Printing the <code><a href="#Dimension">Dimension</a></code> object
|
745 | 719 |
provides useful summary info, including the name and length of the dimension,
|
746 | 720 |
and whether it is unlimited.</p>
|
747 | 721 |
|
|
753 | 727 |
<span class="o"><</span><span class="k">class</span> <span class="err">'</span><span class="nc">netCDF4</span><span class="o">.</span><span class="n">_netCDF4</span><span class="o">.</span><span class="n">Dimension</span><span class="s1">'>: name = '</span><span class="n">lon</span><span class="s1">', size = 144</span>
|
754 | 728 |
</code></pre></div>
|
755 | 729 |
|
756 | |
<p><a href="#Dimension">Dimension</a> names can be changed using the
|
757 | |
<a href="#Datatset.renameDimension">Datatset.renameDimension</a> method of a <a href="#Dataset">Dataset</a> or
|
758 | |
<a href="#Group">Group</a> instance.</p>
|
|
730 |
<p><code><a href="#Dimension">Dimension</a></code> names can be changed using the
|
|
731 |
<code>Datatset.renameDimension</code> method of a <code><a href="#Dataset">Dataset</a></code> or
|
|
732 |
<code><a href="#Group">Group</a></code> instance.</p>
|
759 | 733 |
|
760 | 734 |
<h2 id="variables-in-a-netcdf-file">Variables in a netCDF file</h2>
|
761 | 735 |
|
|
763 | 737 |
supplied by the <a href="http://numpy.scipy.org">numpy module</a>. However,
|
764 | 738 |
unlike numpy arrays, netCDF4 variables can be appended to along one or
|
765 | 739 |
more 'unlimited' dimensions. To create a netCDF variable, use the
|
766 | |
<a href="#<a href="#Dataset.createVariable">Dataset.createVariable</a>"><a href="#Dataset.createVariable">Dataset.createVariable</a></a> method of a <a href="#Dataset">Dataset</a> or
|
767 | |
<a href="#Group">Group</a> instance. The <a href="#<a href="#Dataset.createVariable">Dataset.createVariable</a>"><a href="#Dataset.createVariable">Dataset.createVariable</a></a> method
|
|
740 |
<code><a href="#Dataset.createVariable">Dataset.createVariable</a></code> method of a <code><a href="#Dataset">Dataset</a></code> or
|
|
741 |
<code><a href="#Group">Group</a></code> instance. The <code><a href="#Dataset.createVariable">Dataset.createVariable</a></code>j method
|
768 | 742 |
has two mandatory arguments, the variable name (a Python string), and
|
769 | 743 |
the variable datatype. The variable's dimensions are given by a tuple
|
770 | 744 |
containing the dimension names (defined previously with
|
771 | |
<a href="#<a href="#Dataset.createDimension">Dataset.createDimension</a>"><a href="#Dataset.createDimension">Dataset.createDimension</a></a>). To create a scalar
|
|
745 |
<code><a href="#Dataset.createDimension">Dataset.createDimension</a></code>). To create a scalar
|
772 | 746 |
variable, simply leave out the dimensions keyword. The variable
|
773 | 747 |
primitive datatypes correspond to the dtype attribute of a numpy array.
|
774 | 748 |
You can specify the datatype as a numpy dtype object, or anything that
|
|
786 | 760 |
can only be used if the file format is <code>NETCDF4</code>.</p>
|
787 | 761 |
|
788 | 762 |
<p>The dimensions themselves are usually also defined as variables, called
|
789 | |
coordinate variables. The <a href="#<a href="#Dataset.createVariable">Dataset.createVariable</a>"><a href="#Dataset.createVariable">Dataset.createVariable</a></a>
|
790 | |
method returns an instance of the <a href="#Variable">Variable</a> class whose methods can be
|
|
763 |
coordinate variables. The <code><a href="#Dataset.createVariable">Dataset.createVariable</a></code>
|
|
764 |
method returns an instance of the <code><a href="#Variable">Variable</a></code> class whose methods can be
|
791 | 765 |
used later to access and set variable data and attributes.</p>
|
792 | 766 |
|
793 | 767 |
<div class="codehilite"><pre><span></span><code><span class="o">>>></span> <span class="n">times</span> <span class="o">=</span> <span class="n">rootgrp</span><span class="o">.</span><span class="n">createVariable</span><span class="p">(</span><span class="s2">"time"</span><span class="p">,</span><span class="s2">"f8"</span><span class="p">,(</span><span class="s2">"time"</span><span class="p">,))</span>
|
|
799 | 773 |
<span class="o">>>></span> <span class="n">temp</span><span class="o">.</span><span class="n">units</span> <span class="o">=</span> <span class="s2">"K"</span>
|
800 | 774 |
</code></pre></div>
|
801 | 775 |
|
802 | |
<p>To get summary info on a <a href="#Variable">Variable</a> instance in an interactive session,
|
|
776 |
<p>To get summary info on a <code><a href="#Variable">Variable</a></code> instance in an interactive session,
|
803 | 777 |
just print it.</p>
|
804 | 778 |
|
805 | 779 |
<div class="codehilite"><pre><span></span><code><span class="o">>>></span> <span class="nb">print</span><span class="p">(</span><span class="n">temp</span><span class="p">)</span>
|
|
818 | 792 |
|
819 | 793 |
<p>If the intermediate groups do not yet exist, they will be created.</p>
|
820 | 794 |
|
821 | |
<p>You can also query a <a href="#Dataset">Dataset</a> or <a href="#Group">Group</a> instance directly to obtain <a href="#Group">Group</a> or
|
822 | |
<a href="#Variable">Variable</a> instances using paths.</p>
|
|
795 |
<p>You can also query a <code><a href="#Dataset">Dataset</a></code> or <code><a href="#Group">Group</a></code> instance directly to obtain <code><a href="#Group">Group</a></code> or
|
|
796 |
<code><a href="#Variable">Variable</a></code> instances using paths.</p>
|
823 | 797 |
|
824 | 798 |
<div class="codehilite"><pre><span></span><code><span class="o">>>></span> <span class="nb">print</span><span class="p">(</span><span class="n">rootgrp</span><span class="p">[</span><span class="s2">"/forecasts/model1"</span><span class="p">])</span> <span class="c1"># a Group instance</span>
|
825 | 799 |
<span class="o"><</span><span class="k">class</span> <span class="err">'</span><span class="nc">netCDF4</span><span class="o">.</span><span class="n">_netCDF4</span><span class="o">.</span><span class="n">Group</span><span class="s1">'></span>
|
|
836 | 810 |
<span class="n">filling</span> <span class="n">on</span><span class="p">,</span> <span class="n">default</span> <span class="n">_FillValue</span> <span class="n">of</span> <span class="mf">9.969209968386869e+36</span> <span class="n">used</span>
|
837 | 811 |
</code></pre></div>
|
838 | 812 |
|
839 | |
<p>All of the variables in the <a href="#Dataset">Dataset</a> or <a href="#Group">Group</a> are stored in a
|
|
813 |
<p>All of the variables in the <code><a href="#Dataset">Dataset</a></code> or <code><a href="#Group">Group</a></code> are stored in a
|
840 | 814 |
Python dictionary, in the same way as the dimensions:</p>
|
841 | 815 |
|
842 | 816 |
<div class="codehilite"><pre><span></span><code><span class="o">>>></span> <span class="nb">print</span><span class="p">(</span><span class="n">rootgrp</span><span class="o">.</span><span class="n">variables</span><span class="p">)</span>
|
|
864 | 838 |
<span class="n">filling</span> <span class="n">on</span><span class="p">,</span> <span class="n">default</span> <span class="n">_FillValue</span> <span class="n">of</span> <span class="mf">9.969209968386869e+36</span> <span class="n">used</span><span class="p">}</span>
|
865 | 839 |
</code></pre></div>
|
866 | 840 |
|
867 | |
<p><a href="#Variable">Variable</a> names can be changed using the
|
868 | |
<a href="#<a href="#Dataset.renameVariable">Dataset.renameVariable</a>"><a href="#Dataset.renameVariable">Dataset.renameVariable</a></a> method of a <a href="#Dataset">Dataset</a>
|
|
841 |
<p><code><a href="#Variable">Variable</a></code> names can be changed using the
|
|
842 |
<code><a href="#Dataset.renameVariable">Dataset.renameVariable</a></code> method of a <code><a href="#Dataset">Dataset</a></code>
|
869 | 843 |
instance.</p>
|
870 | 844 |
|
871 | 845 |
<p>Variables can be sliced similar to numpy arrays, but there are some differences. See
|
|
875 | 849 |
|
876 | 850 |
<p>There are two types of attributes in a netCDF file, global and variable.
|
877 | 851 |
Global attributes provide information about a group, or the entire
|
878 | |
dataset, as a whole. <a href="#Variable">Variable</a> attributes provide information about
|
|
852 |
dataset, as a whole. <code><a href="#Variable">Variable</a></code> attributes provide information about
|
879 | 853 |
one of the variables in a group. Global attributes are set by assigning
|
880 | |
values to <a href="#Dataset">Dataset</a> or <a href="#Group">Group</a> instance variables. <a href="#Variable">Variable</a>
|
881 | |
attributes are set by assigning values to <a href="#Variable">Variable</a> instances
|
|
854 |
values to <code><a href="#Dataset">Dataset</a></code> or <code><a href="#Group">Group</a></code> instance variables. <code><a href="#Variable">Variable</a></code>
|
|
855 |
attributes are set by assigning values to <code><a href="#Variable">Variable</a></code> instances
|
882 | 856 |
variables. Attributes can be strings, numbers or sequences. Returning to
|
883 | 857 |
our example,</p>
|
884 | 858 |
|
|
894 | 868 |
<span class="o">>>></span> <span class="n">times</span><span class="o">.</span><span class="n">calendar</span> <span class="o">=</span> <span class="s2">"gregorian"</span>
|
895 | 869 |
</code></pre></div>
|
896 | 870 |
|
897 | |
<p>The <a href="#<a href="#Dataset.ncattrs">Dataset.ncattrs</a>"><a href="#Dataset.ncattrs">Dataset.ncattrs</a></a> method of a <a href="#Dataset">Dataset</a>, <a href="#Group">Group</a> or
|
898 | |
<a href="#Variable">Variable</a> instance can be used to retrieve the names of all the netCDF
|
|
871 |
<p>The <code><a href="#Dataset.ncattrs">Dataset.ncattrs</a></code> method of a <code><a href="#Dataset">Dataset</a></code>, <code><a href="#Group">Group</a></code> or
|
|
872 |
<code><a href="#Variable">Variable</a></code> instance can be used to retrieve the names of all the netCDF
|
899 | 873 |
attributes. This method is provided as a convenience, since using the
|
900 | 874 |
built-in <code>dir</code> Python function will return a bunch of private methods
|
901 | 875 |
and attributes that cannot (or should not) be modified by the user.</p>
|
|
907 | 881 |
<span class="n">Global</span> <span class="n">attr</span> <span class="n">source</span> <span class="o">=</span> <span class="n">netCDF4</span> <span class="n">python</span> <span class="n">module</span> <span class="n">tutorial</span>
|
908 | 882 |
</code></pre></div>
|
909 | 883 |
|
910 | |
<p>The <code>__dict__</code> attribute of a <a href="#Dataset">Dataset</a>, <a href="#Group">Group</a> or <a href="#Variable">Variable</a>
|
|
884 |
<p>The <code>__dict__</code> attribute of a <code><a href="#Dataset">Dataset</a></code>, <code><a href="#Group">Group</a></code> or <code><a href="#Variable">Variable</a></code>
|
911 | 885 |
instance provides all the netCDF attribute name/value pairs in a python
|
912 | 886 |
dictionary:</p>
|
913 | 887 |
|
|
915 | 889 |
<span class="p">{</span><span class="s1">'description'</span><span class="p">:</span> <span class="s1">'bogus example script'</span><span class="p">,</span> <span class="s1">'history'</span><span class="p">:</span> <span class="s1">'Created Mon Jul 8 14:19:41 2019'</span><span class="p">,</span> <span class="s1">'source'</span><span class="p">:</span> <span class="s1">'netCDF4 python module tutorial'</span><span class="p">}</span>
|
916 | 890 |
</code></pre></div>
|
917 | 891 |
|
918 | |
<p>Attributes can be deleted from a netCDF <a href="#Dataset">Dataset</a>, <a href="#Group">Group</a> or
|
919 | |
<a href="#Variable">Variable</a> using the python <code>del</code> statement (i.e. <code>del grp.foo</code>
|
|
892 |
<p>Attributes can be deleted from a netCDF <code><a href="#Dataset">Dataset</a></code>, <code><a href="#Group">Group</a></code> or
|
|
893 |
<code><a href="#Variable">Variable</a></code> using the python <code>del</code> statement (i.e. <code>del grp.foo</code>
|
920 | 894 |
removes the attribute <code>foo</code> the the group <code>grp</code>).</p>
|
921 | 895 |
|
922 | 896 |
<h2 id="writing-data-to-and-retrieving-data-from-a-netcdf-variable">Writing data to and retrieving data from a netCDF variable</h2>
|
923 | 897 |
|
924 | |
<p>Now that you have a netCDF <a href="#Variable">Variable</a> instance, how do you put data
|
|
898 |
<p>Now that you have a netCDF <code><a href="#Variable">Variable</a></code> instance, how do you put data
|
925 | 899 |
into it? You can just treat it like an array and assign data to a slice.</p>
|
926 | 900 |
|
927 | |
<div class="codehilite"><pre><span></span><code><span class="o">>>></span> <span class="kn">import</span> <span class="nn">numpy</span>
|
928 | |
<span class="o">>>></span> <span class="n">lats</span> <span class="o">=</span> <span class="n">numpy</span><span class="o">.</span><span class="n">arange</span><span class="p">(</span><span class="o">-</span><span class="mi">90</span><span class="p">,</span><span class="mi">91</span><span class="p">,</span><span class="mf">2.5</span><span class="p">)</span>
|
929 | |
<span class="o">>>></span> <span class="n">lons</span> <span class="o">=</span> <span class="n">numpy</span><span class="o">.</span><span class="n">arange</span><span class="p">(</span><span class="o">-</span><span class="mi">180</span><span class="p">,</span><span class="mi">180</span><span class="p">,</span><span class="mf">2.5</span><span class="p">)</span>
|
|
901 |
<div class="codehilite"><pre><span></span><code><span class="o">>>></span> <span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span>
|
|
902 |
<span class="o">>>></span> <span class="n">lats</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">arange</span><span class="p">(</span><span class="o">-</span><span class="mi">90</span><span class="p">,</span><span class="mi">91</span><span class="p">,</span><span class="mf">2.5</span><span class="p">)</span>
|
|
903 |
<span class="o">>>></span> <span class="n">lons</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">arange</span><span class="p">(</span><span class="o">-</span><span class="mi">180</span><span class="p">,</span><span class="mi">180</span><span class="p">,</span><span class="mf">2.5</span><span class="p">)</span>
|
930 | 904 |
<span class="o">>>></span> <span class="n">latitudes</span><span class="p">[:]</span> <span class="o">=</span> <span class="n">lats</span>
|
931 | 905 |
<span class="o">>>></span> <span class="n">longitudes</span><span class="p">[:]</span> <span class="o">=</span> <span class="n">lons</span>
|
932 | 906 |
<span class="o">>>></span> <span class="nb">print</span><span class="p">(</span><span class="s2">"latitudes =</span><span class="se">\n</span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">latitudes</span><span class="p">[:]))</span>
|
|
940 | 914 |
<span class="mf">90.</span> <span class="p">]</span>
|
941 | 915 |
</code></pre></div>
|
942 | 916 |
|
943 | |
<p>Unlike NumPy's array objects, netCDF <a href="#Variable">Variable</a>
|
|
917 |
<p>Unlike NumPy's array objects, netCDF <code><a href="#Variable">Variable</a></code>
|
944 | 918 |
objects with unlimited dimensions will grow along those dimensions if you
|
945 | 919 |
assign data outside the currently defined range of indices.</p>
|
946 | 920 |
|
|
1012 | 986 |
|
1013 | 987 |
<p>By default, netcdf4-python returns numpy masked arrays with values equal to the
|
1014 | 988 |
<code>missing_value</code> or <code>_FillValue</code> variable attributes masked. The
|
1015 | |
<a href="#<a href="#Dataset.set_auto_mask">Dataset.set_auto_mask</a>"><a href="#Dataset.set_auto_mask">Dataset.set_auto_mask</a></a> <a href="#Dataset">Dataset</a> and <a href="#Variable">Variable</a> methods
|
|
989 |
<code><a href="#Dataset.set_auto_mask">Dataset.set_auto_mask</a></code> <code><a href="#Dataset">Dataset</a></code> and <code><a href="#Variable">Variable</a></code> methods
|
1016 | 990 |
can be used to disable this feature so that
|
1017 | 991 |
numpy arrays are always returned, with the missing values included. Prior to
|
1018 | 992 |
version 1.4.0 the default behavior was to only return masked arrays when the
|
1019 | 993 |
requested slice contained missing values. This behavior can be recovered
|
1020 | |
using the <a href="#<a href="#Dataset.set_always_mask">Dataset.set_always_mask</a>"><a href="#Dataset.set_always_mask">Dataset.set_always_mask</a></a> method. If a masked array is
|
|
994 |
using the <code><a href="#Dataset.set_always_mask">Dataset.set_always_mask</a></code> method. If a masked array is
|
1021 | 995 |
written to a netCDF variable, the masked elements are filled with the
|
1022 | 996 |
value specified by the <code>missing_value</code> attribute. If the variable has
|
1023 | 997 |
no <code>missing_value</code>, the <code>_FillValue</code> is used instead.</p>
|
|
1050 | 1024 |
<span class="n">real_datetime</span><span class="p">(</span><span class="mi">2001</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">)]</span>
|
1051 | 1025 |
</code></pre></div>
|
1052 | 1026 |
|
1053 | |
<p><code>num2date</code> converts numeric values of time in the specified <code>units</code>
|
1054 | |
and <code>calendar</code> to datetime objects, and <code>date2num</code> does the reverse.
|
|
1027 |
<p><code><a href="#num2date">num2date</a></code> converts numeric values of time in the specified <code>units</code>
|
|
1028 |
and <code>calendar</code> to datetime objects, and <code><a href="#date2num">date2num</a></code> does the reverse.
|
1055 | 1029 |
All the calendars currently defined in the
|
1056 | 1030 |
<a href="http://cfconventions.org">CF metadata convention</a> are supported.
|
1057 | |
A function called <code>date2index</code> is also provided which returns the indices
|
|
1031 |
A function called <code><a href="#date2index">date2index</a></code> is also provided which returns the indices
|
1058 | 1032 |
of a netCDF time variable corresponding to a sequence of datetime instances.</p>
|
1059 | 1033 |
|
1060 | 1034 |
<h2 id="reading-data-from-a-multi-file-netcdf-dataset">Reading data from a multi-file netCDF dataset</h2>
|
1061 | 1035 |
|
1062 | 1036 |
<p>If you want to read data from a variable that spans multiple netCDF files,
|
1063 | |
you can use the <a href="#MFDataset">MFDataset</a> class to read the data as if it were
|
|
1037 |
you can use the <code><a href="#MFDataset">MFDataset</a></code> class to read the data as if it were
|
1064 | 1038 |
contained in a single file. Instead of using a single filename to create
|
1065 | |
a <a href="#Dataset">Dataset</a> instance, create a <a href="#MFDataset">MFDataset</a> instance with either a list
|
|
1039 |
a <code><a href="#Dataset">Dataset</a></code> instance, create a <code><a href="#MFDataset">MFDataset</a></code> instance with either a list
|
1066 | 1040 |
of filenames, or a string with a wildcard (which is then converted to
|
1067 | 1041 |
a sorted list of files using the python glob module).
|
1068 | 1042 |
Variables in the list of files that share the same unlimited
|
|
1077 | 1051 |
<span class="o">...</span> <span class="k">with</span> <span class="n">Dataset</span><span class="p">(</span><span class="s2">"mftest</span><span class="si">%s</span><span class="s2">.nc"</span> <span class="o">%</span> <span class="n">nf</span><span class="p">,</span> <span class="s2">"w"</span><span class="p">,</span> <span class="nb">format</span><span class="o">=</span><span class="s2">"NETCDF4_CLASSIC"</span><span class="p">)</span> <span class="k">as</span> <span class="n">f</span><span class="p">:</span>
|
1078 | 1052 |
<span class="o">...</span> <span class="n">_</span> <span class="o">=</span> <span class="n">f</span><span class="o">.</span><span class="n">createDimension</span><span class="p">(</span><span class="s2">"x"</span><span class="p">,</span><span class="kc">None</span><span class="p">)</span>
|
1079 | 1053 |
<span class="o">...</span> <span class="n">x</span> <span class="o">=</span> <span class="n">f</span><span class="o">.</span><span class="n">createVariable</span><span class="p">(</span><span class="s2">"x"</span><span class="p">,</span><span class="s2">"i"</span><span class="p">,(</span><span class="s2">"x"</span><span class="p">,))</span>
|
1080 | |
<span class="o">...</span> <span class="n">x</span><span class="p">[</span><span class="mi">0</span><span class="p">:</span><span class="mi">10</span><span class="p">]</span> <span class="o">=</span> <span class="n">numpy</span><span class="o">.</span><span class="n">arange</span><span class="p">(</span><span class="n">nf</span><span class="o">*</span><span class="mi">10</span><span class="p">,</span><span class="mi">10</span><span class="o">*</span><span class="p">(</span><span class="n">nf</span><span class="o">+</span><span class="mi">1</span><span class="p">))</span>
|
1081 | |
</code></pre></div>
|
1082 | |
|
1083 | |
<p>Now read all the files back in at once with <a href="#MFDataset">MFDataset</a></p>
|
|
1054 |
<span class="o">...</span> <span class="n">x</span><span class="p">[</span><span class="mi">0</span><span class="p">:</span><span class="mi">10</span><span class="p">]</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">arange</span><span class="p">(</span><span class="n">nf</span><span class="o">*</span><span class="mi">10</span><span class="p">,</span><span class="mi">10</span><span class="o">*</span><span class="p">(</span><span class="n">nf</span><span class="o">+</span><span class="mi">1</span><span class="p">))</span>
|
|
1055 |
</code></pre></div>
|
|
1056 |
|
|
1057 |
<p>Now read all the files back in at once with <code><a href="#MFDataset">MFDataset</a></code></p>
|
1084 | 1058 |
|
1085 | 1059 |
<div class="codehilite"><pre><span></span><code><span class="o">>>></span> <span class="kn">from</span> <span class="nn">netCDF4</span> <span class="kn">import</span> <span class="n">MFDataset</span>
|
1086 | 1060 |
<span class="o">>>></span> <span class="n">f</span> <span class="o">=</span> <span class="n">MFDataset</span><span class="p">(</span><span class="s2">"mftest*nc"</span><span class="p">)</span>
|
|
1092 | 1066 |
<span class="mi">96</span> <span class="mi">97</span> <span class="mi">98</span> <span class="mi">99</span><span class="p">]</span>
|
1093 | 1067 |
</code></pre></div>
|
1094 | 1068 |
|
1095 | |
<p>Note that <a href="#MFDataset">MFDataset</a> can only be used to read, not write, multi-file
|
|
1069 |
<p>Note that <code><a href="#MFDataset">MFDataset</a></code> can only be used to read, not write, multi-file
|
1096 | 1070 |
datasets.</p>
|
1097 | 1071 |
|
1098 | 1072 |
<h2 id="efficient-compression-of-netcdf-variables">Efficient compression of netCDF variables</h2>
|
1099 | 1073 |
|
1100 | |
<p>Data stored in netCDF 4 <a href="#Variable">Variable</a> objects can be compressed and
|
|
1074 |
<p>Data stored in netCDF 4 <code><a href="#Variable">Variable</a></code> objects can be compressed and
|
1101 | 1075 |
decompressed on the fly. The parameters for the compression are
|
1102 | 1076 |
determined by the <code>zlib</code>, <code>complevel</code> and <code>shuffle</code> keyword arguments
|
1103 | |
to the <a href="#<a href="#Dataset.createVariable">Dataset.createVariable</a>"><a href="#Dataset.createVariable">Dataset.createVariable</a></a> method. To turn on
|
|
1077 |
to the <code><a href="#Dataset.createVariable">Dataset.createVariable</a></code> method. To turn on
|
1104 | 1078 |
compression, set <code>zlib=True</code>. The <code>complevel</code> keyword regulates the
|
1105 | 1079 |
speed and efficiency of the compression (1 being fastest, but lowest
|
1106 | 1080 |
compression ratio, 9 being slowest but best compression ratio). The
|
|
1109 | 1083 |
compression by reordering the bytes. The shuffle filter can
|
1110 | 1084 |
significantly improve compression ratios, and is on by default. Setting
|
1111 | 1085 |
<code>fletcher32</code> keyword argument to
|
1112 | |
<a href="#<a href="#Dataset.createVariable">Dataset.createVariable</a>"><a href="#Dataset.createVariable">Dataset.createVariable</a></a> to <code>True</code> (it's <code>False</code> by
|
|
1086 |
<code><a href="#Dataset.createVariable">Dataset.createVariable</a></code> to <code>True</code> (it's <code>False</code> by
|
1113 | 1087 |
default) enables the Fletcher32 checksum algorithm for error detection.
|
1114 | 1088 |
It's also possible to set the HDF5 chunking parameters and endian-ness
|
1115 | 1089 |
of the binary data stored in the HDF5 file with the <code>chunksizes</code>
|
1116 | 1090 |
and <code>endian</code> keyword arguments to
|
1117 | |
<a href="#<a href="#Dataset.createVariable">Dataset.createVariable</a>"><a href="#Dataset.createVariable">Dataset.createVariable</a></a>. These keyword arguments only
|
|
1091 |
<code><a href="#Dataset.createVariable">Dataset.createVariable</a></code>. These keyword arguments only
|
1118 | 1092 |
are relevant for <code>NETCDF4</code> and <code>NETCDF4_CLASSIC</code> files (where the
|
1119 | 1093 |
underlying file format is HDF5) and are silently ignored if the file
|
1120 | 1094 |
format is <code>NETCDF3_CLASSIC</code>, <code>NETCDF3_64BIT_OFFSET</code> or <code>NETCDF3_64BIT_DATA</code>.</p>
|
|
1123 | 1097 |
example, it is temperature data that was measured with a precision of
|
1124 | 1098 |
0.1 degrees), you can dramatically improve zlib compression by
|
1125 | 1099 |
quantizing (or truncating) the data using the <code>least_significant_digit</code>
|
1126 | |
keyword argument to <a href="#<a href="#Dataset.createVariable">Dataset.createVariable</a>"><a href="#Dataset.createVariable">Dataset.createVariable</a></a>. The least
|
|
1100 |
keyword argument to <code><a href="#Dataset.createVariable">Dataset.createVariable</a></code>. The least
|
1127 | 1101 |
significant digit is the power of ten of the smallest decimal place in
|
1128 | 1102 |
the data that is a reliable value. For example if the data has a
|
1129 | 1103 |
precision of 0.1, then setting <code>least_significant_digit=1</code> will cause
|
|
1135 | 1109 |
|
1136 | 1110 |
<p>In our example, try replacing the line</p>
|
1137 | 1111 |
|
1138 | |
<pre><code>```python
|
1139 | |
>>> temp = rootgrp.createVariable("temp","f4",("time","level","lat","lon",))
|
1140 | |
</code></pre>
|
|
1112 |
<div class="codehilite"><pre><span></span><code><span class="o">>>></span> <span class="n">temp</span> <span class="o">=</span> <span class="n">rootgrp</span><span class="o">.</span><span class="n">createVariable</span><span class="p">(</span><span class="s2">"temp"</span><span class="p">,</span><span class="s2">"f4"</span><span class="p">,(</span><span class="s2">"time"</span><span class="p">,</span><span class="s2">"level"</span><span class="p">,</span><span class="s2">"lat"</span><span class="p">,</span><span class="s2">"lon"</span><span class="p">,))</span>
|
|
1113 |
</code></pre></div>
|
1141 | 1114 |
|
1142 | 1115 |
<p>with</p>
|
1143 | 1116 |
|
|
1163 | 1136 |
information for a point by reading one variable, instead of reading
|
1164 | 1137 |
different parameters from different variables. Compound data types
|
1165 | 1138 |
are created from the corresponding numpy data type using the
|
1166 | |
<a href="#<a href="#Dataset.createCompoundType">Dataset.createCompoundType</a>"><a href="#Dataset.createCompoundType">Dataset.createCompoundType</a></a> method of a <a href="#Dataset">Dataset</a> or <a href="#Group">Group</a> instance.
|
|
1139 |
<code><a href="#Dataset.createCompoundType">Dataset.createCompoundType</a></code> method of a <code><a href="#Dataset">Dataset</a></code> or <code><a href="#Group">Group</a></code> instance.
|
1167 | 1140 |
Since there is no native complex data type in netcdf, compound types are handy
|
1168 | 1141 |
for storing numpy complex arrays. Here's an example:</p>
|
1169 | 1142 |
|
1170 | 1143 |
<div class="codehilite"><pre><span></span><code><span class="o">>>></span> <span class="n">f</span> <span class="o">=</span> <span class="n">Dataset</span><span class="p">(</span><span class="s2">"complex.nc"</span><span class="p">,</span><span class="s2">"w"</span><span class="p">)</span>
|
1171 | 1144 |
<span class="o">>>></span> <span class="n">size</span> <span class="o">=</span> <span class="mi">3</span> <span class="c1"># length of 1-d complex array</span>
|
1172 | 1145 |
<span class="o">>>></span> <span class="c1"># create sample complex data.</span>
|
1173 | |
<span class="o">>>></span> <span class="n">datac</span> <span class="o">=</span> <span class="n">numpy</span><span class="o">.</span><span class="n">exp</span><span class="p">(</span><span class="mi">1</span><span class="n">j</span><span class="o">*</span><span class="p">(</span><span class="mf">1.</span><span class="o">+</span><span class="n">numpy</span><span class="o">.</span><span class="n">linspace</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="n">numpy</span><span class="o">.</span><span class="n">pi</span><span class="p">,</span> <span class="n">size</span><span class="p">)))</span>
|
|
1146 |
<span class="o">>>></span> <span class="n">datac</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">exp</span><span class="p">(</span><span class="mi">1</span><span class="n">j</span><span class="o">*</span><span class="p">(</span><span class="mf">1.</span><span class="o">+</span><span class="n">np</span><span class="o">.</span><span class="n">linspace</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="n">np</span><span class="o">.</span><span class="n">pi</span><span class="p">,</span> <span class="n">size</span><span class="p">)))</span>
|
1174 | 1147 |
<span class="o">>>></span> <span class="c1"># create complex128 compound data type.</span>
|
1175 | |
<span class="o">>>></span> <span class="n">complex128</span> <span class="o">=</span> <span class="n">numpy</span><span class="o">.</span><span class="n">dtype</span><span class="p">([(</span><span class="s2">"real"</span><span class="p">,</span><span class="n">numpy</span><span class="o">.</span><span class="n">float_64</span><span class="p">),(</span><span class="s2">"imag"</span><span class="p">,</span><span class="n">numpy</span><span class="o">.</span><span class="n">float_64</span><span class="p">)])</span>
|
|
1148 |
<span class="o">>>></span> <span class="n">complex128</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">dtype</span><span class="p">([(</span><span class="s2">"real"</span><span class="p">,</span><span class="n">np</span><span class="o">.</span><span class="n">float64</span><span class="p">),(</span><span class="s2">"imag"</span><span class="p">,</span><span class="n">np</span><span class="o">.</span><span class="n">float64</span><span class="p">)])</span>
|
1176 | 1149 |
<span class="o">>>></span> <span class="n">complex128_t</span> <span class="o">=</span> <span class="n">f</span><span class="o">.</span><span class="n">createCompoundType</span><span class="p">(</span><span class="n">complex128</span><span class="p">,</span><span class="s2">"complex128"</span><span class="p">)</span>
|
1177 | 1150 |
<span class="o">>>></span> <span class="c1"># create a variable with this data type, write some data to it.</span>
|
1178 | 1151 |
<span class="o">>>></span> <span class="n">x_dim</span> <span class="o">=</span> <span class="n">f</span><span class="o">.</span><span class="n">createDimension</span><span class="p">(</span><span class="s2">"x_dim"</span><span class="p">,</span><span class="kc">None</span><span class="p">)</span>
|
1179 | 1152 |
<span class="o">>>></span> <span class="n">v</span> <span class="o">=</span> <span class="n">f</span><span class="o">.</span><span class="n">createVariable</span><span class="p">(</span><span class="s2">"cmplx_var"</span><span class="p">,</span><span class="n">complex128_t</span><span class="p">,</span><span class="s2">"x_dim"</span><span class="p">)</span>
|
1180 | |
<span class="o">>>></span> <span class="n">data</span> <span class="o">=</span> <span class="n">numpy</span><span class="o">.</span><span class="n">empty</span><span class="p">(</span><span class="n">size</span><span class="p">,</span><span class="n">complex128</span><span class="p">)</span> <span class="c1"># numpy structured array</span>
|
|
1153 |
<span class="o">>>></span> <span class="n">data</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">empty</span><span class="p">(</span><span class="n">size</span><span class="p">,</span><span class="n">complex128</span><span class="p">)</span> <span class="c1"># numpy structured array</span>
|
1181 | 1154 |
<span class="o">>>></span> <span class="n">data</span><span class="p">[</span><span class="s2">"real"</span><span class="p">]</span> <span class="o">=</span> <span class="n">datac</span><span class="o">.</span><span class="n">real</span><span class="p">;</span> <span class="n">data</span><span class="p">[</span><span class="s2">"imag"</span><span class="p">]</span> <span class="o">=</span> <span class="n">datac</span><span class="o">.</span><span class="n">imag</span>
|
1182 | 1155 |
<span class="o">>>></span> <span class="n">v</span><span class="p">[:]</span> <span class="o">=</span> <span class="n">data</span> <span class="c1"># write numpy structured array to netcdf compound var</span>
|
1183 | 1156 |
<span class="o">>>></span> <span class="c1"># close and reopen the file, check the contents.</span>
|
|
1185 | 1158 |
<span class="o">>>></span> <span class="n">v</span> <span class="o">=</span> <span class="n">f</span><span class="o">.</span><span class="n">variables</span><span class="p">[</span><span class="s2">"cmplx_var"</span><span class="p">]</span>
|
1186 | 1159 |
<span class="o">>>></span> <span class="n">datain</span> <span class="o">=</span> <span class="n">v</span><span class="p">[:]</span> <span class="c1"># read in all the data into a numpy structured array</span>
|
1187 | 1160 |
<span class="o">>>></span> <span class="c1"># create an empty numpy complex array</span>
|
1188 | |
<span class="o">>>></span> <span class="n">datac2</span> <span class="o">=</span> <span class="n">numpy</span><span class="o">.</span><span class="n">empty</span><span class="p">(</span><span class="n">datain</span><span class="o">.</span><span class="n">shape</span><span class="p">,</span><span class="n">numpy</span><span class="o">.</span><span class="n">complex128</span><span class="p">)</span>
|
|
1161 |
<span class="o">>>></span> <span class="n">datac2</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">empty</span><span class="p">(</span><span class="n">datain</span><span class="o">.</span><span class="n">shape</span><span class="p">,</span><span class="n">np</span><span class="o">.</span><span class="n">complex128</span><span class="p">)</span>
|
1189 | 1162 |
<span class="o">>>></span> <span class="c1"># .. fill it with contents of structured array.</span>
|
1190 | 1163 |
<span class="o">>>></span> <span class="n">datac2</span><span class="o">.</span><span class="n">real</span> <span class="o">=</span> <span class="n">datain</span><span class="p">[</span><span class="s2">"real"</span><span class="p">];</span> <span class="n">datac2</span><span class="o">.</span><span class="n">imag</span> <span class="o">=</span> <span class="n">datain</span><span class="p">[</span><span class="s2">"imag"</span><span class="p">]</span>
|
1191 | 1164 |
<span class="o">>>></span> <span class="nb">print</span><span class="p">(</span><span class="s1">'</span><span class="si">{}</span><span class="s1">: </span><span class="si">{}</span><span class="s1">'</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">datac</span><span class="o">.</span><span class="n">dtype</span><span class="p">,</span> <span class="n">datac</span><span class="p">))</span> <span class="c1"># original data</span>
|
|
1199 | 1172 |
ones first. All possible numpy structured arrays cannot be
|
1200 | 1173 |
represented as Compound variables - an error message will be
|
1201 | 1174 |
raise if you try to create one that is not supported.
|
1202 | |
All of the compound types defined for a <a href="#Dataset">Dataset</a> or <a href="#Group">Group</a> are stored
|
|
1175 |
All of the compound types defined for a <code><a href="#Dataset">Dataset</a></code> or <code><a href="#Group">Group</a></code> are stored
|
1203 | 1176 |
in a Python dictionary, just like variables and dimensions. As always, printing
|
1204 | 1177 |
objects gives useful summary information in an interactive session:</p>
|
1205 | 1178 |
|
|
1225 | 1198 |
|
1226 | 1199 |
<p>NetCDF 4 has support for variable-length or "ragged" arrays. These are arrays
|
1227 | 1200 |
of variable length sequences having the same type. To create a variable-length
|
1228 | |
data type, use the <a href="#<a href="#Dataset.createVLType">Dataset.createVLType</a>"><a href="#Dataset.createVLType">Dataset.createVLType</a></a> method
|
1229 | |
method of a <a href="#Dataset">Dataset</a> or <a href="#Group">Group</a> instance.</p>
|
|
1201 |
data type, use the <code><a href="#Dataset.createVLType">Dataset.createVLType</a></code> method
|
|
1202 |
method of a <code><a href="#Dataset">Dataset</a></code> or <code><a href="#Group">Group</a></code> instance.</p>
|
1230 | 1203 |
|
1231 | 1204 |
<div class="codehilite"><pre><span></span><code><span class="o">>>></span> <span class="n">f</span> <span class="o">=</span> <span class="n">Dataset</span><span class="p">(</span><span class="s2">"tst_vlen.nc"</span><span class="p">,</span><span class="s2">"w"</span><span class="p">)</span>
|
1232 | |
<span class="o">>>></span> <span class="n">vlen_t</span> <span class="o">=</span> <span class="n">f</span><span class="o">.</span><span class="n">createVLType</span><span class="p">(</span><span class="n">numpy</span><span class="o">.</span><span class="n">int32</span><span class="p">,</span> <span class="s2">"phony_vlen"</span><span class="p">)</span>
|
|
1205 |
<span class="o">>>></span> <span class="n">vlen_t</span> <span class="o">=</span> <span class="n">f</span><span class="o">.</span><span class="n">createVLType</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">int32</span><span class="p">,</span> <span class="s2">"phony_vlen"</span><span class="p">)</span>
|
1233 | 1206 |
</code></pre></div>
|
1234 | 1207 |
|
1235 | 1208 |
<p>The numpy datatype of the variable-length sequences and the name of the
|
|
1253 | 1226 |
|
1254 | 1227 |
<div class="codehilite"><pre><span></span><code><span class="o">>>></span> <span class="kn">import</span> <span class="nn">random</span>
|
1255 | 1228 |
<span class="o">>>></span> <span class="n">random</span><span class="o">.</span><span class="n">seed</span><span class="p">(</span><span class="mi">54321</span><span class="p">)</span>
|
1256 | |
<span class="o">>>></span> <span class="n">data</span> <span class="o">=</span> <span class="n">numpy</span><span class="o">.</span><span class="n">empty</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">y</span><span class="p">)</span><span class="o">*</span><span class="nb">len</span><span class="p">(</span><span class="n">x</span><span class="p">),</span><span class="nb">object</span><span class="p">)</span>
|
|
1229 |
<span class="o">>>></span> <span class="n">data</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">empty</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">y</span><span class="p">)</span><span class="o">*</span><span class="nb">len</span><span class="p">(</span><span class="n">x</span><span class="p">),</span><span class="nb">object</span><span class="p">)</span>
|
1257 | 1230 |
<span class="o">>>></span> <span class="k">for</span> <span class="n">n</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">y</span><span class="p">)</span><span class="o">*</span><span class="nb">len</span><span class="p">(</span><span class="n">x</span><span class="p">)):</span>
|
1258 | |
<span class="o">...</span> <span class="n">data</span><span class="p">[</span><span class="n">n</span><span class="p">]</span> <span class="o">=</span> <span class="n">numpy</span><span class="o">.</span><span class="n">arange</span><span class="p">(</span><span class="n">random</span><span class="o">.</span><span class="n">randint</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span><span class="mi">10</span><span class="p">),</span><span class="n">dtype</span><span class="o">=</span><span class="s2">"int32"</span><span class="p">)</span><span class="o">+</span><span class="mi">1</span>
|
1259 | |
<span class="o">>>></span> <span class="n">data</span> <span class="o">=</span> <span class="n">numpy</span><span class="o">.</span><span class="n">reshape</span><span class="p">(</span><span class="n">data</span><span class="p">,(</span><span class="nb">len</span><span class="p">(</span><span class="n">y</span><span class="p">),</span><span class="nb">len</span><span class="p">(</span><span class="n">x</span><span class="p">)))</span>
|
|
1231 |
<span class="o">...</span> <span class="n">data</span><span class="p">[</span><span class="n">n</span><span class="p">]</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">arange</span><span class="p">(</span><span class="n">random</span><span class="o">.</span><span class="n">randint</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span><span class="mi">10</span><span class="p">),</span><span class="n">dtype</span><span class="o">=</span><span class="s2">"int32"</span><span class="p">)</span><span class="o">+</span><span class="mi">1</span>
|
|
1232 |
<span class="o">>>></span> <span class="n">data</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">reshape</span><span class="p">(</span><span class="n">data</span><span class="p">,(</span><span class="nb">len</span><span class="p">(</span><span class="n">y</span><span class="p">),</span><span class="nb">len</span><span class="p">(</span><span class="n">x</span><span class="p">)))</span>
|
1260 | 1233 |
<span class="o">>>></span> <span class="n">vlvar</span><span class="p">[:]</span> <span class="o">=</span> <span class="n">data</span>
|
1261 | 1234 |
<span class="o">>>></span> <span class="nb">print</span><span class="p">(</span><span class="s2">"vlen variable =</span><span class="se">\n</span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">vlvar</span><span class="p">[:]))</span>
|
1262 | 1235 |
<span class="n">vlen</span> <span class="n">variable</span> <span class="o">=</span>
|
|
1289 | 1262 |
variables, For vlen strings, you don't need to create a vlen data type.
|
1290 | 1263 |
Instead, simply use the python <code>str</code> builtin (or a numpy string datatype
|
1291 | 1264 |
with fixed length greater than 1) when calling the
|
1292 | |
<a href="#<a href="#Dataset.createVariable">Dataset.createVariable</a>"><a href="#Dataset.createVariable">Dataset.createVariable</a></a> method.</p>
|
|
1265 |
<code><a href="#Dataset.createVariable">Dataset.createVariable</a></code> method.</p>
|
1293 | 1266 |
|
1294 | 1267 |
<div class="codehilite"><pre><span></span><code><span class="o">>>></span> <span class="n">z</span> <span class="o">=</span> <span class="n">f</span><span class="o">.</span><span class="n">createDimension</span><span class="p">(</span><span class="s2">"z"</span><span class="p">,</span><span class="mi">10</span><span class="p">)</span>
|
1295 | 1268 |
<span class="o">>>></span> <span class="n">strvar</span> <span class="o">=</span> <span class="n">f</span><span class="o">.</span><span class="n">createVariable</span><span class="p">(</span><span class="s2">"strvar"</span><span class="p">,</span> <span class="nb">str</span><span class="p">,</span> <span class="s2">"z"</span><span class="p">)</span>
|
|
1300 | 1273 |
array is assigned to the vlen string variable.</p>
|
1301 | 1274 |
|
1302 | 1275 |
<div class="codehilite"><pre><span></span><code><span class="o">>>></span> <span class="n">chars</span> <span class="o">=</span> <span class="s2">"1234567890aabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"</span>
|
1303 | |
<span class="o">>>></span> <span class="n">data</span> <span class="o">=</span> <span class="n">numpy</span><span class="o">.</span><span class="n">empty</span><span class="p">(</span><span class="mi">10</span><span class="p">,</span><span class="s2">"O"</span><span class="p">)</span>
|
|
1276 |
<span class="o">>>></span> <span class="n">data</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">empty</span><span class="p">(</span><span class="mi">10</span><span class="p">,</span><span class="s2">"O"</span><span class="p">)</span>
|
1304 | 1277 |
<span class="o">>>></span> <span class="k">for</span> <span class="n">n</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">10</span><span class="p">):</span>
|
1305 | 1278 |
<span class="o">...</span> <span class="n">stringlen</span> <span class="o">=</span> <span class="n">random</span><span class="o">.</span><span class="n">randint</span><span class="p">(</span><span class="mi">2</span><span class="p">,</span><span class="mi">12</span><span class="p">)</span>
|
1306 | 1279 |
<span class="o">...</span> <span class="n">data</span><span class="p">[</span><span class="n">n</span><span class="p">]</span> <span class="o">=</span> <span class="s2">""</span><span class="o">.</span><span class="n">join</span><span class="p">([</span><span class="n">random</span><span class="o">.</span><span class="n">choice</span><span class="p">(</span><span class="n">chars</span><span class="p">)</span> <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="n">stringlen</span><span class="p">)])</span>
|
|
1336 | 1309 |
<p>Here's an example of using an Enum type to hold cloud type data.
|
1337 | 1310 |
The base integer data type and a python dictionary describing the allowed
|
1338 | 1311 |
values and their names are used to define an Enum data type using
|
1339 | |
<a href="#<a href="#Dataset.createEnumType">Dataset.createEnumType</a>"><a href="#Dataset.createEnumType">Dataset.createEnumType</a></a>.</p>
|
|
1312 |
<code><a href="#Dataset.createEnumType">Dataset.createEnumType</a></code>.</p>
|
1340 | 1313 |
|
1341 | 1314 |
<div class="codehilite"><pre><span></span><code><span class="o">>>></span> <span class="n">nc</span> <span class="o">=</span> <span class="n">Dataset</span><span class="p">(</span><span class="s1">'clouds.nc'</span><span class="p">,</span><span class="s1">'w'</span><span class="p">)</span>
|
1342 | 1315 |
<span class="o">>>></span> <span class="c1"># python dict with allowed values and their names.</span>
|
|
1345 | 1318 |
<span class="o">...</span> <span class="s1">'Nimbostratus'</span><span class="p">:</span> <span class="mi">6</span><span class="p">,</span> <span class="s1">'Cumulus'</span><span class="p">:</span> <span class="mi">4</span><span class="p">,</span> <span class="s1">'Altostratus'</span><span class="p">:</span> <span class="mi">5</span><span class="p">,</span>
|
1346 | 1319 |
<span class="o">...</span> <span class="s1">'Cumulonimbus'</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span> <span class="s1">'Stratocumulus'</span><span class="p">:</span> <span class="mi">3</span><span class="p">}</span>
|
1347 | 1320 |
<span class="o">>>></span> <span class="c1"># create the Enum type called 'cloud_t'.</span>
|
1348 | |
<span class="o">>>></span> <span class="n">cloud_type</span> <span class="o">=</span> <span class="n">nc</span><span class="o">.</span><span class="n">createEnumType</span><span class="p">(</span><span class="n">numpy</span><span class="o">.</span><span class="n">uint8</span><span class="p">,</span><span class="s1">'cloud_t'</span><span class="p">,</span><span class="n">enum_dict</span><span class="p">)</span>
|
|
1321 |
<span class="o">>>></span> <span class="n">cloud_type</span> <span class="o">=</span> <span class="n">nc</span><span class="o">.</span><span class="n">createEnumType</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">uint8</span><span class="p">,</span><span class="s1">'cloud_t'</span><span class="p">,</span><span class="n">enum_dict</span><span class="p">)</span>
|
1349 | 1322 |
<span class="o">>>></span> <span class="nb">print</span><span class="p">(</span><span class="n">cloud_type</span><span class="p">)</span>
|
1350 | 1323 |
<span class="o"><</span><span class="k">class</span> <span class="err">'</span><span class="nc">netCDF4</span><span class="o">.</span><span class="n">_netCDF4</span><span class="o">.</span><span class="n">EnumType</span><span class="s1">'>: name = '</span><span class="n">cloud_t</span><span class="s1">', numpy dtype = uint8, fields/values ={'</span><span class="n">Altocumulus</span><span class="s1">': 7, '</span><span class="n">Missing</span><span class="s1">': 255, '</span><span class="n">Stratus</span><span class="s1">': 2, '</span><span class="n">Clear</span><span class="s1">': 0, '</span><span class="n">Nimbostratus</span><span class="s1">': 6, '</span><span class="n">Cumulus</span><span class="s1">': 4, '</span><span class="n">Altostratus</span><span class="s1">': 5, '</span><span class="n">Cumulonimbus</span><span class="s1">': 1, '</span><span class="n">Stratocumulus</span><span class="s1">': 3}</span>
|
1351 | 1324 |
</code></pre></div>
|
|
1414 | 1387 |
written to a different variable index on each task</p>
|
1415 | 1388 |
|
1416 | 1389 |
<div class="codehilite"><pre><span></span><code><span class="o">>>></span> <span class="n">d</span> <span class="o">=</span> <span class="n">nc</span><span class="o">.</span><span class="n">createDimension</span><span class="p">(</span><span class="s1">'dim'</span><span class="p">,</span><span class="mi">4</span><span class="p">)</span>
|
1417 | |
<span class="o">>>></span> <span class="n">v</span> <span class="o">=</span> <span class="n">nc</span><span class="o">.</span><span class="n">createVariable</span><span class="p">(</span><span class="s1">'var'</span><span class="p">,</span> <span class="n">np</span><span class="o">.</span><span class="n">int</span><span class="p">,</span> <span class="s1">'dim'</span><span class="p">)</span>
|
|
1390 |
<span class="o">>>></span> <span class="n">v</span> <span class="o">=</span> <span class="n">nc</span><span class="o">.</span><span class="n">createVariable</span><span class="p">(</span><span class="s1">'var'</span><span class="p">,</span> <span class="n">np</span><span class="o">.</span><span class="n">int64</span><span class="p">,</span> <span class="s1">'dim'</span><span class="p">)</span>
|
1418 | 1391 |
<span class="o">>>></span> <span class="n">v</span><span class="p">[</span><span class="n">rank</span><span class="p">]</span> <span class="o">=</span> <span class="n">rank</span>
|
1419 | 1392 |
<span class="o">>>></span> <span class="n">nc</span><span class="o">.</span><span class="n">close</span><span class="p">()</span>
|
1420 | 1393 |
|
|
1435 | 1408 |
depend on or be affected by other processes. Collective IO is a way of doing
|
1436 | 1409 |
IO defined in the MPI-IO standard; unlike independent IO, all processes must
|
1437 | 1410 |
participate in doing IO. To toggle back and forth between
|
1438 | |
the two types of IO, use the <a href="#<a href="#Variable.set_collective">Variable.set_collective</a>"><a href="#Variable.set_collective">Variable.set_collective</a></a>
|
1439 | |
<a href="#Variable">Variable</a> method. All metadata
|
|
1411 |
the two types of IO, use the <code><a href="#Variable.set_collective">Variable.set_collective</a></code>
|
|
1412 |
<code><a href="#Variable">Variable</a></code> method. All metadata
|
1440 | 1413 |
operations (such as creation of groups, types, variables, dimensions, or attributes)
|
1441 | 1414 |
are collective. There are a couple of important limitations of parallel IO:</p>
|
1442 | 1415 |
|
|
1449 | 1422 |
If the write is done in independent mode, the operation will fail with a
|
1450 | 1423 |
a generic "HDF Error".</li>
|
1451 | 1424 |
<li>You can write compressed data in parallel only with netcdf-c >= 4.7.4
|
1452 | |
and hdf5 >= 1.10.3 (although you can read in parallel with earlier versions).</li>
|
|
1425 |
and hdf5 >= 1.10.3 (although you can read in parallel with earlier versions). To write
|
|
1426 |
compressed data in parallel, the variable must be in 'collective IO mode'. This is done
|
|
1427 |
automatically on variable creation if compression is turned on, but if you are appending
|
|
1428 |
to a variable in an existing file, you must use <code><a href="#Variable.set_collective">Variable.set_collective</a>(True)</code> before attempting
|
|
1429 |
to write to it.</li>
|
1453 | 1430 |
<li>You cannot use variable-length (VLEN) data types.</li>
|
1454 | 1431 |
</ul>
|
1455 | 1432 |
|
|
1466 | 1443 |
To perform the conversion to and from character arrays to fixed-width numpy string arrays, the
|
1467 | 1444 |
following convention is followed by the python interface.
|
1468 | 1445 |
If the <code>_Encoding</code> special attribute is set for a character array
|
1469 | |
(dtype <code>S1</code>) variable, the <a href="#chartostring">chartostring</a> utility function is used to convert the array of
|
|
1446 |
(dtype <code>S1</code>) variable, the <code><a href="#chartostring">chartostring</a></code> utility function is used to convert the array of
|
1470 | 1447 |
characters to an array of strings with one less dimension (the last dimension is
|
1471 | 1448 |
interpreted as the length of each string) when reading the data. The character
|
1472 | 1449 |
set (usually ascii) is specified by the <code>_Encoding</code> attribute. If <code>_Encoding</code>
|
1473 | 1450 |
is 'none' or 'bytes', then the character array is converted to a numpy
|
1474 | 1451 |
fixed-width byte string array (dtype <code>S#</code>), otherwise a numpy unicode (dtype
|
1475 | 1452 |
<code>U#</code>) array is created. When writing the data,
|
1476 | |
<a href="#stringtochar">stringtochar</a> is used to convert the numpy string array to an array of
|
|
1453 |
<code><a href="#stringtochar">stringtochar</a></code> is used to convert the numpy string array to an array of
|
1477 | 1454 |
characters with one more dimension. For example,</p>
|
1478 | 1455 |
|
1479 | 1456 |
<div class="codehilite"><pre><span></span><code><span class="o">>>></span> <span class="kn">from</span> <span class="nn">netCDF4</span> <span class="kn">import</span> <span class="n">stringtochar</span>
|
|
1481 | 1458 |
<span class="o">>>></span> <span class="n">_</span> <span class="o">=</span> <span class="n">nc</span><span class="o">.</span><span class="n">createDimension</span><span class="p">(</span><span class="s1">'nchars'</span><span class="p">,</span><span class="mi">3</span><span class="p">)</span>
|
1482 | 1459 |
<span class="o">>>></span> <span class="n">_</span> <span class="o">=</span> <span class="n">nc</span><span class="o">.</span><span class="n">createDimension</span><span class="p">(</span><span class="s1">'nstrings'</span><span class="p">,</span><span class="kc">None</span><span class="p">)</span>
|
1483 | 1460 |
<span class="o">>>></span> <span class="n">v</span> <span class="o">=</span> <span class="n">nc</span><span class="o">.</span><span class="n">createVariable</span><span class="p">(</span><span class="s1">'strings'</span><span class="p">,</span><span class="s1">'S1'</span><span class="p">,(</span><span class="s1">'nstrings'</span><span class="p">,</span><span class="s1">'nchars'</span><span class="p">))</span>
|
1484 | |
<span class="o">>>></span> <span class="n">datain</span> <span class="o">=</span> <span class="n">numpy</span><span class="o">.</span><span class="n">array</span><span class="p">([</span><span class="s1">'foo'</span><span class="p">,</span><span class="s1">'bar'</span><span class="p">],</span><span class="n">dtype</span><span class="o">=</span><span class="s1">'S3'</span><span class="p">)</span>
|
|
1461 |
<span class="o">>>></span> <span class="n">datain</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">([</span><span class="s1">'foo'</span><span class="p">,</span><span class="s1">'bar'</span><span class="p">],</span><span class="n">dtype</span><span class="o">=</span><span class="s1">'S3'</span><span class="p">)</span>
|
1485 | 1462 |
<span class="o">>>></span> <span class="n">v</span><span class="p">[:]</span> <span class="o">=</span> <span class="n">stringtochar</span><span class="p">(</span><span class="n">datain</span><span class="p">)</span> <span class="c1"># manual conversion to char array</span>
|
1486 | 1463 |
<span class="o">>>></span> <span class="nb">print</span><span class="p">(</span><span class="n">v</span><span class="p">[:])</span> <span class="c1"># data returned as char array</span>
|
1487 | 1464 |
<span class="p">[[</span><span class="sa">b</span><span class="s1">'f'</span> <span class="sa">b</span><span class="s1">'o'</span> <span class="sa">b</span><span class="s1">'o'</span><span class="p">]</span>
|
|
1495 | 1472 |
|
1496 | 1473 |
<p>Even if the <code>_Encoding</code> attribute is set, the automatic conversion of char
|
1497 | 1474 |
arrays to/from string arrays can be disabled with
|
1498 | |
<a href="#<a href="#Variable.set_auto_chartostring">Variable.set_auto_chartostring</a>"><a href="#Variable.set_auto_chartostring">Variable.set_auto_chartostring</a></a>.</p>
|
|
1475 |
<code><a href="#Variable.set_auto_chartostring">Variable.set_auto_chartostring</a></code>.</p>
|
1499 | 1476 |
|
1500 | 1477 |
<p>A similar situation is often encountered with numpy structured arrays with subdtypes
|
1501 | 1478 |
containing fixed-wdith byte strings (dtype=<code>S#</code>). Since there is no native fixed-length string
|
|
1510 | 1487 |
Here's an example:</p>
|
1511 | 1488 |
|
1512 | 1489 |
<div class="codehilite"><pre><span></span><code><span class="o">>>></span> <span class="n">nc</span> <span class="o">=</span> <span class="n">Dataset</span><span class="p">(</span><span class="s1">'compoundstring_example.nc'</span><span class="p">,</span><span class="s1">'w'</span><span class="p">)</span>
|
1513 | |
<span class="o">>>></span> <span class="n">dtype</span> <span class="o">=</span> <span class="n">numpy</span><span class="o">.</span><span class="n">dtype</span><span class="p">([(</span><span class="s1">'observation'</span><span class="p">,</span> <span class="s1">'f4'</span><span class="p">),</span>
|
|
1490 |
<span class="o">>>></span> <span class="n">dtype</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">dtype</span><span class="p">([(</span><span class="s1">'observation'</span><span class="p">,</span> <span class="s1">'f4'</span><span class="p">),</span>
|
1514 | 1491 |
<span class="o">...</span> <span class="p">(</span><span class="s1">'station_name'</span><span class="p">,</span><span class="s1">'S10'</span><span class="p">)])</span>
|
1515 | 1492 |
<span class="o">>>></span> <span class="n">station_data_t</span> <span class="o">=</span> <span class="n">nc</span><span class="o">.</span><span class="n">createCompoundType</span><span class="p">(</span><span class="n">dtype</span><span class="p">,</span><span class="s1">'station_data'</span><span class="p">)</span>
|
1516 | 1493 |
<span class="o">>>></span> <span class="n">_</span> <span class="o">=</span> <span class="n">nc</span><span class="o">.</span><span class="n">createDimension</span><span class="p">(</span><span class="s1">'station'</span><span class="p">,</span><span class="kc">None</span><span class="p">)</span>
|
1517 | 1494 |
<span class="o">>>></span> <span class="n">statdat</span> <span class="o">=</span> <span class="n">nc</span><span class="o">.</span><span class="n">createVariable</span><span class="p">(</span><span class="s1">'station_obs'</span><span class="p">,</span> <span class="n">station_data_t</span><span class="p">,</span> <span class="p">(</span><span class="s1">'station'</span><span class="p">,))</span>
|
1518 | |
<span class="o">>>></span> <span class="n">data</span> <span class="o">=</span> <span class="n">numpy</span><span class="o">.</span><span class="n">empty</span><span class="p">(</span><span class="mi">2</span><span class="p">,</span><span class="n">dtype</span><span class="p">)</span>
|
|
1495 |
<span class="o">>>></span> <span class="n">data</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">empty</span><span class="p">(</span><span class="mi">2</span><span class="p">,</span><span class="n">dtype</span><span class="p">)</span>
|
1519 | 1496 |
<span class="o">>>></span> <span class="n">data</span><span class="p">[</span><span class="s1">'observation'</span><span class="p">][:]</span> <span class="o">=</span> <span class="p">(</span><span class="mf">123.</span><span class="p">,</span><span class="mf">3.14</span><span class="p">)</span>
|
1520 | 1497 |
<span class="o">>>></span> <span class="n">data</span><span class="p">[</span><span class="s1">'station_name'</span><span class="p">][:]</span> <span class="o">=</span> <span class="p">(</span><span class="s1">'Boulder'</span><span class="p">,</span><span class="s1">'New York'</span><span class="p">)</span>
|
1521 | 1498 |
<span class="o">>>></span> <span class="nb">print</span><span class="p">(</span><span class="n">statdat</span><span class="o">.</span><span class="n">dtype</span><span class="p">)</span> <span class="c1"># strings actually stored as character arrays</span>
|
|
1558 | 1535 |
<span class="o">>>></span> <span class="c1"># and persist the file to disk when it is closed.</span>
|
1559 | 1536 |
<span class="o">>>></span> <span class="n">nc</span> <span class="o">=</span> <span class="n">Dataset</span><span class="p">(</span><span class="s1">'diskless_example.nc'</span><span class="p">,</span><span class="s1">'w'</span><span class="p">,</span><span class="n">diskless</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span><span class="n">persist</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
|
1560 | 1537 |
<span class="o">>>></span> <span class="n">d</span> <span class="o">=</span> <span class="n">nc</span><span class="o">.</span><span class="n">createDimension</span><span class="p">(</span><span class="s1">'x'</span><span class="p">,</span><span class="kc">None</span><span class="p">)</span>
|
1561 | |
<span class="o">>>></span> <span class="n">v</span> <span class="o">=</span> <span class="n">nc</span><span class="o">.</span><span class="n">createVariable</span><span class="p">(</span><span class="s1">'v'</span><span class="p">,</span><span class="n">numpy</span><span class="o">.</span><span class="n">int32</span><span class="p">,</span><span class="s1">'x'</span><span class="p">)</span>
|
1562 | |
<span class="o">>>></span> <span class="n">v</span><span class="p">[</span><span class="mi">0</span><span class="p">:</span><span class="mi">5</span><span class="p">]</span> <span class="o">=</span> <span class="n">numpy</span><span class="o">.</span><span class="n">arange</span><span class="p">(</span><span class="mi">5</span><span class="p">)</span>
|
|
1538 |
<span class="o">>>></span> <span class="n">v</span> <span class="o">=</span> <span class="n">nc</span><span class="o">.</span><span class="n">createVariable</span><span class="p">(</span><span class="s1">'v'</span><span class="p">,</span><span class="n">np</span><span class="o">.</span><span class="n">int32</span><span class="p">,</span><span class="s1">'x'</span><span class="p">)</span>
|
|
1539 |
<span class="o">>>></span> <span class="n">v</span><span class="p">[</span><span class="mi">0</span><span class="p">:</span><span class="mi">5</span><span class="p">]</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">arange</span><span class="p">(</span><span class="mi">5</span><span class="p">)</span>
|
1563 | 1540 |
<span class="o">>>></span> <span class="nb">print</span><span class="p">(</span><span class="n">nc</span><span class="p">)</span>
|
1564 | 1541 |
<span class="o"><</span><span class="k">class</span> <span class="err">'</span><span class="nc">netCDF4</span><span class="o">.</span><span class="n">_netCDF4</span><span class="o">.</span><span class="n">Dataset</span><span class="s1">'></span>
|
1565 | 1542 |
<span class="n">root</span> <span class="n">group</span> <span class="p">(</span><span class="n">NETCDF4</span> <span class="n">data</span> <span class="n">model</span><span class="p">,</span> <span class="n">file</span> <span class="nb">format</span> <span class="n">HDF5</span><span class="p">):</span>
|
|
1592 | 1569 |
<span class="o">>>></span> <span class="c1"># (ignored for NETCDF4/HDF5 files).</span>
|
1593 | 1570 |
<span class="o">>>></span> <span class="n">nc</span> <span class="o">=</span> <span class="n">Dataset</span><span class="p">(</span><span class="s1">'inmemory.nc'</span><span class="p">,</span> <span class="n">mode</span><span class="o">=</span><span class="s1">'w'</span><span class="p">,</span><span class="n">memory</span><span class="o">=</span><span class="mi">1028</span><span class="p">)</span>
|
1594 | 1571 |
<span class="o">>>></span> <span class="n">d</span> <span class="o">=</span> <span class="n">nc</span><span class="o">.</span><span class="n">createDimension</span><span class="p">(</span><span class="s1">'x'</span><span class="p">,</span><span class="kc">None</span><span class="p">)</span>
|
1595 | |
<span class="o">>>></span> <span class="n">v</span> <span class="o">=</span> <span class="n">nc</span><span class="o">.</span><span class="n">createVariable</span><span class="p">(</span><span class="s1">'v'</span><span class="p">,</span><span class="n">numpy</span><span class="o">.</span><span class="n">int32</span><span class="p">,</span><span class="s1">'x'</span><span class="p">)</span>
|
1596 | |
<span class="o">>>></span> <span class="n">v</span><span class="p">[</span><span class="mi">0</span><span class="p">:</span><span class="mi">5</span><span class="p">]</span> <span class="o">=</span> <span class="n">numpy</span><span class="o">.</span><span class="n">arange</span><span class="p">(</span><span class="mi">5</span><span class="p">)</span>
|
|
1572 |
<span class="o">>>></span> <span class="n">v</span> <span class="o">=</span> <span class="n">nc</span><span class="o">.</span><span class="n">createVariable</span><span class="p">(</span><span class="s1">'v'</span><span class="p">,</span><span class="n">np</span><span class="o">.</span><span class="n">int32</span><span class="p">,</span><span class="s1">'x'</span><span class="p">)</span>
|
|
1573 |
<span class="o">>>></span> <span class="n">v</span><span class="p">[</span><span class="mi">0</span><span class="p">:</span><span class="mi">5</span><span class="p">]</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">arange</span><span class="p">(</span><span class="mi">5</span><span class="p">)</span>
|
1597 | 1574 |
<span class="o">>>></span> <span class="n">nc_buf</span> <span class="o">=</span> <span class="n">nc</span><span class="o">.</span><span class="n">close</span><span class="p">()</span> <span class="c1"># close returns memoryview</span>
|
1598 | 1575 |
<span class="o">>>></span> <span class="nb">print</span><span class="p">(</span><span class="nb">type</span><span class="p">(</span><span class="n">nc_buf</span><span class="p">))</span>
|
1599 | 1576 |
<span class="o"><</span><span class="k">class</span> <span class="err">'</span><span class="nc">memoryview</span><span class="s1">'></span>
|
|
1616 | 1593 |
the parallel IO example, which is in <code>examples/mpi_example.py</code>.
|
1617 | 1594 |
Unit tests are in the <code>test</code> directory.</p>
|
1618 | 1595 |
|
1619 | |
<p><strong>contact</strong>: Jeffrey Whitaker <a href="mailto:jeffrey.s.whitaker@noaa.gov">jeffrey.s.whitaker@noaa.gov</a></p>
|
|
1596 |
<p><strong>contact</strong>: Jeffrey Whitaker <a href="mailto:jeffrey.s.whitaker@noaa.gov">jeffrey.s.whitaker@noaa.gov</a></p>
|
1620 | 1597 |
|
1621 | 1598 |
<p><strong>copyright</strong>: 2008 by Jeffrey Whitaker.</p>
|
1622 | 1599 |
|
|
1627 | 1604 |
<p>THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.</p>
|
1628 | 1605 |
</div>
|
1629 | 1606 |
|
1630 | |
|
|
1607 |
<details>
|
|
1608 |
<summary>View Source</summary>
|
|
1609 |
<div class="codehilite"><pre><span></span><span class="c1"># init for netCDF4. package</span>
|
|
1610 |
<span class="c1"># Docstring comes from extension module _netCDF4.</span>
|
|
1611 |
<span class="kn">from</span> <span class="nn">._netCDF4</span> <span class="kn">import</span> <span class="o">*</span>
|
|
1612 |
<span class="c1"># Need explicit imports for names beginning with underscores</span>
|
|
1613 |
<span class="kn">from</span> <span class="nn">._netCDF4</span> <span class="kn">import</span> <span class="vm">__doc__</span>
|
|
1614 |
<span class="kn">from</span> <span class="nn">._netCDF4</span> <span class="kn">import</span> <span class="p">(</span><span class="n">__version__</span><span class="p">,</span> <span class="n">__netcdf4libversion__</span><span class="p">,</span> <span class="n">__hdf5libversion__</span><span class="p">,</span>
|
|
1615 |
<span class="n">__has_rename_grp__</span><span class="p">,</span> <span class="n">__has_nc_inq_path__</span><span class="p">,</span>
|
|
1616 |
<span class="n">__has_nc_inq_format_extended__</span><span class="p">,</span> <span class="n">__has_nc_open_mem__</span><span class="p">,</span>
|
|
1617 |
<span class="n">__has_nc_create_mem__</span><span class="p">,</span> <span class="n">__has_cdf5_format__</span><span class="p">,</span>
|
|
1618 |
<span class="n">__has_parallel4_support__</span><span class="p">,</span> <span class="n">__has_pnetcdf_support__</span><span class="p">)</span>
|
|
1619 |
<span class="n">__all__</span> <span class="o">=</span>\
|
|
1620 |
<span class="p">[</span><span class="s1">'Dataset'</span><span class="p">,</span><span class="s1">'Variable'</span><span class="p">,</span><span class="s1">'Dimension'</span><span class="p">,</span><span class="s1">'Group'</span><span class="p">,</span><span class="s1">'MFDataset'</span><span class="p">,</span><span class="s1">'MFTime'</span><span class="p">,</span><span class="s1">'CompoundType'</span><span class="p">,</span><span class="s1">'VLType'</span><span class="p">,</span><span class="s1">'date2num'</span><span class="p">,</span><span class="s1">'num2date'</span><span class="p">,</span><span class="s1">'date2index'</span><span class="p">,</span><span class="s1">'stringtochar'</span><span class="p">,</span><span class="s1">'chartostring'</span><span class="p">,</span><span class="s1">'stringtoarr'</span><span class="p">,</span><span class="s1">'getlibversion'</span><span class="p">,</span><span class="s1">'EnumType'</span><span class="p">,</span><span class="s1">'get_chunk_cache'</span><span class="p">,</span><span class="s1">'set_chunk_cache'</span><span class="p">]</span>
|
|
1621 |
</pre></div>
|
|
1622 |
|
|
1623 |
</details>
|
|
1624 |
|
1631 | 1625 |
</section>
|
1632 | 1626 |
<section id="Dataset">
|
1633 | 1627 |
<div class="attr class">
|
|
1639 | 1633 |
</div>
|
1640 | 1634 |
|
1641 | 1635 |
|
1642 | |
<div class="docstring"><p>A netCDF <a href="#Dataset">Dataset</a> is a collection of dimensions, groups, variables and
|
|
1636 |
<div class="docstring"><p>A netCDF <code><a href="#Dataset">Dataset</a></code> is a collection of dimensions, groups, variables and
|
1643 | 1637 |
attributes. Together they describe the meaning of data and relations among
|
1644 | |
data fields stored in a netCDF file. See <a href="#<a href="#Dataset.__init__">Dataset.__init__</a>"><a href="#Dataset.__init__">Dataset.__init__</a></a> for more
|
|
1638 |
data fields stored in a netCDF file. See <code><a href="#Dataset.__init__">Dataset.__init__</a></code> for more
|
1645 | 1639 |
details.</p>
|
1646 | 1640 |
|
1647 | 1641 |
<p>A list of attribute names corresponding to global netCDF attributes
|
1648 | |
defined for the <a href="#Dataset">Dataset</a> can be obtained with the
|
1649 | |
<a href="#<a href="#Dataset.ncattrs">Dataset.ncattrs</a>"><a href="#Dataset.ncattrs">Dataset.ncattrs</a></a> method.
|
|
1642 |
defined for the <code><a href="#Dataset">Dataset</a></code> can be obtained with the
|
|
1643 |
<code><a href="#Dataset.ncattrs">Dataset.ncattrs</a></code> method.
|
1650 | 1644 |
These attributes can be created by assigning to an attribute of the
|
1651 | |
<a href="#Dataset">Dataset</a> instance. A dictionary containing all the netCDF attribute
|
|
1645 |
<code><a href="#Dataset">Dataset</a></code> instance. A dictionary containing all the netCDF attribute
|
1652 | 1646 |
name/value pairs is provided by the <code>__dict__</code> attribute of a
|
1653 | |
<a href="#Dataset">Dataset</a> instance.</p>
|
|
1647 |
<code><a href="#Dataset">Dataset</a></code> instance.</p>
|
1654 | 1648 |
|
1655 | 1649 |
<p>The following class variables are read-only and should not be
|
1656 | 1650 |
modified by the user.</p>
|
1657 | 1651 |
|
1658 | |
<p><strong><code>dimensions</code></strong>: The <code>dimensions</code> dictionary maps the names of
|
1659 | |
dimensions defined for the <a href="#Group">Group</a> or <a href="#Dataset">Dataset</a> to instances of the
|
1660 | |
<a href="#Dimension">Dimension</a> class.</p>
|
1661 | |
|
1662 | |
<p><strong><code>variables</code></strong>: The <code>variables</code> dictionary maps the names of variables
|
1663 | |
defined for this <a href="#Dataset">Dataset</a> or <a href="#Group">Group</a> to instances of the
|
1664 | |
<a href="#Variable">Variable</a> class.</p>
|
1665 | |
|
1666 | |
<p><strong><code>groups</code></strong>: The groups dictionary maps the names of groups created for
|
1667 | |
this <a href="#Dataset">Dataset</a> or <a href="#Group">Group</a> to instances of the <a href="#Group">Group</a> class (the
|
1668 | |
<a href="#Dataset">Dataset</a> class is simply a special case of the <a href="#Group">Group</a> class which
|
|
1652 |
<p><strong><code><a href="#Dataset.dimensions">dimensions</a></code></strong>: The <code><a href="#Dataset.dimensions">dimensions</a></code> dictionary maps the names of
|
|
1653 |
dimensions defined for the <code><a href="#Group">Group</a></code> or <code><a href="#Dataset">Dataset</a></code> to instances of the
|
|
1654 |
<code><a href="#Dimension">Dimension</a></code> class.</p>
|
|
1655 |
|
|
1656 |
<p><strong><code><a href="#Dataset.variables">variables</a></code></strong>: The <code><a href="#Dataset.variables">variables</a></code> dictionary maps the names of variables
|
|
1657 |
defined for this <code><a href="#Dataset">Dataset</a></code> or <code><a href="#Group">Group</a></code> to instances of the
|
|
1658 |
<code><a href="#Variable">Variable</a></code> class.</p>
|
|
1659 |
|
|
1660 |
<p><strong><code><a href="#Dataset.groups">groups</a></code></strong>: The groups dictionary maps the names of groups created for
|
|
1661 |
this <code><a href="#Dataset">Dataset</a></code> or <code><a href="#Group">Group</a></code> to instances of the <code><a href="#Group">Group</a></code> class (the
|
|
1662 |
<code><a href="#Dataset">Dataset</a></code> class is simply a special case of the <code><a href="#Group">Group</a></code> class which
|
1669 | 1663 |
describes the root group in the netCDF4 file).</p>
|
1670 | 1664 |
|
1671 | |
<p><strong><code>cmptypes</code></strong>: The <code>cmptypes</code> dictionary maps the names of
|
1672 | |
compound types defined for the <a href="#Group">Group</a> or <a href="#Dataset">Dataset</a> to instances of the
|
1673 | |
<a href="#CompoundType">CompoundType</a> class.</p>
|
1674 | |
|
1675 | |
<p><strong><code>vltypes</code></strong>: The <code>vltypes</code> dictionary maps the names of
|
1676 | |
variable-length types defined for the <a href="#Group">Group</a> or <a href="#Dataset">Dataset</a> to instances
|
1677 | |
of the <a href="#VLType">VLType</a> class.</p>
|
1678 | |
|
1679 | |
<p><strong><code>enumtypes</code></strong>: The <code>enumtypes</code> dictionary maps the names of
|
1680 | |
Enum types defined for the <a href="#Group">Group</a> or <a href="#Dataset">Dataset</a> to instances
|
1681 | |
of the <a href="#EnumType">EnumType</a> class.</p>
|
1682 | |
|
1683 | |
<p><strong><code>data_model</code></strong>: <code>data_model</code> describes the netCDF
|
|
1665 |
<p><strong><code><a href="#Dataset.cmptypes">cmptypes</a></code></strong>: The <code><a href="#Dataset.cmptypes">cmptypes</a></code> dictionary maps the names of
|
|
1666 |
compound types defined for the <code><a href="#Group">Group</a></code> or <code><a href="#Dataset">Dataset</a></code> to instances of the
|
|
1667 |
<code><a href="#CompoundType">CompoundType</a></code> class.</p>
|
|
1668 |
|
|
1669 |
<p><strong><code><a href="#Dataset.vltypes">vltypes</a></code></strong>: The <code><a href="#Dataset.vltypes">vltypes</a></code> dictionary maps the names of
|
|
1670 |
variable-length types defined for the <code><a href="#Group">Group</a></code> or <code><a href="#Dataset">Dataset</a></code> to instances
|
|
1671 |
of the <code><a href="#VLType">VLType</a></code> class.</p>
|
|
1672 |
|
|
1673 |
<p><strong><code><a href="#Dataset.enumtypes">enumtypes</a></code></strong>: The <code><a href="#Dataset.enumtypes">enumtypes</a></code> dictionary maps the names of
|
|
1674 |
Enum types defined for the <code><a href="#Group">Group</a></code> or <code><a href="#Dataset">Dataset</a></code> to instances
|
|
1675 |
of the <code><a href="#EnumType">EnumType</a></code> class.</p>
|
|
1676 |
|
|
1677 |
<p><strong><code><a href="#Dataset.data_model">data_model</a></code></strong>: <code><a href="#Dataset.data_model">data_model</a></code> describes the netCDF
|
1684 | 1678 |
data model version, one of <code>NETCDF3_CLASSIC</code>, <code>NETCDF4</code>,
|
1685 | 1679 |
<code>NETCDF4_CLASSIC</code>, <code>NETCDF3_64BIT_OFFSET</code> or <code>NETCDF3_64BIT_DATA</code>.</p>
|
1686 | 1680 |
|
1687 | |
<p><strong><code>file_format</code></strong>: same as <code>data_model</code>, retained for backwards compatibility.</p>
|
1688 | |
|
1689 | |
<p><strong><code>disk_format</code></strong>: <code>disk_format</code> describes the underlying
|
|
1681 |
<p><strong><code><a href="#Dataset.file_format">file_format</a></code></strong>: same as <code><a href="#Dataset.data_model">data_model</a></code>, retained for backwards compatibility.</p>
|
|
1682 |
|
|
1683 |
<p><strong><code><a href="#Dataset.disk_format">disk_format</a></code></strong>: <code><a href="#Dataset.disk_format">disk_format</a></code> describes the underlying
|
1690 | 1684 |
file format, one of <code>NETCDF3</code>, <code>HDF5</code>, <code>HDF4</code>,
|
1691 | 1685 |
<code>PNETCDF</code>, <code>DAP2</code>, <code>DAP4</code> or <code>UNDEFINED</code>. Only available if using
|
1692 | 1686 |
netcdf C library version >= 4.3.1, otherwise will always return
|
1693 | 1687 |
<code>UNDEFINED</code>.</p>
|
1694 | 1688 |
|
1695 | |
<p><strong><code>parent</code></strong>: <code>parent</code> is a reference to the parent
|
1696 | |
<a href="#Group">Group</a> instance. <code>None</code> for the root group or <a href="#Dataset">Dataset</a>
|
|
1689 |
<p><strong><code><a href="#Dataset.parent">parent</a></code></strong>: <code><a href="#Dataset.parent">parent</a></code> is a reference to the parent
|
|
1690 |
<code><a href="#Group">Group</a></code> instance. <code>None</code> for the root group or <code><a href="#Dataset">Dataset</a></code>
|
1697 | 1691 |
instance.</p>
|
1698 | 1692 |
|
1699 | |
<p><strong><code>path</code></strong>: <code>path</code> shows the location of the <a href="#Group">Group</a> in
|
1700 | |
the <a href="#Dataset">Dataset</a> in a unix directory format (the names of groups in the
|
1701 | |
hierarchy separated by backslashes). A <a href="#Dataset">Dataset</a> instance is the root
|
|
1693 |
<p><strong><code><a href="#Dataset.path">path</a></code></strong>: <code><a href="#Dataset.path">path</a></code> shows the location of the <code><a href="#Group">Group</a></code> in
|
|
1694 |
the <code><a href="#Dataset">Dataset</a></code> in a unix directory format (the names of groups in the
|
|
1695 |
hierarchy separated by backslashes). A <code><a href="#Dataset">Dataset</a></code> instance is the root
|
1702 | 1696 |
group, so the path is simply <code>'/'</code>.</p>
|
1703 | 1697 |
|
1704 | |
<p><strong><code>keepweakref</code></strong>: If <code>True</code>, child Dimension and Variables objects only keep weak
|
|
1698 |
<p><strong><code><a href="#Dataset.keepweakref">keepweakref</a></code></strong>: If <code>True</code>, child Dimension and Variables objects only keep weak
|
1705 | 1699 |
references to the parent Dataset or Group.</p>
|
1706 | 1700 |
|
1707 | 1701 |
<p><strong><code>_ncstring_attrs__</code></strong>: If <code>True</code>, all text attributes will be written as variable-length
|
|
1713 | 1707 |
<div class="attr function"><a class="headerlink" href="#Dataset.__init__">#  </a>
|
1714 | 1708 |
|
1715 | 1709 |
|
1716 | |
<span class="name">Dataset</span><span class="signature">(unknown)</span> </div>
|
|
1710 |
<span class="name">Dataset</span><span class="signature">()</span>
|
|
1711 |
</div>
|
1717 | 1712 |
|
1718 | 1713 |
|
1719 | 1714 |
<div class="docstring"><p><strong><code>__init__(self, filename, mode="r", clobber=True, diskless=False,
|
1720 | 1715 |
persist=False, keepweakref=False, memory=None, encoding=None,
|
1721 | 1716 |
parallel=False, comm=None, info=None, format='NETCDF4')</code></strong></p>
|
1722 | 1717 |
|
1723 | |
<p><a href="#Dataset">Dataset</a> constructor.</p>
|
|
1718 |
<p><code><a href="#Dataset">Dataset</a></code> constructor.</p>
|
1724 | 1719 |
|
1725 | 1720 |
<p><strong><code>filename</code></strong>: Name of netCDF file to hold dataset. Can also
|
1726 | 1721 |
be a python 3 pathlib instance or the URL of an OpenDAP dataset. When memory is
|
1727 | |
set this is just used to set the <code>filepath()</code>.</p>
|
|
1722 |
set this is just used to set the <code><a href="#Dataset.filepath">filepath()</a></code>.</p>
|
1728 | 1723 |
|
1729 | 1724 |
<p><strong><code>mode</code></strong>: access mode. <code>r</code> means read-only; no data can be
|
1730 | 1725 |
modified. <code>w</code> means write; a new file is created, an existing file with
|
|
1768 | 1763 |
<p><strong><code>persist</code></strong>: if <code>diskless=True</code>, persist file to disk when closed
|
1769 | 1764 |
(default <code>False</code>).</p>
|
1770 | 1765 |
|
1771 | |
<p><strong><code>keepweakref</code></strong>: if <code>True</code>, child Dimension and Variable instances will keep weak
|
|
1766 |
<p><strong><code><a href="#Dataset.keepweakref">keepweakref</a></code></strong>: if <code>True</code>, child Dimension and Variable instances will keep weak
|
1772 | 1767 |
references to the parent Dataset or Group object. Default is <code>False</code>, which
|
1773 | 1768 |
means strong references will be kept. Having Dimension and Variable instances
|
1774 | 1769 |
keep a strong reference to the parent Dataset instance, which in turn keeps a
|
|
1872 | 1867 |
|
1873 | 1868 |
<div class="docstring"><p><strong><code>sync(self)</code></strong></p>
|
1874 | 1869 |
|
1875 | |
<p>Writes all buffered data in the <a href="#Dataset">Dataset</a> to the disk file.</p>
|
|
1870 |
<p>Writes all buffered data in the <code><a href="#Dataset">Dataset</a></code> to the disk file.</p>
|
1876 | 1871 |
</div>
|
1877 | 1872 |
|
1878 | 1873 |
|
|
1888 | 1883 |
|
1889 | 1884 |
<div class="docstring"><p><strong><code>set_fill_on(self)</code></strong></p>
|
1890 | 1885 |
|
1891 | |
<p>Sets the fill mode for a <a href="#Dataset">Dataset</a> open for writing to <code>on</code>.</p>
|
|
1886 |
<p>Sets the fill mode for a <code><a href="#Dataset">Dataset</a></code> open for writing to <code>on</code>.</p>
|
1892 | 1887 |
|
1893 | 1888 |
<p>This causes data to be pre-filled with fill values. The fill values can be
|
1894 | 1889 |
controlled by the variable's <code>_Fill_Value</code> attribute, but is usually
|
1895 | 1890 |
sufficient to the use the netCDF default <code>_Fill_Value</code> (defined
|
1896 | 1891 |
separately for each variable type). The default behavior of the netCDF
|
1897 | |
library corresponds to <code>set_fill_on</code>. Data which are equal to the
|
|
1892 |
library corresponds to <code><a href="#Dataset.set_fill_on">set_fill_on</a></code>. Data which are equal to the
|
1898 | 1893 |
<code>_Fill_Value</code> indicate that the variable was created, but never written
|
1899 | 1894 |
to.</p>
|
1900 | 1895 |
</div>
|
|
1912 | 1907 |
|
1913 | 1908 |
<div class="docstring"><p><strong><code>set_fill_off(self)</code></strong></p>
|
1914 | 1909 |
|
1915 | |
<p>Sets the fill mode for a <a href="#Dataset">Dataset</a> open for writing to <code>off</code>.</p>
|
|
1910 |
<p>Sets the fill mode for a <code><a href="#Dataset">Dataset</a></code> open for writing to <code>off</code>.</p>
|
1916 | 1911 |
|
1917 | 1912 |
<p>This will prevent the data from being pre-filled with fill values, which
|
1918 | 1913 |
may result in some performance improvements. However, you must then make
|
|
1936 | 1931 |
|
1937 | 1932 |
<p><code>size</code> must be a positive integer or <code>None</code>, which stands for
|
1938 | 1933 |
"unlimited" (default is <code>None</code>). Specifying a size of 0 also
|
1939 | |
results in an unlimited dimension. The return value is the <a href="#Dimension">Dimension</a>
|
|
1934 |
results in an unlimited dimension. The return value is the <code><a href="#Dimension">Dimension</a></code>
|
1940 | 1935 |
class instance describing the new dimension. To determine the current
|
1941 | |
maximum size of the dimension, use the <code>len</code> function on the <a href="#Dimension">Dimension</a>
|
|
1936 |
maximum size of the dimension, use the <code>len</code> function on the <code><a href="#Dimension">Dimension</a></code>
|
1942 | 1937 |
instance. To determine if a dimension is 'unlimited', use the
|
1943 | |
<a href="#<a href="#Dimension.isunlimited">Dimension.isunlimited</a>"><a href="#Dimension.isunlimited">Dimension.isunlimited</a></a> method of the <a href="#Dimension">Dimension</a> instance.</p>
|
|
1938 |
<code><a href="#Dimension.isunlimited">Dimension.isunlimited</a></code> method of the <code><a href="#Dimension">Dimension</a></code> instance.</p>
|
1944 | 1939 |
</div>
|
1945 | 1940 |
|
1946 | 1941 |
|
|
1956 | 1951 |
|
1957 | 1952 |
<div class="docstring"><p><strong><code>renameDimension(self, oldname, newname)</code></strong></p>
|
1958 | 1953 |
|
1959 | |
<p>rename a <a href="#Dimension">Dimension</a> named <code>oldname</code> to <code>newname</code>.</p>
|
|
1954 |
<p>rename a <code><a href="#Dimension">Dimension</a></code> named <code>oldname</code> to <code>newname</code>.</p>
|
1960 | 1955 |
</div>
|
1961 | 1956 |
|
1962 | 1957 |
|
|
1980 | 1975 |
are homogeneous numeric data types), then the 'inner' compound types <strong>must</strong> be
|
1981 | 1976 |
created first.</p>
|
1982 | 1977 |
|
1983 | |
<p>The return value is the <a href="#CompoundType">CompoundType</a> class instance describing the new
|
|
1978 |
<p>The return value is the <code><a href="#CompoundType">CompoundType</a></code> class instance describing the new
|
1984 | 1979 |
datatype.</p>
|
1985 | 1980 |
</div>
|
1986 | 1981 |
|
|
2000 | 1995 |
<p>Creates a new VLEN data type named <code>datatype_name</code> from a numpy
|
2001 | 1996 |
dtype object <code>datatype</code>.</p>
|
2002 | 1997 |
|
2003 | |
<p>The return value is the <a href="#VLType">VLType</a> class instance describing the new
|
|
1998 |
<p>The return value is the <code><a href="#VLType">VLType</a></code> class instance describing the new
|
2004 | 1999 |
datatype.</p>
|
2005 | 2000 |
</div>
|
2006 | 2001 |
|
|
2021 | 2016 |
integer dtype object <code>datatype</code>, and a python dictionary
|
2022 | 2017 |
defining the enum fields and values.</p>
|
2023 | 2018 |
|
2024 | |
<p>The return value is the <a href="#EnumType">EnumType</a> class instance describing the new
|
|
2019 |
<p>The return value is the <code><a href="#EnumType">EnumType</a></code> class instance describing the new
|
2025 | 2020 |
datatype.</p>
|
2026 | 2021 |
</div>
|
2027 | 2022 |
|
|
2041 | 2036 |
endian='native', least_significant_digit=None, fill_value=None, chunk_cache=None)</code></strong></p>
|
2042 | 2037 |
|
2043 | 2038 |
<p>Creates a new variable with the given <code>varname</code>, <code>datatype</code>, and
|
2044 | |
<code>dimensions</code>. If dimensions are not given, the variable is assumed to be
|
|
2039 |
<code><a href="#Dataset.dimensions">dimensions</a></code>. If dimensions are not given, the variable is assumed to be
|
2045 | 2040 |
a scalar.</p>
|
2046 | 2041 |
|
2047 | 2042 |
<p>If <code>varname</code> is specified as a path, using forward slashes as in unix to
|
|
2056 | 2051 |
(NC_BYTE), 'u1' (NC_UBYTE), 'i2' or 'h' or 's' (NC_SHORT), 'u2'
|
2057 | 2052 |
(NC_USHORT), 'i4' or 'i' or 'l' (NC_INT), 'u4' (NC_UINT), 'i8' (NC_INT64),
|
2058 | 2053 |
'u8' (NC_UINT64), 'f4' or 'f' (NC_FLOAT), 'f8' or 'd' (NC_DOUBLE)</code>.
|
2059 | |
<code>datatype</code> can also be a <a href="#CompoundType">CompoundType</a> instance
|
2060 | |
(for a structured, or compound array), a <a href="#VLType">VLType</a> instance
|
|
2054 |
<code>datatype</code> can also be a <code><a href="#CompoundType">CompoundType</a></code> instance
|
|
2055 |
(for a structured, or compound array), a <code><a href="#VLType">VLType</a></code> instance
|
2061 | 2056 |
(for a variable-length array), or the python <code>str</code> builtin
|
2062 | 2057 |
(for a variable-length string array). Numpy string and unicode datatypes with
|
2063 | 2058 |
length greater than one are aliases for <code>str</code>.</p>
|
|
2065 | 2060 |
<p>Data from netCDF variables is presented to python as numpy arrays with
|
2066 | 2061 |
the corresponding data type.</p>
|
2067 | 2062 |
|
2068 | |
<p><code>dimensions</code> must be a tuple containing dimension names (strings) that
|
2069 | |
have been defined previously using <a href="#<a href="#Dataset.createDimension">Dataset.createDimension</a>"><a href="#Dataset.createDimension">Dataset.createDimension</a></a>. The default value
|
|
2063 |
<p><code><a href="#Dataset.dimensions">dimensions</a></code> must be a tuple containing dimension names (strings) that
|
|
2064 |
have been defined previously using <code><a href="#Dataset.createDimension">Dataset.createDimension</a></code>. The default value
|
2070 | 2065 |
is an empty tuple, which means the variable is a scalar.</p>
|
2071 | 2066 |
|
2072 | 2067 |
<p>If the optional keyword <code>zlib</code> is <code>True</code>, the data will be compressed in
|
|
2108 | 2103 |
|
2109 | 2104 |
<p>The optional keyword <code>fill_value</code> can be used to override the default
|
2110 | 2105 |
netCDF <code>_FillValue</code> (the value that the variable gets filled with before
|
2111 | |
any data is written to it, defaults given in <a href="#default_fillvals">default_fillvals</a>).
|
|
2106 |
any data is written to it, defaults given in the dict <code><a href="#default_fillvals">netCDF4.default_fillvals</a></code>).
|
2112 | 2107 |
If fill_value is set to <code>False</code>, then the variable is not pre-filled.</p>
|
2113 | 2108 |
|
2114 | 2109 |
<p>If the optional keyword parameter <code>least_significant_digit</code> is
|
|
2133 | 2128 |
method to change it the next time the Dataset is opened.
|
2134 | 2129 |
Warning - messing with this parameter can seriously degrade performance.</p>
|
2135 | 2130 |
|
2136 | |
<p>The return value is the <a href="#Variable">Variable</a> class instance describing the new
|
|
2131 |
<p>The return value is the <code><a href="#Variable">Variable</a></code> class instance describing the new
|
2137 | 2132 |
variable.</p>
|
2138 | 2133 |
|
2139 | 2134 |
<p>A list of names corresponding to netCDF variable attributes can be
|
2140 | |
obtained with the <a href="#Variable">Variable</a> method <a href="#<a href="#Variable.ncattrs">Variable.ncattrs</a>"><a href="#Variable.ncattrs">Variable.ncattrs</a></a>. A dictionary
|
|
2135 |
obtained with the <code><a href="#Variable">Variable</a></code> method <code><a href="#Variable.ncattrs">Variable.ncattrs</a></code>. A dictionary
|
2141 | 2136 |
containing all the netCDF attribute name/value pairs is provided by
|
2142 | |
the <code>__dict__</code> attribute of a <a href="#Variable">Variable</a> instance.</p>
|
2143 | |
|
2144 | |
<p><a href="#Variable">Variable</a> instances behave much like array objects. Data can be
|
|
2137 |
the <code>__dict__</code> attribute of a <code><a href="#Variable">Variable</a></code> instance.</p>
|
|
2138 |
|
|
2139 |
<p><code><a href="#Variable">Variable</a></code> instances behave much like array objects. Data can be
|
2145 | 2140 |
assigned to or retrieved from a variable with indexing and slicing
|
2146 | |
operations on the <a href="#Variable">Variable</a> instance. A <a href="#Variable">Variable</a> instance has six
|
|
2141 |
operations on the <code><a href="#Variable">Variable</a></code> instance. A <code><a href="#Variable">Variable</a></code> instance has six
|
2147 | 2142 |
Dataset standard attributes: <code>dimensions, dtype, shape, ndim, name</code> and
|
2148 | 2143 |
<code>least_significant_digit</code>. Application programs should never modify
|
2149 | |
these attributes. The <code>dimensions</code> attribute is a tuple containing the
|
|
2144 |
these attributes. The <code><a href="#Dataset.dimensions">dimensions</a></code> attribute is a tuple containing the
|
2150 | 2145 |
names of the dimensions associated with this variable. The <code>dtype</code>
|
2151 | 2146 |
attribute is a string describing the variable's data type (<code>i4, f8,
|
2152 | 2147 |
S1,</code> etc). The <code>shape</code> attribute is a tuple describing the current
|
2153 | |
sizes of all the variable's dimensions. The <code>name</code> attribute is a
|
|
2148 |
sizes of all the variable's dimensions. The <code><a href="#Dataset.name">name</a></code> attribute is a
|
2154 | 2149 |
string containing the name of the Variable instance.
|
2155 | 2150 |
The <code>least_significant_digit</code>
|
2156 | 2151 |
attributes describes the power of ten of the smallest decimal place in
|
2157 | |
the data the contains a reliable value. assigned to the <a href="#Variable">Variable</a>
|
|
2152 |
the data the contains a reliable value. assigned to the <code><a href="#Variable">Variable</a></code>
|
2158 | 2153 |
instance. If <code>None</code>, the data is not truncated. The <code>ndim</code> attribute
|
2159 | 2154 |
is the number of variable dimensions.</p>
|
2160 | 2155 |
</div>
|
|
2172 | 2167 |
|
2173 | 2168 |
<div class="docstring"><p><strong><code>renameVariable(self, oldname, newname)</code></strong></p>
|
2174 | 2169 |
|
2175 | |
<p>rename a <a href="#Variable">Variable</a> named <code>oldname</code> to <code>newname</code></p>
|
|
2170 |
<p>rename a <code><a href="#Variable">Variable</a></code> named <code>oldname</code> to <code>newname</code></p>
|
2176 | 2171 |
</div>
|
2177 | 2172 |
|
2178 | 2173 |
|
|
2188 | 2183 |
|
2189 | 2184 |
<div class="docstring"><p><strong><code>createGroup(self, groupname)</code></strong></p>
|
2190 | 2185 |
|
2191 | |
<p>Creates a new <a href="#Group">Group</a> with the given <code>groupname</code>.</p>
|
|
2186 |
<p>Creates a new <code><a href="#Group">Group</a></code> with the given <code>groupname</code>.</p>
|
2192 | 2187 |
|
2193 | 2188 |
<p>If <code>groupname</code> is specified as a path, using forward slashes as in unix to
|
2194 | 2189 |
separate components, then intermediate groups will be created as necessary
|
|
2198 | 2193 |
If the specified path describes a group that already exists, no error is
|
2199 | 2194 |
raised.</p>
|
2200 | 2195 |
|
2201 | |
<p>The return value is a <a href="#Group">Group</a> class instance.</p>
|
|
2196 |
<p>The return value is a <code><a href="#Group">Group</a></code> class instance.</p>
|
2202 | 2197 |
</div>
|
2203 | 2198 |
|
2204 | 2199 |
|
|
2214 | 2209 |
|
2215 | 2210 |
<div class="docstring"><p><strong><code>ncattrs(self)</code></strong></p>
|
2216 | 2211 |
|
2217 | |
<p>return netCDF global attribute names for this <a href="#Dataset">Dataset</a> or <a href="#Group">Group</a> in a list.</p>
|
|
2212 |
<p>return netCDF global attribute names for this <code><a href="#Dataset">Dataset</a></code> or <code><a href="#Group">Group</a></code> in a list.</p>
|
2218 | 2213 |
</div>
|
2219 | 2214 |
|
2220 | 2215 |
|
|
2324 | 2319 |
|
2325 | 2320 |
<div class="docstring"><p><strong><code>renameAttribute(self, oldname, newname)</code></strong></p>
|
2326 | 2321 |
|
2327 | |
<p>rename a <a href="#Dataset">Dataset</a> or <a href="#Group">Group</a> attribute named <code>oldname</code> to <code>newname</code>.</p>
|
|
2322 |
<p>rename a <code><a href="#Dataset">Dataset</a></code> or <code><a href="#Group">Group</a></code> attribute named <code>oldname</code> to <code>newname</code>.</p>
|
2328 | 2323 |
</div>
|
2329 | 2324 |
|
2330 | 2325 |
|
|
2340 | 2335 |
|
2341 | 2336 |
<div class="docstring"><p><strong><code>renameGroup(self, oldname, newname)</code></strong></p>
|
2342 | 2337 |
|
2343 | |
<p>rename a <a href="#Group">Group</a> named <code>oldname</code> to <code>newname</code> (requires netcdf >= 4.3.1).</p>
|
|
2338 |
<p>rename a <code><a href="#Group">Group</a></code> named <code>oldname</code> to <code>newname</code> (requires netcdf >= 4.3.1).</p>
|
2344 | 2339 |
</div>
|
2345 | 2340 |
|
2346 | 2341 |
|
|
2356 | 2351 |
|
2357 | 2352 |
<div class="docstring"><p><strong><code>set_auto_chartostring(self, True_or_False)</code></strong></p>
|
2358 | 2353 |
|
2359 | |
<p>Call <a href="#<a href="#Variable.set_auto_chartostring">Variable.set_auto_chartostring</a>"><a href="#Variable.set_auto_chartostring">Variable.set_auto_chartostring</a></a> for all variables contained in this <a href="#Dataset">Dataset</a> or
|
2360 | |
<a href="#Group">Group</a>, as well as for all variables in all its subgroups.</p>
|
|
2354 |
<p>Call <code><a href="#Variable.set_auto_chartostring">Variable.set_auto_chartostring</a></code> for all variables contained in this <code><a href="#Dataset">Dataset</a></code> or
|
|
2355 |
<code><a href="#Group">Group</a></code>, as well as for all variables in all its subgroups.</p>
|
2361 | 2356 |
|
2362 | 2357 |
<p><strong><code>True_or_False</code></strong>: Boolean determining if automatic conversion of
|
2363 | 2358 |
all character arrays <--> string arrays should be performed for
|
|
2381 | 2376 |
|
2382 | 2377 |
<div class="docstring"><p><strong><code>set_auto_maskandscale(self, True_or_False)</code></strong></p>
|
2383 | 2378 |
|
2384 | |
<p>Call <a href="#<a href="#Variable.set_auto_maskandscale">Variable.set_auto_maskandscale</a>"><a href="#Variable.set_auto_maskandscale">Variable.set_auto_maskandscale</a></a> for all variables contained in this <a href="#Dataset">Dataset</a> or
|
2385 | |
<a href="#Group">Group</a>, as well as for all variables in all its subgroups.</p>
|
|
2379 |
<p>Call <code><a href="#Variable.set_auto_maskandscale">Variable.set_auto_maskandscale</a></code> for all variables contained in this <code><a href="#Dataset">Dataset</a></code> or
|
|
2380 |
<code><a href="#Group">Group</a></code>, as well as for all variables in all its subgroups.</p>
|
2386 | 2381 |
|
2387 | 2382 |
<p><strong><code>True_or_False</code></strong>: Boolean determining if automatic conversion to masked arrays
|
2388 | 2383 |
and variable scaling shall be applied for all variables.</p>
|
|
2404 | 2399 |
|
2405 | 2400 |
<div class="docstring"><p><strong><code>set_auto_mask(self, True_or_False)</code></strong></p>
|
2406 | 2401 |
|
2407 | |
<p>Call <a href="#<a href="#Variable.set_auto_mask">Variable.set_auto_mask</a>"><a href="#Variable.set_auto_mask">Variable.set_auto_mask</a></a> for all variables contained in this <a href="#Dataset">Dataset</a> or
|
2408 | |
<a href="#Group">Group</a>, as well as for all variables in all its subgroups.</p>
|
|
2402 |
<p>Call <code><a href="#Variable.set_auto_mask">Variable.set_auto_mask</a></code> for all variables contained in this <code><a href="#Dataset">Dataset</a></code> or
|
|
2403 |
<code><a href="#Group">Group</a></code>, as well as for all variables in all its subgroups.</p>
|
2409 | 2404 |
|
2410 | 2405 |
<p><strong><code>True_or_False</code></strong>: Boolean determining if automatic conversion to masked arrays
|
2411 | 2406 |
shall be applied for all variables.</p>
|
|
2427 | 2422 |
|
2428 | 2423 |
<div class="docstring"><p><strong><code>set_auto_scale(self, True_or_False)</code></strong></p>
|
2429 | 2424 |
|
2430 | |
<p>Call <a href="#<a href="#Variable.set_auto_scale">Variable.set_auto_scale</a>"><a href="#Variable.set_auto_scale">Variable.set_auto_scale</a></a> for all variables contained in this <a href="#Dataset">Dataset</a> or
|
2431 | |
<a href="#Group">Group</a>, as well as for all variables in all its subgroups.</p>
|
|
2425 |
<p>Call <code><a href="#Variable.set_auto_scale">Variable.set_auto_scale</a></code> for all variables contained in this <code><a href="#Dataset">Dataset</a></code> or
|
|
2426 |
<code><a href="#Group">Group</a></code>, as well as for all variables in all its subgroups.</p>
|
2432 | 2427 |
|
2433 | 2428 |
<p><strong><code>True_or_False</code></strong>: Boolean determining if automatic variable scaling
|
2434 | 2429 |
shall be applied for all variables.</p>
|
|
2450 | 2445 |
|
2451 | 2446 |
<div class="docstring"><p><strong><code>set_always_mask(self, True_or_False)</code></strong></p>
|
2452 | 2447 |
|
2453 | |
<p>Call <a href="#<a href="#Variable.set_always_mask">Variable.set_always_mask</a>"><a href="#Variable.set_always_mask">Variable.set_always_mask</a></a> for all variables contained in
|
2454 | |
this <a href="#Dataset">Dataset</a> or <a href="#Group">Group</a>, as well as for all
|
|
2448 |
<p>Call <code><a href="#Variable.set_always_mask">Variable.set_always_mask</a></code> for all variables contained in
|
|
2449 |
this <code><a href="#Dataset">Dataset</a></code> or <code><a href="#Group">Group</a></code>, as well as for all
|
2455 | 2450 |
variables in all its subgroups.</p>
|
2456 | 2451 |
|
2457 | 2452 |
<p><strong><code>True_or_False</code></strong>: Boolean determining if automatic conversion of
|
|
2478 | 2473 |
|
2479 | 2474 |
<div class="docstring"><p><strong><code>set_ncstring_attrs(self, True_or_False)</code></strong></p>
|
2480 | 2475 |
|
2481 | |
<p>Call <a href="#<a href="#Variable.set_ncstring_attrs">Variable.set_ncstring_attrs</a>"><a href="#Variable.set_ncstring_attrs">Variable.set_ncstring_attrs</a></a> for all variables contained in
|
2482 | |
this <a href="#Dataset">Dataset</a> or <a href="#Group">Group</a>, as well as for all its
|
|
2476 |
<p>Call <code><a href="#Variable.set_ncstring_attrs">Variable.set_ncstring_attrs</a></code> for all variables contained in
|
|
2477 |
this <code><a href="#Dataset">Dataset</a></code> or <code><a href="#Group">Group</a></code>, as well as for all its
|
2483 | 2478 |
subgroups and their variables.</p>
|
2484 | 2479 |
|
2485 | 2480 |
<p><strong><code>True_or_False</code></strong>: Boolean determining if all string attributes are
|
|
2541 | 2536 |
|
2542 | 2537 |
<div class="docstring"><p><strong><code>fromcdl(cdlfilename, ncfilename=None, mode='a',format='NETCDF4')</code></strong></p>
|
2543 | 2538 |
|
2544 | |
<p>call <code>ncgen</code> via subprocess to create Dataset from <a href="https://www.unidata.ucar.edu/software/netcdf/docs/netcdf_utilities_guide.html#cdl_guide">CDL</a>
|
2545 | |
text representation. Requires <code>ncgen</code> to be installed and in <code>$PATH</code>.</p>
|
|
2539 |
<p>call <a href="https://www.unidata.ucar.edu/software/netcdf/docs/netcdf_utilities_guide.html#ncgen_guide">ncgen</a> via subprocess to create Dataset from <a href="https://www.unidata.ucar.edu/software/netcdf/docs/netcdf_utilities_guide.html#cdl_guide">CDL</a>
|
|
2540 |
text representation. Requires <a href="https://www.unidata.ucar.edu/software/netcdf/docs/netcdf_utilities_guide.html#ncgen_guide">ncgen</a> to be installed and in <code>$PATH</code>.</p>
|
2546 | 2541 |
|
2547 | 2542 |
<p><strong><code>cdlfilename</code></strong>: CDL file.</p>
|
2548 | 2543 |
|
|
2571 | 2566 |
|
2572 | 2567 |
<div class="docstring"><p><strong><code>tocdl(self, coordvars=False, data=False, outfile=None)</code></strong></p>
|
2573 | 2568 |
|
2574 | |
<p>call <code>ncdump</code> via subprocess to create <a href="https://www.unidata.ucar.edu/software/netcdf/docs/netcdf_utilities_guide.html#cdl_guide">CDL</a>
|
2575 | |
text representation of Dataset. Requires <code>ncdump</code> to be installed and in <code>$PATH</code>.</p>
|
|
2569 |
<p>call <a href="https://www.unidata.ucar.edu/software/netcdf/docs/netcdf_utilities_guide.html#ncdump_guide">ncdump</a> via subprocess to create <a href="https://www.unidata.ucar.edu/software/netcdf/docs/netcdf_utilities_guide.html#cdl_guide">CDL</a>
|
|
2570 |
text representation of Dataset. Requires <a href="https://www.unidata.ucar.edu/software/netcdf/docs/netcdf_utilities_guide.html#ncdump_guide">ncdump</a>
|
|
2571 |
to be installed and in <code>$PATH</code>.</p>
|
2576 | 2572 |
|
2577 | 2573 |
<p><strong><code>coordvars</code></strong>: include coordinate variable data (via <code>ncdump -c</code>). Default False</p>
|
2578 | 2574 |
|
|
2586 | 2582 |
<div id="Dataset.name" class="classattr">
|
2587 | 2583 |
<div class="attr variable"><a class="headerlink" href="#Dataset.name">#  </a>
|
2588 | 2584 |
|
2589 | |
<span class="name">name</span><span class="default_value"> = <attribute 'name' of '<a href="#Dataset">netCDF4._netCDF4.Dataset</a>' objects></span>
|
2590 | |
</div>
|
2591 | |
|
2592 | |
|
|
2585 |
<span class="name">name</span><span class="default_value"> = <attribute 'name' of '<a href="#_netCDF4.Dataset">netCDF4._netCDF4.Dataset</a>' objects></span>
|
|
2586 |
</div>
|
|
2587 |
|
|
2588 |
<div class="docstring"><p>string name of Group instance</p>
|
|
2589 |
</div>
|
|
2590 |
|
2593 | 2591 |
|
2594 | 2592 |
</div>
|
2595 | 2593 |
<div id="Dataset.groups" class="classattr">
|
2596 | 2594 |
<div class="attr variable"><a class="headerlink" href="#Dataset.groups">#  </a>
|
2597 | 2595 |
|
2598 | |
<span class="name">groups</span><span class="default_value"> = <attribute 'groups' of '<a href="#Dataset">netCDF4._netCDF4.Dataset</a>' objects></span>
|
|
2596 |
<span class="name">groups</span><span class="default_value"> = <attribute 'groups' of '<a href="#_netCDF4.Dataset">netCDF4._netCDF4.Dataset</a>' objects></span>
|
2599 | 2597 |
</div>
|
2600 | 2598 |
|
2601 | 2599 |
|
|
2604 | 2602 |
<div id="Dataset.dimensions" class="classattr">
|
2605 | 2603 |
<div class="attr variable"><a class="headerlink" href="#Dataset.dimensions">#  </a>
|
2606 | 2604 |
|
2607 | |
<span class="name">dimensions</span><span class="default_value"> = <attribute 'dimensions' of '<a href="#Dataset">netCDF4._netCDF4.Dataset</a>' objects></span>
|
|
2605 |
<span class="name">dimensions</span><span class="default_value"> = <attribute 'dimensions' of '<a href="#_netCDF4.Dataset">netCDF4._netCDF4.Dataset</a>' objects></span>
|
2608 | 2606 |
</div>
|
2609 | 2607 |
|
2610 | 2608 |
|
|
2613 | 2611 |
<div id="Dataset.variables" class="classattr">
|
2614 | 2612 |
<div class="attr variable"><a class="headerlink" href="#Dataset.variables">#  </a>
|
2615 | 2613 |
|
2616 | |
<span class="name">variables</span><span class="default_value"> = <attribute 'variables' of '<a href="#Dataset">netCDF4._netCDF4.Dataset</a>' objects></span>
|
|
2614 |
<span class="name">variables</span><span class="default_value"> = <attribute 'variables' of '<a href="#_netCDF4.Dataset">netCDF4._netCDF4.Dataset</a>' objects></span>
|
2617 | 2615 |
</div>
|
2618 | 2616 |
|
2619 | 2617 |
|
|
2622 | 2620 |
<div id="Dataset.disk_format" class="classattr">
|
2623 | 2621 |
<div class="attr variable"><a class="headerlink" href="#Dataset.disk_format">#  </a>
|
2624 | 2622 |
|
2625 | |
<span class="name">disk_format</span><span class="default_value"> = <attribute 'disk_format' of '<a href="#Dataset">netCDF4._netCDF4.Dataset</a>' objects></span>
|
|
2623 |
<span class="name">disk_format</span><span class="default_value"> = <attribute 'disk_format' of '<a href="#_netCDF4.Dataset">netCDF4._netCDF4.Dataset</a>' objects></span>
|
2626 | 2624 |
</div>
|
2627 | 2625 |
|
2628 | 2626 |
|
|
2631 | 2629 |
<div id="Dataset.path" class="classattr">
|
2632 | 2630 |
<div class="attr variable"><a class="headerlink" href="#Dataset.path">#  </a>
|
2633 | 2631 |
|
2634 | |
<span class="name">path</span><span class="default_value"> = <attribute 'path' of '<a href="#Dataset">netCDF4._netCDF4.Dataset</a>' objects></span>
|
|
2632 |
<span class="name">path</span><span class="default_value"> = <attribute 'path' of '<a href="#_netCDF4.Dataset">netCDF4._netCDF4.Dataset</a>' objects></span>
|
2635 | 2633 |
</div>
|
2636 | 2634 |
|
2637 | 2635 |
|
|
2640 | 2638 |
<div id="Dataset.parent" class="classattr">
|
2641 | 2639 |
<div class="attr variable"><a class="headerlink" href="#Dataset.parent">#  </a>
|
2642 | 2640 |
|
2643 | |
<span class="name">parent</span><span class="default_value"> = <attribute 'parent' of '<a href="#Dataset">netCDF4._netCDF4.Dataset</a>' objects></span>
|
|
2641 |
<span class="name">parent</span><span class="default_value"> = <attribute 'parent' of '<a href="#_netCDF4.Dataset">netCDF4._netCDF4.Dataset</a>' objects></span>
|
2644 | 2642 |
</div>
|
2645 | 2643 |
|
2646 | 2644 |
|
|
2649 | 2647 |
<div id="Dataset.file_format" class="classattr">
|
2650 | 2648 |
<div class="attr variable"><a class="headerlink" href="#Dataset.file_format">#  </a>
|
2651 | 2649 |
|
2652 | |
<span class="name">file_format</span><span class="default_value"> = <attribute 'file_format' of '<a href="#Dataset">netCDF4._netCDF4.Dataset</a>' objects></span>
|
|
2650 |
<span class="name">file_format</span><span class="default_value"> = <attribute 'file_format' of '<a href="#_netCDF4.Dataset">netCDF4._netCDF4.Dataset</a>' objects></span>
|
2653 | 2651 |
</div>
|
2654 | 2652 |
|
2655 | 2653 |
|
|
2658 | 2656 |
<div id="Dataset.data_model" class="classattr">
|
2659 | 2657 |
<div class="attr variable"><a class="headerlink" href="#Dataset.data_model">#  </a>
|
2660 | 2658 |
|
2661 | |
<span class="name">data_model</span><span class="default_value"> = <attribute 'data_model' of '<a href="#Dataset">netCDF4._netCDF4.Dataset</a>' objects></span>
|
|
2659 |
<span class="name">data_model</span><span class="default_value"> = <attribute 'data_model' of '<a href="#_netCDF4.Dataset">netCDF4._netCDF4.Dataset</a>' objects></span>
|
2662 | 2660 |
</div>
|
2663 | 2661 |
|
2664 | 2662 |
|
|
2667 | 2665 |
<div id="Dataset.cmptypes" class="classattr">
|
2668 | 2666 |
<div class="attr variable"><a class="headerlink" href="#Dataset.cmptypes">#  </a>
|
2669 | 2667 |
|
2670 | |
<span class="name">cmptypes</span><span class="default_value"> = <attribute 'cmptypes' of '<a href="#Dataset">netCDF4._netCDF4.Dataset</a>' objects></span>
|
|
2668 |
<span class="name">cmptypes</span><span class="default_value"> = <attribute 'cmptypes' of '<a href="#_netCDF4.Dataset">netCDF4._netCDF4.Dataset</a>' objects></span>
|
2671 | 2669 |
</div>
|
2672 | 2670 |
|
2673 | 2671 |
|
|
2676 | 2674 |
<div id="Dataset.vltypes" class="classattr">
|
2677 | 2675 |
<div class="attr variable"><a class="headerlink" href="#Dataset.vltypes">#  </a>
|
2678 | 2676 |
|
2679 | |
<span class="name">vltypes</span><span class="default_value"> = <attribute 'vltypes' of '<a href="#Dataset">netCDF4._netCDF4.Dataset</a>' objects></span>
|
|
2677 |
<span class="name">vltypes</span><span class="default_value"> = <attribute 'vltypes' of '<a href="#_netCDF4.Dataset">netCDF4._netCDF4.Dataset</a>' objects></span>
|
2680 | 2678 |
</div>
|
2681 | 2679 |
|
2682 | 2680 |
|
|
2685 | 2683 |
<div id="Dataset.enumtypes" class="classattr">
|
2686 | 2684 |
<div class="attr variable"><a class="headerlink" href="#Dataset.enumtypes">#  </a>
|
2687 | 2685 |
|
2688 | |
<span class="name">enumtypes</span><span class="default_value"> = <attribute 'enumtypes' of '<a href="#Dataset">netCDF4._netCDF4.Dataset</a>' objects></span>
|
|
2686 |
<span class="name">enumtypes</span><span class="default_value"> = <attribute 'enumtypes' of '<a href="#_netCDF4.Dataset">netCDF4._netCDF4.Dataset</a>' objects></span>
|
2689 | 2687 |
</div>
|
2690 | 2688 |
|
2691 | 2689 |
|
|
2694 | 2692 |
<div id="Dataset.keepweakref" class="classattr">
|
2695 | 2693 |
<div class="attr variable"><a class="headerlink" href="#Dataset.keepweakref">#  </a>
|
2696 | 2694 |
|
2697 | |
<span class="name">keepweakref</span><span class="default_value"> = <attribute 'keepweakref' of '<a href="#Dataset">netCDF4._netCDF4.Dataset</a>' objects></span>
|
|
2695 |
<span class="name">keepweakref</span><span class="default_value"> = <attribute 'keepweakref' of '<a href="#_netCDF4.Dataset">netCDF4._netCDF4.Dataset</a>' objects></span>
|
2698 | 2696 |
</div>
|
2699 | 2697 |
|
2700 | 2698 |
|
|
2699 |
|
|
2700 |
</div>
|
|
2701 |
</section>
|
|
2702 |
<section id="Variable">
|
|
2703 |
<div class="attr class">
|
|
2704 |
<a class="headerlink" href="#Variable">#  </a>
|
|
2705 |
|
|
2706 |
|
|
2707 |
<span class="def">class</span>
|
|
2708 |
<span class="name">Variable</span>:
|
|
2709 |
</div>
|
|
2710 |
|
|
2711 |
|
|
2712 |
<div class="docstring"><p>A netCDF <code><a href="#Variable">Variable</a></code> is used to read and write netCDF data. They are
|
|
2713 |
analogous to numpy array objects. See <code><a href="#Variable.__init__">Variable.__init__</a></code> for more
|
|
2714 |
details.</p>
|
|
2715 |
|
|
2716 |
<p>A list of attribute names corresponding to netCDF attributes defined for
|
|
2717 |
the variable can be obtained with the <code><a href="#Variable.ncattrs">Variable.ncattrs</a></code> method. These
|
|
2718 |
attributes can be created by assigning to an attribute of the
|
|
2719 |
<code><a href="#Variable">Variable</a></code> instance. A dictionary containing all the netCDF attribute
|
|
2720 |
name/value pairs is provided by the <code>__dict__</code> attribute of a
|
|
2721 |
<code><a href="#Variable">Variable</a></code> instance.</p>
|
|
2722 |
|
|
2723 |
<p>The following class variables are read-only:</p>
|
|
2724 |
|
|
2725 |
<p><strong><code><a href="#Variable.dimensions">dimensions</a></code></strong>: A tuple containing the names of the
|
|
2726 |
dimensions associated with this variable.</p>
|
|
2727 |
|
|
2728 |
<p><strong><code><a href="#Variable.dtype">dtype</a></code></strong>: A numpy dtype object describing the
|
|
2729 |
variable's data type.</p>
|
|
2730 |
|
|
2731 |
<p><strong><code><a href="#Variable.ndim">ndim</a></code></strong>: The number of variable dimensions.</p>
|
|
2732 |
|
|
2733 |
<p><strong><code><a href="#Variable.shape">shape</a></code></strong>: A tuple with the current shape (length of all dimensions).</p>
|
|
2734 |
|
|
2735 |
<p><strong><code><a href="#Variable.scale">scale</a></code></strong>: If True, <code>scale_factor</code> and <code>add_offset</code> are
|
|
2736 |
applied, and signed integer data is automatically converted to
|
|
2737 |
unsigned integer data if the <code>_Unsigned</code> attribute is set.
|
|
2738 |
Default is <code>True</code>, can be reset using <code><a href="#Variable.set_auto_scale">Variable.set_auto_scale</a></code> and
|
|
2739 |
<code><a href="#Variable.set_auto_maskandscale">Variable.set_auto_maskandscale</a></code> methods.</p>
|
|
2740 |
|
|
2741 |
<p><strong><code><a href="#Variable.mask">mask</a></code></strong>: If True, data is automatically converted to/from masked
|
|
2742 |
arrays when missing values or fill values are present. Default is <code>True</code>, can be
|
|
2743 |
reset using <code><a href="#Variable.set_auto_mask">Variable.set_auto_mask</a></code> and <code><a href="#Variable.set_auto_maskandscale">Variable.set_auto_maskandscale</a></code>
|
|
2744 |
methods.</p>
|
|
2745 |
|
|
2746 |
<p><strong><code><a href="#Variable.chartostring">chartostring</a></code></strong>: If True, data is automatically converted to/from character
|
|
2747 |
arrays to string arrays when the <code>_Encoding</code> variable attribute is set.
|
|
2748 |
Default is <code>True</code>, can be reset using
|
|
2749 |
<code><a href="#Variable.set_auto_chartostring">Variable.set_auto_chartostring</a></code> method.</p>
|
|
2750 |
|
|
2751 |
<p><strong><code>least_significant_digit</code></strong>: Describes the power of ten of the
|
|
2752 |
smallest decimal place in the data the contains a reliable value. Data is
|
|
2753 |
truncated to this decimal place when it is assigned to the <code><a href="#Variable">Variable</a></code>
|
|
2754 |
instance. If <code>None</code>, the data is not truncated.</p>
|
|
2755 |
|
|
2756 |
<p><strong><code>__orthogonal_indexing__</code></strong>: Always <code>True</code>. Indicates to client code
|
|
2757 |
that the object supports 'orthogonal indexing', which means that slices
|
|
2758 |
that are 1d arrays or lists slice along each dimension independently. This
|
|
2759 |
behavior is similar to Fortran or Matlab, but different than numpy.</p>
|
|
2760 |
|
|
2761 |
<p><strong><code><a href="#Variable.datatype">datatype</a></code></strong>: numpy data type (for primitive data types) or VLType/CompoundType
|
|
2762 |
instance (for compound or vlen data types).</p>
|
|
2763 |
|
|
2764 |
<p><strong><code><a href="#Variable.name">name</a></code></strong>: String name.</p>
|
|
2765 |
|
|
2766 |
<p><strong><code><a href="#Variable.size">size</a></code></strong>: The number of stored elements.</p>
|
|
2767 |
</div>
|
|
2768 |
|
|
2769 |
|
|
2770 |
<div id="Variable.__init__" class="classattr">
|
|
2771 |
<div class="attr function"><a class="headerlink" href="#Variable.__init__">#  </a>
|
|
2772 |
|
|
2773 |
|
|
2774 |
<span class="name">Variable</span><span class="signature">()</span>
|
|
2775 |
</div>
|
|
2776 |
|
|
2777 |
|
|
2778 |
<div class="docstring"><p><strong><code>__init__(self, group, name, datatype, dimensions=(), zlib=False,
|
|
2779 |
complevel=4, shuffle=True, fletcher32=False, contiguous=False,
|
|
2780 |
chunksizes=None, endian='native',
|
|
2781 |
least_significant_digit=None,fill_value=None,chunk_cache=None)</code></strong></p>
|
|
2782 |
|
|
2783 |
<p><code><a href="#Variable">Variable</a></code> constructor.</p>
|
|
2784 |
|
|
2785 |
<p><strong><code><a href="#Variable.group">group</a></code></strong>: <code><a href="#Group">Group</a></code> or <code><a href="#Dataset">Dataset</a></code> instance to associate with variable.</p>
|
|
2786 |
|
|
2787 |
<p><strong><code><a href="#Variable.name">name</a></code></strong>: Name of the variable.</p>
|
|
2788 |
|
|
2789 |
<p><strong><code><a href="#Variable.datatype">datatype</a></code></strong>: <code><a href="#Variable">Variable</a></code> data type. Can be specified by providing a
|
|
2790 |
numpy dtype object, or a string that describes a numpy dtype object.
|
|
2791 |
Supported values, corresponding to <code>str</code> attribute of numpy dtype
|
|
2792 |
objects, include <code>'f4'</code> (32-bit floating point), <code>'f8'</code> (64-bit floating
|
|
2793 |
point), <code>'i4'</code> (32-bit signed integer), <code>'i2'</code> (16-bit signed integer),
|
|
2794 |
<code>'i8'</code> (64-bit signed integer), <code>'i4'</code> (8-bit signed integer), <code>'i1'</code>
|
|
2795 |
(8-bit signed integer), <code>'u1'</code> (8-bit unsigned integer), <code>'u2'</code> (16-bit
|
|
2796 |
unsigned integer), <code>'u4'</code> (32-bit unsigned integer), <code>'u8'</code> (64-bit
|
|
2797 |
unsigned integer), or <code>'S1'</code> (single-character string). From
|
|
2798 |
compatibility with Scientific.IO.NetCDF, the old Numeric single character
|
|
2799 |
typecodes can also be used (<code>'f'</code> instead of <code>'f4'</code>, <code>'d'</code> instead of
|
|
2800 |
<code>'f8'</code>, <code>'h'</code> or <code>'s'</code> instead of <code>'i2'</code>, <code>'b'</code> or <code>'B'</code> instead of
|
|
2801 |
<code>'i1'</code>, <code>'c'</code> instead of <code>'S1'</code>, and <code>'i'</code> or <code>'l'</code> instead of
|
|
2802 |
<code>'i4'</code>). <code><a href="#Variable.datatype">datatype</a></code> can also be a <code><a href="#CompoundType">CompoundType</a></code> instance
|
|
2803 |
(for a structured, or compound array), a <code><a href="#VLType">VLType</a></code> instance
|
|
2804 |
(for a variable-length array), or the python <code>str</code> builtin
|
|
2805 |
(for a variable-length string array). Numpy string and unicode datatypes with
|
|
2806 |
length greater than one are aliases for <code>str</code>.</p>
|
|
2807 |
|
|
2808 |
<p><strong><code><a href="#Variable.dimensions">dimensions</a></code></strong>: a tuple containing the variable's dimension names
|
|
2809 |
(defined previously with <code>createDimension</code>). Default is an empty tuple
|
|
2810 |
which means the variable is a scalar (and therefore has no dimensions).</p>
|
|
2811 |
|
|
2812 |
<p><strong><code>zlib</code></strong>: if <code>True</code>, data assigned to the <code><a href="#Variable">Variable</a></code>
|
|
2813 |
instance is compressed on disk. Default <code>False</code>.</p>
|
|
2814 |
|
|
2815 |
<p><strong><code>complevel</code></strong>: the level of zlib compression to use (1 is the fastest,
|
|
2816 |
but poorest compression, 9 is the slowest but best compression). Default 4.
|
|
2817 |
Ignored if <code>zlib=False</code>.</p>
|
|
2818 |
|
|
2819 |
<p><strong><code>shuffle</code></strong>: if <code>True</code>, the HDF5 shuffle filter is applied
|
|
2820 |
to improve compression. Default <code>True</code>. Ignored if <code>zlib=False</code>.</p>
|
|
2821 |
|
|
2822 |
<p><strong><code>fletcher32</code></strong>: if <code>True</code> (default <code>False</code>), the Fletcher32 checksum
|
|
2823 |
algorithm is used for error detection.</p>
|
|
2824 |
|
|
2825 |
<p><strong><code>contiguous</code></strong>: if <code>True</code> (default <code>False</code>), the variable data is
|
|
2826 |
stored contiguously on disk. Default <code>False</code>. Setting to <code>True</code> for
|
|
2827 |
a variable with an unlimited dimension will trigger an error.</p>
|
|
2828 |
|
|
2829 |
<p><strong><code>chunksizes</code></strong>: Can be used to specify the HDF5 chunksizes for each
|
|
2830 |
dimension of the variable. A detailed discussion of HDF chunking and I/O
|
|
2831 |
performance is available
|
|
2832 |
<a href="http://www.hdfgroup.org/HDF5/doc/H5.user/Chunking.html">here</a>.
|
|
2833 |
Basically, you want the chunk size for each dimension to match as
|
|
2834 |
closely as possible the size of the data block that users will read
|
|
2835 |
from the file. <code>chunksizes</code> cannot be set if <code>contiguous=True</code>.</p>
|
|
2836 |
|
|
2837 |
<p><strong><code><a href="#Variable.endian">endian</a></code></strong>: Can be used to control whether the
|
|
2838 |
data is stored in little or big endian format on disk. Possible
|
|
2839 |
values are <code>little, big</code> or <code>native</code> (default). The library
|
|
2840 |
will automatically handle endian conversions when the data is read,
|
|
2841 |
but if the data is always going to be read on a computer with the
|
|
2842 |
opposite format as the one used to create the file, there may be
|
|
2843 |
some performance advantage to be gained by setting the endian-ness.
|
|
2844 |
For netCDF 3 files (that don't use HDF5), only <code>endian='native'</code> is allowed.</p>
|
|
2845 |
|
|
2846 |
<p>The <code>zlib, complevel, shuffle, fletcher32, contiguous</code> and <code>chunksizes</code>
|
|
2847 |
keywords are silently ignored for netCDF 3 files that do not use HDF5.</p>
|
|
2848 |
|
|
2849 |
<p><strong><code>least_significant_digit</code></strong>: If specified, variable data will be
|
|
2850 |
truncated (quantized). In conjunction with <code>zlib=True</code> this produces
|
|
2851 |
'lossy', but significantly more efficient compression. For example, if
|
|
2852 |
<code>least_significant_digit=1</code>, data will be quantized using
|
|
2853 |
around(scale<em>data)/scale, where scale = 2</em>*bits, and bits is determined
|
|
2854 |
so that a precision of 0.1 is retained (in this case bits=4). Default is
|
|
2855 |
<code>None</code>, or no quantization.</p>
|
|
2856 |
|
|
2857 |
<p><strong><code>fill_value</code></strong>: If specified, the default netCDF <code>_FillValue</code> (the
|
|
2858 |
value that the variable gets filled with before any data is written to it)
|
|
2859 |
is replaced with this value. If fill_value is set to <code>False</code>, then
|
|
2860 |
the variable is not pre-filled. The default netCDF fill values can be found
|
|
2861 |
in the dictionary <code><a href="#default_fillvals">netCDF4.default_fillvals</a></code>.</p>
|
|
2862 |
|
|
2863 |
<p><strong><code>chunk_cache</code></strong>: If specified, sets the chunk cache size for this variable.
|
|
2864 |
Persists as long as Dataset is open. Use <code><a href="#Variable.set_var_chunk_cache">set_var_chunk_cache</a></code> to
|
|
2865 |
change it when Dataset is re-opened. </p>
|
|
2866 |
|
|
2867 |
<p><strong><em>Note</em></strong>: <code><a href="#Variable">Variable</a></code> instances should be created using the
|
|
2868 |
<code><a href="#Dataset.createVariable">Dataset.createVariable</a></code> method of a <code><a href="#Dataset">Dataset</a></code> or
|
|
2869 |
<code><a href="#Group">Group</a></code> instance, not using this class directly.</p>
|
|
2870 |
</div>
|
|
2871 |
|
|
2872 |
|
|
2873 |
</div>
|
|
2874 |
<div id="Variable.group" class="classattr">
|
|
2875 |
<div class="attr function"><a class="headerlink" href="#Variable.group">#  </a>
|
|
2876 |
|
|
2877 |
|
|
2878 |
<span class="def">def</span>
|
|
2879 |
<span class="name">group</span><span class="signature">(unknown)</span>:
|
|
2880 |
</div>
|
|
2881 |
|
|
2882 |
|
|
2883 |
<div class="docstring"><p><strong><code>group(self)</code></strong></p>
|
|
2884 |
|
|
2885 |
<p>return the group that this <code><a href="#Variable">Variable</a></code> is a member of.</p>
|
|
2886 |
</div>
|
|
2887 |
|
|
2888 |
|
|
2889 |
</div>
|
|
2890 |
<div id="Variable.ncattrs" class="classattr">
|
|
2891 |
<div class="attr function"><a class="headerlink" href="#Variable.ncattrs">#  </a>
|
|
2892 |
|
|
2893 |
|
|
2894 |
<span class="def">def</span>
|
|
2895 |
<span class="name">ncattrs</span><span class="signature">(unknown)</span>:
|
|
2896 |
</div>
|
|
2897 |
|
|
2898 |
|
|
2899 |
<div class="docstring"><p><strong><code>ncattrs(self)</code></strong></p>
|
|
2900 |
|
|
2901 |
<p>return netCDF attribute names for this <code><a href="#Variable">Variable</a></code> in a list.</p>
|
|
2902 |
</div>
|
|
2903 |
|
|
2904 |
|
|
2905 |
</div>
|
|
2906 |
<div id="Variable.setncattr" class="classattr">
|
|
2907 |
<div class="attr function"><a class="headerlink" href="#Variable.setncattr">#  </a>
|
|
2908 |
|
|
2909 |
|
|
2910 |
<span class="def">def</span>
|
|
2911 |
<span class="name">setncattr</span><span class="signature">(unknown)</span>:
|
|
2912 |
</div>
|
|
2913 |
|
|
2914 |
|
|
2915 |
<div class="docstring"><p><strong><code>setncattr(self,name,value)</code></strong></p>
|
|
2916 |
|
|
2917 |
<p>set a netCDF variable attribute using name,value pair. Use if you need to set a
|
|
2918 |
netCDF attribute with the same name as one of the reserved python
|
|
2919 |
attributes.</p>
|
|
2920 |
</div>
|
|
2921 |
|
|
2922 |
|
|
2923 |
</div>
|
|
2924 |
<div id="Variable.setncattr_string" class="classattr">
|
|
2925 |
<div class="attr function"><a class="headerlink" href="#Variable.setncattr_string">#  </a>
|
|
2926 |
|
|
2927 |
|
|
2928 |
<span class="def">def</span>
|
|
2929 |
<span class="name">setncattr_string</span><span class="signature">(unknown)</span>:
|
|
2930 |
</div>
|
|
2931 |
|
|
2932 |
|
|
2933 |
<div class="docstring"><p><strong><code>setncattr_string(self,name,value)</code></strong></p>
|
|
2934 |
|
|
2935 |
<p>set a netCDF variable string attribute using name,value pair.
|
|
2936 |
Use if you need to ensure that a netCDF attribute is created with type
|
|
2937 |
<code>NC_STRING</code> if the file format is <code>NETCDF4</code>.
|
|
2938 |
Use if you need to set an attribute to an array of variable-length strings.</p>
|
|
2939 |
</div>
|
|
2940 |
|
|
2941 |
|
|
2942 |
</div>
|
|
2943 |
<div id="Variable.setncatts" class="classattr">
|
|
2944 |
<div class="attr function"><a class="headerlink" href="#Variable.setncatts">#  </a>
|
|
2945 |
|
|
2946 |
|
|
2947 |
<span class="def">def</span>
|
|
2948 |
<span class="name">setncatts</span><span class="signature">(unknown)</span>:
|
|
2949 |
</div>
|
|
2950 |
|
|
2951 |
|
|
2952 |
<div class="docstring"><p><strong><code>setncatts(self,attdict)</code></strong></p>
|
|
2953 |
|
|
2954 |
<p>set a bunch of netCDF variable attributes at once using a python dictionary.
|
|
2955 |
This may be faster when setting a lot of attributes for a <code>NETCDF3</code>
|
|
2956 |
formatted file, since nc_redef/nc_enddef is not called in between setting
|
|
2957 |
each attribute</p>
|
|
2958 |
</div>
|
|
2959 |
|
|
2960 |
|
|
2961 |
</div>
|
|
2962 |
<div id="Variable.getncattr" class="classattr">
|
|
2963 |
<div class="attr function"><a class="headerlink" href="#Variable.getncattr">#  </a>
|
|
2964 |
|
|
2965 |
|
|
2966 |
<span class="def">def</span>
|
|
2967 |
<span class="name">getncattr</span><span class="signature">(unknown)</span>:
|
|
2968 |
</div>
|
|
2969 |
|
|
2970 |
|
|
2971 |
<div class="docstring"><p><strong><code>getncattr(self,name)</code></strong></p>
|
|
2972 |
|
|
2973 |
<p>retrieve a netCDF variable attribute. Use if you need to set a
|
|
2974 |
netCDF attribute with the same name as one of the reserved python
|
|
2975 |
attributes.</p>
|
|
2976 |
|
|
2977 |
<p>option kwarg <code>encoding</code> can be used to specify the
|
|
2978 |
character encoding of a string attribute (default is <code>utf-8</code>).</p>
|
|
2979 |
</div>
|
|
2980 |
|
|
2981 |
|
|
2982 |
</div>
|
|
2983 |
<div id="Variable.delncattr" class="classattr">
|
|
2984 |
<div class="attr function"><a class="headerlink" href="#Variable.delncattr">#  </a>
|
|
2985 |
|
|
2986 |
|
|
2987 |
<span class="def">def</span>
|
|
2988 |
<span class="name">delncattr</span><span class="signature">(unknown)</span>:
|
|
2989 |
</div>
|
|
2990 |
|
|
2991 |
|
|
2992 |
<div class="docstring"><p><strong><code>delncattr(self,name,value)</code></strong></p>
|
|
2993 |
|
|
2994 |
<p>delete a netCDF variable attribute. Use if you need to delete a
|
|
2995 |
netCDF attribute with the same name as one of the reserved python
|
|
2996 |
attributes.</p>
|
|
2997 |
</div>
|
|
2998 |
|
|
2999 |
|
|
3000 |
</div>
|
|
3001 |
<div id="Variable.filters" class="classattr">
|
|
3002 |
<div class="attr function"><a class="headerlink" href="#Variable.filters">#  </a>
|
|
3003 |
|
|
3004 |
|
|
3005 |
<span class="def">def</span>
|
|
3006 |
<span class="name">filters</span><span class="signature">(unknown)</span>:
|
|
3007 |
</div>
|
|
3008 |
|
|
3009 |
|
|
3010 |
<div class="docstring"><p><strong><code>filters(self)</code></strong></p>
|
|
3011 |
|
|
3012 |
<p>return dictionary containing HDF5 filter parameters.</p>
|
|
3013 |
</div>
|
|
3014 |
|
|
3015 |
|
|
3016 |
</div>
|
|
3017 |
<div id="Variable.endian" class="classattr">
|
|
3018 |
<div class="attr function"><a class="headerlink" href="#Variable.endian">#  </a>
|
|
3019 |
|
|
3020 |
|
|
3021 |
<span class="def">def</span>
|
|
3022 |
<span class="name">endian</span><span class="signature">(unknown)</span>:
|
|
3023 |
</div>
|
|
3024 |
|
|
3025 |
|
|
3026 |
<div class="docstring"><p><strong><code>endian(self)</code></strong></p>
|
|
3027 |
|
|
3028 |
<p>return endian-ness (<code>little,big,native</code>) of variable (as stored in HDF5 file).</p>
|
|
3029 |
</div>
|
|
3030 |
|
|
3031 |
|
|
3032 |
</div>
|
|
3033 |
<div id="Variable.chunking" class="classattr">
|
|
3034 |
<div class="attr function"><a class="headerlink" href="#Variable.chunking">#  </a>
|
|
3035 |
|
|
3036 |
|
|
3037 |
<span class="def">def</span>
|
|
3038 |
<span class="name">chunking</span><span class="signature">(unknown)</span>:
|
|
3039 |
</div>
|
|
3040 |
|
|
3041 |
|
|
3042 |
<div class="docstring"><p><strong><code>chunking(self)</code></strong></p>
|
|
3043 |
|
|
3044 |
<p>return variable chunking information. If the dataset is
|
|
3045 |
defined to be contiguous (and hence there is no chunking) the word 'contiguous'
|
|
3046 |
is returned. Otherwise, a sequence with the chunksize for
|
|
3047 |
each dimension is returned.</p>
|
|
3048 |
</div>
|
|
3049 |
|
|
3050 |
|
|
3051 |
</div>
|
|
3052 |
<div id="Variable.get_var_chunk_cache" class="classattr">
|
|
3053 |
<div class="attr function"><a class="headerlink" href="#Variable.get_var_chunk_cache">#  </a>
|
|
3054 |
|
|
3055 |
|
|
3056 |
<span class="def">def</span>
|
|
3057 |
<span class="name">get_var_chunk_cache</span><span class="signature">(unknown)</span>:
|
|
3058 |
</div>
|
|
3059 |
|
|
3060 |
|
|
3061 |
<div class="docstring"><p><strong><code>get_var_chunk_cache(self)</code></strong></p>
|
|
3062 |
|
|
3063 |
<p>return variable chunk cache information in a tuple (size,nelems,preemption).
|
|
3064 |
See netcdf C library documentation for <code>nc_get_var_chunk_cache</code> for
|
|
3065 |
details.</p>
|
|
3066 |
</div>
|
|
3067 |
|
|
3068 |
|
|
3069 |
</div>
|
|
3070 |
<div id="Variable.set_var_chunk_cache" class="classattr">
|
|
3071 |
<div class="attr function"><a class="headerlink" href="#Variable.set_var_chunk_cache">#  </a>
|
|
3072 |
|
|
3073 |
|
|
3074 |
<span class="def">def</span>
|
|
3075 |
<span class="name">set_var_chunk_cache</span><span class="signature">(unknown)</span>:
|
|
3076 |
</div>
|
|
3077 |
|
|
3078 |
|
|
3079 |
<div class="docstring"><p><strong><code>set_var_chunk_cache(self,size=None,nelems=None,preemption=None)</code></strong></p>
|
|
3080 |
|
|
3081 |
<p>change variable chunk cache settings.
|
|
3082 |
See netcdf C library documentation for <code>nc_set_var_chunk_cache</code> for
|
|
3083 |
details.</p>
|
|
3084 |
</div>
|
|
3085 |
|
|
3086 |
|
|
3087 |
</div>
|
|
3088 |
<div id="Variable.renameAttribute" class="classattr">
|
|
3089 |
<div class="attr function"><a class="headerlink" href="#Variable.renameAttribute">#  </a>
|
|
3090 |
|
|
3091 |
|
|
3092 |
<span class="def">def</span>
|
|
3093 |
<span class="name">renameAttribute</span><span class="signature">(unknown)</span>:
|
|
3094 |
</div>
|
|
3095 |
|
|
3096 |
|
|
3097 |
<div class="docstring"><p><strong><code>renameAttribute(self, oldname, newname)</code></strong></p>
|
|
3098 |
|
|
3099 |
<p>rename a <code><a href="#Variable">Variable</a></code> attribute named <code>oldname</code> to <code>newname</code>.</p>
|
|
3100 |
</div>
|
|
3101 |
|
|
3102 |
|
|
3103 |
</div>
|
|
3104 |
<div id="Variable.assignValue" class="classattr">
|
|
3105 |
<div class="attr function"><a class="headerlink" href="#Variable.assignValue">#  </a>
|
|
3106 |
|
|
3107 |
|
|
3108 |
<span class="def">def</span>
|
|
3109 |
<span class="name">assignValue</span><span class="signature">(unknown)</span>:
|
|
3110 |
</div>
|
|
3111 |
|
|
3112 |
|
|
3113 |
<div class="docstring"><p><strong><code>assignValue(self, val)</code></strong></p>
|
|
3114 |
|
|
3115 |
<p>assign a value to a scalar variable. Provided for compatibility with
|
|
3116 |
Scientific.IO.NetCDF, can also be done by assigning to an Ellipsis slice ([...]).</p>
|
|
3117 |
</div>
|
|
3118 |
|
|
3119 |
|
|
3120 |
</div>
|
|
3121 |
<div id="Variable.getValue" class="classattr">
|
|
3122 |
<div class="attr function"><a class="headerlink" href="#Variable.getValue">#  </a>
|
|
3123 |
|
|
3124 |
|
|
3125 |
<span class="def">def</span>
|
|
3126 |
<span class="name">getValue</span><span class="signature">(unknown)</span>:
|
|
3127 |
</div>
|
|
3128 |
|
|
3129 |
|
|
3130 |
<div class="docstring"><p><strong><code>getValue(self)</code></strong></p>
|
|
3131 |
|
|
3132 |
<p>get the value of a scalar variable. Provided for compatibility with
|
|
3133 |
Scientific.IO.NetCDF, can also be done by slicing with an Ellipsis ([...]).</p>
|
|
3134 |
</div>
|
|
3135 |
|
|
3136 |
|
|
3137 |
</div>
|
|
3138 |
<div id="Variable.set_auto_chartostring" class="classattr">
|
|
3139 |
<div class="attr function"><a class="headerlink" href="#Variable.set_auto_chartostring">#  </a>
|
|
3140 |
|
|
3141 |
|
|
3142 |
<span class="def">def</span>
|
|
3143 |
<span class="name">set_auto_chartostring</span><span class="signature">(unknown)</span>:
|
|
3144 |
</div>
|
|
3145 |
|
|
3146 |
|
|
3147 |
<div class="docstring"><p><strong><code>set_auto_chartostring(self,chartostring)</code></strong></p>
|
|
3148 |
|
|
3149 |
<p>turn on or off automatic conversion of character variable data to and
|
|
3150 |
from numpy fixed length string arrays when the <code>_Encoding</code> variable attribute
|
|
3151 |
is set.</p>
|
|
3152 |
|
|
3153 |
<p>If <code><a href="#Variable.chartostring">chartostring</a></code> is set to <code>True</code>, when data is read from a character variable
|
|
3154 |
(dtype = <code>S1</code>) that has an <code>_Encoding</code> attribute, it is converted to a numpy
|
|
3155 |
fixed length unicode string array (dtype = <code>UN</code>, where <code>N</code> is the length
|
|
3156 |
of the the rightmost dimension of the variable). The value of <code>_Encoding</code>
|
|
3157 |
is the unicode encoding that is used to decode the bytes into strings.</p>
|
|
3158 |
|
|
3159 |
<p>When numpy string data is written to a variable it is converted back to
|
|
3160 |
indiviual bytes, with the number of bytes in each string equalling the
|
|
3161 |
rightmost dimension of the variable.</p>
|
|
3162 |
|
|
3163 |
<p>The default value of <code><a href="#Variable.chartostring">chartostring</a></code> is <code>True</code>
|
|
3164 |
(automatic conversions are performed).</p>
|
|
3165 |
</div>
|
|
3166 |
|
|
3167 |
|
|
3168 |
</div>
|
|
3169 |
<div id="Variable.use_nc_get_vars" class="classattr">
|
|
3170 |
<div class="attr function"><a class="headerlink" href="#Variable.use_nc_get_vars">#  </a>
|
|
3171 |
|
|
3172 |
|
|
3173 |
<span class="def">def</span>
|
|
3174 |
<span class="name">use_nc_get_vars</span><span class="signature">(unknown)</span>:
|
|
3175 |
</div>
|
|
3176 |
|
|
3177 |
|
|
3178 |
<div class="docstring"><p><strong><code>use_nc_get_vars(self,_use_get_vars)</code></strong></p>
|
|
3179 |
|
|
3180 |
<p>enable the use of netcdf library routine <code>nc_get_vars</code>
|
|
3181 |
to retrieve strided variable slices. By default,
|
|
3182 |
<code>nc_get_vars</code> may not used by default (depending on the
|
|
3183 |
version of the netcdf-c library being used) since it may be
|
|
3184 |
slower than multiple calls to the unstrided read routine <code>nc_get_vara</code>.</p>
|
|
3185 |
</div>
|
|
3186 |
|
|
3187 |
|
|
3188 |
</div>
|
|
3189 |
<div id="Variable.set_auto_maskandscale" class="classattr">
|
|
3190 |
<div class="attr function"><a class="headerlink" href="#Variable.set_auto_maskandscale">#  </a>
|
|
3191 |
|
|
3192 |
|
|
3193 |
<span class="def">def</span>
|
|
3194 |
<span class="name">set_auto_maskandscale</span><span class="signature">(unknown)</span>:
|
|
3195 |
</div>
|
|
3196 |
|
|
3197 |
|
|
3198 |
<div class="docstring"><p><strong><code>set_auto_maskandscale(self,maskandscale)</code></strong></p>
|
|
3199 |
|
|
3200 |
<p>turn on or off automatic conversion of variable data to and
|
|
3201 |
from masked arrays, automatic packing/unpacking of variable
|
|
3202 |
data using <code>scale_factor</code> and <code>add_offset</code> attributes and
|
|
3203 |
automatic conversion of signed integer data to unsigned integer
|
|
3204 |
data if the <code>_Unsigned</code> attribute exists.</p>
|
|
3205 |
|
|
3206 |
<p>If <code>maskandscale</code> is set to <code>True</code>, when data is read from a variable
|
|
3207 |
it is converted to a masked array if any of the values are exactly
|
|
3208 |
equal to the either the netCDF _FillValue or the value specified by the
|
|
3209 |
missing_value variable attribute. The fill_value of the masked array
|
|
3210 |
is set to the missing_value attribute (if it exists), otherwise
|
|
3211 |
the netCDF _FillValue attribute (which has a default value
|
|
3212 |
for each data type). If the variable has no missing_value attribute, the
|
|
3213 |
_FillValue is used instead. If the variable has valid_min/valid_max and
|
|
3214 |
missing_value attributes, data outside the specified range will be masked.
|
|
3215 |
When data is written to a variable, the masked
|
|
3216 |
array is converted back to a regular numpy array by replacing all the
|
|
3217 |
masked values by the missing_value attribute of the variable (if it
|
|
3218 |
exists). If the variable has no missing_value attribute, the _FillValue
|
|
3219 |
is used instead. </p>
|
|
3220 |
|
|
3221 |
<p>If <code>maskandscale</code> is set to <code>True</code>, and the variable has a
|
|
3222 |
<code>scale_factor</code> or an <code>add_offset</code> attribute, then data read
|
|
3223 |
from that variable is unpacked using::</p>
|
|
3224 |
|
|
3225 |
<pre><code>data = self.scale_factor*data + self.add_offset
|
|
3226 |
</code></pre>
|
|
3227 |
|
|
3228 |
<p>When data is written to a variable it is packed using::</p>
|
|
3229 |
|
|
3230 |
<pre><code>data = (data - self.add_offset)/self.scale_factor
|
|
3231 |
</code></pre>
|
|
3232 |
|
|
3233 |
<p>If either scale_factor is present, but add_offset is missing, add_offset
|
|
3234 |
is assumed zero. If add_offset is present, but scale_factor is missing,
|
|
3235 |
scale_factor is assumed to be one.
|
|
3236 |
For more information on how <code>scale_factor</code> and <code>add_offset</code> can be
|
|
3237 |
used to provide simple compression, see the
|
|
3238 |
<a href="http://www.esrl.noaa.gov/psl/data/gridded/conventions/cdc_netcdf_standard.shtml">PSL metadata conventions</a>.</p>
|
|
3239 |
|
|
3240 |
<p>In addition, if <code>maskandscale</code> is set to <code>True</code>, and if the variable has an
|
|
3241 |
attribute <code>_Unsigned</code> set, and the variable has a signed integer data type,
|
|
3242 |
a view to the data is returned with the corresponding unsigned integer data type.
|
|
3243 |
This convention is used by the netcdf-java library to save unsigned integer
|
|
3244 |
data in <code>NETCDF3</code> or <code>NETCDF4_CLASSIC</code> files (since the <code>NETCDF3</code>
|
|
3245 |
data model does not have unsigned integer data types).</p>
|
|
3246 |
|
|
3247 |
<p>The default value of <code>maskandscale</code> is <code>True</code>
|
|
3248 |
(automatic conversions are performed).</p>
|
|
3249 |
</div>
|
|
3250 |
|
|
3251 |
|
|
3252 |
</div>
|
|
3253 |
<div id="Variable.set_auto_scale" class="classattr">
|
|
3254 |
<div class="attr function"><a class="headerlink" href="#Variable.set_auto_scale">#  </a>
|
|
3255 |
|
|
3256 |
|
|
3257 |
<span class="def">def</span>
|
|
3258 |
<span class="name">set_auto_scale</span><span class="signature">(unknown)</span>:
|
|
3259 |
</div>
|
|
3260 |
|
|
3261 |
|
|
3262 |
<div class="docstring"><p><strong><code>set_auto_scale(self,scale)</code></strong></p>
|
|
3263 |
|
|
3264 |
<p>turn on or off automatic packing/unpacking of variable
|
|
3265 |
data using <code>scale_factor</code> and <code>add_offset</code> attributes.
|
|
3266 |
Also turns on and off automatic conversion of signed integer data
|
|
3267 |
to unsigned integer data if the variable has an <code>_Unsigned</code>
|
|
3268 |
attribute.</p>
|
|
3269 |
|
|
3270 |
<p>If <code><a href="#Variable.scale">scale</a></code> is set to <code>True</code>, and the variable has a
|
|
3271 |
<code>scale_factor</code> or an <code>add_offset</code> attribute, then data read
|
|
3272 |
from that variable is unpacked using::</p>
|
|
3273 |
|
|
3274 |
<pre><code>data = self.scale_factor*data + self.add_offset
|
|
3275 |
</code></pre>
|
|
3276 |
|
|
3277 |
<p>When data is written to a variable it is packed using::</p>
|
|
3278 |
|
|
3279 |
<pre><code>data = (data - self.add_offset)/self.scale_factor
|
|
3280 |
</code></pre>
|
|
3281 |
|
|
3282 |
<p>If either scale_factor is present, but add_offset is missing, add_offset
|
|
3283 |
is assumed zero. If add_offset is present, but scale_factor is missing,
|
|
3284 |
scale_factor is assumed to be one.
|
|
3285 |
For more information on how <code>scale_factor</code> and <code>add_offset</code> can be
|
|
3286 |
used to provide simple compression, see the
|
|
3287 |
<a href="http://www.esrl.noaa.gov/psl/data/gridded/conventions/cdc_netcdf_standard.shtml">PSL metadata conventions</a>.</p>
|
|
3288 |
|
|
3289 |
<p>In addition, if <code><a href="#Variable.scale">scale</a></code> is set to <code>True</code>, and if the variable has an
|
|
3290 |
attribute <code>_Unsigned</code> set, and the variable has a signed integer data type,
|
|
3291 |
a view to the data is returned with the corresponding unsigned integer datatype.
|
|
3292 |
This convention is used by the netcdf-java library to save unsigned integer
|
|
3293 |
data in <code>NETCDF3</code> or <code>NETCDF4_CLASSIC</code> files (since the <code>NETCDF3</code>
|
|
3294 |
data model does not have unsigned integer data types).</p>
|
|
3295 |
|
|
3296 |
<p>The default value of <code><a href="#Variable.scale">scale</a></code> is <code>True</code>
|
|
3297 |
(automatic conversions are performed).</p>
|
|
3298 |
</div>
|
|
3299 |
|
|
3300 |
|
|
3301 |
</div>
|
|
3302 |
<div id="Variable.set_auto_mask" class="classattr">
|
|
3303 |
<div class="attr function"><a class="headerlink" href="#Variable.set_auto_mask">#  </a>
|
|
3304 |
|
|
3305 |
|
|
3306 |
<span class="def">def</span>
|
|
3307 |
<span class="name">set_auto_mask</span><span class="signature">(unknown)</span>:
|
|
3308 |
</div>
|
|
3309 |
|
|
3310 |
|
|
3311 |
<div class="docstring"><p><strong><code>set_auto_mask(self,mask)</code></strong></p>
|
|
3312 |
|
|
3313 |
<p>turn on or off automatic conversion of variable data to and
|
|
3314 |
from masked arrays .</p>
|
|
3315 |
|
|
3316 |
<p>If <code><a href="#Variable.mask">mask</a></code> is set to <code>True</code>, when data is read from a variable
|
|
3317 |
it is converted to a masked array if any of the values are exactly
|
|
3318 |
equal to the either the netCDF _FillValue or the value specified by the
|
|
3319 |
missing_value variable attribute. The fill_value of the masked array
|
|
3320 |
is set to the missing_value attribute (if it exists), otherwise
|
|
3321 |
the netCDF _FillValue attribute (which has a default value
|
|
3322 |
for each data type). If the variable has no missing_value attribute, the
|
|
3323 |
_FillValue is used instead. If the variable has valid_min/valid_max and
|
|
3324 |
missing_value attributes, data outside the specified range will be masked.
|
|
3325 |
When data is written to a variable, the masked
|
|
3326 |
array is converted back to a regular numpy array by replacing all the
|
|
3327 |
masked values by the missing_value attribute of the variable (if it
|
|
3328 |
exists). If the variable has no missing_value attribute, the _FillValue
|
|
3329 |
is used instead. </p>
|
|
3330 |
|
|
3331 |
<p>The default value of <code><a href="#Variable.mask">mask</a></code> is <code>True</code>
|
|
3332 |
(automatic conversions are performed).</p>
|
|
3333 |
</div>
|
|
3334 |
|
|
3335 |
|
|
3336 |
</div>
|
|
3337 |
<div id="Variable.set_always_mask" class="classattr">
|
|
3338 |
<div class="attr function"><a class="headerlink" href="#Variable.set_always_mask">#  </a>
|
|
3339 |
|
|
3340 |
|
|
3341 |
<span class="def">def</span>
|
|
3342 |
<span class="name">set_always_mask</span><span class="signature">(unknown)</span>:
|
|
3343 |
</div>
|
|
3344 |
|
|
3345 |
|
|
3346 |
<div class="docstring"><p><strong><code>set_always_mask(self,always_mask)</code></strong></p>
|
|
3347 |
|
|
3348 |
<p>turn on or off conversion of data without missing values to regular
|
|
3349 |
numpy arrays.</p>
|
|
3350 |
|
|
3351 |
<p><code><a href="#Variable.always_mask">always_mask</a></code> is a Boolean determining if automatic conversion of
|
|
3352 |
masked arrays with no missing values to regular numpy arrays shall be
|
|
3353 |
applied. Default is True. Set to False to restore the default behaviour
|
|
3354 |
in versions prior to 1.4.1 (numpy array returned unless missing values are present,
|
|
3355 |
otherwise masked array returned).</p>
|
|
3356 |
</div>
|
|
3357 |
|
|
3358 |
|
|
3359 |
</div>
|
|
3360 |
<div id="Variable.set_ncstring_attrs" class="classattr">
|
|
3361 |
<div class="attr function"><a class="headerlink" href="#Variable.set_ncstring_attrs">#  </a>
|
|
3362 |
|
|
3363 |
|
|
3364 |
<span class="def">def</span>
|
|
3365 |
<span class="name">set_ncstring_attrs</span><span class="signature">(unknown)</span>:
|
|
3366 |
</div>
|
|
3367 |
|
|
3368 |
|
|
3369 |
<div class="docstring"><p><strong><code>set_always_mask(self,ncstring_attrs)</code></strong></p>
|
|
3370 |
|
|
3371 |
<p>turn on or off creating NC_STRING string attributes.</p>
|
|
3372 |
|
|
3373 |
<p>If <code>ncstring_attrs</code> is set to <code>True</code> then text attributes will be variable-length
|
|
3374 |
NC_STRINGs.</p>
|
|
3375 |
|
|
3376 |
<p>The default value of <code>ncstring_attrs</code> is <code>False</code> (writing ascii text attributes as
|
|
3377 |
NC_CHAR).</p>
|
|
3378 |
</div>
|
|
3379 |
|
|
3380 |
|
|
3381 |
</div>
|
|
3382 |
<div id="Variable.set_collective" class="classattr">
|
|
3383 |
<div class="attr function"><a class="headerlink" href="#Variable.set_collective">#  </a>
|
|
3384 |
|
|
3385 |
|
|
3386 |
<span class="def">def</span>
|
|
3387 |
<span class="name">set_collective</span><span class="signature">(unknown)</span>:
|
|
3388 |
</div>
|
|
3389 |
|
|
3390 |
|
|
3391 |
<div class="docstring"><p><strong><code>set_collective(self,True_or_False)</code></strong></p>
|
|
3392 |
|
|
3393 |
<p>turn on or off collective parallel IO access. Ignored if file is not
|
|
3394 |
open for parallel access.</p>
|
|
3395 |
</div>
|
|
3396 |
|
|
3397 |
|
|
3398 |
</div>
|
|
3399 |
<div id="Variable.get_dims" class="classattr">
|
|
3400 |
<div class="attr function"><a class="headerlink" href="#Variable.get_dims">#  </a>
|
|
3401 |
|
|
3402 |
|
|
3403 |
<span class="def">def</span>
|
|
3404 |
<span class="name">get_dims</span><span class="signature">(unknown)</span>:
|
|
3405 |
</div>
|
|
3406 |
|
|
3407 |
|
|
3408 |
<div class="docstring"><p><strong><code>get_dims(self)</code></strong></p>
|
|
3409 |
|
|
3410 |
<p>return a tuple of <code><a href="#Dimension">Dimension</a></code> instances associated with this
|
|
3411 |
<code><a href="#Variable">Variable</a></code>.</p>
|
|
3412 |
</div>
|
|
3413 |
|
|
3414 |
|
|
3415 |
</div>
|
|
3416 |
<div id="Variable.name" class="classattr">
|
|
3417 |
<div class="attr variable"><a class="headerlink" href="#Variable.name">#  </a>
|
|
3418 |
|
|
3419 |
<span class="name">name</span><span class="default_value"> = <attribute 'name' of '<a href="#_netCDF4.Variable">netCDF4._netCDF4.Variable</a>' objects></span>
|
|
3420 |
</div>
|
|
3421 |
|
|
3422 |
<div class="docstring"><p>string name of Variable instance</p>
|
|
3423 |
</div>
|
|
3424 |
|
|
3425 |
|
|
3426 |
</div>
|
|
3427 |
<div id="Variable.datatype" class="classattr">
|
|
3428 |
<div class="attr variable"><a class="headerlink" href="#Variable.datatype">#  </a>
|
|
3429 |
|
|
3430 |
<span class="name">datatype</span><span class="default_value"> = <attribute 'datatype' of '<a href="#_netCDF4.Variable">netCDF4._netCDF4.Variable</a>' objects></span>
|
|
3431 |
</div>
|
|
3432 |
|
|
3433 |
<div class="docstring"><p>numpy data type (for primitive data types) or
|
|
3434 |
VLType/CompoundType/EnumType instance
|
|
3435 |
(for compound, vlen or enum data types)</p>
|
|
3436 |
</div>
|
|
3437 |
|
|
3438 |
|
|
3439 |
</div>
|
|
3440 |
<div id="Variable.shape" class="classattr">
|
|
3441 |
<div class="attr variable"><a class="headerlink" href="#Variable.shape">#  </a>
|
|
3442 |
|
|
3443 |
<span class="name">shape</span><span class="default_value"> = <attribute 'shape' of '<a href="#_netCDF4.Variable">netCDF4._netCDF4.Variable</a>' objects></span>
|
|
3444 |
</div>
|
|
3445 |
|
|
3446 |
<div class="docstring"><p>find current sizes of all variable dimensions</p>
|
|
3447 |
</div>
|
|
3448 |
|
|
3449 |
|
|
3450 |
</div>
|
|
3451 |
<div id="Variable.size" class="classattr">
|
|
3452 |
<div class="attr variable"><a class="headerlink" href="#Variable.size">#  </a>
|
|
3453 |
|
|
3454 |
<span class="name">size</span><span class="default_value"> = <attribute 'size' of '<a href="#_netCDF4.Variable">netCDF4._netCDF4.Variable</a>' objects></span>
|
|
3455 |
</div>
|
|
3456 |
|
|
3457 |
<div class="docstring"><p>Return the number of stored elements.</p>
|
|
3458 |
</div>
|
|
3459 |
|
|
3460 |
|
|
3461 |
</div>
|
|
3462 |
<div id="Variable.dimensions" class="classattr">
|
|
3463 |
<div class="attr variable"><a class="headerlink" href="#Variable.dimensions">#  </a>
|
|
3464 |
|
|
3465 |
<span class="name">dimensions</span><span class="default_value"> = <attribute 'dimensions' of '<a href="#_netCDF4.Variable">netCDF4._netCDF4.Variable</a>' objects></span>
|
|
3466 |
</div>
|
|
3467 |
|
|
3468 |
<div class="docstring"><p>get variables's dimension names</p>
|
|
3469 |
</div>
|
|
3470 |
|
|
3471 |
|
|
3472 |
</div>
|
|
3473 |
<div id="Variable.ndim" class="classattr">
|
|
3474 |
<div class="attr variable"><a class="headerlink" href="#Variable.ndim">#  </a>
|
|
3475 |
|
|
3476 |
<span class="name">ndim</span><span class="default_value"> = <attribute 'ndim' of '<a href="#_netCDF4.Variable">netCDF4._netCDF4.Variable</a>' objects></span>
|
|
3477 |
</div>
|
|
3478 |
|
|
3479 |
|
|
3480 |
|
|
3481 |
</div>
|
|
3482 |
<div id="Variable.dtype" class="classattr">
|
|
3483 |
<div class="attr variable"><a class="headerlink" href="#Variable.dtype">#  </a>
|
|
3484 |
|
|
3485 |
<span class="name">dtype</span><span class="default_value"> = <attribute 'dtype' of '<a href="#_netCDF4.Variable">netCDF4._netCDF4.Variable</a>' objects></span>
|
|
3486 |
</div>
|
|
3487 |
|
|
3488 |
|
|
3489 |
|
|
3490 |
</div>
|
|
3491 |
<div id="Variable.mask" class="classattr">
|
|
3492 |
<div class="attr variable"><a class="headerlink" href="#Variable.mask">#  </a>
|
|
3493 |
|
|
3494 |
<span class="name">mask</span><span class="default_value"> = <attribute 'mask' of '<a href="#_netCDF4.Variable">netCDF4._netCDF4.Variable</a>' objects></span>
|
|
3495 |
</div>
|
|
3496 |
|
|
3497 |
|
|
3498 |
|
|
3499 |
</div>
|
|
3500 |
<div id="Variable.scale" class="classattr">
|
|
3501 |
<div class="attr variable"><a class="headerlink" href="#Variable.scale">#  </a>
|
|
3502 |
|
|
3503 |
<span class="name">scale</span><span class="default_value"> = <attribute 'scale' of '<a href="#_netCDF4.Variable">netCDF4._netCDF4.Variable</a>' objects></span>
|
|
3504 |
</div>
|
|
3505 |
|
|
3506 |
|
|
3507 |
|
|
3508 |
</div>
|
|
3509 |
<div id="Variable.always_mask" class="classattr">
|
|
3510 |
<div class="attr variable"><a class="headerlink" href="#Variable.always_mask">#  </a>
|
|
3511 |
|
|
3512 |
<span class="name">always_mask</span><span class="default_value"> = <attribute 'always_mask' of '<a href="#_netCDF4.Variable">netCDF4._netCDF4.Variable</a>' objects></span>
|
|
3513 |
</div>
|
|
3514 |
|
|
3515 |
|
|
3516 |
|
|
3517 |
</div>
|
|
3518 |
<div id="Variable.chartostring" class="classattr">
|
|
3519 |
<div class="attr variable"><a class="headerlink" href="#Variable.chartostring">#  </a>
|
|
3520 |
|
|
3521 |
<span class="name">chartostring</span><span class="default_value"> = <attribute 'chartostring' of '<a href="#_netCDF4.Variable">netCDF4._netCDF4.Variable</a>' objects></span>
|
|
3522 |
</div>
|
|
3523 |
|
|
3524 |
|
|
3525 |
|
|
3526 |
</div>
|
|
3527 |
</section>
|
|
3528 |
<section id="Dimension">
|
|
3529 |
<div class="attr class">
|
|
3530 |
<a class="headerlink" href="#Dimension">#  </a>
|
|
3531 |
|
|
3532 |
|
|
3533 |
<span class="def">class</span>
|
|
3534 |
<span class="name">Dimension</span>:
|
|
3535 |
</div>
|
|
3536 |
|
|
3537 |
|
|
3538 |
<div class="docstring"><p>A netCDF <code><a href="#Dimension">Dimension</a></code> is used to describe the coordinates of a <code><a href="#Variable">Variable</a></code>.
|
|
3539 |
See <code><a href="#Dimension.__init__">Dimension.__init__</a></code> for more details.</p>
|
|
3540 |
|
|
3541 |
<p>The current maximum size of a <code><a href="#Dimension">Dimension</a></code> instance can be obtained by
|
|
3542 |
calling the python <code>len</code> function on the <code><a href="#Dimension">Dimension</a></code> instance. The
|
|
3543 |
<code><a href="#Dimension.isunlimited">Dimension.isunlimited</a></code> method of a <code><a href="#Dimension">Dimension</a></code> instance can be used to
|
|
3544 |
determine if the dimension is unlimited.</p>
|
|
3545 |
|
|
3546 |
<p>Read-only class variables:</p>
|
|
3547 |
|
|
3548 |
<p><strong><code><a href="#Dimension.name">name</a></code></strong>: String name, used when creating a <code><a href="#Variable">Variable</a></code> with
|
|
3549 |
<code><a href="#Dataset.createVariable">Dataset.createVariable</a></code>.</p>
|
|
3550 |
|
|
3551 |
<p><strong><code><a href="#Dimension.size">size</a></code></strong>: Current <code><a href="#Dimension">Dimension</a></code> size (same as <code>len(d)</code>, where <code>d</code> is a
|
|
3552 |
<code><a href="#Dimension">Dimension</a></code> instance).</p>
|
|
3553 |
</div>
|
|
3554 |
|
|
3555 |
|
|
3556 |
<div id="Dimension.__init__" class="classattr">
|
|
3557 |
<div class="attr function"><a class="headerlink" href="#Dimension.__init__">#  </a>
|
|
3558 |
|
|
3559 |
|
|
3560 |
<span class="name">Dimension</span><span class="signature">()</span>
|
|
3561 |
</div>
|
|
3562 |
|
|
3563 |
|
|
3564 |
<div class="docstring"><p><strong><code>__init__(self, group, name, size=None)</code></strong></p>
|
|
3565 |
|
|
3566 |
<p><code><a href="#Dimension">Dimension</a></code> constructor.</p>
|
|
3567 |
|
|
3568 |
<p><strong><code><a href="#Dimension.group">group</a></code></strong>: <code><a href="#Group">Group</a></code> instance to associate with dimension.</p>
|
|
3569 |
|
|
3570 |
<p><strong><code><a href="#Dimension.name">name</a></code></strong>: Name of the dimension.</p>
|
|
3571 |
|
|
3572 |
<p><strong><code><a href="#Dimension.size">size</a></code></strong>: Size of the dimension. <code>None</code> or 0 means unlimited. (Default <code>None</code>).</p>
|
|
3573 |
|
|
3574 |
<p><strong><em>Note</em></strong>: <code><a href="#Dimension">Dimension</a></code> instances should be created using the
|
|
3575 |
<code><a href="#Dataset.createDimension">Dataset.createDimension</a></code> method of a <code><a href="#Group">Group</a></code> or
|
|
3576 |
<code><a href="#Dataset">Dataset</a></code> instance, not using <code><a href="#Dimension.__init__">Dimension.__init__</a></code> directly.</p>
|
|
3577 |
</div>
|
|
3578 |
|
|
3579 |
|
|
3580 |
</div>
|
|
3581 |
<div id="Dimension.group" class="classattr">
|
|
3582 |
<div class="attr function"><a class="headerlink" href="#Dimension.group">#  </a>
|
|
3583 |
|
|
3584 |
|
|
3585 |
<span class="def">def</span>
|
|
3586 |
<span class="name">group</span><span class="signature">(unknown)</span>:
|
|
3587 |
</div>
|
|
3588 |
|
|
3589 |
|
|
3590 |
<div class="docstring"><p><strong><code>group(self)</code></strong></p>
|
|
3591 |
|
|
3592 |
<p>return the group that this <code><a href="#Dimension">Dimension</a></code> is a member of.</p>
|
|
3593 |
</div>
|
|
3594 |
|
|
3595 |
|
|
3596 |
</div>
|
|
3597 |
<div id="Dimension.isunlimited" class="classattr">
|
|
3598 |
<div class="attr function"><a class="headerlink" href="#Dimension.isunlimited">#  </a>
|
|
3599 |
|
|
3600 |
|
|
3601 |
<span class="def">def</span>
|
|
3602 |
<span class="name">isunlimited</span><span class="signature">(unknown)</span>:
|
|
3603 |
</div>
|
|
3604 |
|
|
3605 |
|
|
3606 |
<div class="docstring"><p><strong><code>isunlimited(self)</code></strong></p>
|
|
3607 |
|
|
3608 |
<p>returns <code>True</code> if the <code><a href="#Dimension">Dimension</a></code> instance is unlimited, <code>False</code> otherwise.</p>
|
|
3609 |
</div>
|
|
3610 |
|
|
3611 |
|
|
3612 |
</div>
|
|
3613 |
<div id="Dimension.name" class="classattr">
|
|
3614 |
<div class="attr variable"><a class="headerlink" href="#Dimension.name">#  </a>
|
|
3615 |
|
|
3616 |
<span class="name">name</span><span class="default_value"> = <attribute 'name' of '<a href="#_netCDF4.Dimension">netCDF4._netCDF4.Dimension</a>' objects></span>
|
|
3617 |
</div>
|
|
3618 |
|
|
3619 |
<div class="docstring"><p>string name of Dimension instance</p>
|
|
3620 |
</div>
|
|
3621 |
|
|
3622 |
|
|
3623 |
</div>
|
|
3624 |
<div id="Dimension.size" class="classattr">
|
|
3625 |
<div class="attr variable"><a class="headerlink" href="#Dimension.size">#  </a>
|
|
3626 |
|
|
3627 |
<span class="name">size</span><span class="default_value"> = <attribute 'size' of '<a href="#_netCDF4.Dimension">netCDF4._netCDF4.Dimension</a>' objects></span>
|
|
3628 |
</div>
|
|
3629 |
|
|
3630 |
<div class="docstring"><p>current size of Dimension (calls <code>len</code> on Dimension instance)</p>
|
|
3631 |
</div>
|
|
3632 |
|
2701 | 3633 |
|
2702 | 3634 |
</div>
|
2703 | 3635 |
</section>
|
|
2707 | 3639 |
|
2708 | 3640 |
|
2709 | 3641 |
<span class="def">class</span>
|
2710 | |
<span class="name">Group</span>(<span class="base"><a href="#Dataset">Dataset</a></span>):
|
|
3642 |
<span class="name">Group</span>(<span class="base"><a href="#Dataset">netCDF4.Dataset</a></span>):
|
2711 | 3643 |
</div>
|
2712 | 3644 |
|
2713 | 3645 |
|
2714 | 3646 |
<div class="docstring"><p>Groups define a hierarchical namespace within a netCDF file. They are
|
2715 | |
analogous to directories in a unix filesystem. Each <a href="#Group">Group</a> behaves like
|
2716 | |
a <a href="#Dataset">Dataset</a> within a Dataset, and can contain it's own variables,
|
2717 | |
dimensions and attributes (and other Groups). See <a href="#<a href="#Group.__init__">Group.__init__</a>"><a href="#Group.__init__">Group.__init__</a></a>
|
|
3647 |
analogous to directories in a unix filesystem. Each <code><a href="#Group">Group</a></code> behaves like
|
|
3648 |
a <code><a href="#Dataset">Dataset</a></code> within a Dataset, and can contain it's own variables,
|
|
3649 |
dimensions and attributes (and other Groups). See <code><a href="#Group.__init__">Group.__init__</a></code>
|
2718 | 3650 |
for more details.</p>
|
2719 | 3651 |
|
2720 | |
<p><a href="#Group">Group</a> inherits from <a href="#Dataset">Dataset</a>, so all the
|
2721 | |
<a href="#Dataset">Dataset</a> class methods and variables are available
|
2722 | |
to a <a href="#Group">Group</a> instance (except the <code>close</code> method).</p>
|
|
3652 |
<p><code><a href="#Group">Group</a></code> inherits from <code><a href="#Dataset">Dataset</a></code>, so all the
|
|
3653 |
<code><a href="#Dataset">Dataset</a></code> class methods and variables are available
|
|
3654 |
to a <code><a href="#Group">Group</a></code> instance (except the <code><a href="#Group.close">close</a></code> method).</p>
|
2723 | 3655 |
|
2724 | 3656 |
<p>Additional read-only class variables:</p>
|
2725 | 3657 |
|
2726 | |
<p><strong><code>name</code></strong>: String describing the group name.</p>
|
|
3658 |
<p><strong><code><a href="#Group.name">name</a></code></strong>: String describing the group name.</p>
|
2727 | 3659 |
</div>
|
2728 | 3660 |
|
2729 | 3661 |
|
|
2731 | 3663 |
<div class="attr function"><a class="headerlink" href="#Group.__init__">#  </a>
|
2732 | 3664 |
|
2733 | 3665 |
|
2734 | |
<span class="name">Group</span><span class="signature">(unknown)</span> </div>
|
|
3666 |
<span class="name">Group</span><span class="signature">()</span>
|
|
3667 |
</div>
|
2735 | 3668 |
|
2736 | 3669 |
|
2737 | 3670 |
<div class="docstring"><p><strong><code>__init__(self, parent, name)</code></strong>
|
2738 | |
<a href="#Group">Group</a> constructor.</p>
|
2739 | |
|
2740 | |
<p><strong><code>parent</code></strong>: <a href="#Group">Group</a> instance for the parent group. If being created
|
2741 | |
in the root group, use a <a href="#Dataset">Dataset</a> instance.</p>
|
2742 | |
|
2743 | |
<p><strong><code>name</code></strong>: - Name of the group.</p>
|
2744 | |
|
2745 | |
<p><strong><em>Note</em></strong>: <a href="#Group">Group</a> instances should be created using the
|
2746 | |
<a href="#<a href="#Dataset.createGroup">Dataset.createGroup</a>"><a href="#Dataset.createGroup">Dataset.createGroup</a></a> method of a <a href="#Dataset">Dataset</a> instance, or
|
2747 | |
another <a href="#Group">Group</a> instance, not using this class directly.</p>
|
|
3671 |
<code><a href="#Group">Group</a></code> constructor.</p>
|
|
3672 |
|
|
3673 |
<p><strong><code><a href="#Group.parent">parent</a></code></strong>: <code><a href="#Group">Group</a></code> instance for the parent group. If being created
|
|
3674 |
in the root group, use a <code><a href="#Dataset">Dataset</a></code> instance.</p>
|
|
3675 |
|
|
3676 |
<p><strong><code><a href="#Group.name">name</a></code></strong>: - Name of the group.</p>
|
|
3677 |
|
|
3678 |
<p><strong><em>Note</em></strong>: <code><a href="#Group">Group</a></code> instances should be created using the
|
|
3679 |
<code><a href="#Dataset.createGroup">Dataset.createGroup</a></code> method of a <code><a href="#Dataset">Dataset</a></code> instance, or
|
|
3680 |
another <code><a href="#Group">Group</a></code> instance, not using this class directly.</p>
|
2748 | 3681 |
</div>
|
2749 | 3682 |
|
2750 | 3683 |
|
|
2760 | 3693 |
|
2761 | 3694 |
<div class="docstring"><p><strong><code>close(self)</code></strong></p>
|
2762 | 3695 |
|
2763 | |
<p>overrides <a href="#Dataset">Dataset</a> close method which does not apply to <a href="#Group">Group</a>
|
|
3696 |
<p>overrides <code><a href="#Dataset">Dataset</a></code> close method which does not apply to <code><a href="#Group">Group</a></code>
|
2764 | 3697 |
instances, raises IOError.</p>
|
2765 | 3698 |
</div>
|
2766 | 3699 |
|
|
2769 | 3702 |
<div class="inherited">
|
2770 | 3703 |
<h5>Inherited Members</h5>
|
2771 | 3704 |
<dl>
|
2772 | |
<div><dt><a href="#Dataset">netCDF4._netCDF4.Dataset</a></dt>
|
|
3705 |
<div><dt><a href="#Dataset">Dataset</a></dt>
|
2773 | 3706 |
<dd id="Group.filepath" class="function"><a href="#Dataset.filepath">filepath</a></dd>
|
2774 | 3707 |
<dd id="Group.isopen" class="function"><a href="#Dataset.isopen">isopen</a></dd>
|
2775 | 3708 |
<dd id="Group.sync" class="function"><a href="#Dataset.sync">sync</a></dd>
|
|
2818 | 3751 |
</dl>
|
2819 | 3752 |
</div>
|
2820 | 3753 |
</section>
|
2821 | |
<section id="Dimension">
|
2822 | |
<div class="attr class">
|
2823 | |
<a class="headerlink" href="#Dimension">#  </a>
|
2824 | |
|
2825 | |
|
2826 | |
<span class="def">class</span>
|
2827 | |
<span class="name">Dimension</span>:
|
2828 | |
</div>
|
2829 | |
|
2830 | |
|
2831 | |
<div class="docstring"><p>A netCDF <a href="#Dimension">Dimension</a> is used to describe the coordinates of a <a href="#Variable">Variable</a>.
|
2832 | |
See <a href="#<a href="#Dimension.__init__">Dimension.__init__</a>"><a href="#Dimension.__init__">Dimension.__init__</a></a> for more details.</p>
|
2833 | |
|
2834 | |
<p>The current maximum size of a <a href="#Dimension">Dimension</a> instance can be obtained by
|
2835 | |
calling the python <code>len</code> function on the <a href="#Dimension">Dimension</a> instance. The
|
2836 | |
<a href="#<a href="#Dimension.isunlimited">Dimension.isunlimited</a>"><a href="#Dimension.isunlimited">Dimension.isunlimited</a></a> method of a <a href="#Dimension">Dimension</a> instance can be used to
|
2837 | |
determine if the dimension is unlimited.</p>
|
2838 | |
|
2839 | |
<p>Read-only class variables:</p>
|
2840 | |
|
2841 | |
<p><strong><code>name</code></strong>: String name, used when creating a <a href="#Variable">Variable</a> with
|
2842 | |
<a href="#<a href="#Dataset.createVariable">Dataset.createVariable</a>"><a href="#Dataset.createVariable">Dataset.createVariable</a></a>.</p>
|
2843 | |
|
2844 | |
<p><strong><code>size</code></strong>: Current <a href="#Dimension">Dimension</a> size (same as <code>len(d)</code>, where <code>d</code> is a
|
2845 | |
<a href="#Dimension">Dimension</a> instance).</p>
|
2846 | |
</div>
|
2847 | |
|
2848 | |
|
2849 | |
<div id="Dimension.__init__" class="classattr">
|
2850 | |
<div class="attr function"><a class="headerlink" href="#Dimension.__init__">#  </a>
|
2851 | |
|
2852 | |
|
2853 | |
<span class="name">Dimension</span><span class="signature">(unknown)</span> </div>
|
2854 | |
|
2855 | |
|
2856 | |
<div class="docstring"><p><strong><code>__init__(self, group, name, size=None)</code></strong></p>
|
2857 | |
|
2858 | |
<p><a href="#Dimension">Dimension</a> constructor.</p>
|
2859 | |
|
2860 | |
<p><strong><code>group</code></strong>: <a href="#Group">Group</a> instance to associate with dimension.</p>
|
2861 | |
|
2862 | |
<p><strong><code>name</code></strong>: Name of the dimension.</p>
|
2863 | |
|
2864 | |
<p><strong><code>size</code></strong>: Size of the dimension. <code>None</code> or 0 means unlimited. (Default <code>None</code>).</p>
|
2865 | |
|
2866 | |
<p><strong><em>Note</em></strong>: <a href="#Dimension">Dimension</a> instances should be created using the
|
2867 | |
<a href="#<a href="#Dataset.createDimension">Dataset.createDimension</a>"><a href="#Dataset.createDimension">Dataset.createDimension</a></a> method of a <a href="#Group">Group</a> or
|
2868 | |
<a href="#Dataset">Dataset</a> instance, not using <a href="#<a href="#Dimension.__init__">Dimension.__init__</a>"><a href="#Dimension.__init__">Dimension.__init__</a></a> directly.</p>
|
2869 | |
</div>
|
2870 | |
|
2871 | |
|
2872 | |
</div>
|
2873 | |
<div id="Dimension.group" class="classattr">
|
2874 | |
<div class="attr function"><a class="headerlink" href="#Dimension.group">#  </a>
|
2875 | |
|
2876 | |
|
2877 | |
<span class="def">def</span>
|
2878 | |
<span class="name">group</span><span class="signature">(unknown)</span>:
|
2879 | |
</div>
|
2880 | |
|
2881 | |
|
2882 | |
<div class="docstring"><p><strong><code>group(self)</code></strong></p>
|
2883 | |
|
2884 | |
<p>return the group that this <a href="#Dimension">Dimension</a> is a member of.</p>
|
2885 | |
</div>
|
2886 | |
|
2887 | |
|
2888 | |
</div>
|
2889 | |
<div id="Dimension.isunlimited" class="classattr">
|
2890 | |
<div class="attr function"><a class="headerlink" href="#Dimension.isunlimited">#  </a>
|
2891 | |
|
2892 | |
|
2893 | |
<span class="def">def</span>
|
2894 | |
<span class="name">isunlimited</span><span class="signature">(unknown)</span>:
|
2895 | |
</div>
|
2896 | |
|
2897 | |
|
2898 | |
<div class="docstring"><p><strong><code>isunlimited(self)</code></strong></p>
|
2899 | |
|
2900 | |
<p>returns <code>True</code> if the <a href="#Dimension">Dimension</a> instance is unlimited, <code>False</code> otherwise.</p>
|
2901 | |
</div>
|
2902 | |
|
2903 | |
|
2904 | |
</div>
|
2905 | |
<div id="Dimension.name" class="classattr">
|
2906 | |
<div class="attr variable"><a class="headerlink" href="#Dimension.name">#  </a>
|
2907 | |
|
2908 | |
<span class="name">name</span><span class="default_value"> = <attribute 'name' of '<a href="#Dimension">netCDF4._netCDF4.Dimension</a>' objects></span>
|
2909 | |
</div>
|
2910 | |
|
2911 | |
|
2912 | |
|
2913 | |
</div>
|
2914 | |
<div id="Dimension.size" class="classattr">
|
2915 | |
<div class="attr variable"><a class="headerlink" href="#Dimension.size">#  </a>
|
2916 | |
|
2917 | |
<span class="name">size</span><span class="default_value"> = <attribute 'size' of '<a href="#Dimension">netCDF4._netCDF4.Dimension</a>' objects></span>
|
2918 | |
</div>
|
2919 | |
|
2920 | |
|
2921 | |
|
2922 | |
</div>
|
2923 | |
</section>
|
2924 | |
<section id="Variable">
|
2925 | |
<div class="attr class">
|
2926 | |
<a class="headerlink" href="#Variable">#  </a>
|
2927 | |
|
2928 | |
|
2929 | |
<span class="def">class</span>
|
2930 | |
<span class="name">Variable</span>:
|
2931 | |
</div>
|
2932 | |
|
2933 | |
|
2934 | |
<div class="docstring"><p>A netCDF <a href="#Variable">Variable</a> is used to read and write netCDF data. They are
|
2935 | |
analogous to numpy array objects. See <a href="#<a href="#Variable.__init__">Variable.__init__</a>"><a href="#Variable.__init__">Variable.__init__</a></a> for more
|
2936 | |
details.</p>
|
2937 | |
|
2938 | |
<p>A list of attribute names corresponding to netCDF attributes defined for
|
2939 | |
the variable can be obtained with the <a href="#<a href="#Variable.ncattrs">Variable.ncattrs</a>"><a href="#Variable.ncattrs">Variable.ncattrs</a></a> method. These
|
2940 | |
attributes can be created by assigning to an attribute of the
|
2941 | |
<a href="#Variable">Variable</a> instance. A dictionary containing all the netCDF attribute
|
2942 | |
name/value pairs is provided by the <code>__dict__</code> attribute of a
|
2943 | |
<a href="#Variable">Variable</a> instance.</p>
|
2944 | |
|
2945 | |
<p>The following class variables are read-only:</p>
|
2946 | |
|
2947 | |
<p><strong><code>dimensions</code></strong>: A tuple containing the names of the
|
2948 | |
dimensions associated with this variable.</p>
|
2949 | |
|
2950 | |
<p><strong><code>dtype</code></strong>: A numpy dtype object describing the
|
2951 | |
variable's data type.</p>
|
2952 | |
|
2953 | |
<p><strong><code>ndim</code></strong>: The number of variable dimensions.</p>
|
2954 | |
|
2955 | |
<p><strong><code>shape</code></strong>: A tuple with the current shape (length of all dimensions).</p>
|
2956 | |
|
2957 | |
<p><strong><code>scale</code></strong>: If True, <code>scale_factor</code> and <code>add_offset</code> are
|
2958 | |
applied, and signed integer data is automatically converted to
|
2959 | |
unsigned integer data if the <code>_Unsigned</code> attribute is set.
|
2960 | |
Default is <code>True</code>, can be reset using <a href="#<a href="#Variable.set_auto_scale">Variable.set_auto_scale</a>"><a href="#Variable.set_auto_scale">Variable.set_auto_scale</a></a> and
|
2961 | |
<a href="#<a href="#Variable.set_auto_maskandscale">Variable.set_auto_maskandscale</a>"><a href="#Variable.set_auto_maskandscale">Variable.set_auto_maskandscale</a></a> methods.</p>
|
2962 | |
|
2963 | |
<p><strong><code>mask</code></strong>: If True, data is automatically converted to/from masked
|
2964 | |
arrays when missing values or fill values are present. Default is <code>True</code>, can be
|
2965 | |
reset using <a href="#<a href="#Variable.set_auto_mask">Variable.set_auto_mask</a>"><a href="#Variable.set_auto_mask">Variable.set_auto_mask</a></a> and <a href="#<a href="#Variable.set_auto_maskandscale">Variable.set_auto_maskandscale</a>"><a href="#Variable.set_auto_maskandscale">Variable.set_auto_maskandscale</a></a>
|
2966 | |
methods.</p>
|
2967 | |
|
2968 | |
<p><strong><code><a href="#chartostring">chartostring</a></code></strong>: If True, data is automatically converted to/from character
|
2969 | |
arrays to string arrays when the <code>_Encoding</code> variable attribute is set.
|
2970 | |
Default is <code>True</code>, can be reset using
|
2971 | |
<a href="#<a href="#Variable.set_auto_chartostring">Variable.set_auto_chartostring</a>"><a href="#Variable.set_auto_chartostring">Variable.set_auto_chartostring</a></a> method.</p>
|
2972 | |
|
2973 | |
<p><strong><code>least_significant_digit</code></strong>: Describes the power of ten of the
|
2974 | |
smallest decimal place in the data the contains a reliable value. Data is
|
2975 | |
truncated to this decimal place when it is assigned to the <a href="#Variable">Variable</a>
|
2976 | |
instance. If <code>None</code>, the data is not truncated.</p>
|
2977 | |
|
2978 | |
<p><strong><code>__orthogonal_indexing__</code></strong>: Always <code>True</code>. Indicates to client code
|
2979 | |
that the object supports 'orthogonal indexing', which means that slices
|
2980 | |
that are 1d arrays or lists slice along each dimension independently. This
|
2981 | |
behavior is similar to Fortran or Matlab, but different than numpy.</p>
|
2982 | |
|
2983 | |
<p><strong><code>datatype</code></strong>: numpy data type (for primitive data types) or VLType/CompoundType
|
2984 | |
instance (for compound or vlen data types).</p>
|
2985 | |
|
2986 | |
<p><strong><code>name</code></strong>: String name.</p>
|
2987 | |
|
2988 | |
<p><strong><code>size</code></strong>: The number of stored elements.</p>
|
2989 | |
</div>
|
2990 | |
|
2991 | |
|
2992 | |
<div id="Variable.__init__" class="classattr">
|
2993 | |
<div class="attr function"><a class="headerlink" href="#Variable.__init__">#  </a>
|
2994 | |
|
2995 | |
|
2996 | |
<span class="name">Variable</span><span class="signature">(unknown)</span> </div>
|
2997 | |
|
2998 | |
|
2999 | |
<div class="docstring"><p><strong><code>__init__(self, group, name, datatype, dimensions=(), zlib=False,
|
3000 | |
complevel=4, shuffle=True, fletcher32=False, contiguous=False,
|
3001 | |
chunksizes=None, endian='native',
|
3002 | |
least_significant_digit=None,fill_value=None,chunk_cache=None)</code></strong></p>
|
3003 | |
|
3004 | |
<p><a href="#Variable">Variable</a> constructor.</p>
|
3005 | |
|
3006 | |
<p><strong><code>group</code></strong>: <a href="#Group">Group</a> or <a href="#Dataset">Dataset</a> instance to associate with variable.</p>
|
3007 | |
|
3008 | |
<p><strong><code>name</code></strong>: Name of the variable.</p>
|
3009 | |
|
3010 | |
<p><strong><code>datatype</code></strong>: <a href="#Variable">Variable</a> data type. Can be specified by providing a
|
3011 | |
numpy dtype object, or a string that describes a numpy dtype object.
|
3012 | |
Supported values, corresponding to <code>str</code> attribute of numpy dtype
|
3013 | |
objects, include <code>'f4'</code> (32-bit floating point), <code>'f8'</code> (64-bit floating
|
3014 | |
point), <code>'i4'</code> (32-bit signed integer), <code>'i2'</code> (16-bit signed integer),
|
3015 | |
<code>'i8'</code> (64-bit signed integer), <code>'i4'</code> (8-bit signed integer), <code>'i1'</code>
|
3016 | |
(8-bit signed integer), <code>'u1'</code> (8-bit unsigned integer), <code>'u2'</code> (16-bit
|
3017 | |
unsigned integer), <code>'u4'</code> (32-bit unsigned integer), <code>'u8'</code> (64-bit
|
3018 | |
unsigned integer), or <code>'S1'</code> (single-character string). From
|
3019 | |
compatibility with Scientific.IO.NetCDF, the old Numeric single character
|
3020 | |
typecodes can also be used (<code>'f'</code> instead of <code>'f4'</code>, <code>'d'</code> instead of
|
3021 | |
<code>'f8'</code>, <code>'h'</code> or <code>'s'</code> instead of <code>'i2'</code>, <code>'b'</code> or <code>'B'</code> instead of
|
3022 | |
<code>'i1'</code>, <code>'c'</code> instead of <code>'S1'</code>, and <code>'i'</code> or <code>'l'</code> instead of
|
3023 | |
<code>'i4'</code>). <code>datatype</code> can also be a <a href="#CompoundType">CompoundType</a> instance
|
3024 | |
(for a structured, or compound array), a <a href="#VLType">VLType</a> instance
|
3025 | |
(for a variable-length array), or the python <code>str</code> builtin
|
3026 | |
(for a variable-length string array). Numpy string and unicode datatypes with
|
3027 | |
length greater than one are aliases for <code>str</code>.</p>
|
3028 | |
|
3029 | |
<p><strong><code>dimensions</code></strong>: a tuple containing the variable's dimension names
|
3030 | |
(defined previously with <code>createDimension</code>). Default is an empty tuple
|
3031 | |
which means the variable is a scalar (and therefore has no dimensions).</p>
|
3032 | |
|
3033 | |
<p><strong><code>zlib</code></strong>: if <code>True</code>, data assigned to the <a href="#Variable">Variable</a>
|
3034 | |
instance is compressed on disk. Default <code>False</code>.</p>
|
3035 | |
|
3036 | |
<p><strong><code>complevel</code></strong>: the level of zlib compression to use (1 is the fastest,
|
3037 | |
but poorest compression, 9 is the slowest but best compression). Default 4.
|
3038 | |
Ignored if <code>zlib=False</code>.</p>
|
3039 | |
|
3040 | |
<p><strong><code>shuffle</code></strong>: if <code>True</code>, the HDF5 shuffle filter is applied
|
3041 | |
to improve compression. Default <code>True</code>. Ignored if <code>zlib=False</code>.</p>
|
3042 | |
|
3043 | |
<p><strong><code>fletcher32</code></strong>: if <code>True</code> (default <code>False</code>), the Fletcher32 checksum
|
3044 | |
algorithm is used for error detection.</p>
|
3045 | |
|
3046 | |
<p><strong><code>contiguous</code></strong>: if <code>True</code> (default <code>False</code>), the variable data is
|
3047 | |
stored contiguously on disk. Default <code>False</code>. Setting to <code>True</code> for
|
3048 | |
a variable with an unlimited dimension will trigger an error.</p>
|
3049 | |
|
3050 | |
<p><strong><code>chunksizes</code></strong>: Can be used to specify the HDF5 chunksizes for each
|
3051 | |
dimension of the variable. A detailed discussion of HDF chunking and I/O
|
3052 | |
performance is available
|
3053 | |
<a href="http://www.hdfgroup.org/HDF5/doc/H5.user/Chunking.html">here</a>.
|
3054 | |
Basically, you want the chunk size for each dimension to match as
|
3055 | |
closely as possible the size of the data block that users will read
|
3056 | |
from the file. <code>chunksizes</code> cannot be set if <code>contiguous=True</code>.</p>
|
3057 | |
|
3058 | |
<p><strong><code>endian</code></strong>: Can be used to control whether the
|
3059 | |
data is stored in little or big endian format on disk. Possible
|
3060 | |
values are <code>little, big</code> or <code>native</code> (default). The library
|
3061 | |
will automatically handle endian conversions when the data is read,
|
3062 | |
but if the data is always going to be read on a computer with the
|
3063 | |
opposite format as the one used to create the file, there may be
|
3064 | |
some performance advantage to be gained by setting the endian-ness.
|
3065 | |
For netCDF 3 files (that don't use HDF5), only <code>endian='native'</code> is allowed.</p>
|
3066 | |
|
3067 | |
<p>The <code>zlib, complevel, shuffle, fletcher32, contiguous</code> and <code>chunksizes</code>
|
3068 | |
keywords are silently ignored for netCDF 3 files that do not use HDF5.</p>
|
3069 | |
|
3070 | |
<p><strong><code>least_significant_digit</code></strong>: If specified, variable data will be
|
3071 | |
truncated (quantized). In conjunction with <code>zlib=True</code> this produces
|
3072 | |
'lossy', but significantly more efficient compression. For example, if
|
3073 | |
<code>least_significant_digit=1</code>, data will be quantized using
|
3074 | |
around(scale<em>data)/scale, where scale = 2</em>*bits, and bits is determined
|
3075 | |
so that a precision of 0.1 is retained (in this case bits=4). Default is
|
3076 | |
<code>None</code>, or no quantization.</p>
|
3077 | |
|
3078 | |
<p><strong><code>fill_value</code></strong>: If specified, the default netCDF <code>_FillValue</code> (the
|
3079 | |
value that the variable gets filled with before any data is written to it)
|
3080 | |
is replaced with this value. If fill_value is set to <code>False</code>, then
|
3081 | |
the variable is not pre-filled. The default netCDF fill values can be found
|
3082 | |
in <a href="#default_fillvals">default_fillvals</a>.</p>
|
3083 | |
|
3084 | |
<p><strong><code>chunk_cache</code></strong>: If specified, sets the chunk cache size for this variable.
|
3085 | |
Persists as long as Dataset is open. Use <a href="#set_var_chunk_cache">set_var_chunk_cache</a> to
|
3086 | |
change it when Dataset is re-opened. </p>
|
3087 | |
|
3088 | |
<p><strong><em>Note</em></strong>: <a href="#Variable">Variable</a> instances should be created using the
|
3089 | |
<a href="#<a href="#Dataset.createVariable">Dataset.createVariable</a>"><a href="#Dataset.createVariable">Dataset.createVariable</a></a> method of a <a href="#Dataset">Dataset</a> or
|
3090 | |
<a href="#Group">Group</a> instance, not using this class directly.</p>
|
3091 | |
</div>
|
3092 | |
|
3093 | |
|
3094 | |
</div>
|
3095 | |
<div id="Variable.group" class="classattr">
|
3096 | |
<div class="attr function"><a class="headerlink" href="#Variable.group">#  </a>
|
3097 | |
|
3098 | |
|
3099 | |
<span class="def">def</span>
|
3100 | |
<span class="name">group</span><span class="signature">(unknown)</span>:
|
3101 | |
</div>
|
3102 | |
|
3103 | |
|
3104 | |
<div class="docstring"><p><strong><code>group(self)</code></strong></p>
|
3105 | |
|
3106 | |
<p>return the group that this <a href="#Variable">Variable</a> is a member of.</p>
|
3107 | |
</div>
|
3108 | |
|
3109 | |
|
3110 | |
</div>
|
3111 | |
<div id="Variable.ncattrs" class="classattr">
|
3112 | |
<div class="attr function"><a class="headerlink" href="#Variable.ncattrs">#  </a>
|
3113 | |
|
3114 | |
|
3115 | |
<span class="def">def</span>
|
3116 | |
<span class="name">ncattrs</span><span class="signature">(unknown)</span>:
|
3117 | |
</div>
|
3118 | |
|
3119 | |
|
3120 | |
<div class="docstring"><p><strong><code>ncattrs(self)</code></strong></p>
|
3121 | |
|
3122 | |
<p>return netCDF attribute names for this <a href="#Variable">Variable</a> in a list.</p>
|
3123 | |
</div>
|
3124 | |
|
3125 | |
|
3126 | |
</div>
|
3127 | |
<div id="Variable.setncattr" class="classattr">
|
3128 | |
<div class="attr function"><a class="headerlink" href="#Variable.setncattr">#  </a>
|
3129 | |
|
3130 | |
|
3131 | |
<span class="def">def</span>
|
3132 | |
<span class="name">setncattr</span><span class="signature">(unknown)</span>:
|
3133 | |
</div>
|
3134 | |
|
3135 | |
|
3136 | |
<div class="docstring"><p><strong><code>setncattr(self,name,value)</code></strong></p>
|
3137 | |
|
3138 | |
<p>set a netCDF variable attribute using name,value pair. Use if you need to set a
|
3139 | |
netCDF attribute with the same name as one of the reserved python
|
3140 | |
attributes.</p>
|
3141 | |
</div>
|
3142 | |
|
3143 | |
|
3144 | |
</div>
|
3145 | |
<div id="Variable.setncattr_string" class="classattr">
|
3146 | |
<div class="attr function"><a class="headerlink" href="#Variable.setncattr_string">#  </a>
|
3147 | |
|
3148 | |
|
3149 | |
<span class="def">def</span>
|
3150 | |
<span class="name">setncattr_string</span><span class="signature">(unknown)</span>:
|
3151 | |
</div>
|
3152 | |
|
3153 | |
|
3154 | |
<div class="docstring"><p><strong><code>setncattr_string(self,name,value)</code></strong></p>
|
3155 | |
|
3156 | |
<p>set a netCDF variable string attribute using name,value pair.
|
3157 | |
Use if you need to ensure that a netCDF attribute is created with type
|
3158 | |
<code>NC_STRING</code> if the file format is <code>NETCDF4</code>.
|
3159 | |
Use if you need to set an attribute to an array of variable-length strings.</p>
|
3160 | |
</div>
|
3161 | |
|
3162 | |
|
3163 | |
</div>
|
3164 | |
<div id="Variable.setncatts" class="classattr">
|
3165 | |
<div class="attr function"><a class="headerlink" href="#Variable.setncatts">#  </a>
|
3166 | |
|
3167 | |
|
3168 | |
<span class="def">def</span>
|
3169 | |
<span class="name">setncatts</span><span class="signature">(unknown)</span>:
|
3170 | |
</div>
|
3171 | |
|
3172 | |
|
3173 | |
<div class="docstring"><p><strong><code>setncatts(self,attdict)</code></strong></p>
|
3174 | |
|
3175 | |
<p>set a bunch of netCDF variable attributes at once using a python dictionary.
|
3176 | |
This may be faster when setting a lot of attributes for a <code>NETCDF3</code>
|
3177 | |
formatted file, since nc_redef/nc_enddef is not called in between setting
|
3178 | |
each attribute</p>
|
3179 | |
</div>
|
3180 | |
|
3181 | |
|
3182 | |
</div>
|
3183 | |
<div id="Variable.getncattr" class="classattr">
|
3184 | |
<div class="attr function"><a class="headerlink" href="#Variable.getncattr">#  </a>
|
3185 | |
|
3186 | |
|
3187 | |
<span class="def">def</span>
|
3188 | |
<span class="name">getncattr</span><span class="signature">(unknown)</span>:
|
3189 | |
</div>
|
3190 | |
|
3191 | |
|
3192 | |
<div class="docstring"><p><strong><code>getncattr(self,name)</code></strong></p>
|
3193 | |
|
3194 | |
<p>retrieve a netCDF variable attribute. Use if you need to set a
|
3195 | |
netCDF attribute with the same name as one of the reserved python
|
3196 | |
attributes.</p>
|
3197 | |
|
3198 | |
<p>option kwarg <code>encoding</code> can be used to specify the
|
3199 | |
character encoding of a string attribute (default is <code>utf-8</code>).</p>
|
3200 | |
</div>
|
3201 | |
|
3202 | |
|
3203 | |
</div>
|
3204 | |
<div id="Variable.delncattr" class="classattr">
|
3205 | |
<div class="attr function"><a class="headerlink" href="#Variable.delncattr">#  </a>
|
3206 | |
|
3207 | |
|
3208 | |
<span class="def">def</span>
|
3209 | |
<span class="name">delncattr</span><span class="signature">(unknown)</span>:
|
3210 | |
</div>
|
3211 | |
|
3212 | |
|
3213 | |
<div class="docstring"><p><strong><code>delncattr(self,name,value)</code></strong></p>
|
3214 | |
|
3215 | |
<p>delete a netCDF variable attribute. Use if you need to delete a
|
3216 | |
netCDF attribute with the same name as one of the reserved python
|
3217 | |
attributes.</p>
|
3218 | |
</div>
|
3219 | |
|
3220 | |
|
3221 | |
</div>
|
3222 | |
<div id="Variable.filters" class="classattr">
|
3223 | |
<div class="attr function"><a class="headerlink" href="#Variable.filters">#  </a>
|
3224 | |
|
3225 | |
|
3226 | |
<span class="def">def</span>
|
3227 | |
<span class="name">filters</span><span class="signature">(unknown)</span>:
|
3228 | |
</div>
|
3229 | |
|
3230 | |
|
3231 | |
<div class="docstring"><p><strong><code>filters(self)</code></strong></p>
|
3232 | |
|
3233 | |
<p>return dictionary containing HDF5 filter parameters.</p>
|
3234 | |
</div>
|
3235 | |
|
3236 | |
|
3237 | |
</div>
|
3238 | |
<div id="Variable.endian" class="classattr">
|
3239 | |
<div class="attr function"><a class="headerlink" href="#Variable.endian">#  </a>
|
3240 | |
|
3241 | |
|
3242 | |
<span class="def">def</span>
|
3243 | |
<span class="name">endian</span><span class="signature">(unknown)</span>:
|
3244 | |
</div>
|
3245 | |
|
3246 | |
|
3247 | |
<div class="docstring"><p><strong><code>endian(self)</code></strong></p>
|
3248 | |
|
3249 | |
<p>return endian-ness (<code>little,big,native</code>) of variable (as stored in HDF5 file).</p>
|
3250 | |
</div>
|
3251 | |
|
3252 | |
|
3253 | |
</div>
|
3254 | |
<div id="Variable.chunking" class="classattr">
|
3255 | |
<div class="attr function"><a class="headerlink" href="#Variable.chunking">#  </a>
|
3256 | |
|
3257 | |
|
3258 | |
<span class="def">def</span>
|
3259 | |
<span class="name">chunking</span><span class="signature">(unknown)</span>:
|
3260 | |
</div>
|
3261 | |
|
3262 | |
|
3263 | |
<div class="docstring"><p><strong><code>chunking(self)</code></strong></p>
|
3264 | |
|
3265 | |
<p>return variable chunking information. If the dataset is
|
3266 | |
defined to be contiguous (and hence there is no chunking) the word 'contiguous'
|
3267 | |
is returned. Otherwise, a sequence with the chunksize for
|
3268 | |
each dimension is returned.</p>
|
3269 | |
</div>
|
3270 | |
|
3271 | |
|
3272 | |
</div>
|
3273 | |
<div id="Variable.get_var_chunk_cache" class="classattr">
|
3274 | |
<div class="attr function"><a class="headerlink" href="#Variable.get_var_chunk_cache">#  </a>
|
3275 | |
|
3276 | |
|
3277 | |
<span class="def">def</span>
|
3278 | |
<span class="name">get_var_chunk_cache</span><span class="signature">(unknown)</span>:
|
3279 | |
</div>
|
3280 | |
|
3281 | |
|
3282 | |
<div class="docstring"><p><strong><code>get_var_chunk_cache(self)</code></strong></p>
|
3283 | |
|
3284 | |
<p>return variable chunk cache information in a tuple (size,nelems,preemption).
|
3285 | |
See netcdf C library documentation for <code>nc_get_var_chunk_cache</code> for
|
3286 | |
details.</p>
|
3287 | |
</div>
|
3288 | |
|
3289 | |
|
3290 | |
</div>
|
3291 | |
<div id="Variable.set_var_chunk_cache" class="classattr">
|
3292 | |
<div class="attr function"><a class="headerlink" href="#Variable.set_var_chunk_cache">#  </a>
|
3293 | |
|
3294 | |
|
3295 | |
<span class="def">def</span>
|
3296 | |
<span class="name">set_var_chunk_cache</span><span class="signature">(unknown)</span>:
|
3297 | |
</div>
|
3298 | |
|
3299 | |
|
3300 | |
<div class="docstring"><p><strong><code>set_var_chunk_cache(self,size=None,nelems=None,preemption=None)</code></strong></p>
|
3301 | |
|
3302 | |
<p>change variable chunk cache settings.
|
3303 | |
See netcdf C library documentation for <code>nc_set_var_chunk_cache</code> for
|
3304 | |
details.</p>
|
3305 | |
</div>
|
3306 | |
|
3307 | |
|
3308 | |
</div>
|
3309 | |
<div id="Variable.renameAttribute" class="classattr">
|
3310 | |
<div class="attr function"><a class="headerlink" href="#Variable.renameAttribute">#  </a>
|
3311 | |
|
3312 | |
|
3313 | |
<span class="def">def</span>
|
3314 | |
<span class="name">renameAttribute</span><span class="signature">(unknown)</span>:
|
3315 | |
</div>
|
3316 | |
|
3317 | |
|
3318 | |
<div class="docstring"><p><strong><code>renameAttribute(self, oldname, newname)</code></strong></p>
|
3319 | |
|
3320 | |
<p>rename a <a href="#Variable">Variable</a> attribute named <code>oldname</code> to <code>newname</code>.</p>
|
3321 | |
</div>
|
3322 | |
|
3323 | |
|
3324 | |
</div>
|
3325 | |
<div id="Variable.assignValue" class="classattr">
|
3326 | |
<div class="attr function"><a class="headerlink" href="#Variable.assignValue">#  </a>
|
3327 | |
|
3328 | |
|
3329 | |
<span class="def">def</span>
|
3330 | |
<span class="name">assignValue</span><span class="signature">(unknown)</span>:
|
3331 | |
</div>
|
3332 | |
|
3333 | |
|
3334 | |
<div class="docstring"><p><strong><code>assignValue(self, val)</code></strong></p>
|
3335 | |
|
3336 | |
<p>assign a value to a scalar variable. Provided for compatibility with
|
3337 | |
Scientific.IO.NetCDF, can also be done by assigning to an Ellipsis slice ([...]).</p>
|
3338 | |
</div>
|
3339 | |
|
3340 | |
|
3341 | |
</div>
|
3342 | |
<div id="Variable.getValue" class="classattr">
|
3343 | |
<div class="attr function"><a class="headerlink" href="#Variable.getValue">#  </a>
|
3344 | |
|
3345 | |
|
3346 | |
<span class="def">def</span>
|
3347 | |
<span class="name">getValue</span><span class="signature">(unknown)</span>:
|
3348 | |
</div>
|
3349 | |
|
3350 | |
|
3351 | |
<div class="docstring"><p><strong><code>getValue(self)</code></strong></p>
|
3352 | |
|
3353 | |
<p>get the value of a scalar variable. Provided for compatibility with
|
3354 | |
Scientific.IO.NetCDF, can also be done by slicing with an Ellipsis ([...]).</p>
|
3355 | |
</div>
|
3356 | |
|
3357 | |
|
3358 | |
</div>
|
3359 | |
<div id="Variable.set_auto_chartostring" class="classattr">
|
3360 | |
<div class="attr function"><a class="headerlink" href="#Variable.set_auto_chartostring">#  </a>
|
3361 | |
|
3362 | |
|
3363 | |
<span class="def">def</span>
|
3364 | |
<span class="name">set_auto_chartostring</span><span class="signature">(unknown)</span>:
|
3365 | |
</div>
|
3366 | |
|
3367 | |
|
3368 | |
<div class="docstring"><p><strong><code>set_auto_chartostring(self,chartostring)</code></strong></p>
|
3369 | |
|
3370 | |
<p>turn on or off automatic conversion of character variable data to and
|
3371 | |
from numpy fixed length string arrays when the <code>_Encoding</code> variable attribute
|
3372 | |
is set.</p>
|
3373 | |
|
3374 | |
<p>If <code><a href="#chartostring">chartostring</a></code> is set to <code>True</code>, when data is read from a character variable
|
3375 | |
(dtype = <code>S1</code>) that has an <code>_Encoding</code> attribute, it is converted to a numpy
|
3376 | |
fixed length unicode string array (dtype = <code>UN</code>, where <code>N</code> is the length
|
3377 | |
of the the rightmost dimension of the variable). The value of <code>_Encoding</code>
|
3378 | |
is the unicode encoding that is used to decode the bytes into strings.</p>
|
3379 | |
|
3380 | |
<p>When numpy string data is written to a variable it is converted back to
|
3381 | |
indiviual bytes, with the number of bytes in each string equalling the
|
3382 | |
rightmost dimension of the variable.</p>
|
3383 | |
|
3384 | |
<p>The default value of <code><a href="#chartostring">chartostring</a></code> is <code>True</code>
|
3385 | |
(automatic conversions are performed).</p>
|
3386 | |
</div>
|
3387 | |
|
3388 | |
|
3389 | |
</div>
|
3390 | |
<div id="Variable.use_nc_get_vars" class="classattr">
|
3391 | |
<div class="attr function"><a class="headerlink" href="#Variable.use_nc_get_vars">#  </a>
|
3392 | |
|
3393 | |
|
3394 | |
<span class="def">def</span>
|
3395 | |
<span class="name">use_nc_get_vars</span><span class="signature">(unknown)</span>:
|
3396 | |
</div>
|
3397 | |
|
3398 | |
|
3399 | |
<div class="docstring"><p><strong><code>use_nc_get_vars(self,_use_get_vars)</code></strong></p>
|
3400 | |
|
3401 | |
<p>enable the use of netcdf library routine <code>nc_get_vars</code>
|
3402 | |
to retrieve strided variable slices. By default,
|
3403 | |
<code>nc_get_vars</code> may not used by default (depending on the
|
3404 | |
version of the netcdf-c library being used) since it may be
|
3405 | |
slower than multiple calls to the unstrided read routine <code>nc_get_vara</code>.</p>
|
3406 | |
</div>
|
3407 | |
|
3408 | |
|
3409 | |
</div>
|
3410 | |
<div id="Variable.set_auto_maskandscale" class="classattr">
|
3411 | |
<div class="attr function"><a class="headerlink" href="#Variable.set_auto_maskandscale">#  </a>
|
3412 | |
|
3413 | |
|
3414 | |
<span class="def">def</span>
|
3415 | |
<span class="name">set_auto_maskandscale</span><span class="signature">(unknown)</span>:
|
3416 | |
</div>
|
3417 | |
|
3418 | |
|
3419 | |
<div class="docstring"><p><strong><code>set_auto_maskandscale(self,maskandscale)</code></strong></p>
|
3420 | |
|
3421 | |
<p>turn on or off automatic conversion of variable data to and
|
3422 | |
from masked arrays, automatic packing/unpacking of variable
|
3423 | |
data using <code>scale_factor</code> and <code>add_offset</code> attributes and
|
3424 | |
automatic conversion of signed integer data to unsigned integer
|
3425 | |
data if the <code>_Unsigned</code> attribute exists.</p>
|
3426 | |
|
3427 | |
<p>If <code>maskandscale</code> is set to <code>True</code>, when data is read from a variable
|
3428 | |
it is converted to a masked array if any of the values are exactly
|
3429 | |
equal to the either the netCDF _FillValue or the value specified by the
|
3430 | |
missing_value variable attribute. The fill_value of the masked array
|
3431 | |
is set to the missing_value attribute (if it exists), otherwise
|
3432 | |
the netCDF _FillValue attribute (which has a default value
|
3433 | |
for each data type). When data is written to a variable, the masked
|
3434 | |
array is converted back to a regular numpy array by replacing all the
|
3435 | |
masked values by the missing_value attribute of the variable (if it
|
3436 | |
exists). If the variable has no missing_value attribute, the _FillValue
|
3437 | |
is used instead. If the variable has valid_min/valid_max and
|
3438 | |
missing_value attributes, data outside the specified range will be
|
3439 | |
set to missing_value.</p>
|
3440 | |
|
3441 | |
<p>If <code>maskandscale</code> is set to <code>True</code>, and the variable has a
|
3442 | |
<code>scale_factor</code> or an <code>add_offset</code> attribute, then data read
|
3443 | |
from that variable is unpacked using::</p>
|
3444 | |
|
3445 | |
<pre><code>data = self.scale_factor*data + self.add_offset
|
3446 | |
</code></pre>
|
3447 | |
|
3448 | |
<p>When data is written to a variable it is packed using::</p>
|
3449 | |
|
3450 | |
<pre><code>data = (data - self.add_offset)/self.scale_factor
|
3451 | |
</code></pre>
|
3452 | |
|
3453 | |
<p>If either scale_factor is present, but add_offset is missing, add_offset
|
3454 | |
is assumed zero. If add_offset is present, but scale_factor is missing,
|
3455 | |
scale_factor is assumed to be one.
|
3456 | |
For more information on how <code>scale_factor</code> and <code>add_offset</code> can be
|
3457 | |
used to provide simple compression, see the
|
3458 | |
<a href="http://www.esrl.noaa.gov/psl/data/gridded/conventions/cdc_netcdf_standard.shtml">PSL metadata conventions</a>.</p>
|
3459 | |
|
3460 | |
<p>In addition, if <code>maskandscale</code> is set to <code>True</code>, and if the variable has an
|
3461 | |
attribute <code>_Unsigned</code> set, and the variable has a signed integer data type,
|
3462 | |
a view to the data is returned with the corresponding unsigned integer data type.
|
3463 | |
This convention is used by the netcdf-java library to save unsigned integer
|
3464 | |
data in <code>NETCDF3</code> or <code>NETCDF4_CLASSIC</code> files (since the <code>NETCDF3</code>
|
3465 | |
data model does not have unsigned integer data types).</p>
|
3466 | |
|
3467 | |
<p>The default value of <code>maskandscale</code> is <code>True</code>
|
3468 | |
(automatic conversions are performed).</p>
|
3469 | |
</div>
|
3470 | |
|
3471 | |
|
3472 | |
</div>
|
3473 | |
<div id="Variable.set_auto_scale" class="classattr">
|
3474 | |
<div class="attr function"><a class="headerlink" href="#Variable.set_auto_scale">#  </a>
|
3475 | |
|
3476 | |
|
3477 | |
<span class="def">def</span>
|
3478 | |
<span class="name">set_auto_scale</span><span class="signature">(unknown)</span>:
|
3479 | |
</div>
|
3480 | |
|
3481 | |
|
3482 | |
<div class="docstring"><p><strong><code>set_auto_scale(self,scale)</code></strong></p>
|
3483 | |
|
3484 | |
<p>turn on or off automatic packing/unpacking of variable
|
3485 | |
data using <code>scale_factor</code> and <code>add_offset</code> attributes.
|
3486 | |
Also turns on and off automatic conversion of signed integer data
|
3487 | |
to unsigned integer data if the variable has an <code>_Unsigned</code>
|
3488 | |
attribute.</p>
|
3489 | |
|
3490 | |
<p>If <code>scale</code> is set to <code>True</code>, and the variable has a
|
3491 | |
<code>scale_factor</code> or an <code>add_offset</code> attribute, then data read
|
3492 | |
from that variable is unpacked using::</p>
|
3493 | |
|
3494 | |
<pre><code>data = self.scale_factor*data + self.add_offset
|
3495 | |
</code></pre>
|
3496 | |
|
3497 | |
<p>When data is written to a variable it is packed using::</p>
|
3498 | |
|
3499 | |
<pre><code>data = (data - self.add_offset)/self.scale_factor
|
3500 | |
</code></pre>
|
3501 | |
|
3502 | |
<p>If either scale_factor is present, but add_offset is missing, add_offset
|
3503 | |
is assumed zero. If add_offset is present, but scale_factor is missing,
|
3504 | |
scale_factor is assumed to be one.
|
3505 | |
For more information on how <code>scale_factor</code> and <code>add_offset</code> can be
|
3506 | |
used to provide simple compression, see the
|
3507 | |
<a href="http://www.esrl.noaa.gov/psl/data/gridded/conventions/cdc_netcdf_standard.shtml">PSL metadata conventions</a>.</p>
|
3508 | |
|
3509 | |
<p>In addition, if <code>scale</code> is set to <code>True</code>, and if the variable has an
|
3510 | |
attribute <code>_Unsigned</code> set, and the variable has a signed integer data type,
|
3511 | |
a view to the data is returned with the corresponding unsigned integer datatype.
|
3512 | |
This convention is used by the netcdf-java library to save unsigned integer
|
3513 | |
data in <code>NETCDF3</code> or <code>NETCDF4_CLASSIC</code> files (since the <code>NETCDF3</code>
|
3514 | |
data model does not have unsigned integer data types).</p>
|
3515 | |
|
3516 | |
<p>The default value of <code>scale</code> is <code>True</code>
|
3517 | |
(automatic conversions are performed).</p>
|
3518 | |
</div>
|
3519 | |
|
3520 | |
|
3521 | |
</div>
|
3522 | |
<div id="Variable.set_auto_mask" class="classattr">
|
3523 | |
<div class="attr function"><a class="headerlink" href="#Variable.set_auto_mask">#  </a>
|
3524 | |
|
3525 | |
|
3526 | |
<span class="def">def</span>
|
3527 | |
<span class="name">set_auto_mask</span><span class="signature">(unknown)</span>:
|
3528 | |
</div>
|
3529 | |
|
3530 | |
|
3531 | |
<div class="docstring"><p><strong><code>set_auto_mask(self,mask)</code></strong></p>
|
3532 | |
|
3533 | |
<p>turn on or off automatic conversion of variable data to and
|
3534 | |
from masked arrays .</p>
|
3535 | |
|
3536 | |
<p>If <code>mask</code> is set to <code>True</code>, when data is read from a variable
|
3537 | |
it is converted to a masked array if any of the values are exactly
|
3538 | |
equal to the either the netCDF _FillValue or the value specified by the
|
3539 | |
missing_value variable attribute. The fill_value of the masked array
|
3540 | |
is set to the missing_value attribute (if it exists), otherwise
|
3541 | |
the netCDF _FillValue attribute (which has a default value
|
3542 | |
for each data type). When data is written to a variable, the masked
|
3543 | |
array is converted back to a regular numpy array by replacing all the
|
3544 | |
masked values by the missing_value attribute of the variable (if it
|
3545 | |
exists). If the variable has no missing_value attribute, the _FillValue
|
3546 | |
is used instead. If the variable has valid_min/valid_max and
|
3547 | |
missing_value attributes, data outside the specified range will be
|
3548 | |
set to missing_value.</p>
|
3549 | |
|
3550 | |
<p>The default value of <code>mask</code> is <code>True</code>
|
3551 | |
(automatic conversions are performed).</p>
|
3552 | |
</div>
|
3553 | |
|
3554 | |
|
3555 | |
</div>
|
3556 | |
<div id="Variable.set_always_mask" class="classattr">
|
3557 | |
<div class="attr function"><a class="headerlink" href="#Variable.set_always_mask">#  </a>
|
3558 | |
|
3559 | |
|
3560 | |
<span class="def">def</span>
|
3561 | |
<span class="name">set_always_mask</span><span class="signature">(unknown)</span>:
|
3562 | |
</div>
|
3563 | |
|
3564 | |
|
3565 | |
<div class="docstring"><p><strong><code>set_always_mask(self,always_mask)</code></strong></p>
|
3566 | |
|
3567 | |
<p>turn on or off conversion of data without missing values to regular
|
3568 | |
numpy arrays.</p>
|
3569 | |
|
3570 | |
<p><code>always_mask</code> is a Boolean determining if automatic conversion of
|
3571 | |
masked arrays with no missing values to regular numpy arrays shall be
|
3572 | |
applied. Default is True. Set to False to restore the default behaviour
|
3573 | |
in versions prior to 1.4.1 (numpy array returned unless missing values are present,
|
3574 | |
otherwise masked array returned).</p>
|
3575 | |
</div>
|
3576 | |
|
3577 | |
|
3578 | |
</div>
|
3579 | |
<div id="Variable.set_ncstring_attrs" class="classattr">
|
3580 | |
<div class="attr function"><a class="headerlink" href="#Variable.set_ncstring_attrs">#  </a>
|
3581 | |
|
3582 | |
|
3583 | |
<span class="def">def</span>
|
3584 | |
<span class="name">set_ncstring_attrs</span><span class="signature">(unknown)</span>:
|
3585 | |
</div>
|
3586 | |
|
3587 | |
|
3588 | |
<div class="docstring"><p><strong><code>set_always_mask(self,ncstring_attrs)</code></strong></p>
|
3589 | |
|
3590 | |
<p>turn on or off creating NC_STRING string attributes.</p>
|
3591 | |
|
3592 | |
<p>If <code>ncstring_attrs</code> is set to <code>True</code> then text attributes will be variable-length
|
3593 | |
NC_STRINGs.</p>
|
3594 | |
|
3595 | |
<p>The default value of <code>ncstring_attrs</code> is <code>False</code> (writing ascii text attributes as
|
3596 | |
NC_CHAR).</p>
|
3597 | |
</div>
|
3598 | |
|
3599 | |
|
3600 | |
</div>
|
3601 | |
<div id="Variable.set_collective" class="classattr">
|
3602 | |
<div class="attr function"><a class="headerlink" href="#Variable.set_collective">#  </a>
|
3603 | |
|
3604 | |
|
3605 | |
<span class="def">def</span>
|
3606 | |
<span class="name">set_collective</span><span class="signature">(unknown)</span>:
|
3607 | |
</div>
|
3608 | |
|
3609 | |
|
3610 | |
<div class="docstring"><p><strong><code>set_collective(self,True_or_False)</code></strong></p>
|
3611 | |
|
3612 | |
<p>turn on or off collective parallel IO access. Ignored if file is not
|
3613 | |
open for parallel access.</p>
|
3614 | |
</div>
|
3615 | |
|
3616 | |
|
3617 | |
</div>
|
3618 | |
<div id="Variable.get_dims" class="classattr">
|
3619 | |
<div class="attr function"><a class="headerlink" href="#Variable.get_dims">#  </a>
|
3620 | |
|
3621 | |
|
3622 | |
<span class="def">def</span>
|
3623 | |
<span class="name">get_dims</span><span class="signature">(unknown)</span>:
|
3624 | |
</div>
|
3625 | |
|
3626 | |
|
3627 | |
<div class="docstring"><p><strong><code>get_dims(self)</code></strong></p>
|
3628 | |
|
3629 | |
<p>return a tuple of <a href="#Dimension">Dimension</a> instances associated with this
|
3630 | |
<a href="#Variable">Variable</a>.</p>
|
3631 | |
</div>
|
3632 | |
|
3633 | |
|
3634 | |
</div>
|
3635 | |
<div id="Variable.name" class="classattr">
|
3636 | |
<div class="attr variable"><a class="headerlink" href="#Variable.name">#  </a>
|
3637 | |
|
3638 | |
<span class="name">name</span><span class="default_value"> = <attribute 'name' of '<a href="#Variable">netCDF4._netCDF4.Variable</a>' objects></span>
|
3639 | |
</div>
|
3640 | |
|
3641 | |
|
3642 | |
|
3643 | |
</div>
|
3644 | |
<div id="Variable.datatype" class="classattr">
|
3645 | |
<div class="attr variable"><a class="headerlink" href="#Variable.datatype">#  </a>
|
3646 | |
|
3647 | |
<span class="name">datatype</span><span class="default_value"> = <attribute 'datatype' of '<a href="#Variable">netCDF4._netCDF4.Variable</a>' objects></span>
|
3648 | |
</div>
|
3649 | |
|
3650 | |
|
3651 | |
|
3652 | |
</div>
|
3653 | |
<div id="Variable.shape" class="classattr">
|
3654 | |
<div class="attr variable"><a class="headerlink" href="#Variable.shape">#  </a>
|
3655 | |
|
3656 | |
<span class="name">shape</span><span class="default_value"> = <attribute 'shape' of '<a href="#Variable">netCDF4._netCDF4.Variable</a>' objects></span>
|
3657 | |
</div>
|
3658 | |
|
3659 | |
|
3660 | |
|
3661 | |
</div>
|
3662 | |
<div id="Variable.size" class="classattr">
|
3663 | |
<div class="attr variable"><a class="headerlink" href="#Variable.size">#  </a>
|
3664 | |
|
3665 | |
<span class="name">size</span><span class="default_value"> = <attribute 'size' of '<a href="#Variable">netCDF4._netCDF4.Variable</a>' objects></span>
|
3666 | |
</div>
|
3667 | |
|
3668 | |
|
3669 | |
|
3670 | |
</div>
|
3671 | |
<div id="Variable.dimensions" class="classattr">
|
3672 | |
<div class="attr variable"><a class="headerlink" href="#Variable.dimensions">#  </a>
|
3673 | |
|
3674 | |
<span class="name">dimensions</span><span class="default_value"> = <attribute 'dimensions' of '<a href="#Variable">netCDF4._netCDF4.Variable</a>' objects></span>
|
3675 | |
</div>
|
3676 | |
|
3677 | |
|
3678 | |
|
3679 | |
</div>
|
3680 | |
<div id="Variable.ndim" class="classattr">
|
3681 | |
<div class="attr variable"><a class="headerlink" href="#Variable.ndim">#  </a>
|
3682 | |
|
3683 | |
<span class="name">ndim</span><span class="default_value"> = <attribute 'ndim' of '<a href="#Variable">netCDF4._netCDF4.Variable</a>' objects></span>
|
3684 | |
</div>
|
3685 | |
|
3686 | |
|
3687 | |
|
3688 | |
</div>
|
3689 | |
<div id="Variable.dtype" class="classattr">
|
3690 | |
<div class="attr variable"><a class="headerlink" href="#Variable.dtype">#  </a>
|
3691 | |
|
3692 | |
<span class="name">dtype</span><span class="default_value"> = <attribute 'dtype' of '<a href="#Variable">netCDF4._netCDF4.Variable</a>' objects></span>
|
3693 | |
</div>
|
3694 | |
|
3695 | |
|
3696 | |
|
3697 | |
</div>
|
3698 | |
<div id="Variable.mask" class="classattr">
|
3699 | |
<div class="attr variable"><a class="headerlink" href="#Variable.mask">#  </a>
|
3700 | |
|
3701 | |
<span class="name">mask</span><span class="default_value"> = <attribute 'mask' of '<a href="#Variable">netCDF4._netCDF4.Variable</a>' objects></span>
|
3702 | |
</div>
|
3703 | |
|
3704 | |
|
3705 | |
|
3706 | |
</div>
|
3707 | |
<div id="Variable.scale" class="classattr">
|
3708 | |
<div class="attr variable"><a class="headerlink" href="#Variable.scale">#  </a>
|
3709 | |
|
3710 | |
<span class="name">scale</span><span class="default_value"> = <attribute 'scale' of '<a href="#Variable">netCDF4._netCDF4.Variable</a>' objects></span>
|
3711 | |
</div>
|
3712 | |
|
3713 | |
|
3714 | |
|
3715 | |
</div>
|
3716 | |
<div id="Variable.always_mask" class="classattr">
|
3717 | |
<div class="attr variable"><a class="headerlink" href="#Variable.always_mask">#  </a>
|
3718 | |
|
3719 | |
<span class="name">always_mask</span><span class="default_value"> = <attribute 'always_mask' of '<a href="#Variable">netCDF4._netCDF4.Variable</a>' objects></span>
|
3720 | |
</div>
|
3721 | |
|
3722 | |
|
3723 | |
|
3724 | |
</div>
|
3725 | |
<div id="Variable.chartostring" class="classattr">
|
3726 | |
<div class="attr variable"><a class="headerlink" href="#Variable.chartostring">#  </a>
|
3727 | |
|
3728 | |
<span class="name">chartostring</span><span class="default_value"> = <attribute 'chartostring' of '<a href="#Variable">netCDF4._netCDF4.Variable</a>' objects></span>
|
3729 | |
</div>
|
3730 | |
|
3731 | |
|
3732 | |
|
3733 | |
</div>
|
3734 | |
</section>
|
3735 | |
<section id="CompoundType">
|
3736 | |
<div class="attr class">
|
3737 | |
<a class="headerlink" href="#CompoundType">#  </a>
|
3738 | |
|
3739 | |
|
3740 | |
<span class="def">class</span>
|
3741 | |
<span class="name">CompoundType</span>:
|
3742 | |
</div>
|
3743 | |
|
3744 | |
|
3745 | |
<div class="docstring"><p>A <a href="#CompoundType">CompoundType</a> instance is used to describe a compound data
|
3746 | |
type, and can be passed to the the <a href="#<a href="#Dataset.createVariable">Dataset.createVariable</a>"><a href="#Dataset.createVariable">Dataset.createVariable</a></a> method of
|
3747 | |
a <a href="#Dataset">Dataset</a> or <a href="#Group">Group</a> instance.
|
3748 | |
Compound data types map to numpy structured arrays.
|
3749 | |
See <a href="#<a href="#CompoundType.__init__">CompoundType.__init__</a>"><a href="#CompoundType.__init__">CompoundType.__init__</a></a> for more details.</p>
|
3750 | |
|
3751 | |
<p>The instance variables <code>dtype</code> and <code>name</code> should not be modified by
|
3752 | |
the user.</p>
|
3753 | |
</div>
|
3754 | |
|
3755 | |
|
3756 | |
<div id="CompoundType.__init__" class="classattr">
|
3757 | |
<div class="attr function"><a class="headerlink" href="#CompoundType.__init__">#  </a>
|
3758 | |
|
3759 | |
|
3760 | |
<span class="name">CompoundType</span><span class="signature">(unknown)</span> </div>
|
3761 | |
|
3762 | |
|
3763 | |
<div class="docstring"><p><strong><em><code>__init__(group, datatype, datatype_name)</code></em></strong></p>
|
3764 | |
|
3765 | |
<p>CompoundType constructor.</p>
|
3766 | |
|
3767 | |
<p><strong><code>group</code></strong>: <a href="#Group">Group</a> instance to associate with the compound datatype.</p>
|
3768 | |
|
3769 | |
<p><strong><code>datatype</code></strong>: A numpy dtype object describing a structured (a.k.a record)
|
3770 | |
array. Can be composed of homogeneous numeric or character data types, or
|
3771 | |
other structured array data types.</p>
|
3772 | |
|
3773 | |
<p><strong><code>datatype_name</code></strong>: a Python string containing a description of the
|
3774 | |
compound data type.</p>
|
3775 | |
|
3776 | |
<p><strong><em>Note 1</em></strong>: When creating nested compound data types,
|
3777 | |
the inner compound data types must already be associated with CompoundType
|
3778 | |
instances (so create CompoundType instances for the innermost structures
|
3779 | |
first).</p>
|
3780 | |
|
3781 | |
<p><strong><em>Note 2</em></strong>: <a href="#CompoundType">CompoundType</a> instances should be created using the
|
3782 | |
<a href="#<a href="#Dataset.createCompoundType">Dataset.createCompoundType</a>"><a href="#Dataset.createCompoundType">Dataset.createCompoundType</a></a>
|
3783 | |
method of a <a href="#Dataset">Dataset</a> or <a href="#Group">Group</a> instance, not using this class directly.</p>
|
3784 | |
</div>
|
3785 | |
|
3786 | |
|
3787 | |
</div>
|
3788 | |
<div id="CompoundType.dtype" class="classattr">
|
3789 | |
<div class="attr variable"><a class="headerlink" href="#CompoundType.dtype">#  </a>
|
3790 | |
|
3791 | |
<span class="name">dtype</span><span class="default_value"> = <attribute 'dtype' of '<a href="#CompoundType">netCDF4._netCDF4.CompoundType</a>' objects></span>
|
3792 | |
</div>
|
3793 | |
|
3794 | |
|
3795 | |
|
3796 | |
</div>
|
3797 | |
<div id="CompoundType.dtype_view" class="classattr">
|
3798 | |
<div class="attr variable"><a class="headerlink" href="#CompoundType.dtype_view">#  </a>
|
3799 | |
|
3800 | |
<span class="name">dtype_view</span><span class="default_value"> = <attribute 'dtype_view' of '<a href="#CompoundType">netCDF4._netCDF4.CompoundType</a>' objects></span>
|
3801 | |
</div>
|
3802 | |
|
3803 | |
|
3804 | |
|
3805 | |
</div>
|
3806 | |
<div id="CompoundType.name" class="classattr">
|
3807 | |
<div class="attr variable"><a class="headerlink" href="#CompoundType.name">#  </a>
|
3808 | |
|
3809 | |
<span class="name">name</span><span class="default_value"> = <attribute 'name' of '<a href="#CompoundType">netCDF4._netCDF4.CompoundType</a>' objects></span>
|
3810 | |
</div>
|
3811 | |
|
3812 | |
|
3813 | |
|
3814 | |
</div>
|
3815 | |
</section>
|
3816 | |
<section id="VLType">
|
3817 | |
<div class="attr class">
|
3818 | |
<a class="headerlink" href="#VLType">#  </a>
|
3819 | |
|
3820 | |
|
3821 | |
<span class="def">class</span>
|
3822 | |
<span class="name">VLType</span>:
|
3823 | |
</div>
|
3824 | |
|
3825 | |
|
3826 | |
<div class="docstring"><p>A <a href="#VLType">VLType</a> instance is used to describe a variable length (VLEN) data
|
3827 | |
type, and can be passed to the the <a href="#<a href="#Dataset.createVariable">Dataset.createVariable</a>"><a href="#Dataset.createVariable">Dataset.createVariable</a></a> method of
|
3828 | |
a <a href="#Dataset">Dataset</a> or <a href="#Group">Group</a> instance. See
|
3829 | |
<a href="#<a href="#VLType.__init__">VLType.__init__</a>"><a href="#VLType.__init__">VLType.__init__</a></a>for more details.</p>
|
3830 | |
|
3831 | |
<p>The instance variables <code>dtype</code> and <code>name</code> should not be modified by
|
3832 | |
the user.</p>
|
3833 | |
</div>
|
3834 | |
|
3835 | |
|
3836 | |
<div id="VLType.__init__" class="classattr">
|
3837 | |
<div class="attr function"><a class="headerlink" href="#VLType.__init__">#  </a>
|
3838 | |
|
3839 | |
|
3840 | |
<span class="name">VLType</span><span class="signature">(unknown)</span> </div>
|
3841 | |
|
3842 | |
|
3843 | |
<div class="docstring"><p><strong><code>__init__(group, datatype, datatype_name)</code></strong></p>
|
3844 | |
|
3845 | |
<p>VLType constructor.</p>
|
3846 | |
|
3847 | |
<p><strong><code>group</code></strong>: <a href="#Group">Group</a> instance to associate with the VLEN datatype.</p>
|
3848 | |
|
3849 | |
<p><strong><code>datatype</code></strong>: An numpy dtype object describing the component type for the
|
3850 | |
variable length array.</p>
|
3851 | |
|
3852 | |
<p><strong><code>datatype_name</code></strong>: a Python string containing a description of the
|
3853 | |
VLEN data type.</p>
|
3854 | |
|
3855 | |
<p><strong><em><code>Note</code></em></strong>: <a href="#VLType">VLType</a> instances should be created using the
|
3856 | |
<a href="#<a href="#Dataset.createVLType">Dataset.createVLType</a>"><a href="#Dataset.createVLType">Dataset.createVLType</a></a>
|
3857 | |
method of a <a href="#Dataset">Dataset</a> or <a href="#Group">Group</a> instance, not using this class directly.</p>
|
3858 | |
</div>
|
3859 | |
|
3860 | |
|
3861 | |
</div>
|
3862 | |
<div id="VLType.dtype" class="classattr">
|
3863 | |
<div class="attr variable"><a class="headerlink" href="#VLType.dtype">#  </a>
|
3864 | |
|
3865 | |
<span class="name">dtype</span><span class="default_value"> = <attribute 'dtype' of '<a href="#VLType">netCDF4._netCDF4.VLType</a>' objects></span>
|
3866 | |
</div>
|
3867 | |
|
3868 | |
|
3869 | |
|
3870 | |
</div>
|
3871 | |
<div id="VLType.name" class="classattr">
|
3872 | |
<div class="attr variable"><a class="headerlink" href="#VLType.name">#  </a>
|
3873 | |
|
3874 | |
<span class="name">name</span><span class="default_value"> = <attribute 'name' of '<a href="#VLType">netCDF4._netCDF4.VLType</a>' objects></span>
|
3875 | |
</div>
|
3876 | |
|
3877 | |
|
3878 | |
|
3879 | |
</div>
|
3880 | |
</section>
|
3881 | |
<section id="EnumType">
|
3882 | |
<div class="attr class">
|
3883 | |
<a class="headerlink" href="#EnumType">#  </a>
|
3884 | |
|
3885 | |
|
3886 | |
<span class="def">class</span>
|
3887 | |
<span class="name">EnumType</span>:
|
3888 | |
</div>
|
3889 | |
|
3890 | |
|
3891 | |
<div class="docstring"><p>A <a href="#EnumType">EnumType</a> instance is used to describe an Enum data
|
3892 | |
type, and can be passed to the the <a href="#<a href="#Dataset.createVariable">Dataset.createVariable</a>"><a href="#Dataset.createVariable">Dataset.createVariable</a></a> method of
|
3893 | |
a <a href="#Dataset">Dataset</a> or <a href="#Group">Group</a> instance. See
|
3894 | |
<a href="#<a href="#EnumType.__init__">EnumType.__init__</a>"><a href="#EnumType.__init__">EnumType.__init__</a></a> for more details.</p>
|
3895 | |
|
3896 | |
<p>The instance variables <code>dtype</code>, <code>name</code> and <code>enum_dict</code> should not be modified by
|
3897 | |
the user.</p>
|
3898 | |
</div>
|
3899 | |
|
3900 | |
|
3901 | |
<div id="EnumType.__init__" class="classattr">
|
3902 | |
<div class="attr function"><a class="headerlink" href="#EnumType.__init__">#  </a>
|
3903 | |
|
3904 | |
|
3905 | |
<span class="name">EnumType</span><span class="signature">(unknown)</span> </div>
|
3906 | |
|
3907 | |
|
3908 | |
<div class="docstring"><p><strong><code>__init__(group, datatype, datatype_name, enum_dict)</code></strong></p>
|
3909 | |
|
3910 | |
<p>EnumType constructor.</p>
|
3911 | |
|
3912 | |
<p><strong><code>group</code></strong>: <a href="#Group">Group</a> instance to associate with the VLEN datatype.</p>
|
3913 | |
|
3914 | |
<p><strong><code>datatype</code></strong>: An numpy integer dtype object describing the base type
|
3915 | |
for the Enum.</p>
|
3916 | |
|
3917 | |
<p><strong><code>datatype_name</code></strong>: a Python string containing a description of the
|
3918 | |
Enum data type.</p>
|
3919 | |
|
3920 | |
<p><strong><code>enum_dict</code></strong>: a Python dictionary containing the Enum field/value
|
3921 | |
pairs.</p>
|
3922 | |
|
3923 | |
<p><strong><em><code>Note</code></em></strong>: <a href="#EnumType">EnumType</a> instances should be created using the
|
3924 | |
<a href="#<a href="#Dataset.createEnumType">Dataset.createEnumType</a>"><a href="#Dataset.createEnumType">Dataset.createEnumType</a></a>
|
3925 | |
method of a <a href="#Dataset">Dataset</a> or <a href="#Group">Group</a> instance, not using this class directly.</p>
|
3926 | |
</div>
|
3927 | |
|
3928 | |
|
3929 | |
</div>
|
3930 | |
<div id="EnumType.dtype" class="classattr">
|
3931 | |
<div class="attr variable"><a class="headerlink" href="#EnumType.dtype">#  </a>
|
3932 | |
|
3933 | |
<span class="name">dtype</span><span class="default_value"> = <attribute 'dtype' of '<a href="#EnumType">netCDF4._netCDF4.EnumType</a>' objects></span>
|
3934 | |
</div>
|
3935 | |
|
3936 | |
|
3937 | |
|
3938 | |
</div>
|
3939 | |
<div id="EnumType.name" class="classattr">
|
3940 | |
<div class="attr variable"><a class="headerlink" href="#EnumType.name">#  </a>
|
3941 | |
|
3942 | |
<span class="name">name</span><span class="default_value"> = <attribute 'name' of '<a href="#EnumType">netCDF4._netCDF4.EnumType</a>' objects></span>
|
3943 | |
</div>
|
3944 | |
|
3945 | |
|
3946 | |
|
3947 | |
</div>
|
3948 | |
<div id="EnumType.enum_dict" class="classattr">
|
3949 | |
<div class="attr variable"><a class="headerlink" href="#EnumType.enum_dict">#  </a>
|
3950 | |
|
3951 | |
<span class="name">enum_dict</span><span class="default_value"> = <attribute 'enum_dict' of '<a href="#EnumType">netCDF4._netCDF4.EnumType</a>' objects></span>
|
3952 | |
</div>
|
3953 | |
|
3954 | |
|
3955 | |
|
3956 | |
</div>
|
3957 | |
</section>
|
3958 | |
<section id="getlibversion">
|
3959 | |
<div class="attr function"><a class="headerlink" href="#getlibversion">#  </a>
|
3960 | |
|
3961 | |
|
3962 | |
<span class="def">def</span>
|
3963 | |
<span class="name">getlibversion</span><span class="signature">(unknown)</span>:
|
3964 | |
</div>
|
3965 | |
|
3966 | |
|
3967 | |
<div class="docstring"><p><strong><code><a href="#getlibversion">getlibversion()</a></code></strong></p>
|
3968 | |
|
3969 | |
<p>returns a string describing the version of the netcdf library
|
3970 | |
used to build the module, and when it was built.</p>
|
3971 | |
</div>
|
3972 | |
|
3973 | |
|
3974 | |
</section>
|
3975 | |
<section id="get_chunk_cache">
|
3976 | |
<div class="attr function"><a class="headerlink" href="#get_chunk_cache">#  </a>
|
3977 | |
|
3978 | |
|
3979 | |
<span class="def">def</span>
|
3980 | |
<span class="name">get_chunk_cache</span><span class="signature">(unknown)</span>:
|
3981 | |
</div>
|
3982 | |
|
3983 | |
|
3984 | |
<div class="docstring"><p><strong><code><a href="#get_chunk_cache">get_chunk_cache()</a></code></strong></p>
|
3985 | |
|
3986 | |
<p>return current netCDF chunk cache information in a tuple (size,nelems,preemption).
|
3987 | |
See netcdf C library documentation for <code>nc_get_chunk_cache</code> for
|
3988 | |
details. Values can be reset with <a href="#set_chunk_cache">set_chunk_cache</a>.</p>
|
3989 | |
</div>
|
3990 | |
|
3991 | |
|
3992 | |
</section>
|
3993 | |
<section id="set_chunk_cache">
|
3994 | |
<div class="attr function"><a class="headerlink" href="#set_chunk_cache">#  </a>
|
3995 | |
|
3996 | |
|
3997 | |
<span class="def">def</span>
|
3998 | |
<span class="name">set_chunk_cache</span><span class="signature">(unknown)</span>:
|
3999 | |
</div>
|
4000 | |
|
4001 | |
|
4002 | |
<div class="docstring"><p><strong><code>set_chunk_cache(self,size=None,nelems=None,preemption=None)</code></strong></p>
|
4003 | |
|
4004 | |
<p>change netCDF4 chunk cache settings.
|
4005 | |
See netcdf C library documentation for <code>nc_set_chunk_cache</code> for
|
4006 | |
details.</p>
|
4007 | |
</div>
|
4008 | |
|
4009 | |
|
4010 | |
</section>
|
4011 | |
<section id="stringtoarr">
|
4012 | |
<div class="attr function"><a class="headerlink" href="#stringtoarr">#  </a>
|
4013 | |
|
4014 | |
|
4015 | |
<span class="def">def</span>
|
4016 | |
<span class="name">stringtoarr</span><span class="signature">(unknown)</span>:
|
4017 | |
</div>
|
4018 | |
|
4019 | |
|
4020 | |
<div class="docstring"><p><strong><code>stringtoarr(a, NUMCHARS,dtype='S')</code></strong></p>
|
4021 | |
|
4022 | |
<p>convert a string to a character array of length <code>NUMCHARS</code></p>
|
4023 | |
|
4024 | |
<p><strong><code>a</code></strong>: Input python string.</p>
|
4025 | |
|
4026 | |
<p><strong><code>NUMCHARS</code></strong>: number of characters used to represent string
|
4027 | |
(if len(a) < <code>NUMCHARS</code>, it will be padded on the right with blanks).</p>
|
4028 | |
|
4029 | |
<p><strong><code>dtype</code></strong>: type of numpy array to return. Default is <code>'S'</code>, which
|
4030 | |
means an array of dtype <code>'S1'</code> will be returned. If dtype=<code>'U'</code>, a
|
4031 | |
unicode array (dtype = <code>'U1'</code>) will be returned.</p>
|
4032 | |
|
4033 | |
<p>returns a rank 1 numpy character array of length NUMCHARS with datatype <code>'S1'</code>
|
4034 | |
(default) or <code>'U1'</code> (if dtype=<code>'U'</code>)</p>
|
4035 | |
</div>
|
4036 | |
|
4037 | |
|
4038 | |
</section>
|
4039 | |
<section id="stringtochar">
|
4040 | |
<div class="attr function"><a class="headerlink" href="#stringtochar">#  </a>
|
4041 | |
|
4042 | |
|
4043 | |
<span class="def">def</span>
|
4044 | |
<span class="name">stringtochar</span><span class="signature">(unknown)</span>:
|
4045 | |
</div>
|
4046 | |
|
4047 | |
|
4048 | |
<div class="docstring"><p><strong><code>stringtochar(a,encoding='utf-8')</code></strong></p>
|
4049 | |
|
4050 | |
<p>convert a string array to a character array with one extra dimension</p>
|
4051 | |
|
4052 | |
<p><strong><code>a</code></strong>: Input numpy string array with numpy datatype <code>'SN'</code> or <code>'UN'</code>, where N
|
4053 | |
is the number of characters in each string. Will be converted to
|
4054 | |
an array of characters (datatype <code>'S1'</code> or <code>'U1'</code>) of shape <code>a.shape + (N,)</code>.</p>
|
4055 | |
|
4056 | |
<p>optional kwarg <code>encoding</code> can be used to specify character encoding (default
|
4057 | |
<code>utf-8</code>). If <code>encoding</code> is 'none' or 'bytes', a <code>numpy.string_</code> the input array
|
4058 | |
is treated a raw byte strings (<code>numpy.string_</code>).</p>
|
4059 | |
|
4060 | |
<p>returns a numpy character array with datatype <code>'S1'</code> or <code>'U1'</code>
|
4061 | |
and shape <code>a.shape + (N,)</code>, where N is the length of each string in a.</p>
|
4062 | |
</div>
|
4063 | |
|
4064 | |
|
4065 | |
</section>
|
4066 | |
<section id="chartostring">
|
4067 | |
<div class="attr function"><a class="headerlink" href="#chartostring">#  </a>
|
4068 | |
|
4069 | |
|
4070 | |
<span class="def">def</span>
|
4071 | |
<span class="name">chartostring</span><span class="signature">(unknown)</span>:
|
4072 | |
</div>
|
4073 | |
|
4074 | |
|
4075 | |
<div class="docstring"><p><strong><code>chartostring(b,encoding='utf-8')</code></strong></p>
|
4076 | |
|
4077 | |
<p>convert a character array to a string array with one less dimension.</p>
|
4078 | |
|
4079 | |
<p><strong><code>b</code></strong>: Input character array (numpy datatype <code>'S1'</code> or <code>'U1'</code>).
|
4080 | |
Will be converted to a array of strings, where each string has a fixed
|
4081 | |
length of <code>b.shape[-1]</code> characters.</p>
|
4082 | |
|
4083 | |
<p>optional kwarg <code>encoding</code> can be used to specify character encoding (default
|
4084 | |
<code>utf-8</code>). If <code>encoding</code> is 'none' or 'bytes', a <code>numpy.string_</code> btye array is
|
4085 | |
returned.</p>
|
4086 | |
|
4087 | |
<p>returns a numpy string array with datatype <code>'UN'</code> (or <code>'SN'</code>) and shape
|
4088 | |
<code>b.shape[:-1]</code> where where <code>N=b.shape[-1]</code>.</p>
|
4089 | |
</div>
|
4090 | |
|
4091 | |
|
4092 | |
</section>
|
4093 | 3754 |
<section id="MFDataset">
|
4094 | 3755 |
<div class="attr class">
|
4095 | 3756 |
<a class="headerlink" href="#MFDataset">#  </a>
|
4096 | 3757 |
|
4097 | 3758 |
|
4098 | 3759 |
<span class="def">class</span>
|
4099 | |
<span class="name">MFDataset</span>(<span class="base"><a href="#Dataset">Dataset</a></span>):
|
|
3760 |
<span class="name">MFDataset</span>(<span class="base"><a href="#Dataset">netCDF4.Dataset</a></span>):
|
4100 | 3761 |
</div>
|
4101 | 3762 |
|
4102 | 3763 |
|
|
4107 | 3768 |
|
4108 | 3769 |
<p>Adapted from <a href="http://pysclint.sourceforge.net/pycdf">pycdf</a> by Andre Gosselin.</p>
|
4109 | 3770 |
|
4110 | |
<p>Example usage (See <a href="#<a href="#MFDataset.__init__">MFDataset.__init__</a>"><a href="#MFDataset.__init__">MFDataset.__init__</a></a> for more details):</p>
|
|
3771 |
<p>Example usage (See <code><a href="#MFDataset.__init__">MFDataset.__init__</a></code> for more details):</p>
|
4111 | 3772 |
|
4112 | 3773 |
<div class="codehilite"><pre><span></span><code><span class="o">>>></span> <span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span>
|
4113 | 3774 |
<span class="o">>>></span> <span class="c1"># create a series of netCDF files with a variable sharing</span>
|
|
4133 | 3794 |
<div class="attr function"><a class="headerlink" href="#MFDataset.__init__">#  </a>
|
4134 | 3795 |
|
4135 | 3796 |
|
4136 | |
<span class="name">MFDataset</span><span class="signature">(files, check=False, aggdim=None, exclude=[], master_file=None)</span> </div>
|
|
3797 |
<span class="name">MFDataset</span><span class="signature">(files, check=False, aggdim=None, exclude=[], master_file=None)</span>
|
|
3798 |
</div>
|
4137 | 3799 |
|
4138 | 3800 |
|
4139 | 3801 |
<div class="docstring"><p><strong><code>__init__(self, files, check=False, aggdim=None, exclude=[],
|
|
4207 | 3869 |
<div class="inherited">
|
4208 | 3870 |
<h5>Inherited Members</h5>
|
4209 | 3871 |
<dl>
|
4210 | |
<div><dt><a href="#Dataset">netCDF4._netCDF4.Dataset</a></dt>
|
|
3872 |
<div><dt><a href="#Dataset">Dataset</a></dt>
|
4211 | 3873 |
<dd id="MFDataset.filepath" class="function"><a href="#Dataset.filepath">filepath</a></dd>
|
4212 | 3874 |
<dd id="MFDataset.isopen" class="function"><a href="#Dataset.isopen">isopen</a></dd>
|
4213 | 3875 |
<dd id="MFDataset.sync" class="function"><a href="#Dataset.sync">sync</a></dd>
|
|
4261 | 3923 |
|
4262 | 3924 |
|
4263 | 3925 |
<span class="def">class</span>
|
4264 | |
<span class="name">MFTime</span>(<span class="base"><a href="#_Variable">_Variable</a></span>):
|
|
3926 |
<span class="name">MFTime</span>(<span class="base">netCDF4._netCDF4._Variable</span>):
|
4265 | 3927 |
</div>
|
4266 | 3928 |
|
4267 | 3929 |
|
4268 | 3930 |
<div class="docstring"><p>Class providing an interface to a MFDataset time Variable by imposing a unique common
|
4269 | 3931 |
time unit and/or calendar to all files.</p>
|
4270 | 3932 |
|
4271 | |
<p>Example usage (See <a href="#<a href="#MFTime.__init__">MFTime.__init__</a>"><a href="#MFTime.__init__">MFTime.__init__</a></a> for more details):</p>
|
4272 | |
|
4273 | |
<div class="codehilite"><pre><span></span><code><span class="o">>>></span> <span class="kn">import</span> <span class="nn">numpy</span>
|
|
3933 |
<p>Example usage (See <code><a href="#MFTime.__init__">MFTime.__init__</a></code> for more details):</p>
|
|
3934 |
|
|
3935 |
<div class="codehilite"><pre><span></span><code><span class="o">>>></span> <span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span>
|
4274 | 3936 |
<span class="o">>>></span> <span class="n">f1</span> <span class="o">=</span> <span class="n">Dataset</span><span class="p">(</span><span class="s2">"mftest_1.nc"</span><span class="p">,</span><span class="s2">"w"</span><span class="p">,</span> <span class="nb">format</span><span class="o">=</span><span class="s2">"NETCDF4_CLASSIC"</span><span class="p">)</span>
|
4275 | 3937 |
<span class="o">>>></span> <span class="n">f2</span> <span class="o">=</span> <span class="n">Dataset</span><span class="p">(</span><span class="s2">"mftest_2.nc"</span><span class="p">,</span><span class="s2">"w"</span><span class="p">,</span> <span class="nb">format</span><span class="o">=</span><span class="s2">"NETCDF4_CLASSIC"</span><span class="p">)</span>
|
4276 | 3938 |
<span class="o">>>></span> <span class="n">f1</span><span class="o">.</span><span class="n">createDimension</span><span class="p">(</span><span class="s2">"time"</span><span class="p">,</span><span class="kc">None</span><span class="p">)</span>
|
|
4281 | 3943 |
<span class="o">>>></span> <span class="n">t2</span><span class="o">.</span><span class="n">units</span> <span class="o">=</span> <span class="s2">"days since 2000-02-01"</span>
|
4282 | 3944 |
<span class="o">>>></span> <span class="n">t1</span><span class="o">.</span><span class="n">calendar</span> <span class="o">=</span> <span class="s2">"standard"</span>
|
4283 | 3945 |
<span class="o">>>></span> <span class="n">t2</span><span class="o">.</span><span class="n">calendar</span> <span class="o">=</span> <span class="s2">"standard"</span>
|
4284 | |
<span class="o">>>></span> <span class="n">t1</span><span class="p">[:]</span> <span class="o">=</span> <span class="n">numpy</span><span class="o">.</span><span class="n">arange</span><span class="p">(</span><span class="mi">31</span><span class="p">)</span>
|
4285 | |
<span class="o">>>></span> <span class="n">t2</span><span class="p">[:]</span> <span class="o">=</span> <span class="n">numpy</span><span class="o">.</span><span class="n">arange</span><span class="p">(</span><span class="mi">30</span><span class="p">)</span>
|
|
3946 |
<span class="o">>>></span> <span class="n">t1</span><span class="p">[:]</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">arange</span><span class="p">(</span><span class="mi">31</span><span class="p">)</span>
|
|
3947 |
<span class="o">>>></span> <span class="n">t2</span><span class="p">[:]</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">arange</span><span class="p">(</span><span class="mi">30</span><span class="p">)</span>
|
4286 | 3948 |
<span class="o">>>></span> <span class="n">f1</span><span class="o">.</span><span class="n">close</span><span class="p">()</span>
|
4287 | 3949 |
<span class="o">>>></span> <span class="n">f2</span><span class="o">.</span><span class="n">close</span><span class="p">()</span>
|
4288 | 3950 |
<span class="o">>>></span> <span class="c1"># Read the two files in at once, in one Dataset.</span>
|
|
4303 | 3965 |
<div class="attr function"><a class="headerlink" href="#MFTime.__init__">#  </a>
|
4304 | 3966 |
|
4305 | 3967 |
|
4306 | |
<span class="name">MFTime</span><span class="signature">(time, units=None, calendar=None)</span> </div>
|
|
3968 |
<span class="name">MFTime</span><span class="signature">(time, units=None, calendar=None)</span>
|
|
3969 |
</div>
|
4307 | 3970 |
|
4308 | 3971 |
|
4309 | 3972 |
<div class="docstring"><p><strong><code>__init__(self, time, units=None, calendar=None)</code></strong></p>
|
|
4311 | 3974 |
<p>Create a time Variable with units consistent across a multifile
|
4312 | 3975 |
dataset.</p>
|
4313 | 3976 |
|
4314 | |
<p><strong><code>time</code></strong>: Time variable from a <a href="#MFDataset">MFDataset</a>.</p>
|
|
3977 |
<p><strong><code>time</code></strong>: Time variable from a <code><a href="#MFDataset">MFDataset</a></code>.</p>
|
4315 | 3978 |
|
4316 | 3979 |
<p><strong><code>units</code></strong>: Time units, for example, <code>'days since 1979-01-01'</code>. If <code>None</code>,
|
4317 | 3980 |
use the units from the master variable.</p>
|
|
4327 | 3990 |
<div class="inherited">
|
4328 | 3991 |
<h5>Inherited Members</h5>
|
4329 | 3992 |
<dl>
|
4330 | |
<div><dt><a href="#_Variable">netCDF4._netCDF4._Variable</a></dt>
|
4331 | |
<dd id="MFTime.typecode" class="function"><a href="#_Variable.typecode">typecode</a></dd>
|
4332 | |
<dd id="MFTime.ncattrs" class="function"><a href="#_Variable.ncattrs">ncattrs</a></dd>
|
4333 | |
<dd id="MFTime.set_auto_chartostring" class="function"><a href="#_Variable.set_auto_chartostring">set_auto_chartostring</a></dd>
|
4334 | |
<dd id="MFTime.set_auto_maskandscale" class="function"><a href="#_Variable.set_auto_maskandscale">set_auto_maskandscale</a></dd>
|
4335 | |
<dd id="MFTime.set_auto_mask" class="function"><a href="#_Variable.set_auto_mask">set_auto_mask</a></dd>
|
4336 | |
<dd id="MFTime.set_auto_scale" class="function"><a href="#_Variable.set_auto_scale">set_auto_scale</a></dd>
|
4337 | |
<dd id="MFTime.set_always_mask" class="function"><a href="#_Variable.set_always_mask">set_always_mask</a></dd>
|
|
3993 |
<div><dt>netCDF4._netCDF4._Variable</dt>
|
|
3994 |
<dd id="MFTime.typecode" class="function">typecode</dd>
|
|
3995 |
<dd id="MFTime.ncattrs" class="function">ncattrs</dd>
|
|
3996 |
<dd id="MFTime.set_auto_chartostring" class="function">set_auto_chartostring</dd>
|
|
3997 |
<dd id="MFTime.set_auto_maskandscale" class="function">set_auto_maskandscale</dd>
|
|
3998 |
<dd id="MFTime.set_auto_mask" class="function">set_auto_mask</dd>
|
|
3999 |
<dd id="MFTime.set_auto_scale" class="function">set_auto_scale</dd>
|
|
4000 |
<dd id="MFTime.set_always_mask" class="function">set_always_mask</dd>
|
4338 | 4001 |
|
4339 | 4002 |
</div>
|
4340 | 4003 |
</dl>
|
4341 | 4004 |
</div>
|
|
4005 |
</section>
|
|
4006 |
<section id="CompoundType">
|
|
4007 |
<div class="attr class">
|
|
4008 |
<a class="headerlink" href="#CompoundType">#  </a>
|
|
4009 |
|
|
4010 |
|
|
4011 |
<span class="def">class</span>
|
|
4012 |
<span class="name">CompoundType</span>:
|
|
4013 |
</div>
|
|
4014 |
|
|
4015 |
|
|
4016 |
<div class="docstring"><p>A <code><a href="#CompoundType">CompoundType</a></code> instance is used to describe a compound data
|
|
4017 |
type, and can be passed to the the <code><a href="#Dataset.createVariable">Dataset.createVariable</a></code> method of
|
|
4018 |
a <code><a href="#Dataset">Dataset</a></code> or <code><a href="#Group">Group</a></code> instance.
|
|
4019 |
Compound data types map to numpy structured arrays.
|
|
4020 |
See <code><a href="#CompoundType.__init__">CompoundType.__init__</a></code> for more details.</p>
|
|
4021 |
|
|
4022 |
<p>The instance variables <code><a href="#CompoundType.dtype">dtype</a></code> and <code><a href="#CompoundType.name">name</a></code> should not be modified by
|
|
4023 |
the user.</p>
|
|
4024 |
</div>
|
|
4025 |
|
|
4026 |
|
|
4027 |
<div id="CompoundType.__init__" class="classattr">
|
|
4028 |
<div class="attr function"><a class="headerlink" href="#CompoundType.__init__">#  </a>
|
|
4029 |
|
|
4030 |
|
|
4031 |
<span class="name">CompoundType</span><span class="signature">()</span>
|
|
4032 |
</div>
|
|
4033 |
|
|
4034 |
|
|
4035 |
<div class="docstring"><p><strong><em><code>__init__(group, datatype, datatype_name)</code></em></strong></p>
|
|
4036 |
|
|
4037 |
<p>CompoundType constructor.</p>
|
|
4038 |
|
|
4039 |
<p><strong><code>group</code></strong>: <code><a href="#Group">Group</a></code> instance to associate with the compound datatype.</p>
|
|
4040 |
|
|
4041 |
<p><strong><code>datatype</code></strong>: A numpy dtype object describing a structured (a.k.a record)
|
|
4042 |
array. Can be composed of homogeneous numeric or character data types, or
|
|
4043 |
other structured array data types.</p>
|
|
4044 |
|
|
4045 |
<p><strong><code>datatype_name</code></strong>: a Python string containing a description of the
|
|
4046 |
compound data type.</p>
|
|
4047 |
|
|
4048 |
<p><strong><em>Note 1</em></strong>: When creating nested compound data types,
|
|
4049 |
the inner compound data types must already be associated with CompoundType
|
|
4050 |
instances (so create CompoundType instances for the innermost structures
|
|
4051 |
first).</p>
|
|
4052 |
|
|
4053 |
<p><strong><em>Note 2</em></strong>: <code><a href="#CompoundType">CompoundType</a></code> instances should be created using the
|
|
4054 |
<code><a href="#Dataset.createCompoundType">Dataset.createCompoundType</a></code> method of a <code><a href="#Dataset">Dataset</a></code> or
|
|
4055 |
<code><a href="#Group">Group</a></code> instance, not using this class directly.</p>
|
|
4056 |
</div>
|
|
4057 |
|
|
4058 |
|
|
4059 |
</div>
|
|
4060 |
<div id="CompoundType.dtype" class="classattr">
|
|
4061 |
<div class="attr variable"><a class="headerlink" href="#CompoundType.dtype">#  </a>
|
|
4062 |
|
|
4063 |
<span class="name">dtype</span><span class="default_value"> = <attribute 'dtype' of '<a href="#_netCDF4.CompoundType">netCDF4._netCDF4.CompoundType</a>' objects></span>
|
|
4064 |
</div>
|
|
4065 |
|
|
4066 |
|
|
4067 |
|
|
4068 |
</div>
|
|
4069 |
<div id="CompoundType.dtype_view" class="classattr">
|
|
4070 |
<div class="attr variable"><a class="headerlink" href="#CompoundType.dtype_view">#  </a>
|
|
4071 |
|
|
4072 |
<span class="name">dtype_view</span><span class="default_value"> = <attribute 'dtype_view' of '<a href="#_netCDF4.CompoundType">netCDF4._netCDF4.CompoundType</a>' objects></span>
|
|
4073 |
</div>
|
|
4074 |
|
|
4075 |
|
|
4076 |
|
|
4077 |
</div>
|
|
4078 |
<div id="CompoundType.name" class="classattr">
|
|
4079 |
<div class="attr variable"><a class="headerlink" href="#CompoundType.name">#  </a>
|
|
4080 |
|
|
4081 |
<span class="name">name</span><span class="default_value"> = <attribute 'name' of '<a href="#_netCDF4.CompoundType">netCDF4._netCDF4.CompoundType</a>' objects></span>
|
|
4082 |
</div>
|
|
4083 |
|
|
4084 |
|
|
4085 |
|
|
4086 |
</div>
|
|
4087 |
</section>
|
|
4088 |
<section id="VLType">
|
|
4089 |
<div class="attr class">
|
|
4090 |
<a class="headerlink" href="#VLType">#  </a>
|
|
4091 |
|
|
4092 |
|
|
4093 |
<span class="def">class</span>
|
|
4094 |
<span class="name">VLType</span>:
|
|
4095 |
</div>
|
|
4096 |
|
|
4097 |
|
|
4098 |
<div class="docstring"><p>A <code><a href="#VLType">VLType</a></code> instance is used to describe a variable length (VLEN) data
|
|
4099 |
type, and can be passed to the the <code><a href="#Dataset.createVariable">Dataset.createVariable</a></code> method of
|
|
4100 |
a <code><a href="#Dataset">Dataset</a></code> or <code><a href="#Group">Group</a></code> instance. See
|
|
4101 |
<code><a href="#VLType.__init__">VLType.__init__</a></code> for more details.</p>
|
|
4102 |
|
|
4103 |
<p>The instance variables <code><a href="#VLType.dtype">dtype</a></code> and <code><a href="#VLType.name">name</a></code> should not be modified by
|
|
4104 |
the user.</p>
|
|
4105 |
</div>
|
|
4106 |
|
|
4107 |
|
|
4108 |
<div id="VLType.__init__" class="classattr">
|
|
4109 |
<div class="attr function"><a class="headerlink" href="#VLType.__init__">#  </a>
|
|
4110 |
|
|
4111 |
|
|
4112 |
<span class="name">VLType</span><span class="signature">()</span>
|
|
4113 |
</div>
|
|
4114 |
|
|
4115 |
|
|
4116 |
<div class="docstring"><p><strong><code>__init__(group, datatype, datatype_name)</code></strong></p>
|
|
4117 |
|
|
4118 |
<p>VLType constructor.</p>
|
|
4119 |
|
|
4120 |
<p><strong><code>group</code></strong>: <code><a href="#Group">Group</a></code> instance to associate with the VLEN datatype.</p>
|
|
4121 |
|
|
4122 |
<p><strong><code>datatype</code></strong>: An numpy dtype object describing the component type for the
|
|
4123 |
variable length array.</p>
|
|
4124 |
|
|
4125 |
<p><strong><code>datatype_name</code></strong>: a Python string containing a description of the
|
|
4126 |
VLEN data type.</p>
|
|
4127 |
|
|
4128 |
<p><strong><em><code>Note</code></em></strong>: <code><a href="#VLType">VLType</a></code> instances should be created using the
|
|
4129 |
<code><a href="#Dataset.createVLType">Dataset.createVLType</a></code> method of a <code><a href="#Dataset">Dataset</a></code> or
|
|
4130 |
<code><a href="#Group">Group</a></code> instance, not using this class directly.</p>
|
|
4131 |
</div>
|
|
4132 |
|
|
4133 |
|
|
4134 |
</div>
|
|
4135 |
<div id="VLType.dtype" class="classattr">
|
|
4136 |
<div class="attr variable"><a class="headerlink" href="#VLType.dtype">#  </a>
|
|
4137 |
|
|
4138 |
<span class="name">dtype</span><span class="default_value"> = <attribute 'dtype' of '<a href="#_netCDF4.VLType">netCDF4._netCDF4.VLType</a>' objects></span>
|
|
4139 |
</div>
|
|
4140 |
|
|
4141 |
|
|
4142 |
|
|
4143 |
</div>
|
|
4144 |
<div id="VLType.name" class="classattr">
|
|
4145 |
<div class="attr variable"><a class="headerlink" href="#VLType.name">#  </a>
|
|
4146 |
|
|
4147 |
<span class="name">name</span><span class="default_value"> = <attribute 'name' of '<a href="#_netCDF4.VLType">netCDF4._netCDF4.VLType</a>' objects></span>
|
|
4148 |
</div>
|
|
4149 |
|
|
4150 |
|
|
4151 |
|
|
4152 |
</div>
|
|
4153 |
</section>
|
|
4154 |
<section id="date2num">
|
|
4155 |
<div class="attr function"><a class="headerlink" href="#date2num">#  </a>
|
|
4156 |
|
|
4157 |
|
|
4158 |
<span class="def">def</span>
|
|
4159 |
<span class="name">date2num</span><span class="signature">(unknown)</span>:
|
|
4160 |
</div>
|
|
4161 |
|
|
4162 |
|
|
4163 |
<div class="docstring"><p>date2num(dates, units, calendar=None, has_year_zero=None)</p>
|
|
4164 |
|
|
4165 |
<p>Return numeric time values given datetime objects. The units
|
|
4166 |
of the numeric time values are described by the <strong>units</strong> argument
|
|
4167 |
and the <strong>calendar</strong> keyword. The datetime objects must
|
|
4168 |
be in UTC with no time-zone offset. If there is a
|
|
4169 |
time-zone offset in <strong>units</strong>, it will be applied to the
|
|
4170 |
returned numeric values.</p>
|
|
4171 |
|
|
4172 |
<p><strong>dates</strong>: A datetime object or a sequence of datetime objects.
|
|
4173 |
The datetime objects should not include a time-zone offset. They
|
|
4174 |
can be either native python datetime instances (which use
|
|
4175 |
the proleptic gregorian calendar) or cftime.datetime instances.</p>
|
|
4176 |
|
|
4177 |
<p><strong>units</strong>: a string of the form <strong><time units> since <reference time></strong>
|
|
4178 |
describing the time units. <strong><time units></strong> can be days, hours, minutes,
|
|
4179 |
seconds, milliseconds or microseconds. <strong><reference time></strong> is the time
|
|
4180 |
origin. <strong>months_since</strong> is allowed <em>only</em> for the <strong>360_day</strong> calendar.</p>
|
|
4181 |
|
|
4182 |
<p><strong>calendar</strong>: describes the calendar to be used in the time calculations.
|
|
4183 |
All the values currently defined in the
|
|
4184 |
<code>CF metadata convention <http://cfconventions.org/cf-conventions/cf-conventions#calendar></code>__ are supported.
|
|
4185 |
Valid calendars <strong>'standard', 'gregorian', 'proleptic_gregorian'
|
|
4186 |
'noleap', '365_day', '360_day', 'julian', 'all_leap', '366_day'</strong>.
|
|
4187 |
Default is <code>None</code> which means the calendar associated with the first
|
|
4188 |
input datetime instance will be used.</p>
|
|
4189 |
|
|
4190 |
<p><strong>has_year_zero</strong>: If set to True, astronomical year numbering
|
|
4191 |
is used and the year zero exists. If set to False for real-world
|
|
4192 |
calendars, then historical year numbering is used and the year 1 is
|
|
4193 |
preceded by year -1 and no year zero exists.
|
|
4194 |
The defaults are set to conform with
|
|
4195 |
CF version 1.9 conventions (False for 'julian', 'gregorian'/'standard', True
|
|
4196 |
for 'proleptic_gregorian' (ISO 8601) and True for the idealized
|
|
4197 |
calendars 'noleap'/'365_day', '360_day', 366_day'/'all_leap')
|
|
4198 |
The defaults can only be over-ridden for the real-world calendars,
|
|
4199 |
for the the idealized calendars the year zero
|
|
4200 |
always exists and the has_year_zero kwarg is ignored.
|
|
4201 |
This kwarg is not needed to define calendar systems allowed by CF
|
|
4202 |
(the calendar-specific defaults do this).</p>
|
|
4203 |
|
|
4204 |
<p>returns a numeric time value, or an array of numeric time values
|
|
4205 |
with approximately 1 microsecond accuracy.</p>
|
|
4206 |
</div>
|
|
4207 |
|
|
4208 |
|
|
4209 |
</section>
|
|
4210 |
<section id="num2date">
|
|
4211 |
<div class="attr function"><a class="headerlink" href="#num2date">#  </a>
|
|
4212 |
|
|
4213 |
|
|
4214 |
<span class="def">def</span>
|
|
4215 |
<span class="name">num2date</span><span class="signature">(unknown)</span>:
|
|
4216 |
</div>
|
|
4217 |
|
|
4218 |
|
|
4219 |
<div class="docstring"><p>num2date(times, units, calendar=u'standard', only_use_cftime_datetimes=True, only_use_python_datetimes=False, has_year_zero=None)</p>
|
|
4220 |
|
|
4221 |
<p>Return datetime objects given numeric time values. The units
|
|
4222 |
of the numeric time values are described by the <strong>units</strong> argument
|
|
4223 |
and the <strong>calendar</strong> keyword. The returned datetime objects represent
|
|
4224 |
UTC with no time-zone offset, even if the specified
|
|
4225 |
<strong>units</strong> contain a time-zone offset.</p>
|
|
4226 |
|
|
4227 |
<p><strong>times</strong>: numeric time values.</p>
|
|
4228 |
|
|
4229 |
<p><strong>units</strong>: a string of the form <strong><time units> since <reference time></strong>
|
|
4230 |
describing the time units. <strong><time units></strong> can be days, hours, minutes,
|
|
4231 |
seconds, milliseconds or microseconds. <strong><reference time></strong> is the time
|
|
4232 |
origin. <strong>months_since</strong> is allowed <em>only</em> for the <strong>360_day</strong> calendar.</p>
|
|
4233 |
|
|
4234 |
<p><strong>calendar</strong>: describes the calendar used in the time calculations.
|
|
4235 |
All the values currently defined in the
|
|
4236 |
<code>CF metadata convention <http://cfconventions.org/cf-conventions/cf-conventions#calendar></code>__ are supported.
|
|
4237 |
Valid calendars <strong>'standard', 'gregorian', 'proleptic_gregorian'
|
|
4238 |
'noleap', '365_day', '360_day', 'julian', 'all_leap', '366_day'</strong>.
|
|
4239 |
Default is <strong>'standard'</strong>, which is a mixed Julian/Gregorian calendar.</p>
|
|
4240 |
|
|
4241 |
<p><strong>only_use_cftime_datetimes</strong>: if False, python datetime.datetime
|
|
4242 |
objects are returned from num2date where possible; if True dates which
|
|
4243 |
subclass cftime.datetime are returned for all calendars. Default <strong>True</strong>.</p>
|
|
4244 |
|
|
4245 |
<p><strong>only_use_python_datetimes</strong>: always return python datetime.datetime
|
|
4246 |
objects and raise an error if this is not possible. Ignored unless
|
|
4247 |
<strong>only_use_cftime_datetimes=False</strong>. Default <strong>False</strong>.</p>
|
|
4248 |
|
|
4249 |
<p><strong>has_year_zero</strong>: if set to True, astronomical year numbering
|
|
4250 |
is used and the year zero exists. If set to False for real-world
|
|
4251 |
calendars, then historical year numbering is used and the year 1 is
|
|
4252 |
preceded by year -1 and no year zero exists.
|
|
4253 |
The defaults are set to conform with
|
|
4254 |
CF version 1.9 conventions (False for 'julian', 'gregorian'/'standard', True
|
|
4255 |
for 'proleptic_gregorian' (ISO 8601) and True for the idealized
|
|
4256 |
calendars 'noleap'/'365_day', '360_day', 366_day'/'all_leap')
|
|
4257 |
The defaults can only be over-ridden for the real-world calendars,
|
|
4258 |
for the the idealized calendars the year zero
|
|
4259 |
always exists and the has_year_zero kwarg is ignored.
|
|
4260 |
This kwarg is not needed to define calendar systems allowed by CF
|
|
4261 |
(the calendar-specific defaults do this).</p>
|
|
4262 |
|
|
4263 |
<p>returns a datetime instance, or an array of datetime instances with
|
|
4264 |
microsecond accuracy, if possible.</p>
|
|
4265 |
|
|
4266 |
<p><strong><em>Note</em></strong>: If only_use_cftime_datetimes=False and
|
|
4267 |
use_only_python_datetimes=False, the datetime instances
|
|
4268 |
returned are 'real' python datetime
|
|
4269 |
objects if <strong>calendar='proleptic_gregorian'</strong>, or
|
|
4270 |
<strong>calendar='standard'</strong> or <strong>'gregorian'</strong>
|
|
4271 |
and the date is after the breakpoint between the Julian and
|
|
4272 |
Gregorian calendars (1582-10-15). Otherwise, they are ctime.datetime
|
|
4273 |
objects which support some but not all the methods of native python
|
|
4274 |
datetime objects. The datetime instances
|
|
4275 |
do not contain a time-zone offset, even if the specified <strong>units</strong>
|
|
4276 |
contains one.</p>
|
|
4277 |
</div>
|
|
4278 |
|
|
4279 |
|
|
4280 |
</section>
|
|
4281 |
<section id="date2index">
|
|
4282 |
<div class="attr function"><a class="headerlink" href="#date2index">#  </a>
|
|
4283 |
|
|
4284 |
|
|
4285 |
<span class="def">def</span>
|
|
4286 |
<span class="name">date2index</span><span class="signature">(unknown)</span>:
|
|
4287 |
</div>
|
|
4288 |
|
|
4289 |
|
|
4290 |
<div class="docstring"><p>date2index(dates, nctime, calendar=None, select=u'exact', has_year_zero=None)</p>
|
|
4291 |
|
|
4292 |
<p>Return indices of a netCDF time variable corresponding to the given dates.</p>
|
|
4293 |
|
|
4294 |
<p><strong>dates</strong>: A datetime object or a sequence of datetime objects.
|
|
4295 |
The datetime objects should not include a time-zone offset.</p>
|
|
4296 |
|
|
4297 |
<p><strong>nctime</strong>: A netCDF time variable object. The nctime object must have a
|
|
4298 |
<strong>units</strong> attribute.</p>
|
|
4299 |
|
|
4300 |
<p><strong>calendar</strong>: describes the calendar to be used in the time calculations.
|
|
4301 |
All the values currently defined in the
|
|
4302 |
<code>CF metadata convention <http://cfconventions.org/cf-conventions/cf-conventions#calendar></code>__ are supported.
|
|
4303 |
Valid calendars <strong>'standard', 'gregorian', 'proleptic_gregorian'
|
|
4304 |
'noleap', '365_day', '360_day', 'julian', 'all_leap', '366_day'</strong>.
|
|
4305 |
Default is <code>None</code> which means the calendar associated with the first
|
|
4306 |
input datetime instance will be used.</p>
|
|
4307 |
|
|
4308 |
<p><strong>select</strong>: <strong>'exact', 'before', 'after', 'nearest'</strong>
|
|
4309 |
The index selection method. <strong>exact</strong> will return the indices perfectly
|
|
4310 |
matching the dates given. <strong>before</strong> and <strong>after</strong> will return the indices
|
|
4311 |
corresponding to the dates just before or just after the given dates if
|
|
4312 |
an exact match cannot be found. <strong>nearest</strong> will return the indices that
|
|
4313 |
correspond to the closest dates.</p>
|
|
4314 |
|
|
4315 |
<p><strong>has_year_zero</strong>: if set to True, astronomical year numbering
|
|
4316 |
is used and the year zero exists. If set to False for real-world
|
|
4317 |
calendars, then historical year numbering is used and the year 1 is
|
|
4318 |
preceded by year -1 and no year zero exists.
|
|
4319 |
The defaults are set to conform with
|
|
4320 |
CF version 1.9 conventions (False for 'julian', 'gregorian'/'standard', True
|
|
4321 |
for 'proleptic_gregorian' (ISO 8601) and True for the idealized
|
|
4322 |
calendars 'noleap'/'365_day', '360_day', 366_day'/'all_leap')
|
|
4323 |
The defaults can only be over-ridden for the real-world calendars,
|
|
4324 |
for the the idealized calendars the year zero
|
|
4325 |
always exists and the has_year_zero kwarg is ignored.
|
|
4326 |
This kwarg is not needed to define calendar systems allowed by CF
|
|
4327 |
(the calendar-specific defaults do this).</p>
|
|
4328 |
|
|
4329 |
<p>returns an index (indices) of the netCDF time variable corresponding
|
|
4330 |
to the given datetime object(s).</p>
|
|
4331 |
</div>
|
|
4332 |
|
|
4333 |
|
|
4334 |
</section>
|
|
4335 |
<section id="stringtochar">
|
|
4336 |
<div class="attr function"><a class="headerlink" href="#stringtochar">#  </a>
|
|
4337 |
|
|
4338 |
|
|
4339 |
<span class="def">def</span>
|
|
4340 |
<span class="name">stringtochar</span><span class="signature">(unknown)</span>:
|
|
4341 |
</div>
|
|
4342 |
|
|
4343 |
|
|
4344 |
<div class="docstring"><p><strong><code>stringtochar(a,encoding='utf-8')</code></strong></p>
|
|
4345 |
|
|
4346 |
<p>convert a string array to a character array with one extra dimension</p>
|
|
4347 |
|
|
4348 |
<p><strong><code>a</code></strong>: Input numpy string array with numpy datatype <code>'SN'</code> or <code>'UN'</code>, where N
|
|
4349 |
is the number of characters in each string. Will be converted to
|
|
4350 |
an array of characters (datatype <code>'S1'</code> or <code>'U1'</code>) of shape <code>a.shape + (N,)</code>.</p>
|
|
4351 |
|
|
4352 |
<p>optional kwarg <code>encoding</code> can be used to specify character encoding (default
|
|
4353 |
<code>utf-8</code>). If <code>encoding</code> is 'none' or 'bytes', a <code>numpy.string_</code> the input array
|
|
4354 |
is treated a raw byte strings (<code>numpy.string_</code>).</p>
|
|
4355 |
|
|
4356 |
<p>returns a numpy character array with datatype <code>'S1'</code> or <code>'U1'</code>
|
|
4357 |
and shape <code>a.shape + (N,)</code>, where N is the length of each string in a.</p>
|
|
4358 |
</div>
|
|
4359 |
|
|
4360 |
|
|
4361 |
</section>
|
|
4362 |
<section id="chartostring">
|
|
4363 |
<div class="attr function"><a class="headerlink" href="#chartostring">#  </a>
|
|
4364 |
|
|
4365 |
|
|
4366 |
<span class="def">def</span>
|
|
4367 |
<span class="name">chartostring</span><span class="signature">(unknown)</span>:
|
|
4368 |
</div>
|
|
4369 |
|
|
4370 |
|
|
4371 |
<div class="docstring"><p><strong><code>chartostring(b,encoding='utf-8')</code></strong></p>
|
|
4372 |
|
|
4373 |
<p>convert a character array to a string array with one less dimension.</p>
|
|
4374 |
|
|
4375 |
<p><strong><code>b</code></strong>: Input character array (numpy datatype <code>'S1'</code> or <code>'U1'</code>).
|
|
4376 |
Will be converted to a array of strings, where each string has a fixed
|
|
4377 |
length of <code>b.shape[-1]</code> characters.</p>
|
|
4378 |
|
|
4379 |
<p>optional kwarg <code>encoding</code> can be used to specify character encoding (default
|
|
4380 |
<code>utf-8</code>). If <code>encoding</code> is 'none' or 'bytes', a <code>numpy.string_</code> btye array is
|
|
4381 |
returned.</p>
|
|
4382 |
|
|
4383 |
<p>returns a numpy string array with datatype <code>'UN'</code> (or <code>'SN'</code>) and shape
|
|
4384 |
<code>b.shape[:-1]</code> where where <code>N=b.shape[-1]</code>.</p>
|
|
4385 |
</div>
|
|
4386 |
|
|
4387 |
|
|
4388 |
</section>
|
|
4389 |
<section id="stringtoarr">
|
|
4390 |
<div class="attr function"><a class="headerlink" href="#stringtoarr">#  </a>
|
|
4391 |
|
|
4392 |
|
|
4393 |
<span class="def">def</span>
|
|
4394 |
<span class="name">stringtoarr</span><span class="signature">(unknown)</span>:
|
|
4395 |
</div>
|
|
4396 |
|
|
4397 |
|
|
4398 |
<div class="docstring"><p><strong><code>stringtoarr(a, NUMCHARS,dtype='S')</code></strong></p>
|
|
4399 |
|
|
4400 |
<p>convert a string to a character array of length <code>NUMCHARS</code></p>
|
|
4401 |
|
|
4402 |
<p><strong><code>a</code></strong>: Input python string.</p>
|
|
4403 |
|
|
4404 |
<p><strong><code>NUMCHARS</code></strong>: number of characters used to represent string
|
|
4405 |
(if len(a) < <code>NUMCHARS</code>, it will be padded on the right with blanks).</p>
|
|
4406 |
|
|
4407 |
<p><strong><code>dtype</code></strong>: type of numpy array to return. Default is <code>'S'</code>, which
|
|
4408 |
means an array of dtype <code>'S1'</code> will be returned. If dtype=<code>'U'</code>, a
|
|
4409 |
unicode array (dtype = <code>'U1'</code>) will be returned.</p>
|
|
4410 |
|
|
4411 |
<p>returns a rank 1 numpy character array of length NUMCHARS with datatype <code>'S1'</code>
|
|
4412 |
(default) or <code>'U1'</code> (if dtype=<code>'U'</code>)</p>
|
|
4413 |
</div>
|
|
4414 |
|
|
4415 |
|
|
4416 |
</section>
|
|
4417 |
<section id="getlibversion">
|
|
4418 |
<div class="attr function"><a class="headerlink" href="#getlibversion">#  </a>
|
|
4419 |
|
|
4420 |
|
|
4421 |
<span class="def">def</span>
|
|
4422 |
<span class="name">getlibversion</span><span class="signature">(unknown)</span>:
|
|
4423 |
</div>
|
|
4424 |
|
|
4425 |
|
|
4426 |
<div class="docstring"><p><strong><code><a href="#getlibversion">getlibversion()</a></code></strong></p>
|
|
4427 |
|
|
4428 |
<p>returns a string describing the version of the netcdf library
|
|
4429 |
used to build the module, and when it was built.</p>
|
|
4430 |
</div>
|
|
4431 |
|
|
4432 |
|
|
4433 |
</section>
|
|
4434 |
<section id="EnumType">
|
|
4435 |
<div class="attr class">
|
|
4436 |
<a class="headerlink" href="#EnumType">#  </a>
|
|
4437 |
|
|
4438 |
|
|
4439 |
<span class="def">class</span>
|
|
4440 |
<span class="name">EnumType</span>:
|
|
4441 |
</div>
|
|
4442 |
|
|
4443 |
|
|
4444 |
<div class="docstring"><p>A <code><a href="#EnumType">EnumType</a></code> instance is used to describe an Enum data
|
|
4445 |
type, and can be passed to the the <code><a href="#Dataset.createVariable">Dataset.createVariable</a></code> method of
|
|
4446 |
a <code><a href="#Dataset">Dataset</a></code> or <code><a href="#Group">Group</a></code> instance. See
|
|
4447 |
<code><a href="#EnumType.__init__">EnumType.__init__</a></code> for more details.</p>
|
|
4448 |
|
|
4449 |
<p>The instance variables <code><a href="#EnumType.dtype">dtype</a></code>, <code><a href="#EnumType.name">name</a></code> and <code><a href="#EnumType.enum_dict">enum_dict</a></code> should not be modified by
|
|
4450 |
the user.</p>
|
|
4451 |
</div>
|
|
4452 |
|
|
4453 |
|
|
4454 |
<div id="EnumType.__init__" class="classattr">
|
|
4455 |
<div class="attr function"><a class="headerlink" href="#EnumType.__init__">#  </a>
|
|
4456 |
|
|
4457 |
|
|
4458 |
<span class="name">EnumType</span><span class="signature">()</span>
|
|
4459 |
</div>
|
|
4460 |
|
|
4461 |
|
|
4462 |
<div class="docstring"><p><strong><code>__init__(group, datatype, datatype_name, enum_dict)</code></strong></p>
|
|
4463 |
|
|
4464 |
<p>EnumType constructor.</p>
|
|
4465 |
|
|
4466 |
<p><strong><code>group</code></strong>: <code><a href="#Group">Group</a></code> instance to associate with the VLEN datatype.</p>
|
|
4467 |
|
|
4468 |
<p><strong><code>datatype</code></strong>: An numpy integer dtype object describing the base type
|
|
4469 |
for the Enum.</p>
|
|
4470 |
|
|
4471 |
<p><strong><code>datatype_name</code></strong>: a Python string containing a description of the
|
|
4472 |
Enum data type.</p>
|
|
4473 |
|
|
4474 |
<p><strong><code><a href="#EnumType.enum_dict">enum_dict</a></code></strong>: a Python dictionary containing the Enum field/value
|
|
4475 |
pairs.</p>
|
|
4476 |
|
|
4477 |
<p><strong><em><code>Note</code></em></strong>: <code><a href="#EnumType">EnumType</a></code> instances should be created using the
|
|
4478 |
<code><a href="#Dataset.createEnumType">Dataset.createEnumType</a></code> method of a <code><a href="#Dataset">Dataset</a></code> or
|
|
4479 |
<code><a href="#Group">Group</a></code> instance, not using this class directly.</p>
|
|
4480 |
</div>
|
|
4481 |
|
|
4482 |
|
|
4483 |
</div>
|
|
4484 |
<div id="EnumType.dtype" class="classattr">
|
|
4485 |
<div class="attr variable"><a class="headerlink" href="#EnumType.dtype">#  </a>
|
|
4486 |
|
|
4487 |
<span class="name">dtype</span><span class="default_value"> = <attribute 'dtype' of '<a href="#_netCDF4.EnumType">netCDF4._netCDF4.EnumType</a>' objects></span>
|
|
4488 |
</div>
|
|
4489 |
|
|
4490 |
|
|
4491 |
|
|
4492 |
</div>
|
|
4493 |
<div id="EnumType.name" class="classattr">
|
|
4494 |
<div class="attr variable"><a class="headerlink" href="#EnumType.name">#  </a>
|
|
4495 |
|
|
4496 |
<span class="name">name</span><span class="default_value"> = <attribute 'name' of '<a href="#_netCDF4.EnumType">netCDF4._netCDF4.EnumType</a>' objects></span>
|
|
4497 |
</div>
|
|
4498 |
|
|
4499 |
|
|
4500 |
|
|
4501 |
</div>
|
|
4502 |
<div id="EnumType.enum_dict" class="classattr">
|
|
4503 |
<div class="attr variable"><a class="headerlink" href="#EnumType.enum_dict">#  </a>
|
|
4504 |
|
|
4505 |
<span class="name">enum_dict</span><span class="default_value"> = <attribute 'enum_dict' of '<a href="#_netCDF4.EnumType">netCDF4._netCDF4.EnumType</a>' objects></span>
|
|
4506 |
</div>
|
|
4507 |
|
|
4508 |
|
|
4509 |
|
|
4510 |
</div>
|
|
4511 |
</section>
|
|
4512 |
<section id="get_chunk_cache">
|
|
4513 |
<div class="attr function"><a class="headerlink" href="#get_chunk_cache">#  </a>
|
|
4514 |
|
|
4515 |
|
|
4516 |
<span class="def">def</span>
|
|
4517 |
<span class="name">get_chunk_cache</span><span class="signature">(unknown)</span>:
|
|
4518 |
</div>
|
|
4519 |
|
|
4520 |
|
|
4521 |
<div class="docstring"><p><strong><code><a href="#get_chunk_cache">get_chunk_cache()</a></code></strong></p>
|
|
4522 |
|
|
4523 |
<p>return current netCDF chunk cache information in a tuple (size,nelems,preemption).
|
|
4524 |
See netcdf C library documentation for <code>nc_get_chunk_cache</code> for
|
|
4525 |
details. Values can be reset with <code><a href="#set_chunk_cache">set_chunk_cache</a></code>.</p>
|
|
4526 |
</div>
|
|
4527 |
|
|
4528 |
|
|
4529 |
</section>
|
|
4530 |
<section id="set_chunk_cache">
|
|
4531 |
<div class="attr function"><a class="headerlink" href="#set_chunk_cache">#  </a>
|
|
4532 |
|
|
4533 |
|
|
4534 |
<span class="def">def</span>
|
|
4535 |
<span class="name">set_chunk_cache</span><span class="signature">(unknown)</span>:
|
|
4536 |
</div>
|
|
4537 |
|
|
4538 |
|
|
4539 |
<div class="docstring"><p><strong><code>set_chunk_cache(self,size=None,nelems=None,preemption=None)</code></strong></p>
|
|
4540 |
|
|
4541 |
<p>change netCDF4 chunk cache settings.
|
|
4542 |
See netcdf C library documentation for <code>nc_set_chunk_cache</code> for
|
|
4543 |
details.</p>
|
|
4544 |
</div>
|
|
4545 |
|
|
4546 |
|
4342 | 4547 |
</section>
|
4343 | 4548 |
</main>
|
4344 | 4549 |
</body>
|