Welcome to iraf.net Saturday, April 27 2024 @ 02:53 AM GMT


 Forum Index > Help Desk > Applications New Topic Post Reply
 Error: Cannot open file (tmp$ftmpXXXXX)
   
fks
 05/02/2013 02:40PM (Read 2498 times)  
+----
Newbie

Status: offline


Registered: 04/06/2011
Posts: 6
Dear All,
Can anybody please point us to the possible causes of the following error message? (We have already verified that we have the relevant read write permissions and the disk space on the /tmp/ directory, and that the image files exists in the working directory).ERROR on line 175: Cannot open file (tmp$ftmp2841m)
apcalc (mode=h)For reference, we are running the following script: (apcalc.cl from the vaphot package)-------------apcalc.cl script begins here----------------------------------------------
procedure apcalc (image,stcor,result)
# version 24.8.2007 hjd
# For an image, calculates the apertures were the best S/N
# for stellar aperture photometry is achived. # version history:
# 21.7.95 first version
# 24.8.2007 changed definition of radius apopt to correspond to r(pix)/fwhm
# as used by vaphotfile image {filetype="r",prompt="Image to use for aperture calculation"}
file stcor {filetype="r",prompt="File with star coordinates"}
file result {filetype="n",prompt="Output file with coordinates and apertures"}
real fwhminit {5,prompt="Initial FWHM for psf fitting"}
real gain {1,prompt="CCD gain in e/ADU"}
struct *imglist {mode="h",prompt="ignore"}
struct *stlist {mode="h",prompt="ignore"}
struct *tlist {mode="h",prompt="ignore"} #dummy list for result
struct *maglist {mode="h",prompt="ignore"}begin

string imgfile,workimage
string fitout,txout
string photcoord,photout,txmags
string coordstr
struct scanstring
struct comments
string outstring
real rsig
real fwhm
char scan1,scan2,scan3,scan4
real msky
real sum
real area
real fl
real skynoise
real cc
real ri
real r
real apopt
real backgrd
int m
real tmp1,tmp2,tmp3,tmp4,tmp5#check that apphot package is loaded
if(!defpac("apphot")){
print("load apphot package before running this")
bye
}# Expand image template into a text file
imgfile = mktemp("tmp$itmp")
sections(image,option="fullname",>imgfile)
imglist=imgfile #set list pointer to file#get more parameters
tlist=result #dummy assignment to initiate query
result.p_mode="h" #to suppress further querying of result
stlist=stcor
stcor.p_mode="h" #to suppress further querying of stcor#presetting of parameters
fitpsf.function = "radgauss"
fitpsf.coord = stcor
fitpsf.interactive = no
fitpsf.verify =no
fitpsf.verbose = no
centerpars.cbox =1
phot.interac = no
phot.verify = no
phot.verbose = yes
datapars.fwhmpsf = fwhminit
delete.verify = no
txdump.headers = no delete(result, ver-, >& "dev$null") #delete old resultfile
#main loopwhile (fscan(imglist,workimage) !=EOF) {#strip .imh from workimage, if its there
if (substr(workimage,strlen(workimage)-3,strlen(workimage))==".imh"){
workimage=substr(workimage,1,strlen(workimage)-4)
}
#get BACKGRD (if subback.cl was run on images) from header
imgets(workimage,"BACKGRD", >& "dev$null")
backgrd=real(imgets.value)
#print("backgrd= ",backgrd)#do fitting of psf and set datapars.scale
fitout = mktemp("tmp$ftmp")
txout = mktemp("tmp$tftmp")
fitpsf.output = fitout
datapars.scale = 1 #reset scale for fitpsf.box size
fitpsf(workimage,20)
txdump(fitout,'RSIGMA',yes, > txout)
type(txout) |scan(scanstring)
rsig=real(scanstring)
fwhm = rsig*2.355 #convert sigma to FWHM
# type(fitout)
# type(txout)
# print(rsig)
delete (fitout)
delete (txout)
print(workimage,' FWHM: ',fwhm,"pix")
datapars.scale = 1/(fwhm)#parse starlist and run phot and apercalc on each starstlist=stcor #to reset stlist to begining
while (fscan(stlist,scan1,scan2,comments) !=EOF){
photcoord=mktemp("tmp$pctmp")
photout=mktemp("tmp$potmp")
txmags = mktemp("tmp$tmtmp")
# print(scan1," ",scan2)
print(scan1," ",scan2,>photcoord) #photcor is a file
coordstr = scan1//" "//scan2
#run phot and write results to txmag
phot.coord = photcoord
photpars.aperture = 2.0 #the exact aperture size is not critical
if (real(photpars.aperture) > fitskypars.annulus)
print("fitskypars.annulus is smaller than aperture used!")
phot.output = photout
phot(workimage)
txdump(photout,'SUM,AREA,MSKY,STDEV',yes, >> txmags )
type(txmags)|scan(scan1,scan2,scan3,scan4,scanstring)
sum=real(scan1)
area=real(scan2)
msky=real(scan3)
msky=msky+backgrd #BACKGRD is added back in, if it was taken out before
skynoise = real(scan4)
#type (photout)
delete (photout)
delete (photcoord)
delete (txmags) #run aperture calculation
#apopt=apercalc(fl,rsig,gain,skynoise)
fl= (sum - (area*msky)) #starcount in ADU
# print("count of star: ",fl," ADU, backgrdnoise: ",skynoise," ADU")
cc = 3.14159265*((skynoise*gain)**2) #equals 'c' in notes
fl = fl*gain #starcount in photons
# print(fl,cc,gain) #interation, r = aperture radius in pixels
r = fwhm #intial guess of aperture radius = FWHM
ri = 0.5*r #just to get around the first 'while' while((abs(r-ri))>0.001){
ri=r
tmp1=exp(0.5*(ri/rsig)**2)
tmp2=(-fl-2*cc*ri**2 - 2*cc*rsig**2)
tmp3=2*cc*rsig**2
tmp4=-(fl+tmp1*tmp2)/tmp3
r=rsig*sqrt(log(tmp4))
# print(tmp1,tmp2,tmp3,tmp4,r)
apopt = r/fwhm #in pre-2007 version this was r*2/fwhm
}

