comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: Rebin for strings
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: Rebin for strings [message #70095] Thu, 11 March 2010 19:35
Michael Galloy is currently offline  Michael Galloy
Messages: 1114
Registered: April 2006
Senior Member
On 3/11/10 2:31 pm, Gray wrote:
> Hi all,
>
> I'm looking for a way to expand a 1-d string array into 2-d, just like
> I would use rebin for almost any other data type. For example, I'd
> like to do something like this:
>
> IDL> o = ['d','b','m','q','t']
> IDL> oo = rebin(transpose(o),14,5,/sample)
>
> But obviously that won't work. Is there a better way than something
> like this (which is okay here, but for more complicated examples might
> not be feasible):
>
> IDL> tmp = execute('oo = transpose([['+strjoin(replicate('o',14),'],[')
> +']]'))
>
> Any suggestions would be helpful!
>
> --Gray

The correspondence between strings and byte arrays makes strings not so
different from other types:

IDL> oo = string(reform(rebin(byte(o), 14, 5), 1, 14, 5))

Mike
--
www.michaelgalloy.com
Research Mathematician
Tech-X Corporation
Re: Rebin for strings [message #70096 is a reply to message #70095] Thu, 11 March 2010 19:19 Go to previous message
Heinz Stege is currently offline  Heinz Stege
Messages: 189
Registered: January 2003
Senior Member
On Thu, 11 Mar 2010 13:31:53 -0800 (PST), Gray wrote:

> Hi all,
>
> I'm looking for a way to expand a 1-d string array into 2-d, just like
> I would use rebin for almost any other data type. For example, I'd
> like to do something like this:
>
> IDL> o = ['d','b','m','q','t']
> IDL> oo = rebin(transpose(o),14,5,/sample)
>
> But obviously that won't work. Is there a better way than something
> like this (which is okay here, but for more complicated examples might
> not be feasible):
>
> IDL> tmp = execute('oo = transpose([['+strjoin(replicate('o',14),'],[')
> +']]'))
>
> Any suggestions would be helpful!
>
> --Gray

My suggestion is:

o = ['d','b','m','q','t']
ii = rebin(lindgen(1,5),14,5,/sample)
oo = o[ii]

HTH, Heinz
Re: Rebin for strings [message #70102 is a reply to message #70096] Thu, 11 March 2010 14:18 Go to previous message
rogass is currently offline  rogass
Messages: 200
Registered: April 2008
Senior Member
On 11 Mrz., 23:05, Paolo <pgri...@gmail.com> wrote:
> On Mar 11, 4:31 pm, Gray <grayliketheco...@gmail.com> wrote:
>
>
>
>
>
>> Hi all,
>
>> I'm looking for a way to expand a 1-d string array into 2-d, just like
>> I would use rebin for almost any other data type.  For example, I'd
>> like to do something like this:
>
>> IDL> o = ['d','b','m','q','t']
>> IDL> oo = rebin(transpose(o),14,5,/sample)
>
>> But obviously that won't work.  Is there a better way than something
>> like this (which is okay here, but for more complicated examples might
>> not be feasible):
>
>> IDL> tmp = execute('oo = transpose([['+strjoin(replicate('o',14),'],[')
>> +']]'))
>
>> Any suggestions would be helpful!
>
> Well,
> what about a little looping?
>
> oo=strarr(14,5)
> for i=0,13 do oo[i,*]=o
>
> Loops are not that evil after all :)
> at least not for small-ish arrays.
>
> Ciao,
> Paolo
>
>
>
>
>
>> --Gray

Hi, why not: oo=(replicate({o : ['d','b','m','q','t']} ,14)).(0)

Cheers :)

CR
Re: Rebin for strings [message #70103 is a reply to message #70102] Thu, 11 March 2010 14:05 Go to previous message
pgrigis is currently offline  pgrigis
Messages: 436
Registered: September 2007
Senior Member
On Mar 11, 4:31 pm, Gray <grayliketheco...@gmail.com> wrote:
> Hi all,
>
> I'm looking for a way to expand a 1-d string array into 2-d, just like
> I would use rebin for almost any other data type.  For example, I'd
> like to do something like this:
>
> IDL> o = ['d','b','m','q','t']
> IDL> oo = rebin(transpose(o),14,5,/sample)
>
> But obviously that won't work.  Is there a better way than something
> like this (which is okay here, but for more complicated examples might
> not be feasible):
>
> IDL> tmp = execute('oo = transpose([['+strjoin(replicate('o',14),'],[')
> +']]'))
>
> Any suggestions would be helpful!

Well,
what about a little looping?

oo=strarr(14,5)
for i=0,13 do oo[i,*]=o

Loops are not that evil after all :)
at least not for small-ish arrays.

Ciao,
Paolo

>
> --Gray
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: idl program for calling c program
Next Topic: debugging a c-code called by CALL_EXTERNAL

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 19:05:21 PDT 2025

Total time taken to generate the page: 0.00604 seconds