Welcome to iraf.net Monday, May 13 2024 @ 07:00 PM GMT


 Forum Index > Help Desk > General IRAF New Topic Post Reply
 Script Problem
   
craigswenson
 08/14/2007 07:39PM (Read 3229 times)  
++---
Junior

Status: offline


Registered: 07/10/2007
Posts: 23
I was having problems with nstar not placing stars that wander off the frame in the .nrj file and posted a question which nobody responded to, so I ended up writing a little script to try and insert the missing stars into the files myself. Unfortunately, it's getting hung up. Here's the code:[code:1:e42dbb35b1]#Declare all necessary variables
string s1 = ""
string s2 = ""
string s3 = ""
string s4 = ""
string s5 = ""string id
string mag
string otime
string xairmass
string ifilter
int staridint n = 1
int l = 1struct *list1
struct *list2
struct *list3
#Combine .nst and .nrj files together into a .concat file, and psort id in .concat
sections ("a-*.fits", opt="fullname", > "datalistfits")
match (".fits.","datalistfits",stop+,>"datalistimages")
sed 's/.fits/.fits.nst.1/g' "datalistimages" > "datalistnst"
sed 's/.fits/.fits.nrj.1/g' "datalistimages" > "datalistnrj"
sed 's/.fits/.concat/g' "datalistimages" > "datalistconcat"
joinlines ("datalistimages"//","//"datalistnst"//","//"datalistnrj"//","//"datalistconcat", > "datalistfull")
list = "datalistfull"
while(fscan(list,s1,s2,s3,s4) != EOF){
pconcat (s2//","//s3, s4)
psort (s4,"ID")
}del data*
#Pull out the columns from .concat files needed for use in varstar into files called star*.joined
sections ("*.concat", opt="fullname", > "datalistconcat")
list1 = "datalistconcat"
while(fscan(list1,s1) != EOF){
for(l=1;l<=sections.nimages; l+=1){
txdump (s1, "id"//","//"mag"//","//"otime"//","//"xairmass"//","//"ifilter", yes, > "star-"//(l)//".joined")
}
}
#Add missing stars into star*.joined files and create .lst files for varstar
sections ("*.joined", opt="fullname", > "dataliststarfiles")
list2 = "dataliststarfiles"
while(fscan(list2,s5) != EOF){
list3 = (s5)
while(fscan(list3,id,mag,otime,xairmass,ifilter) != EOF){
starid = int(id)
while(starid>=n){
if(starid==n){
print(starid,>>"datalistid")
print(mag,>>"datalistmag")
print(otime,>>"datalistotime")
print(xairmass,>>"datalistairmass")
print(ifilter,>>"datalistfilter")
};
if(starid!=n){
print(n,>>"datalistid")
print("INDEF",>>"datalistmag")
print(otime,>>"datalistotime")
print(xairmass,>>"datalistairmass")
print(ifilter,>>"datalistfilter")
};
n=n+1
}
}
joinlines ("datalistid"//","//"datalistmag"//","//"datalistotime"//","//"datalistairmass"//","//"datalistfilter", > (s5)//".lst")
del data*
n = 1
}
[/code:1:e42dbb35b1]The problem seems to be on this line:[code:1:e42dbb35b1]
sections ("*.joined", opt="fullname", > "dataliststarfiles")
[/code:1:e42dbb35b1]When the script reaches that point I get the error "cannot open star-1.joined for writing". But if I manually enter the exact same code at the cl prompt and then continue the script starting on the next line, everything runs just fine and the .lst files are created just the way I want them to be.Any ideas? I don't really understand why I'm getting a "writing" error, since I'm not trying to write anything to a file.-Craig

 
Profile Email
 Quote
fitz
 08/14/2007 07:39PM  
AAAAA
Admin

Status: offline


Registered: 09/30/2005
Posts: 4040
Craig,I suspect the problem is in the TXDUMP call earlier in the script where star-1.joined is created. This is done in a loop and with a single '>' for the redirection meaning it gets overwritten. If you really want to overwrite, you should set the 'clobber' variable to allow this, otherwise use '>>' to append within the loop.I looked briefly at your earlier post but couldn't think of a reason why the star wouldn't appear in the reject file as advertised. If you could put together a small test dataset and example of how it fails I'd be happy to look again.Cheers,
-Mike

 
Profile Email
 Quote
craigswenson
 08/14/2007 07:39PM  
++---
Junior

Status: offline


Registered: 07/10/2007
Posts: 23
Thanks, Mike. That's something Paul and I didn't know. I guess you learn something new every day.

 
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