Welcome to iraf.net Saturday, April 27 2024 @ 07:05 PM GMT


 Forum Index > Help Desk > Systems New Topic Post Reply
 lists within list for imcombine
   
FSBoyden
 12/14/2012 05:17PM (Read 2524 times)  
++++-
Regular Member

Status: offline


Registered: 06/07/2006
Posts: 95
Hi allI am trying to modify some scripts I use to combine images. But I haven't coded IRAF cl for some time and is a bit rusty.What I want to do is bin images in the time domain (stacking). I have a large list of all the images (2500), and i want to run through them sequentially and use [b:f36d94b355]hselect[/b:f36d94b355] to extract the JD values, and then use them to set up a time checking for the stacking section.Say I want to stack every section of images taken within a 5 second period per whole obs run, pass the sub-list to [b:f36d94b355]imcombine[/b:f36d94b355] and generate new image. Run through the large list sequentially and .......Therefore I would then sit with say 750 images every 5 seconds instead of 2500 every 1.5 seconds. With off course the positives that comes from image stacking with S/N boosting etc... I have the whole script up and running, but for the list - sub-list generation bit. I use image-list templates at this stage in a cl environment. Below the section of code that is at the hart of the problem. (The section for binning = 0 is to combine all the images)[code:1:f36d94b355]
# Scan through image list
while (fscan (imglist, img) != EOF) {

if (binning == 0){
print (img, >> "images.lis")
}
else {

tfinal = tinit + binning

# Get MJD-OBS and calculate binning list and then combine lists
hselect (img, "MJD-OBS", "yes") | scan(mjd)
if (mjd == 0) {
next
}
else if(mjd < tfinal){

# Print the results to file
#print (xoffset, yoffset, >> imgoffset)
print (img, >> "images.lis")
print(mjd, tfinal, binning)

}
;

combinedimg = strname // k // "Combined_" // filt // ".fits"
if(access(combinedimg))
delete(combinedimg)

tinit = tfinal #Combine images using imcombine
imcombine ("@images.lis", output=combinedimg, combine='lmedian', reject='pclip', outtype='ushort',
scale='exposure', expname='EXPTIME') # Check the acceptability of the combine data-frame
if (access (combinedimg)) {
display (combinedimg, 1)
}
;

k = k + 1
delete("images.lis")
}
;
}
;

if (binning == 0){

print(tinit) combinedimg = strname // "Combined_" // filt // ".fits"
if(access(combinedimg))
delete(combinedimg) #Combine images using imcombine
imcombine ("@images.lis", output=combinedimg, combine='lmedian', reject='pclip', outtype='ushort',
scale='exposure', expname='EXPTIME') # Check the acceptability of the combine data-frame
if (access (combinedimg)) {
display (combinedimg, 1)
}
;

delete("images.lis") }
;
[/code:1:f36d94b355]Hope someone can give me possible pointers.Much appreciated.
Pat

 
Profile Email
 Quote
FSBoyden
 12/14/2012 05:17PM  
++++-
Regular Member

Status: offline


Registered: 06/07/2006
Posts: 95
HiFixed the problem, although I expect there is a more elegant way to do it. See below:[code:1:ec299e612d]
# Scan through image list, get number of files
while (fscan (imglist, img) != EOF) {
k = k + 1
}
; imglist = ""
imglist = imgname # Scan through image list and either list all images for combining or generate binned images
if (binning == 0) { while (fscan (imglist, img) != EOF) {
print (img, >> "images.lis")
}
;

imglist = ""
imglist = imgname print(tinit) combinedimg = strname // "Combined_" // filt // ".fits"
if(access(combinedimg))
delete(combinedimg) #Combine images using imcombine
imcombine ("@images.lis", output=combinedimg, combine='lmedian', reject='pclip', outtype='ushort',
scale='exposure', expname='EXPTIME') # Check the acceptability of the combine data-frame
if (access (combinedimg))
display (combinedimg, 1)

delete("images.lis")

}
else {
while (j < k){

j = 1
tfinal = tinit + binning

# Get MJD-OBS and calculate binning list and then combine lists
while (fscan (imglist, img) != EOF) {

hselect (img, "MJD-OBS", "yes") | scan(mjd)
if (mjd < tinit){
j = j + 1
next
}
else if(mjd > tinit && mjd < tfinal){

j = j + 1
# Print the results to file
#print (xoffset, yoffset, >> imgoffset)
print (img, >> "images.lis")
print(mjd, tfinal, binning)

}
;
}
;

combinedimg = strname // i // "Combined_" // filt // ".fits"
if(access(combinedimg))
delete(combinedimg)

tinit = tfinal #Combine images using imcombine
imcombine ("@images.lis", output=combinedimg, combine='lmedian', reject='pclip', outtype='ushort',
scale='exposure', expname='EXPTIME') # Check the acceptability of the combine data-frame
if (access (combinedimg)) {
display (combinedimg, 1)
}
;

i = i + 1
imglist = ""
imglist = imgname
delete("images.lis")
}
;
}
;
[/code:1:ec299e612d]

 
Profile Email
 Quote
