Welcome to iraf.net Thursday, May 09 2024 @ 11:58 PM GMT


 Forum Index > Help Desk > Systems New Topic Post Reply
 trouble with txdump!
   
FSBoyden
 11/16/2006 09:51AM (Read 14371 times)  
++++-
Regular Member

Status: offline


Registered: 06/07/2006
Posts: 95
Hi allI have a little trouble getting txdump to do what I want it to do.
After running the batch psf photometry script and thus generating (for 60 images) a .pst file for every image with values for the five stars measured, I wanted to txdump the xcen,ycen,mag for the stars into individual textfiles.I.E. For 60 .pst files, and 5 stars' measured, I want to create 5 stardata files (nl. star1, star2, star3, ...) which contain that stars' xcen,ycen,mag and when I figure out how the obs. time.The thing is I want to do it in a script (like automated stuff, don't like typing :wink: ). The way I thought to go about it is to run through the list of .pst files and write the data out to the appr. file. Thus for 5 stars it will load the .pst file and then run through a loop from i = 1:5, dumping the data to the files, or vice versa.
[code:1:e9f4f45a40]# Do the txdump. The rest of the code is cutoff.
int i, j
string starfile, pststruct = *pstlist #Contain the list of starsi = 5
for (j = 1; j <= i; j+=1) {
starfile = "star" // j #Create the data file
while (fscan (pstlist, pst) != EOF) { #Scan through the list
txdump pst xcenter,ycenter,mag 'id == j' >> starfile #Dump the data
}
}
[/code:1:e9f4f45a40]I suspect that there might be quite a few errors in the code, and how I call txdump.Advice would be nice Big Grin ThanXRegards
Pat

 
Profile Email
 Quote
FSBoyden
 11/16/2006 09:51AM  
++++-
Regular Member

Status: offline


Registered: 06/07/2006
Posts: 95
Hi allI sorted the trouble with txdump. Called it wrongly. Now I have a new problem with my stardump script. I build in a choice function, i.e. if the user wants to dump an specific stars' data or all the stars (nl star- 4 or star- 1:5) If the user wants to dump 1:5, he enters 5 else if he wants 4 he enters 4'. Might be simple but it works for a short test script. The trouble is my final script gives me an error at the if - else statement. It says that there is a syntax error at the "else" statment, line 40.Somehow I just can't see the source of the error. If someone can mybe help me solve it. Much appreciated!! Big Grin Here's the script
[code:1:f4edfd3b20]
i = strlen (nstars)
if (substr (nstars, i, i) == "'" )
n = int(substr (nstars, 1, i-1))

# Do the txdump. The textfiles containing the data will
# appear in the same directory as the source files!
starfile = "star" // n
expr = "id ==" // n
while (fscan (pstlist, pst) != EOF ) {
txdump (pst, "xcenter,ycenter,mag", expr, >> starfile)
}
else
n = int(nstars)

# Do the txdump. The textfiles containing the data will
# appear in the same directory as the source files!
for (k = 1; k <= n; k+=1) {
starfile = "star" // k
expr = "id ==" // k
while (fscan (pstlist, pst) != EOF ) {
txdump (pst, "xcenter,ycenter,mag", expr, >> starfile)
}
}
[/code:1:f4edfd3b20]ThanxRegards
Pat

 
Profile Email
 Quote
fitz
 11/16/2006 09:51AM  
AAAAA
Admin

Status: offline


Registered: 09/30/2005
Posts: 4040
You've apparently been corrupted by Python, braces are required around the if statement (and while, and for....) compound-statement blocks. With no brace, only a single statement is used, so you're else appears out of nowhere as far as the parser is concerned.

-Mike

 
Profile Email
 Quote
FSBoyden
 11/16/2006 09:51AM  
++++-
Regular Member

Status: offline


Registered: 06/07/2006
Posts: 95
Hi MikeSorry for the "bad coding". Oops! I am not a full time software devol. I know just enough to write bad code.Thus far I have coded in VB6, C++, Matlab M-files, and now "Csh"/Iraf.Hard to keep track of all the diff. conventions!!! :wink: Anyway! The stardump script now work correctly. (Just had to swap the for and while loops in the else statement). Now I just have to include the UT - OBSTIME from the im-header in the star files as well. Then I can start to do some graphing for analysis. Big GrinThanX for ALL the help!!Regards
Pat

 
Profile Email
 Quote
FSBoyden
 11/16/2006 09:51AM  
++++-
Regular Member

Status: offline


Registered: 06/07/2006
Posts: 95
HiPicked up some error again! Confused The Script worked a couple of days ago. I then proceeded to include a code section to display the stars' id's that the daophot package write into the .pst. files. So the user can see what id's to use when he wants to dump the data.Now all of a sudden the code does not want to work. Up until the end of the scan part. The error seems to occur with the "nscan" part. I think. Confused Here is the code.[code:1:73dd34ef11]
procedure stardump (pst_temp, pst_files, num_stars) # Define procedure# Define procedure variablesstring pst_temp {prompt="The pstfile template for the star id's"}
string pst_files {prompt="The pstfiles containing the calculated magnitudes"}
string num_stars {prompt="The number of stars, or the starnumber to be dumped"}struct *pstlistbegin # Define script variables
int i, n, k
string pststar, pst, nstars, starfile, expr, starid, pstid

# Make sure the nessecary packages are installed
if ( ! defpac ("daophot")) {
bye()
}
;

# Get the star id's from the pst file, and display them for the user to choose.
pstid = pst_temp
starid = mktemp ("tmp$pst")
txdump (pstid, "id", yes, > starid)
print ("Measured stars' id's!")
type (starid)

# Expand the image template into a text file list
pststar = mktemp ("tmp$pst")
sections (pst_files, option="fullname" , > pststar)

# Get the rest of the parameters
nstars = num_stars
pstlist = pststar

# Scan through nstars to get the starnumber
scan (nstars)
if (nscan () != 0) {

# If there is a starnumber do the textdump
i = strlen (nstars)

if (substr (nstars, i, i) == "'" ) { # Check for specific stars
n = int(substr (nstars, 1, i-1))

# Do the txdump. The textfiles containing the data will
# appear in the same directory as the source files!

starfile = "star" // n
expr = "id ==" // n
while (fscan (pstlist, pst) != EOF ) {
txdump (pst, "ifilter,otime,xairmass,xcenter,ycenter,mag,msky", expr, >> starfile)
}
;
}
else {
n = int(nstars) # Dump all the stars in order, if numbered from 1 to n

# Do the txdump. The textfiles containing the data will
# appear in the same directory as the source files!

while (fscan (pstlist, pst) != EOF ) {
for (k = 1; k <= n; k+=1) {
starfile = "star" // k
expr = "id ==" // k
txdump (pst, "ifilter,otime,xairmass,xcenter,ycenter,mag,msky", expr, >> starfile)
}
;
}
;
}
;
}
;

# Clean up
delete (pststar, ver-, >& "dev$null")
delete (starid, ver-, >& "dev$null")

end[/code:1:73dd34ef11]Hope U can helpRegards
Pat

 
Profile Email
 Quote
fitz
 11/16/2006 09:51AM  
AAAAA
Admin

Status: offline


Registered: 09/30/2005
Posts: 4040
Hi Pat,I'm not quite sure what your intent is, or what specifically you changed other than to make this a procedure script. The scan() function reads from the stdin, so a statement like "scan(nstars)" means to take a number typed at the keyboard (or redirected) and store it in the 'nstars' variable. But, you set 'nstars' a few lines before that so it already has a value.-Mike

 
Profile Email
 Quote
FSBoyden
 11/16/2006 09:51AM  
++++-
Regular Member

Status: offline


Registered: 06/07/2006
Posts: 95
Hi MikeThe scan part is just to check for a non-zero value for nstars. I.E. dit the user enter a value. I expect that I could do it in a different way. But it did work a week ago, before I added the extra code,[code:1:45780d8dce]
# Get the star id's from the pst file, and display them for the user to choose.
pstid = pst_temp
starid = mktemp ("tmp$pst")
txdump (pstid, "id", yes, > starid)
print ("Measured stars' id's!")
type (starid)
[/code:1:45780d8dce]
and relevant variables, declarations, enc...Hope that answers your Q.Thanx
Pat

 
Profile Email
 Quote
fitz
 11/16/2006 09:51AM  
AAAAA
Admin

Status: offline


Registered: 09/30/2005
Posts: 4040
Pat,I'm not as psychic as I used to be and "It used to work" isn't a helpful report, what exactly is the error message or problem with the new code?-Mike

 
Profile Email
 Quote
FSBoyden
 11/16/2006 09:51AM  
++++-
Regular Member

Status: offline


Registered: 06/07/2006
Posts: 95
Sorry Mike Oops! Before I edited it, it gave me the correct output. That is. If I entered as input the .pst. files, with a star id of either 5 (to dump all stars from 1:5) or 4' (Dump star number 4), then it created the data files. (star1, star2, star3, ... or star4) With the relevant data included. When I used it on some test data (that i'm using the work out the bugs in the pipeline i'm building), it created the data files without error, to the extend that I could afterwards plot some prelimanary light curves.What it does now is that it does not give any final output. It prints the message, and the star id file. The it prompts for the rest of the input. After I have entered the relevant files, and star id, the script just seem to do nothing. A blank line appear after the prompt, and when I press enter after a while, it exits.When I ls the dir. The data file does not appear, i.e. it was not created. It seems that the script does not enter the part where it dumps the text. I think. Confused I tried doing a mkiraf, but did not work. I tried to convert it back to the way it was, but it did not work. The code seem correct. It shouldn't give an error. It can't be that it does not access the files?? I do not specify that it should look for specific files. Cry These kind of errors is my death. Seems that nothing is wrong, but still they exits.Please HelpThanx
Pat

 
Profile Email
 Quote
fitz
 11/16/2006 09:51AM  
AAAAA
Admin

Status: offline


Registered: 09/30/2005
Posts: 4040
Hi Pat,I still think the problem is with the "scan(nstars)" statement, i.e. that's where it's waiting for the input. If you replace this with something like "print (nstars) | scan(s1)" you'll still be able to check for a value the way I think you want. I copied your script and (think) I got it to run doing this.Before running the script you can type "cl> d_trace" to toggle the trace flag, at least that will tell you where the script appears to "hang". Hope this helps.Cheers,
-Mike

 
Profile Email
 Quote
FSBoyden
 11/16/2006 09:51AM  
++++-
Regular Member

Status: offline


Registered: 06/07/2006
Posts: 95
Hi MikeIt now works. Thanx. It seems that even though I have almost completed a full package for our photometry pipeline, I still need to learn a lott when it comes to coding in Csh.RegardsPat Big Grin

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