Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #76934
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.mixmin.net!hq-usenetpeers.eweka.nl!hq-usenetpeers.eweka.nl!xlned.com!feeder5.xlned.com!newsfeed.xs4all.nl!newsfeed4a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <gary.herron@islandtraining.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.001 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; '480': 0.05; 'subject:Python': 0.06; 'binary': 0.07; 'subject:code': 0.07; 'correct,': 0.09; 'output,': 0.09; 'received:67.192': 0.09; 'received:67.192.241': 0.09; 'received:dfw.emailsrvr.com': 0.09; 'subject:into': 0.09; 'python': 0.11; "'rb')": 0.16; '*must*': 0.16; 'code?': 0.16; 'does,': 0.16; 'here.\xa0': 0.16; 'paste.': 0.16; 'skip:n 90': 0.16; 'subject:simple': 0.16; 'url:gz': 0.16; 'url:nasa': 0.16; 'do,': 0.16; 'wrote:': 0.18; 'code.': 0.18; 'meant': 0.20; 'code,': 0.22; 'saying': 0.22; 'header:User- Agent:1': 0.23; 'error': 0.23; 'received:emailsrvr.com': 0.24; 'url:gov': 0.24; 'received:(smtp server)': 0.26; 'code:': 0.26; 'skip:" 20': 0.27; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; "doesn't": 0.30; 'code': 0.31; 'gary': 0.31; 'second,': 0.31; 'file': 0.32; 'probably': 0.32; 'supposed': 0.32; 'actual': 0.34; 'but': 0.35; 'there': 0.35; 'wrong': 0.37; 'two': 0.37; 'same.': 0.38; 'to:addr:python-list': 0.38; 'expect': 0.39; 'does': 0.39; 'to:addr:python.org': 0.39; 'tell': 0.60; 'first': 0.61; 'here:': 0.62; 'charset:windows-1252': 0.65; 'here': 0.66; 'results': 0.69; 'legal': 0.71; 'cut': 0.74; 'contents,': 0.84; 'absolutely': 0.87; 'examine': 0.93; 'obtained': 0.96 |
| X-Virus-Scanned | OK |
| X-Sender-Id | gary.herron@islandtraining.com |
| Date | Sun, 24 Aug 2014 10:40:27 -0700 |
| From | Gary Herron <gary.herron@islandtraining.com> |
| User-Agent | Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.0 |
| MIME-Version | 1.0 |
| To | python-list@python.org |
| Subject | Re: Challenge to convert a simple IDL code into Python |
| References | <CAMorJ8FXPp0Ne7YBaBCr4N_mTHUScK56LzpM76-ENvEe=-iTdg@mail.gmail.com> |
| In-Reply-To | <CAMorJ8FXPp0Ne7YBaBCr4N_mTHUScK56LzpM76-ENvEe=-iTdg@mail.gmail.com> |
| Content-Type | multipart/alternative; boundary="------------010800030801090401050106" |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.13378.1408902408.18130.python-list@python.org> (permalink) |
| Lines | 487 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1408902408 news.xs4all.nl 2830 [2001:888:2000:d::a6]:60437 |
| X-Complaints-To | abuse@xs4all.nl |
| X-Received-Bytes | 30534 |
| X-Received-Body-CRC | 4024614238 |
| Xref | csiph.com comp.lang.python:76934 |
Show key headers only | View raw
[Multipart message — attachments visible in raw view] - view raw
On 08/24/2014 08:38 AM, Cleo Drakos wrote:
>
> Here is IDL code:
>
> |pro read_binary_file
>
> file= "3B42RT.2014010318.7.bin"
>
> num_lon= 1440
> num_lat= 480
>
> data= {header: bytarr(num_lon*2), precip: intarr(num_lon,num_lat), precip_error: intarr(num_lon,num_lat), $
> source_of_estimate: bytarr(num_lon,num_lat), precip_uncal: intarr(num_lon,num_lat)}
>
> close, 1
> openr, 1, file
> readu, 1, data
> close, 1
> precip= swap_endian(data.precip)
>
> print, precip
> end|
>
> My attempt in Python is here:
>
> |fname= '3B42RT.2014010318.7.bin'
>
> num_lon= 1440
> num_lat= 480
>
> with open(fname, 'rb') as fi:
> contents= fi.read()
> precip= struct.unpack_from('>'+str(num_lon*num_lat)+'I', contents, offset= num_lon*2)
>
> precip= np.array(data,dtype=int)
> precip data|
>
> But, the results obtained from two codes above are not same. The IDL
> code is correct, but what is wrong with my python code?
>
You are not giving us much to go on here.
First that's not legal Python . The |last line was probably meant to be
a print|||, but if you expect us to examine your code, you absolutely
*must* give us the actual code. Please cut and paste.
Second, saying it doesn't work us useless. Please tell us what the code
is supposed to do, and what it actually does, what you expected... If
there is output, cut and paste it. If there is an error traceback, cut
and paste it.
While you are at it, tell us what the IDL code does and cut and paste
it's output.
Gary Herron
> Here is binary file I was working
> with:ftp://trmmopen.gsfc.nasa.gov/pub/merged/3B42RT/3B42RT.2014010318.7.bin.gz
>
>
> cleo
>
>
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: Challenge to convert a simple IDL code into Python Gary Herron <gary.herron@islandtraining.com> - 2014-08-24 10:40 -0700
csiph-web