Welcome to iraf.net Thursday, April 18 2024 @ 04:56 AM GMT


 Forum Index > Help Desk > General IRAF New Topic Post Reply
 IRAF Expressions
   
blackhole612
 11/14/2016 08:02PM (Read 872 times)  
+----
Newbie

Status: offline


Registered: 09/15/2016
Posts: 2
Hello,

I am translating some IRAF code to another programming language, but I can't figure out this snippet of code below.

n_expression="z"//n_i//"*(nclus=="//n_i//")+1000.*(nclus!="//n_i//")"
print(n_expression, \$this->_split2($m[0])tmpexp)
tcalc(tmpall,"z"//n_i,"@"//tmpexp,colfmt="f6.3")

For context, the z"//n_i//" refers to part of a table for the zeropoints, while the the main thing I don't get is what exactly the (nclus=="//n_i//") and (nclus!="//n_i//")" parts. The nclus refers to a cluster number, which is in the data table as well, and n_i is a variable that increments through all the nclus numbers.

I have been having a hard time finding anything that helps too much with explaining how this works. I am assuming that the two snippets I don't understand are selecting the parts of the tables that have a matching nclus number and then the rest, respectively. But how does the multiplication work? For example, does the 1000.* multiply all the fields of the rows that do not match the nclus number, does it only multiply 1000. * the z"//n_i//" number, or something else? Any help or pointers is very appreciated.

Thanks

 
Profile Email
 Quote
fitz
 11/14/2016 08:52PM  
AAAAA
Admin

Status: offline


Registered: 09/30/2005
Posts: 4040
The '//' is a string concatenation operator, so the final expression written to the file (assuming the variable n_i=123) would be something like

z123 * (nclus == 123) + 1000. * (nclus != 123)

where I'm guessing 'z123' and 'nclus' are then valid column names in the table. The trick is that the logical expressions will return either a 0 (false) or 1 (true) value so when 'nclus=123' the expression is just the value of the 'z123' column, otherwise it's a flag value of 1000.

 
Profile Email
 Quote
   
Content generated in: 0.11 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