outstring=subst(str(apopt),1,4)//" "//comments
print("aperture ",outstring)
outstring = coordstr//" "//outstring
print(outstring,>>result)
print(" ")
} #END of loop for individual stars
} #END of MAIN LOOP#clean up
delete (imgfile)
result.p_mode="a" #to reset this for further invocations
stcor.p_mode="a"
end
-----------apcalc.cl script ends here----------------------------------------------The script is invoked via:
cl> epar apcalc
Image Reduction and Analysis Facility
PACKAGE = stplot
TASK = apcalcimage = @target1.list Image to use for aperture calculation
stcor = newrefstarcoor1.cor File with star coordinates
result = apcfile1.apc Output file with coordinates and apertures
(fwhmini= 40.) Initial FWHM for psf fitting
(gain = 0.93) CCD gain in e/ADU
(imglist= ) ignore
(stlist = ) ignore
(tlist = ) ignore
(maglist= ) ignore
(mode = ql)All files as given in target1.list are verified to be correct and present.Many thanks in advance for any help you can give,
Regards,
-fks.

 
Profile Email
 Quote
fitz
 05/02/2013 02:40PM  
AAAAA
Admin

Status: offline


Registered: 09/30/2005
Posts: 4040
Without knowing the size of your image lists it's hard to give a specific answer. You sometimes get the message if e.g. the /tmp partition fills up during processing, it can also happen if you run out of file descriptors.Since you're looping over loops one way to "free" a list pointer is to set it to a null string when done, e.g.[code:1:2fae5ff51b]
list = "somefile"
while (fscan (list, .....) != EOF) {
....something
}
list = "" # release the pointer
[/code:1:2fae5ff51b]The system level number of descriptors could also be raised outside of IRAF using[code:1:2fae5ff51b]
% limit descriptors unlimited # for C-shell
or % ulimit -n unlimited # for Bash shells
[/code:1:2fae5ff51b]

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