Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!tudelft.nl!txtfeed1.tudelft.nl!feeder3.cambriumusenet.nl!feed.tweaknews.nl!194.134.4.91.MISMATCH!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!194.109.133.85.MISMATCH!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.004 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'library,': 0.05; 'mode,': 0.07; 'skipping': 0.07; 'variable,': 0.07; 'python': 0.08; 'array.': 0.09; 'curious.': 0.09; '2.7': 0.13; 'binary': 0.13; 'numpy': 0.16; 'subject:variable': 0.16; 'cc:addr:python-list': 0.16; 'wrote:': 0.18; 'bytes': 0.18; 'seems': 0.20; 'cc:no real name:2**0': 0.21; 'trying': 0.21; 'file,': 0.21; 'appropriate': 0.22; 'header:In-Reply-To:1': 0.22; 'creating': 0.25; 'modify': 0.25; 'scale': 0.25; 'cc:2**0': 0.26; 'asking': 0.28; 'variable': 0.28; "i'm": 0.28; 'module.': 0.29; 'cc:addr:python.org': 0.29; 'pm,': 0.29; 'error': 0.30; 'file.': 0.31; 'version': 0.32; 'anyone': 0.32; 'does': 0.32; "can't": 0.33; 'header:User- Agent:1': 0.33; 'it.': 0.33; 'file': 0.34; 'done.': 0.34; 'hi,': 0.34; 'help,': 0.35; 'post': 0.36; 'link,': 0.37; 'but': 0.37; 'similar': 0.37; 'using': 0.37; 'received:192': 0.38; 'some': 0.38; 'getting': 0.38; 'should': 0.38; 'back': 0.60; 'you.': 0.62; 'kind': 0.62; 'special': 0.66; 'header:Reply-To:1': 0.70; 'reply- to:no real name:2**0': 0.72; 'hand,': 0.76; 'manuals': 0.84 Date: Mon, 20 Feb 2012 17:52:51 -0500 From: Dave Angel User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.24) Gecko/20111109 Thunderbird/3.1.16 MIME-Version: 1.0 To: Sheldon Subject: Re: netCDF4 variable manipulation References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Provags-ID: V02:K0:ec540NhxhyIIgDLFubtqIeCrtCdvk0LnZJV6toCYbwe TavoOJmFdACqiL9GCvd5wMZMcqYPxRYtSXyXF3Ty5Ib60xnfAz SuJMFfCBZHDL/KsMaJweCHOwfJUTSMBPG8vga7k6umOTBb3DO9 fJ/3PahSbOxDUE5k8+cqtvsnAEv6yD7CQJiAXbJcFHTyZ8cwt9 65DdPuQx7eJxL+4V3fUWjdSFUkRX9zaZT+yxO2Q3dDzz17bse1 ztTZn82mIWDLFYvRoZxZqwNwDb/raK7YVFvWJfpmPtmaRBfhvW Vxad4YVsicSzuS5hISklgjPIY6IEc7OK40/AQ2AXvQWzFhR+SK OBGenygH0bNgkTMYbf6s= Cc: python-list@python.org X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list Reply-To: d@davea.name List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 32 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1329778379 news.xs4all.nl 6909 [2001:888:2000:d::a6]:54174 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:20636 On 02/20/2012 03:37 PM, Sheldon wrote: > Hi, > > I'm trying to read a netCDF4 variable from a file (no problem) and > then scale it before writing over the original variable in the file. > > I'm using python 2.7 and the latest netCDF4 module. It's not that I > keep getting an error message but I want to do this without using for > loops and all the manuals seems to be skipping this task as if it is > never done. I'm new to python and coming over from matlab. Does anyone > know how to modify the netCDF4 variable in python and then write it > back without creating a new variable, or using for loops? > > Appreciate the help, > /S Are you using netcdf version 4, or is that name just a coincidence? If you're using a 3rd party library, you really should say so, and post a link, for those curious. in any case, if you are, I can't help you. This is apparently some special kind of variable similar to a numpy array. On the other hand, you may just be asking how to update some bytes in a file, in place. if you read the file in binary mode, then you can use seek() to go back the appropriate distance, and simply write it. -- DaveA