FSBoyden
 12/14/2012 05:17PM  
++++-
Regular Member

Status: offline


Registered: 06/07/2006
Posts: 95
HiFixed some bugs and included additional checks. Seemed to work fine on test dataset. Just a bit resource intensive for image-list larger than 500....Use it if you like. Let me know if there is a more elegant way.Cheers
Pat[code:1:da77e04483]
# STARCOMBINE.CL - Starcombine script for the BOYDEN package.
# Version 1.0 March 2008. Version 2.0 Dec 2012. Developed by H.J. van Heerden M.Sc
# Starcombine script for combining a image set with exposure time correction.
# Additional time dependent combine algorithm included for starcking/binning around
# a specified time frame, i.e. 5,10,... seconds etc.
# Removed imageshifting process - handled in staroffset.clprocedure starcombine (imagelist, starname, filter, bintime, inittime) # Define procedure# Define procedure variablesstring imagelist {prompt="The list of images to be combined"}
string starname {prompt="The prefix for the combined images"}
string filter {prompt="Specific filter for image set"}
real bintime {0,prompt="The binning time for image stacking"}
real inittime {0,prompt="The initial time from where to start binning"}struct *imglistbegin # Define script variables
real binning, mjd, tinit, tfinal, k, j, i
string datalist, imgname, img, expr, combinedimg, strname, filt # Check for null values for imagelist
datalist = imagelist
if (datalist != "") {

# Expand the imagelist template into a text file list
imgname = mktemp ("tmp$str")
sections (datalist, option="fullname", > imgname)
}
else {
print ("No images defined")
bye()
}
; # Redirect
imglist = imgname
strname = starname
filt = filter
binning = bintime/86400
tinit = inittime
k = 1
j = 1
i = 1 # Scan through image list, get number of files
while (fscan (imglist, img) != EOF) {
k = k + 1
}
; imglist = ""
imglist = imgname # Scan through image list and either list all images for combining or generate binned images
if (binning == 0) { while (fscan (imglist, img) != EOF) {
print (img, >> "images.lis")
}
;

imglist = ""
imglist = imgname print(tinit) combinedimg = strname // "Combined_" // filt // ".fits"
if(access(combinedimg))
delete(combinedimg) #Combine images using imcombine
imcombine ("@images.lis", output=combinedimg, combine='lmedian', reject='pclip', outtype='ushort',
scale='exposure', expname='EXPTIME') # Check the acceptability of the combine data-frame
if (access (combinedimg))
display (combinedimg, 1)

delete("images.lis")

}
else {
while (j < k){

j = 1
tfinal = tinit + binning # Get MJD-OBS and calculate binning list and then combine lists
while (fscan (imglist, img) != EOF) {

hselect (img, "MJD-OBS", "yes") | scan(mjd)
if (mjd < tinit){
next
}
else if(mjd > tinit && mjd < tfinal){

j = j + 1
# Print the results to file
#print (xoffset, yoffset, >> imgoffset)
print (img, >> "images.lis")
print(mjd, tfinal, (tfinal-mjd)*86400)

}
else if(mjd > tfinal){
tinit = mjd
break
}
;
}
;

if(access("images.lis")){ combinedimg = strname // "_Combined_" // filt // i // "fits"
if(access(combinedimg))
delete(combinedimg)

tinit = tfinal #Combine images using imcombine
imcombine ("@images.lis", output=combinedimg, combine='lmedian', reject='pclip', outtype='ushort',
scale='exposure', expname='EXPTIME') # Check the acceptability of the combine data-frame
if (access (combinedimg)) {
display (combinedimg, 1)
}
;

i = i + 1
imglist = ""
imglist = imgname
delete("images.lis")
}
;
}
;
}
;

# Clean up
imglist = ""
delete (imgname, ver-, >& "dev$null")end
[/code:1:da77e04483]

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