Welcome to iraf.net Wednesday, May 01 2024 @ 05:50 PM GMT


 Forum Index > Help Desk > General IRAF New Topic Post Reply
 strange problem in printing variables in procedure script
   
christian
 04/25/2008 05:01PM (Read 3344 times)  
+----
Newbie

Status: offline


Registered: 04/25/2008
Posts: 13
Hi Folks,first of all let me thank you for this wonderfull Forum. I have allready found a lot of answers for my newby questions in here Smile ... That said here we go with my resent problem 8) I have written my first procedure script and so far everything works fine except from the ouput file i want to generate. Here the part of the code that is responsible for this:[code:1:16adf79179]real distance
real stddev[/code:1:16adf79179]...[code:1:16adf79179] result = distance // "_____" // stddev
print (distance // "_____" // stddev)
print (result, >> "result")[/code:1:16adf79179]The values of "stddev" and "distance" come from some very simpel calculations so I don't think this is the Problem. However what i get (in the terminal and the file) ist something like that:
[code:1:16adf79179]2.9306321843589<0.03920643
2.795_____0.03413983
2.721257981155<0.03597416
2.7144548255589<0.0433135[/code:1:16adf79179]So from time to time i get exactely what I want (like in the second row) but most of the time i get strange Stuff like the "<" sign in the middle of the both values.Maybe it has something to do with the number of decimales or with the real type ?I hope this question is not to noobish Smile but at the moment i'm pretty stuck... so I would be thankfull for any advice.Greetings
christian

 
Profile Email
 Quote
fitz
 04/25/2008 05:01PM  
AAAAA
Admin

Status: offline


Registered: 09/30/2005
Posts: 4040
I'm assuming that 'result' is a string variable?From the code snippets it appears like it should work as you expect, if I had to
guess I'd say that the 'result' variable was being overwritten elsewhere in the script. It would help to see the entire script (please post it or mail it to fitz@iraf.net)Cheers,
-Mike

 
Profile Email
 Quote
christian
 04/25/2008 05:01PM  
+----
Newbie

Status: offline


Registered: 04/25/2008
Posts: 13
yep it is a string...
here the complete code ... hope its not to confusing Smile[code:1:85ad851d15]
procedure test1 (data, boxsize_mas, peakx, peaky, n, tmp, maxpix)file data
real boxsize_mas
int peakx,peaky,n
string tmp
int maxpix############################Versteckte Variablen#######################struct *halloint n1 = 43
int n2 = 75
int n3 = 200
begin############################Bermerkungen################################ reset clobber = yes # damit die temporäre Datei immer wieder überschrieben werden kann############################Variablen##################################int box = 0
int i, j
struct peak
struct stddev_tmp
file mbox
real peak_r
real distance
real stddev
real xbox_min, xbox_max, ybox_min, ybox_max
string result###########################Hauptteil##################################hallo = tmpswitch (n)
{
case 1 : box = int (boxsize_mas / n1)
case 2 : box = int (boxsize_mas / n2)
case 3 : box = int (boxsize_mas / n3)
}imstat (data, fields="max", lower=INDEF, upper=INDEF, binwidth=0.1, format=no, > "testfile2") #gibt Ergebnis in Datei aus
if (fscan (hallo, peak) != EOF)
print (peak)peak_r = real (peak) for (i=1; i <= maxpix; i+=10){
for (j=1; j <= maxpix; j+=10){ switch (n)
{
case 1 : distance = n1 * (sqrt((peakx - i) * (peakx - i) + (peaky - j) * (peaky - j) )) / 1000
case 2 : distance = n2 * (sqrt((peakx - i) * (peakx - i) + (peaky - j) * (peaky - j) )) / 1000
case 3 : distance = n3 * (sqrt((peakx - i) * (peakx - i) + (peaky - j) * (peaky - j) )) / 1000
} xbox_min = i - box
ybox_min = j - box
xbox_max = i + box
ybox_max = j + box if (xbox_min >= 1 && ybox_min >= 1 && xbox_max <= maxpix && ybox_max <= maxpix)
{
mbox = data // "[" // int(xbox_min) // ":" // int(xbox_max) // "," // int(ybox_min) // ":" // int(ybox_max) \
// "]"
imstat(mbox, fields="stddev", lower=INDEF, upper=INDEF, binwidth=0.1, format=no, >> "testfile2")
if (fscan (hallo, stddev_tmp) != EOF) stddev = real (stddev_tmp)
result = distance // "_____" // stddev
print (distance // "_____" // stddev)
print (result, >> "dynamic_result")
}
# print (distance)
}
}end[/code:1:85ad851d15]sorry for the chaos in the code... this one is for testing some stuff before the beginning of the real work 8) Greetings
christian

 
Profile Email
 Quote
fitz
 04/25/2008 05:01PM  
AAAAA
Admin

Status: offline


Registered: 09/30/2005
Posts: 4040
Sorry, but I was able to run the script with some made up values and I didn't
see the problem, and there's nothing obviously wrong in reading the script. I do wonder why you declare e.g. 'peak' to be a struct and then convert it to a real instead of reading into the real variable directly, but that's not the problem.FWIW, here's the commandline I used:[code:1:691dde48c7]cl> test dev$wpix 10 100 100 1 /tmp/hallo 100[/code:1:691dde48c7]where the /tmp/hallo file just contained two lines of some real number.-Mike

 
Profile Email
 Quote
christian
 04/25/2008 05:01PM  
+----
Newbie

Status: offline


Registered: 04/25/2008
Posts: 13
So this is though.... you get at the end realy a textfile "dynamic_result" where you have just two real numbers separated by "_____" ? And also you get the same output on the terminal ? :shock: ... This is what i'm trying for hours now and it doesn't matter what i plug in as separator of my two real numbers i get just some strange stuff between them...Any suggestions ?Greetings
christianbtw...thanks a lot for the fast help and your trouble

 
Profile Email
 Quote
fitz
 04/25/2008 05:01PM  
AAAAA
Admin

Status: offline


Registered: 09/30/2005
Posts: 4040
What version of IRAF are you using? I found the following in the changelog after remembering some issue with string concatenation:[code:1:35a090eeba]
pkg/cl/binop.c
The concat operator could create garbage in the output string when
the first operand was not a string. The problem is that the operands
are popped from the stack in reverse order, but when the first op
is recast as a string it then gets a string storage area which can
overwrite the pointer of the second op. The popop() program comments
even warn that the string should be used before another pushop() (as
is done in opcast()) or else the string will be clobbered. Added code
to preserve the second string (3/22/04, MJF)
[/code:1:35a090eeba]I confirmed that in v2.12 and older systems your script will not run, in the latest v2.14 version it works just fine.Cheers,
-Mike

 
Profile Email
 Quote
christian
 04/25/2008 05:01PM  
+----
Newbie

Status: offline


Registered: 04/25/2008
Posts: 13
Maybe thats it....i am currently working with version 2.11.3 Exclaimation
I will try my script with the new 2.14 version asap SmileThanks a lot for your help Exclaimation christian

 
Profile Email
 Quote
   
Content generated in: 0.15 seconds
New Topic Post Reply

Normal Topic Normal Topic
Sticky Topic Sticky Topic
Locked Topic Locked Topic
New Post New Post
Sticky Topic W/ New Post Sticky Topic W/ New Post
Locked Topic W/ New Post Locked Topic W/ New Post
View Anonymous Posts 
Anonymous users can post 
Filtered HTML Allowed 
Censored Content 
dog allergies remedies cialis 20 mg chilblain remedies


Privacy Policy
Terms of Use

User Functions

Login