Re: raw contents of data memory [message #90310 is a reply to message #90270] |
Wed, 18 February 2015 19:45   |
Russell[1]
Messages: 101 Registered: August 2011
|
Senior Member |
|
|
Yeah XPA can work with fits and I was passing the data back and forth that way. It just still seemed strange that I had to write the fits file only to read it elsewhere. I was more or less fine with this, until I saw that someone cracked this in Python. Meaning, they managed to send the data to XPA and then ds9 by passing it through XPA's stdin and not using cat. From looking at their code, it seemed the feature I was missing was numpy.tostring()...
R
On Wednesday, February 18, 2015 at 5:07:43 PM UTC-5, Chris Torrence wrote:
> On Wednesday, February 18, 2015 at 2:35:24 PM UTC-7, rrya...@gmail.com wrote:
>> Hiya Chris
>>
>> The program is the XPA tools, which I'm using to pass data into/out of ds9 (which is an astronomical image viewer). I can make it work by doing:
>>
>>
>> foo=dist(100)
>> openw,1,'foo.arr'
>> writeu,1,foo
>> close,1
>> spawn,'cat foo.arr | xpaset ...." ; the ellipses stand for more options to xpaset which include the endianness and dimensionality/datatype of the data in foo.arr
>>
>> While this works, it can be painfully slow if the image is large, because it takes time to write the binary data to disk then to read it in with XPA. It just seems such a waste to write the ttempoary file "foo.arr" only to read it in, and then delete it immediately after it's written. I understand I'll have to transfer the data at least once, but it just seems like I should be able to transfer it directly to XPA w/o the intermediate step.
>>
>> I'll give IDL_BASE64 a try. I tried that already, but it was before I knew about David's pack float tutorial on repackaging a float as a byte array.
>>
>> Thanks again for your time, I knew you guys would know what to do.... DO you think I'm at least on the right track?
>>
>> Russell
>>
>>
>>
>>
>> On Wednesday, February 18, 2015 at 4:21:36 PM UTC-5, Chris Torrence wrote:
>>> On Wednesday, February 18, 2015 at 2:14:34 PM UTC-7, rrya...@gmail.com wrote:
>>>> Ah... Ok David this definitely smells like the right track... It's certainly the case that the data that your pack float tutorial makes is similar to the data that writeu sends out. But now I'm curious about strings, arrays, and so on.
>>>>
>>>> So, I can create a byte datatype like you said... well, sorta...
>>>>
>>>> img=dist(50)
>>>>
>>>> img=reform(img,50*50,/overwrite)
>>>>
>>>> dat=byte(img,0,4,50*50)
>>>>
>>>> dat=string(dat)
>>>>
>>>> Now, dat is the string encoded, binary data of the image. Do you have any idea of how to send that through stdin of another program? I guess it might depend on the details of the other program, but I guess I mean more like the datatype and/or commands to use... I was trying to do something like
>>>>
>>>>
>>>> spawn,'echo '+dat+' | some_other_program '
>>>>
>>>> but dat is an array... I guess I'm sorta confused here. I know what I want to do, but I'm not sure the right language or jargon to use when googling this or even asking you all.
>>>>
>>>> Thanks a million,
>>>> Russell
>>>>
>>>>
>>>>
>>>> On Wednesday, February 18, 2015 at 3:24:34 PM UTC-5, David Fanning wrote:
>>>>
>>>> >
>>>> > > Thanks for the response... but I'm not quite sure I understand. To be a bit more concrete, I have a 2-d floating point array that I want to convert using this type of thing. I can certainly write the data out using writeu, but I didn't know if there was a way to convert the data in IDL. I'm trying to pass the data into another program's stdin, and using byte or string or some such then that doesn't seem quite right...
>>>> >
>>>> > Maybe this is what you are looking for:
>>>> >
>>>> > http://www.idlcoyote.com/code_tips/packfloat.php
>>>> >
>>>> > Cheers,
>>>> >
>>>> > David
>>>> > --
>>>> > David Fanning, Ph.D.
>>>> > Fanning Software Consulting, Inc.
>>>> > Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
>>>> > Sepore ma de ni thue. ("Perhaps thou speakest truth.")
>>>
>>> Hi Russell,
>>>
>>> What language or application are you trying to send this to? What exactly is "some_other_program"?
>>>
>>> Why does it need to be a string?
>>>
>>> If it does need to be a string, you probably want to call IDL_BASE64 to encode the string so that the bytes don't get clobbered (things like null characters or carriage returns will mess you up).
>>>
>>> -Chris
>
> Well, I'm worried that XPA is not going to understand your Base64 string representation of the data. I'd be surprised if the file I/O is really the bottleneck. I have to imagine that the "cat" is the culprit. Is it possible to pass a FITS file to DS9? If that's possible, you could use the astrolib FITS functions to write out the data in that format, and then read it into DS9.
>
> Good luck!
> -Chris
|
|
|