Re: a newbie question on code efficiency [message #26277] |
Mon, 20 August 2001 11:06  |
Dominic R. Scales
Messages: 12 Registered: April 2001
|
Junior Member |
|
|
David Fanning wrote:
> Folks,
>
> I'm writing "A GE 50" *not* (and I repeat, *not*) "A > 50".
>
> IDL> print, a GE 50
> 0 0 0 0 0 0 0 0 0 0
> 0 0 0 0 0 0 0 0 0 0
> 0 0 0 0 0 0 0 0 0 0
> 0 0 0 0 0 0 0 0 0 0
> 0 0 0 0 0 0 0 0 0 0
> 1 1 1 1 1 1 1 1 1 1
> 1 1 1 1 1 1 1 1 1 1
> 1 1 1 1 1 1 1 1 1 1
> 1 1 1 1 1 1 1 1 1 1
> 1 1 1 1 1 1 1 1 1 1
>
> Cheers,
>
> David
Argh, pardon me, please.
You've pointed it out ever so clear. Seems that people who can
read DO have advatages in life...
Yours humbly,
Dominic
--
Dipl. Phys. Dominic R. Scales | Aero-Sensing Radarsysteme GmbH
Tel: +49 (0)8153-90 88 90 | c/o DLR Oberpfaffenhofen
Fax: +49 (0)8153-908 700 | 82234 Wessling, Germany
WWW: aerosensing.de | email: Dominic.Scales@aerosensing.de
|
|
|
|
|
Re: a newbie question on code efficiency [message #26293 is a reply to message #26292] |
Sat, 18 August 2001 06:41   |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Dominic R. Scales (dominic.scales@aerosensing.de) writes:
> Hi David,
>
> this seems to be not true as b = a > cutoff sets the values smaller
> than cutoff to cutoff and keeps the others as they are.
>
> IDL> a=bindgen(10,10)
> IDL> b = a > 50
> IDL> print,a
> 0 1 2 3 4 5 6 7 8 9
> 10 11 12 13 14 15 16 17 18 19
> 20 21 22 23 24 25 26 27 28 29
> 30 31 32 33 34 35 36 37 38 39
> 40 41 42 43 44 45 46 47 48 49
> 50 51 52 53 54 55 56 57 58 59
> 60 61 62 63 64 65 66 67 68 69
> 70 71 72 73 74 75 76 77 78 79
> 80 81 82 83 84 85 86 87 88 89
> 90 91 92 93 94 95 96 97 98 99
> IDL> b= a > 50
> IDL> print,b
> 50 50 50 50 50 50 50 50 50 50
> 50 50 50 50 50 50 50 50 50 50
> 50 50 50 50 50 50 50 50 50 50
> 50 50 50 50 50 50 50 50 50 50
> 50 50 50 50 50 50 50 50 50 50
> 50 51 52 53 54 55 56 57 58 59
> 60 61 62 63 64 65 66 67 68 69
> 70 71 72 73 74 75 76 77 78 79
> 80 81 82 83 84 85 86 87 88 89
> 90 91 92 93 94 95 96 97 98 99
> IDL>
>
> the following does the trick:
>
> IDL> b[where(a le 50)] = 0
> IDL> b[where(a gt 50)] = 1
> IDL> print,b
> 0 0 0 0 0 0 0 0 0 0
> 0 0 0 0 0 0 0 0 0 0
> 0 0 0 0 0 0 0 0 0 0
> 0 0 0 0 0 0 0 0 0 0
> 0 0 0 0 0 0 0 0 0 0
> 0 1 1 1 1 1 1 1 1 1
> 1 1 1 1 1 1 1 1 1 1
> 1 1 1 1 1 1 1 1 1 1
> 1 1 1 1 1 1 1 1 1 1
> 1 1 1 1 1 1 1 1 1 1
Folks,
I'm writing "A GE 50" *not* (and I repeat, *not*) "A > 50".
IDL> print, a GE 50
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1
Cheers,
David
--
David W. Fanning, Ph.D.
Fanning Software Consulting
Phone: 970-221-0438, E-mail: david@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
|
|
|
|
|
|
|
Re: a newbie question on code efficiency [message #26298 is a reply to message #26297] |
Fri, 17 August 2001 20:47   |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
GB Smith (gogosgogos@usa.net) writes:
> i have a little challenge for you which i stumbled into..
> i tried to write a program which takes a 3d array,
> sets a cutoff at a certain level and then creates a mask
> of all values above that level. the mask has to be 1 and 0.
> i came up with this code, but could never get rid of the loop.
>
> any suggestions on how to get rid of the loop?
> i would prefer array operators for speed :)
>
> ;----------------------------------------------------------- ------
>
> PRO MAKE_MASK
>
> a = dialog_pickfile()
> b = READ_BINARY(a, DATA_TYPE=1, DATA_DIMS=[160,256,256])
>
> b_dims = size(b)
> x_dim = b_dims[1]
> y_dim = b_dims[2]
> z_dim = b_dims[3]
>
> cutoff = 180
>
>
> e = b
>
> for i = 0, (x_dim-1) do begin
> for j = 0, (y_dim-1) do begin
> for k = 0, (z_dim-1) do begin
>
> if e[i,j,k] lt cutoff then e[i,j,k]=0
> if e[i,j,k] ge cutoff then e[i,j,k]=1
>
> endfor
> endfor
> endfor
>
> ; and so on to use the mask further in the program
>
>
> END
My goodness, an array operator question even I
can handle! :-)
e = b GE cutoff
Cheers,
David
--
---
David W. Fanning, Ph.D.
Fanning Software Consulting
Phone: 970-221-0438, E-mail: david@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
|
|
|
Re: a newbie question on code efficiency [message #26533 is a reply to message #26291] |
Sun, 09 September 2001 11:48  |
R.Bauer
Messages: 1424 Registered: November 1998
|
Senior Member |
|
|
David Fanning wrote:
>
> GB Smith (gogosgogos@usa.net) writes:
>
>> i feel soooo stupid :)
>> better go back to the books and study the old fashioned way :P
>
> Yeah, well, it happens to, uh, all of us occasionally.
> Although usually it has something to do with a
> Histogram function. :-(
>
> Cheers,
>
> David
>
> --
> David W. Fanning, Ph.D.
> Fanning Software Consulting
> Phone: 970-221-0438, E-mail: david@dfanning.com
> Coyote's Guide to IDL Programming: http://www.dfanning.com/
> Toll-Free IDL Book Orders: 1-888-461-0155
Here is my solution,
cut_off=180
x=indgen(255)
v=make_array(/int,255 ,value=cut_off)
x[((x-v) >1 +cut_off)]=1
print,x
0 1 2 3 4 5 6 7 8
9 10 11 12 13 14 15 16 17
18 19 20 21 22 23 24 25 26
27 28 29 30 31 32 33 34 35
36 37 38 39 40 41 42 43 44
45 46 47 48 49 50 51 52 53
54 55 56 57 58 59 60 61 62
63 64 65 66 67 68 69 70 71
72 73 74 75 76 77 78 79 80
81 82 83 84 85 86 87 88 89
90 91 92 93 94 95 96 97 98
99 100 101 102 103 104 105 106 107
108 109 110 111 112 113 114 115 116
117 118 119 120 121 122 123 124 125
126 127 128 129 130 131 132 133 134
135 136 137 138 139 140 141 142 143
144 145 146 147 148 149 150 151 152
153 154 155 156 157 158 159 160 161
162 163 164 165 166 167 168 169 170
171 172 173 174 175 176 177 178 179
180 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1
1 1 1
regards
Reimar
--
Reimar Bauer
Institut fuer Stratosphaerische Chemie (ICG-1)
Forschungszentrum Juelich
email: R.Bauer@fz-juelich.de
http://www.fz-juelich.de/icg/icg1/
============================================================ ======
a IDL library at ForschungsZentrum Juelich
http://www.fz-juelich.de/icg/icg1/idl_icglib/idl_lib_intro.h tml
http://www.fz-juelich.de/zb/text/publikation/juel3786.html
============================================================ ======
read something about linux / windows
http://www.suse.de/de/news/hotnews/MS.html
|
|
|