lists within list for imcombine
H.J. van Heerden wrote on Dec 14, 2012
Hi all
I 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 hselect 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 imcombine 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)
Hope someone can give me possible pointers.
Much appreciated.
Pat
I 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 hselect 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 imcombine 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)
# 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")
}
;
Hope someone can give me possible pointers.
Much appreciated.
Pat
H.J. van Heerden wrote on Dec 14, 2012
Hi
Fixed the problem, although I expect there is a more elegant way to do it. See below:
Fixed the problem, although I expect there is a more elegant way to do it. See below:
# 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")
}
;
}
;
H.J. van Heerden wrote on Dec 14, 2012
Hi
Fixed 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
Fixed 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
# 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.cl
procedure starcombine (imagelist, starname, filter, bintime, inittime) # Define procedure
# Define procedure variables
string 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 *imglist
begin
# 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
Last post on Dec 14, 2012