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

Home » Public Forums » archive » Opening and read .dat file double format
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Opening and read .dat file double format [message #92481 is a reply to message #92480] Sat, 26 December 2015 04:00 Go to previous messageGo to previous message
alghafisuct is currently offline  alghafisuct
Messages: 20
Registered: November 2014
Junior Member
On Saturday, December 26, 2015 at 3:14:12 AM UTC-8, Helder wrote:
> On Saturday, December 26, 2015 at 9:12:21 AM UTC, algha...@gmail.com wrote:
>> On Friday, December 25, 2015 at 2:11:02 PM UTC-8, Helder wrote:
>>> On Friday, December 25, 2015 at 1:05:20 PM UTC, algha...@gmail.com wrote:
>>>> On Wednesday, December 23, 2015 at 3:33:21 AM UTC-8, Helder wrote:
>>>> > On Wednesday, December 23, 2015 at 8:49:31 AM UTC, algha...@gmail.com wrote:
>>>> > > On Monday, December 21, 2015 at 3:17:33 AM UTC-8, Helder wrote:
>>>> > > > On Monday, December 21, 2015 at 11:04:11 AM UTC, algha...@gmail.com wrote:
>>>> > > > > On Monday, December 21, 2015 at 1:42:19 AM UTC-8, Helder wrote:
>>>> > > > > > On Monday, December 21, 2015 at 8:14:22 AM UTC, algha...@gmail.com wrote:
>>>> > > > > > > On Sunday, December 20, 2015 at 9:52:23 AM UTC-8, Helder wrote:
>>>> > > > > > > > On Sunday, December 20, 2015 at 4:42:19 PM UTC, algha...@gmail.com wrote:
>>>> > > > > > > > > On Friday, December 18, 2015 at 7:22:10 AM UTC-8, Craig Markwardt wrote:
>>>> > > > > > > > > > On Friday, December 18, 2015 at 7:26:07 AM UTC-5, algha...@gmail.com wrote:
>>>> > > > > > > > > > > Hi everyone
>>>> > > > > > > > > > >
>>>> > > > > > > > > > > I have a .dat file double and is 5000 by 8039. I'm using the file in Matlab and I want to try to open it in IDL. So I know it is very basic question but I'm new in IDL and I want to start using it. After I open the file, I want to read like the value of (1,1)
>>>> > > > > > > > > >
>>>> > > > > > > > > > What format is the data in? ASCII? Binary? Matlab format? It makes a difference.
>>>> > > > > > > > >
>>>> > > > > > > > > Thanks Craig
>>>> > > > > > > > >
>>>> > > > > > > > > My data is Binary double format and I used the following because I want to extact the image to see as I'm doing in Matlab
>>>> > > > > > > > >
>>>> > > > > > > > > template = BINARY_TEMPLATE('C:\Users\asus\Desktop\Metasensing\IDL_PROJE CTS\20151021115853_11_SAR_CPLX_0_pres_8.dat')
>>>> > > > > > > > > Result = READ_BINARY('C:\Users\asus\Desktop\Metasensing\IDL_PROJECTS\ 20151021115853_11_SAR_CPLX_0_pres_8.dat', DATA_DIMS = [4999, 8038])
>>>> > > > > > > > > im = IMAGE(Result)
>>>> > > > > > > > > end
>>>> > > > > > > > >
>>>> > > > > > > > > But I got an image meaning nothing to me only white and black image
>>>> > > > > > > > >
>>>> > > > > > > > > Am I doing the right way or there are other ways to see the image
>>>> > > > > > > > >
>>>> > > > > > > > > Thanks
>>>> > > > > > > >
>>>> > > > > > > > Difficult to tell.
>>>> > > > > > > > My suggestion would be to try:
>>>> > > > > > > > template = BINARY_TEMPLATE('C:\Users\asus\Desktop\Metasensing\IDL_PROJE CTS\20151021115853_11_SAR_CPLX_0_pres_8.dat')
>>>> > > > > > > > Result = READ_BINARY('C:\Users\asus\Desktop\Metasensing\IDL_PROJECTS\ 20151021115853_11_SAR_CPLX_0_pres_8.dat', DATA_DIMS = [4999, 8038])
>>>> > > > > > > > mn = min(Result, max=mx)
>>>> > > > > > > > print, mn, mx
>>>> > > > > > > > im = IMAGE(Result)
>>>> > > > > > > > im.min_value = mn
>>>> > > > > > > > im.max_value = mx
>>>> > > > > > > >
>>>> > > > > > > > Any better? If not, what does "print, mn, mx" show? If you're getting the same value, then there must a problem with the import (read_binary()). (*)
>>>> > > > > > > >
>>>> > > > > > > > Cheers,
>>>> > > > > > > > Helder
>>>> > > > > > > >
>>>> > > > > > > > (*) - or the min/max values are not evenly distributed. Meaning that if one pixel is 0, one is 1000 and the rest of your data is distributed between 500 and 501... then you won't see much unless you set min_value and max_value at 500 and 501. You could also try to have a look at the histogram distribution.
>>>> > > > > > >
>>>> > > > > > > Hi
>>>> > > > > > >
>>>> > > > > > > I got the same thing and the min vale is 0 and the max value is 255
>>>> > > > > > >
>>>> > > > > > > any suggestions ?
>>>> > > > > >
>>>> > > > > > I just noticed that you import using BINARY_TEMPLATE() and READ_BINARY(). I never used these functions because I normally know how my template looks like and use readu directely. I'll try to do some guess work: it seems to me as if you're missing something. With binary_template you generate a structure for importing data that you call "template". This template should be used in READ_BINARY() to import the data, but you don't use it.
>>>> > > > > > Why don't you try:
>>>> > > > > > Result = READ_BINARY('C:\Users\asus\Desktop\Metasensing\IDL_PROJECTS\ 20151021115853_11_SAR_CPLX_0_pres_8.dat', template=template, DATA_DIMS = [4999, 8038])
>>>> > > > > >
>>>> > > > > > and see what happens.
>>>> > > > > >
>>>> > > > > > If that doesn't work out. Do you know how the data is stored? If it's a simple array of doubles, you could use something like:
>>>> > > > > >
>>>> > > > > > array = make_array(4999, 8038, /double, /nozero)
>>>> > > > > > filename = 'C:\....' ;your file name
>>>> > > > > > OPENR, importUnit, filename, /GET_LUN
>>>> > > > > > READU, importUnit, array
>>>> > > > > > CLOSE, importUnit
>>>> > > > > > FREE_LUN, importUnit
>>>> > > > > > im = IMAGE(array)
>>>> > > > > >
>>>> > > > > > cheers,
>>>> > > > > > Helder
>>>> > > > >
>>>> > > > > Thank you very much it's good know. I tried the OPENR way it's double.
>>>> > > > >
>>>> > > > > On my MATLAB code I seprated real and imaginary such as the following
>>>> > > > >
>>>> > > > > array = array (1:2:end, :) + j * array (2:2:end, :);
>>>> > > > >
>>>> > > > > how can that be done in IDL so I can have imagenary and real values
>>>> > > > >
>>>> > > > > Thanks
>>>> > > >
>>>> > > > I don't know Matlab. But I guess (yes, it's a guess...) that those Matlab commands put every odd position value in the real part and even position values in the imaginary part. If so, then I would try with:
>>>> > > > array = make_array(4999, 8038, /dcomplex, /nozero)
>>>> > > > This is also a guess... but I suppose that imaginary data is written this way.
>>>> > > > Try this and then display the image as:
>>>> > > >
>>>> > > > im_r = IMAGE(real_part(array))
>>>> > > > im_i = IMAGE(imaginary(array))
>>>> > > >
>>>> > > > and you should see real and imaginary part displayed. Then you can play around and use other useful commands for imaginary data: abs() and atan(). See the help for details:
>>>> > > > http://www.exelisvis.com/docs/ABS.html
>>>> > > > http://www.exelisvis.com/docs/ATAN.html with the phase keyword.
>>>> > > >
>>>> > > > Cheers,
>>>> > > > Helder
>>>> > >
>>>> > > Thanks Helder for the help
>>>> > >
>>>> > > I tried print,ABS(image(array)) and im_r = IMAGE(real_part(array)) and im_i = IMAGE(imaginary(array)) to see images but I'm getting the following :
>>>> > >
>>>> > > % IMAGE: Unable to allocate memory: to make array.
>>>> > >
>>>> > > if the problem is the memory is not enough, how can I get a small subset of the image and save it as a new file then I can see if it is working
>>>> > >
>>>> > > Thanks
>>>> >
>>>> > Hi,
>>>> > I think that the command:
>>>> > print,ABS(image(array))
>>>> > makes no sense.
>>>> >
>>>> > What happens if you try this:
>>>> > im_r = real_part(array)
>>>> > im_i = imaginary(array)
>>>> >
>>>> > Everything ok? (it should not give an error unless you run out of memory)
>>>> > If that is ok, then you can try to reduce the size of the images. Given that you have an odd number of rows (8039), you're going to have to use congrid to reduce the size of the image:
>>>> > smaller_im_r = congrid(im_r,5000/10.0,8039/10.0)
>>>> > smaller_im_i = congrid(im_i,5000/10.0,8039/10.0)
>>>> > then
>>>> > oIm_r = image(smaller_im_r)
>>>> > oIm_i = image(smaller_im_i)
>>>> >
>>>> > If you do get an error, you have to tell me *which* line generated the error.
>>>> >
>>>> > Cheers,
>>>> > Helder
>>>>
>>>> Thanks Helder for the help I finally got the image as follows
>>>>
>>>> array_VV = make_array(5000, 5359, /dcomplex, /nozero)
>>>> filename_VV = ('C:\Users\asus\Desktop\Metasensing\IDL_PROJECTS\20151021115 853_22_SAR_CPLX_0_pres_8.dat')
>>>> OPENR, importUnit, filename_VV, /GET_LUN
>>>> READU, importUnit, array_VV
>>>> A_VV = ABS(array_VV)
>>>> B_VV = A_VV^(0.7/2)
>>>> images_VV = image(B_VV, TITLE='Intensity VV')
>>>> CLOSE, importUnit
>>>> FREE_LUN, importUnit
>>>> end
>>>>
>>>> Know I have two things to solve. The first one is the gray image is a little bit dark so how can I increase the intensity of it and make it more brighter
>>>>
>>>> The secound is I want to open other .dat file dcomplex in the same page with the same number of array so I can compare them. Can I just copy the previouse thinf and pate it and change the file path ? is that right as follow
>>>>
>>>> array_HH = make_array(5000, 5359, /dcomplex, /nozero)
>>>> filename_HH = ('C:\Users\asus\Desktop\Metasensing\IDL_PROJECTS\20151021115 853_11_SAR_CPLX_0_pres_8.dat')
>>>> OPENR, importUnit, filename_HH, /GET_LUN
>>>> READU, importUnit, array_HH
>>>> A = ABS(array_HH)
>>>> B = A^(0.7/2)
>>>> image_HH = image(B, TITLE='Intensity HH')
>>>> CLOSE, importUnit
>>>> FREE_LUN, importUnit
>>>> array_VV = make_array(5000, 5359, /dcomplex, /nozero)
>>>> filename_VV = ('C:\Users\asus\Desktop\Metasensing\IDL_PROJECTS\20151021115 853_22_SAR_CPLX_0_pres_8.dat')
>>>> OPENR, importUnit, filename_VV, /GET_LUN
>>>> READU, importUnit, array_VV
>>>> A_VV = ABS(array_VV)
>>>> B_VV = A_VV^(0.7/2)
>>>> images_VV = image(B_VV, TITLE='Intensity VV')
>>>> CLOSE, importUnit
>>>> FREE_LUN, importUnit
>>>> end
>>>>
>>>>
>>>> Thanks you
>>>
>>> A couple of comments:
>>> 1) after opening and reading the file, you can close it right away:
>>>
>>>> OPENR, importUnit, filename_VV, /GET_LUN
>>>> READU, importUnit, array_VV
>>>> CLOSE, importUnit
>>>> FREE_LUN, importUnit
>>>> A_VV = ABS(array_VV)
>>>> B_VV = A_VV^(0.7/2)
>>>> images_VV = image(B_VV, TITLE='Intensity VV')
>>>
>>> 2) regarding your question:
>>>> Know I have two things to solve. The first one is the gray image is a little bit dark so how can I increase the intensity of it and make it more brighter
>>>
>>> remember my answer:
>>> im.min_value = mn
>>> im.max_value = mx
>>>
>>> check what im.max_value is and try to make it lower. This defines the white level.
>>>
>>> 3) same page? Try to adapt this code:
>>>
>>> ww = window(dimensions=[1200,600])
>>> im1 = image(/test, margin=0, layout=[2,1,1], current=ww)
>>> im2 = image(/test, margin=0, layout=[2,1,2], current=ww)
>>>
>>> Check http://www.exelisvis.com/docs/IMAGE.html for details.
>>>
>>> Keep in mind that every image is about 400 Mb. Are you using 64-bit version of IDL (type print, !version to find out)
>>>
>>> Cheers,
>>> Helder
>>
>> Thanks Helder
>>
>> What I mean in 3 is to open and read more than one file (complex- double ) and all the files have the same number of colomus and raws (5000,5359). So do I tried to do the previous step of opening a file twice but did not work
>> The first file is:
>> array_HH = make_array(5000, 5359, /dcomplex, /nozero)
>> filename = ('C:\Users\asus\Desktop\Metasensing\IDL_PROJECTS\20151021115 853_11_SAR_CPLX_0_pres_8.dat')
>> OPENR, importUnit, filename, /GET_LUN
>> READU, importUnit, array_HH
>> CLOSE, importUnit
>> FREE_LUN, importUnit
>>
>> array_VV = make_array(5000, 5359, /dcomplex, /nozero)
>> filename_VV =('C:\Users\asus\Desktop\Metasensing\IDL_PROJECTS\2015102111 5853_22_SAR_CPLX_0_pres_8.dat')
>> OPENR, importUnit, filename_VV, /GET_LUN
>> READU, importUnit, array_VV
>> CLOSE, importUnit
>> FREE_LUN, importUnit
>> end
>>
>> This is what I need so I can compare things from file array_HH to array_VV
>>
>> Thanks
>
> why wouldn't that work? what is the error message? Which line throws the error?
> You've gotta tell a bit more if you want some response...
>
> h

Sorry Helder When I run it in my desktop it works now but not in the laptob and I think memory issues

Thanks
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: 4D interpolation
Next Topic: DLM for video capture

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

Current Time: Wed Oct 08 16:09:47 PDT 2025

Total time taken to generate the page: 0.00200 seconds