Re: number formats inputing ascii data [message #43817] |
Sat, 30 April 2005 13:35 |
Craig Markwardt
Messages: 1869 Registered: November 1996
|
Senior Member |
|
|
"Haje Korth" <haje.korth@jhuapl.edu> writes:
> Dave,
> I see two issues you can try:
> 1. You are defining aa=0l. Why do you define as a long if you want a double
> in the end? Try aa=0.0d0 and so on
> 2. Your combo array is defined as float (fltarr). Use dblarr to get a double
> precision array.
And,
3. The FORMAT keyword does not appear to be correct. For me to get it
to work, I need () parentheses.
4. You don't need to give both the LUN and the FILENAME, pick one.
Craig
>
> Haje
>
>
>
>
> "dave" <dcfinnegan@gmail.com> wrote in message
> news:1114784794.648073.62000@f14g2000cwb.googlegroups.com...
>> A quick question that I guess follows on to Ed's precision question.
>>
>> I'm having similar problems when I import an ascii datafile of X,Y,Z
>> values.
>>
>> the x and y values are utm meter and the z value is mm's
>>
>> When I import the data it definitely looks different than it should?
>>
>> I'm using the transread program from Craig M. to import the data. I've
>> attached a snipet of the data and the code below...any ideas?
>>
>> Dave
>>
>> ----data file
>> LAT LON ELEV
>> 37626408 5352625 668694
>> 37626406 5352080 671058
>> 37626406 5352015 674405
>> 37626405 5351812 682801
>> 37626409 5352791 668146
>> 37626405 5351757 686651
>> 37626405 5351655 694568
>> 37626407 5352339 669945
>> 37626405 5351701 690698
>> 37626405 5351914 677368
>> 37626411 5353354 666662
>> 37626409 5352874 667493
>> 37626410 5353031 666536
>> 37626404 5351470 702865
>> 37626408 5352625 668677
>> 37626407 5352209 670414
>> 37626411 5353456 668980
>> 37626406 5352034 673583
>> 37626412 5353788 666713
>> 37626409 5352920 667493
>> 37626404 5351554 698988
>> 37626409 5352837 667973
>> 37626404 5351406 709303
>> 37626404 5351424 707796
>> 37626404 5351517 700894
>> 37626410 5353003 666463
>> 37626409 5352883 667347
>> 37626409 5352874 667493
>> 37626410 5353003 666474
>> 37626409 5352948 667574
>> 37626408 5352717 668299
>> 37626405 5351868 679227
>> 37626407 5352394 670108
>> 37626404 5351646 695965
>> 37626408 5352569 669591
>> 37626406 5351988 675233
>> 37626407 5352339 670110
>> 37626406 5352172 670095
>> 37626408 5352597 668901
>> 37626407 5352422 670716
>> 37626408 5352560 668695
>> 37626405 5351674 690904
>> ---end data file
>>
>> pro plane_fit, x, y, z, file=filnam
>>
>> IF NOT Keyword_set(filnam) THEN BEGIN
>> filnam=dialog_PICKFILE( PATH=path,TITLE='Select xyz Data for',
>> /MULTIPLE_FILES, /MUST_EXIST)
>> ENDIF
>>
>> print, ''
>> print,'Filename: ', filnam
>> print, '
>>
>>
>> A = 0L & B = 0L & C =0L
>>
>> FOR i=0, N_ELEMENTS(FILNAM)- 1 DO BEGIN
>> Aa = 0L & Bb = 0L & Cc =0L
>> OPENR, lun, filnam[i], /GET_LUN
>> TRANSREAD, lun, Aa, Bb, Cc,FORMAT='D0.0, D0.0, D0.0', $
>> FILENAME=filnam[i]
>> FREE_LUN, lun
>> xA=[A,Aa]
>> yB=[B,Bb]
>> zC=[C,Cc]
>> ENDFOR
>>
>>
>> print, 'number of data lines: ', n_elements(xA)
>>
>> ;---Extracting the data from the variables
>> lon=xA[*]
>> lat=yB[*]
>> elev=zC[*]
>>
>> ;-- Creating a 3 column dbl array to house the lon, lat and elev data
>> combo=fltarr(3,N_ELEMENTS(lon))
>>
>> ;-- Passing the data into the array
>> combo[0,*] = lon
>> combo[1,*] = lat
>> combo[2,*] = elev
>> data=combo
>> print, 'first lines of data from original file: ', data(*, 0:2)
>> ;--Display the original data
>> return
>> end;
>>
>> Thanks in advance,
>>
>> Dave
>>
>
>
--
------------------------------------------------------------ --------------
Craig B. Markwardt, Ph.D. EMAIL: craigmnet@REMOVEcow.physics.wisc.edu
Astrophysics, IDL, Finance, Derivatives | Remove "net" for better response
------------------------------------------------------------ --------------
|
|
|
Re: number formats inputing ascii data [message #43824 is a reply to message #43817] |
Fri, 29 April 2005 08:43  |
Haje Korth
Messages: 651 Registered: May 1997
|
Senior Member |
|
|
Dave,
I see two issues you can try:
1. You are defining aa=0l. Why do you define as a long if you want a double
in the end? Try aa=0.0d0 and so on
2. Your combo array is defined as float (fltarr). Use dblarr to get a double
precision array.
Haje
"dave" <dcfinnegan@gmail.com> wrote in message
news:1114784794.648073.62000@f14g2000cwb.googlegroups.com...
> A quick question that I guess follows on to Ed's precision question.
>
> I'm having similar problems when I import an ascii datafile of X,Y,Z
> values.
>
> the x and y values are utm meter and the z value is mm's
>
> When I import the data it definitely looks different than it should?
>
> I'm using the transread program from Craig M. to import the data. I've
> attached a snipet of the data and the code below...any ideas?
>
> Dave
>
> ----data file
> LAT LON ELEV
> 37626408 5352625 668694
> 37626406 5352080 671058
> 37626406 5352015 674405
> 37626405 5351812 682801
> 37626409 5352791 668146
> 37626405 5351757 686651
> 37626405 5351655 694568
> 37626407 5352339 669945
> 37626405 5351701 690698
> 37626405 5351914 677368
> 37626411 5353354 666662
> 37626409 5352874 667493
> 37626410 5353031 666536
> 37626404 5351470 702865
> 37626408 5352625 668677
> 37626407 5352209 670414
> 37626411 5353456 668980
> 37626406 5352034 673583
> 37626412 5353788 666713
> 37626409 5352920 667493
> 37626404 5351554 698988
> 37626409 5352837 667973
> 37626404 5351406 709303
> 37626404 5351424 707796
> 37626404 5351517 700894
> 37626410 5353003 666463
> 37626409 5352883 667347
> 37626409 5352874 667493
> 37626410 5353003 666474
> 37626409 5352948 667574
> 37626408 5352717 668299
> 37626405 5351868 679227
> 37626407 5352394 670108
> 37626404 5351646 695965
> 37626408 5352569 669591
> 37626406 5351988 675233
> 37626407 5352339 670110
> 37626406 5352172 670095
> 37626408 5352597 668901
> 37626407 5352422 670716
> 37626408 5352560 668695
> 37626405 5351674 690904
> ---end data file
>
> pro plane_fit, x, y, z, file=filnam
>
> IF NOT Keyword_set(filnam) THEN BEGIN
> filnam=dialog_PICKFILE( PATH=path,TITLE='Select xyz Data for',
> /MULTIPLE_FILES, /MUST_EXIST)
> ENDIF
>
> print, ''
> print,'Filename: ', filnam
> print, '
>
>
> A = 0L & B = 0L & C =0L
>
> FOR i=0, N_ELEMENTS(FILNAM)- 1 DO BEGIN
> Aa = 0L & Bb = 0L & Cc =0L
> OPENR, lun, filnam[i], /GET_LUN
> TRANSREAD, lun, Aa, Bb, Cc,FORMAT='D0.0, D0.0, D0.0', $
> FILENAME=filnam[i]
> FREE_LUN, lun
> xA=[A,Aa]
> yB=[B,Bb]
> zC=[C,Cc]
> ENDFOR
>
>
> print, 'number of data lines: ', n_elements(xA)
>
> ;---Extracting the data from the variables
> lon=xA[*]
> lat=yB[*]
> elev=zC[*]
>
> ;-- Creating a 3 column dbl array to house the lon, lat and elev data
> combo=fltarr(3,N_ELEMENTS(lon))
>
> ;-- Passing the data into the array
> combo[0,*] = lon
> combo[1,*] = lat
> combo[2,*] = elev
> data=combo
> print, 'first lines of data from original file: ', data(*, 0:2)
> ;--Display the original data
> return
> end;
>
> Thanks in advance,
>
> Dave
>
|
|
|