Manipulation of array [message #92154] |
Tue, 20 October 2015 10:12  |
d.poreh
Messages: 406 Registered: October 2007
|
Senior Member |
|
|
Folks,
Hi,
I have an array like this:
.....
1.4230952e+01 4.1166347e+01 1.2507140e+00
1.4227723e+01 4.1166677e+01 1.1362271e+00
1.4237998e+01 4.1164458e+01 6.1420846e-01
1.4243945e+01 4.1163519e+01 9.6166451e-01
1.4240970e+01 4.1163741e+01 5.1939466e-01
1.4222639e+01 4.1165726e+01 9.7572900e-01
1.4234044e+01 4.1163449e+01 1.7582878e+00
1.4223516e+01 4.1164088e+01 9.9535919e-01
1.4232525e+01 4.1162614e+01 9.5377207e-01
1.4236729e+01 4.1161653e+01 6.0755449e-01
.....
and i want to select the lines with this attribute (n is the matrix's name):
idx=where(n[2,*] ge -10 and n[2,*] le 10, count)
that says select the lines that third column are between -10 and 10.
At the end
m=reform(n(idx),3, 28548)
BUT it is not working for me and the final array is like this:
14.2361 41.1661 0.928023
14.2310 41.1663 1.25071
14.2277 41.1667 1.13623
14.2380 41.1645 0.614208
14.2439 41.1635 0.961664
14.2410 41.1637 0.519395
14.2226 14.2235 0.607554
14.2266 41.1617 -26.9755
41.1580 -15.8549 14.3032
-5.20631 14.3030 41.1567
29.9021 41.1564 41.1564
14.3038 14.3019 41.1563
41.1564 41.1584 14.2994
41.1584 14.2988 14.3000
41.1579 14.2980 41.1580
-35.7340 14.2972 41.1575
.....
As you can see the data is mixed somehow>
Can someone pls give me some hand:)
Thanks in advance,
Cheers,
Dave
|
|
|
Re: Manipulation of array [message #92155 is a reply to message #92154] |
Tue, 20 October 2015 10:30   |
Lajos Foldy
Messages: 176 Registered: December 2011
|
Senior Member |
|
|
On Tuesday, October 20, 2015 at 7:12:24 PM UTC+2, dave poreh wrote:
> Folks,
> Hi,
> I have an array like this:
> .....
>
> 1.4230952e+01 4.1166347e+01 1.2507140e+00
> 1.4227723e+01 4.1166677e+01 1.1362271e+00
> 1.4237998e+01 4.1164458e+01 6.1420846e-01
> 1.4243945e+01 4.1163519e+01 9.6166451e-01
> 1.4240970e+01 4.1163741e+01 5.1939466e-01
> 1.4222639e+01 4.1165726e+01 9.7572900e-01
> 1.4234044e+01 4.1163449e+01 1.7582878e+00
> 1.4223516e+01 4.1164088e+01 9.9535919e-01
> 1.4232525e+01 4.1162614e+01 9.5377207e-01
> 1.4236729e+01 4.1161653e+01 6.0755449e-01
>
> .....
> and i want to select the lines with this attribute (n is the matrix's name):
>
> idx=where(n[2,*] ge -10 and n[2,*] le 10, count)
>
> that says select the lines that third column are between -10 and 10.
> At the end
>
> m=reform(n(idx),3, 28548)
>
> BUT it is not working for me and the final array is like this:
>
> 14.2361 41.1661 0.928023
> 14.2310 41.1663 1.25071
> 14.2277 41.1667 1.13623
> 14.2380 41.1645 0.614208
> 14.2439 41.1635 0.961664
> 14.2410 41.1637 0.519395
> 14.2226 14.2235 0.607554
> 14.2266 41.1617 -26.9755
> 41.1580 -15.8549 14.3032
> -5.20631 14.3030 41.1567
> 29.9021 41.1564 41.1564
> 14.3038 14.3019 41.1563
> 41.1564 41.1584 14.2994
> 41.1584 14.2988 14.3000
> 41.1579 14.2980 41.1580
> -35.7340 14.2972 41.1575
> .....
> As you can see the data is mixed somehow>
> Can someone pls give me some hand:)
> Thanks in advance,
> Cheers,
> Dave
m=n[*,idx]
regards,
Lajos
|
|
|
Re: Manipulation of array [message #92156 is a reply to message #92155] |
Tue, 20 October 2015 23:19  |
d.poreh
Messages: 406 Registered: October 2007
|
Senior Member |
|
|
On Tuesday, October 20, 2015 at 9:00:18 PM UTC+3:30, fawltyl...@gmail.com wrote:
> On Tuesday, October 20, 2015 at 7:12:24 PM UTC+2, dave poreh wrote:
>> Folks,
>> Hi,
>> I have an array like this:
>> .....
>>
>> 1.4230952e+01 4.1166347e+01 1.2507140e+00
>> 1.4227723e+01 4.1166677e+01 1.1362271e+00
>> 1.4237998e+01 4.1164458e+01 6.1420846e-01
>> 1.4243945e+01 4.1163519e+01 9.6166451e-01
>> 1.4240970e+01 4.1163741e+01 5.1939466e-01
>> 1.4222639e+01 4.1165726e+01 9.7572900e-01
>> 1.4234044e+01 4.1163449e+01 1.7582878e+00
>> 1.4223516e+01 4.1164088e+01 9.9535919e-01
>> 1.4232525e+01 4.1162614e+01 9.5377207e-01
>> 1.4236729e+01 4.1161653e+01 6.0755449e-01
>>
>> .....
>> and i want to select the lines with this attribute (n is the matrix's name):
>>
>> idx=where(n[2,*] ge -10 and n[2,*] le 10, count)
>>
>> that says select the lines that third column are between -10 and 10.
>> At the end
>>
>> m=reform(n(idx),3, 28548)
>>
>> BUT it is not working for me and the final array is like this:
>>
>> 14.2361 41.1661 0.928023
>> 14.2310 41.1663 1.25071
>> 14.2277 41.1667 1.13623
>> 14.2380 41.1645 0.614208
>> 14.2439 41.1635 0.961664
>> 14.2410 41.1637 0.519395
>> 14.2226 14.2235 0.607554
>> 14.2266 41.1617 -26.9755
>> 41.1580 -15.8549 14.3032
>> -5.20631 14.3030 41.1567
>> 29.9021 41.1564 41.1564
>> 14.3038 14.3019 41.1563
>> 41.1564 41.1584 14.2994
>> 41.1584 14.2988 14.3000
>> 41.1579 14.2980 41.1580
>> -35.7340 14.2972 41.1575
>> .....
>> As you can see the data is mixed somehow>
>> Can someone pls give me some hand:)
>> Thanks in advance,
>> Cheers,
>> Dave
>
> m=n[*,idx]
>
> regards,
> Lajos
Thanks Lajos :)
It works like a charm :)
Best,
Cheers,
Dave
|
|
|