View on GitHub

IRAF Community Distribution

IRAF maintained by the community

Home | Installation | Packages | X11IRAF | PyRAF | Forum

Memory error when running script

Elden Paul Iverson wrote on Apr 29, 2008

I received the following error and don't know how to fix it.

PANIC in `/iraf/iraf/noao/bin.linux/x_apphot.e': Memory has been corrupted
ERROR: Out of memory
"phot (files, output=files//".mag."//n, coords="star-"//n//".reg", in ..."
line 272: /home/piverson/research/ap_apphot_v_5.cl
called as: `ap_apphot_v_5 ()'


Does anyone know how to fix this?

Thanks.

-Paul

Mike Fitzpatrick wrote on Apr 29, 2008

Be sure the APPHOT package 'cache' parameter is turned off. When enabled, it will try to store the entire image in memory. A 'Memory has been corrupted' is sometimes a different error, usually a coding bug, so this only applies to the 'out of memory' problem. Note I'm assuming this is NOT a gigpixel image.

Cheers,
-Mike

craigswenson wrote on Apr 29, 2008

Hey Mike-

Paul is busy, so I'll ask the follow-up question here:

We checked, and APPHOT 'cache' is set to no, and we are definitely NOT working with gigapixel images. Any clue as to what else could be causing it?

Here's the code if it will help (the newest portion is shown separately at the bottom).


#DOCUMENTATION:ap_apphot_v_5.cl
#	

procedure ap_apphot_v_5 (search_align_phot, coordinate_file, flux_per, z_mag, pier_side_method)

string search_align_phot	{prompt="Enter search parameters for the aligned frames to phot (i.e. a-*star*B)"}
string coordinate_file		{prompt="Enter the name of the coordinate file (i.e. ds9.reg)"}
int flux_per				{prompt="Enter the percentage of flux to use for each star", min=80, max=99}
int z_mag				{prompt="Enter the zmag value"}
string pier_side_method	{prompt="Phot frames by pier side (requires that ap_pierside was run previously)", enum="Yes|No"}

begin
	string searchalignphotometry
	string coordinate
	int flux_percent
	int zero_mag
	string pier_side

	searchalignphotometry=search_align_phot
	coordinate=coordinate_file
	flux_percent=flux_per
	zero_mag=z_mag
	pier_side=pier_side_method
end

#variable declarations
int		dann=1
int		count=1
int		contin=0
int		i, n
int		l=1
int		xlen, ylen
real	HJD, exptime, gain, rdnoise, skydev, fwhm, xshift, yshift
real	xcoor, ycoor
real	apsize, skypix
string	files, lstfiles
string	id, mag, otime, xairmass, filter, pier, itime
string	checkfilter=""
string	checkpier=""
string	checkitime=""
string	checkid=""
string	s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12, s13
string	temp
struct	*list1, *list2, *list3

#deletes possibly incompatible datalists
delete ("data*")
delete ("onframe*")
delete ("nomo*")
delete ("radius.*")
delete ("fwhm.*")
delete ("*temp*")
delete ("star-*")

sections ((searchalignphotometry)//"*.fits", opt="fullname", >>"datalistfile")
if (sections.nimages>0&&pier_side=="Yes"){
	hselect ((searchalignphotometry)//"*.fits", "$I, HJD, EXPTIME, SUBSET, PIER, GAIN, RDNOISE, SKYDEV, FWHM, X_PIXEL_, Y_PIXEL_", yes, >>"datatotal")
	tsort ("datatotal", 2)
}
;
if (sections.nimages>0&&pier_side=="No"){
	hselect ((searchalignphotometry)//"*.fits", "$I, HJD, EXPTIME, SUBSET, PIER, GAIN, RDNOISE, SKYDEV, FWHM, X_PIXEL_, Y_PIXEL_", yes, >>"datatotal")
	tsort ("datatotal", 2)
}
;

hselect ((searchalignphotometry)//"*.fits", "PIER", yes, >>"datapier")
tsort ("datapier", 1)
list1="datapier"
while (fscan(list1, s1)!=EOF){
	pier=(s1)
	if (pier!=checkpier){
		print (pier, >>"datapiertable")
	}
	;
	checkpier=pier
}
delete ("datapier")

hselect ((searchalignphotometry)//"*.fits", "SUBSET", yes, >>"datafilter")
tsort ("datafilter", 1)
list1="datafilter"
while (fscan(list1, s1)!=EOF){
	filter=(s1)
	if (filter!=checkfilter){
		print (filter, >>"datafiltertable")
	}
	;
	checkfilter=filter
}
delete ("datafilter")

hselect ((searchalignphotometry)//"*.fits", "EXPTIME", yes, >>"dataexptime")
tsort ("dataexptime", 1)
list1="dataexptime"
while (fscan(list1, s1)!=EOF){
	itime=(s1)
	if (itime!=checkitime){
		print (itime, >>"dataexptimetable")
	}
	;
	checkitime=itime
}
delete ("dataexptime")

sections ("@datatotal")
if (sections.nimages>0){
	list1="datatotal"
	if (pier_side=="Yes"){
		while (fscan(list1,s1,s2,s3,s4,s5,s6,s7,s8,s9,s10,s11)!=EOF){
			files=(s1)
			HJD=real(s2)
			exptime=real(s3)
			filter=(s4)
			pier=(s5)
			gain=real(s6)
			rdnoise=real(s7)
			skydev=real(s8)
			fwhm=real(s9)
			xshift=real(s10)
			yshift=real(s11)
			
			centerpars.calg="centroid"
			centerpars.cbox=10
			centerpars.cthreshold=0.75
			centerpars.cmaxiter=20
			centerpars.maxshift=8.5

			fitskypars.salgorithm="mode"	
			fitskypars.annulus=15
			fitskypars.dannulu=dann
			fitskypars.sloclip=0.
			fitskypars.shiclip=10.

			photpars.weighting="constant"
			photpars.apertures=3*fwhm
			photpars.zmag=zero_mag
	
			datapars.fwhmpsf=fwhm
			datapars.sigma=skydev
			datapars.datamin=INDEF
			datapars.datamax=INDEF
			datapars.ccdread="RDNOISE"
			datapars.gain="GAIN"
			datapars.readnoise=rdnoise
			datapars.epadu=gain
			datapars.exposure="EXPTIME"
			datapars.airmass="AIRMASS"
			datapars.filter="SUBSET"
			datapars.obstime="HJD"

			psfmeasure.radius=5
			psfmeasure.sbuffer=5
			psfmeasure.swidth=5
	
			if (count==1){
				imgets (files, param="i_naxis1")
				xlen=int(imgets.value)
				imgets (files, param="i_naxis2")
				ylen=int(imgets.value)
			
				list2=(coordinate)
				while (fscan(list2, s12, s13)!=EOF){
					xcoor=real(s12)
					ycoor=real(s13)			
					print (xcoor//" "//ycoor, >"star-"//count//".reg")
					count=count+1
				}
			}
			;
		
			if ((abs(xshift)>0.5*xlen) || (abs(yshift)>0.5*ylen)){
				delete (files)
				next
			}
			;
								
			sections ("@"//(coordinate))
			for (n=1;n<=sections.nimages;n+=1){
				tabpar ((coordinate), 1, n)
				xcoor=real(tabpar.value)
				tabpar ((coordinate), 2, n)
				ycoor=real(tabpar.value)

				print (files, >>"temp-"//n//"-file.info")
				print (HJD, >>"temp-"//n//"-HJD.info")
				print (exptime, >>"temp-"//n//"-exptime.info")
				print (filter, >>"temp-"//n//"-filter.info")

				if ((xshift<=0 && xcoor>xlen+xshift-10) || (xshift>=0 && xcoor<0+xshift+10) || (xcoor>xlen-10) || (xcoor<10)){
					print (3*fwhm, >>"star_radi-"//n)
					
					print (3*fwhm, >>"temp-"//n//"-radius.info")
					print ("BAD", >>"temp-"//n//"-quality.info")

					contin=1
				}
				;
								
				if (contin!=1){
					if ((yshift<=0 && ycoor>ylen+yshift-10) || (yshift>=0 && ycoor<0+yshift+10) || (ycoor>ylen-10) || (ycoor<10)){
						print (3*real(s2), >>"star_radi-"//n)
						
						print (3*fwhm, >>"temp-"//n//"-radius.info")
						print ("BAD", >>"temp-"//n//"-quality.info")
						
						contin=1	
					}
					;				
				}
				;
				
				if (contin!=1){
					print ("q", >>"nomoreqs")
					
					clear
					print ("Current file", files)
					print ("Calculating PSF Flux of star: star-",n,".reg")
											
					psfmeasure (files,disp-,level=flux_percent,size="Radius",imagecur="star-"//n//".reg",graphcur="nomoreqs",>"dataradA")
	
					sed -e '/NOAO/d' -e '/Image/d' -e '/Average/d' -e '/flux/d' -e 's/" "/d/g' -e 's/obj-.........../ddddddddddddddd/g' "dataradA" >> "dataradB"
					
					list2="dataradB"
					while (fscan(list2,s12)!=EOF){
						temp=(s12)
						i=strlen(temp)
						if (l!=1 && l<=2){
							temp=substr(temp, 41, i-15)
							print (temp,>>"dataradC")				
						}
						;		
						l=l+1
					}
					l=1	
					
					sed -e 's/d//g' "dataradC" >> "dataradD"
					rename ("dataradD", "star_radi-"//n)

					tabpar ("star_radi-"//n, 1, 1)

					print (tabpar.value, >>"temp-"//n//"-radius.info")
					print ("Flux", >>"temp-"//n//"-quality.info")
				}
				;
			
				if (n==1){
					rename ("star_radi-1", "radius.info")
				}
				;
				if (n!=1){
					concat ("radius.info,star_radi-"//n, >"tempradii")
					delete ("radius.info")
					rename ("tempradii", "radius.info")
				}
				;
			
				delete ("datarad*")
				contin=0
			}
			n=1
		
			list2="radius.info"
			while (fscan(list2,s12)!=EOF){
				apsize=real(s12)
				photpars.apertures=apsize
				fitskypars.annulus=apsize+750/(flux_percent)
			
				clear
				print ("Photting: star-"//n//".reg")

				phot (files, output=files//".mag."//n, coords="star-"//n//".reg", interac-, verif-)
				
				txdump (files//".mag."//n, "nsky", yes, >>"nsky.info")
				tabpar ("nsky.info", 1, 1)
				skypix=real(tabpar.value)

				delete ("*sky*")
	
				while (skypix<500){
					dann=dann+1
					fitskypars.dannulu=dann
			
					clear
					print ("Determining proper annulus and dannulus"
					print ("")

					delete (files//".mag."//n)
					phot (files, output=files//".mag."//n, coords="star-"//n//".reg", interac-, verif-)

					txdump (files//".mag."//n, "nsky", yes, >>"nsky.info")
					tabpar ("nsky.info", 1, 1)
					skypix=real(tabpar.value)
			
					delete ("*sky*")
				}
				while (skypix>505){
					dann=dann-0.1
					fitskypars.dannulu=dann
				
					clear
					print ("Determining proper annulus and dannulus"
					print ("")
	
					delete (files//".mag."//n)
					phot (files, output=files//".mag."//n, coords="star-"//n//".reg", interac-, verif-)

					txdump (files//".mag."//n, "nsky", yes, >>"nsky.info")
					tabpar ("nsky.info", 1, 1)
					skypix=real(tabpar.value)

					delete ("*sky*")
				}
				dann=1
						
				if (n==1){
					rename (files//".mag.1", "magfile")
				}
				;
				if (n!=1){
					pconcat ("magfile"//", "//files//".mag."//n, "tempmag")
					delete ("magfile")
					rename ("tempmag", "magfile")
				}
				;
				n=n+1
			}
			n=1
		
			delete (files//".mag*")

			prenumber ("magfile")
		
			rename ("magfile", files//"_"//pier//"_flux"//flux_percent//".mag.1")
						
			delete ("star_*")
			delete ("radius.info")
			
			txdump (files//"_"//pier//"_flux"//flux_percent//".mag.1", "id, mag, otime, xairmass, ifilter, itime", yes, >>"star-"//pier//".lst")
		}
	
		list1="datapiertable"
		while (fscan(list1,s1)!=EOF){
			pier=(s1)
			list2="star-"//pier//".lst"
			while (fscan(list2,s2,s3,s4,s5,s6,s7)!=EOF){
				id=(s2)
				mag=(s3)
				otime=(s4)
				xairmass=(s5)
				filter=(s6)
				itime=(s7)

				print (id,>>"dataid")
				if (mag=="INDEF"){
					print ("99.999",>>"datamag")
				}
				;
				if (mag!="INDEF"){
					print (mag,>>"datamag")
				}
				;			
				print (otime,>>"dataotime")
				print (xairmass,>>"dataxairmass")
				print (filter,>>"datafilter")
				print (itime,>>"dataitime")	
			}
			delete ("star-"//pier//".lst")
			joinlines ("dataid,datamag,dataotime,dataxairmass,datafilter,dataitime", >"star-"//pier//".lst")

			list2="datafiltertable"
			while (fscan(list2,s2)!=EOF){
				filter=(s2)
				list3="dataexptimetable"
				while (fscan(list3, s3)!=EOF){
					itime=(s3)
					
					match (filter, "star-"//pier//".lst",>"startemp.lst")
					match (itime, "startemp.lst",>"startemp2.lst")
					fields ("startemp2.lst","1-5",>"star"//filter//"_"//itime//"_"//pier//"_flux"//flux_percent//".lst")
					sections ("@star"//filter//"_"//itime//"_"//pier//"_flux"//flux_percent//".lst")
					if (sections.nimages==0){
						delete ("star"//filter//"_"//itime//"_"//pier//"_flux"//flux_percent//".lst")
					}
					;

					tsort ("star"//filter//"_"//itime//"_"//pier//"_flux"//flux_percent//".lst","3,1")	
					sections ("star"//filter//"_"//itime//"_"//pier//"_flux"//flux_percent//".lst", >>"datalstfiles")					

					delete ("startemp.lst")
					delete ("startemp2.lst")
				}
			}
			delete ("star-"//pier//".lst")
		}
	}
	;
	if (pier_side=="No"){
		while (fscan(list1,s1,s2,s3,s4,s5,s6,s7,s8,s9,s10,s11)!=EOF){
			files=(s1)
			HJD=real(s2)
			exptime=real(s3)
			filter=(s4)
			pier=(s5)
			gain=real(s6)
			rdnoise=real(s7)
			skydev=real(s8)
			fwhm=real(s9)
			xshift=real(s10)
			yshift=real(s11)
			
			centerpars.calg="centroid"
			centerpars.cbox=10
			centerpars.cthreshold=0.75
			centerpars.cmaxiter=20
			centerpars.maxshift=8.5

			fitskypars.salgorithm="mode"	
			fitskypars.annulus=15
			fitskypars.dannulu=dann
			fitskypars.sloclip=0.
			fitskypars.shiclip=10.

			photpars.weighting="constant"
			photpars.apertures=3*fwhm
			photpars.zmag=zero_mag
	
			datapars.fwhmpsf=fwhm
			datapars.sigma=skydev
			datapars.datamin=INDEF
			datapars.datamax=INDEF
			datapars.ccdread="RDNOISE"
			datapars.gain="GAIN"
			datapars.readnoise=rdnoise
			datapars.epadu=gain
			datapars.exposure="EXPTIME"
			datapars.airmass="AIRMASS"
			datapars.filter="SUBSET"
			datapars.obstime="HJD"

			psfmeasure.radius=5
			psfmeasure.sbuffer=5
			psfmeasure.swidth=5
	
			if (count==1){
				imgets (files, param="i_naxis1")
				xlen=int(imgets.value)
				imgets (files, param="i_naxis2")
				ylen=int(imgets.value)
			
				list2=(coordinate)
				while (fscan(list2, s12, s13)!=EOF){
					xcoor=real(s12)
					ycoor=real(s13)			
					print (xcorr//", ",ycorr, >"star-"//count//".reg")
					count=count+1
				}
			}
			;
		
			if ((abs(xshift)>0.5*xlen) || (abs(yshift)>0.5*ylen)){
				delete (files)
				next
			}
			;
								
			sections ("@"//(coordinate))
			for (n=1;n<=sections.nimages;n+=1){
				tabpar ((coordinate), 1, n)
				xcoor=real(tabpar.value)
				tabpar ((coordinate), 2, n)
				ycoor=real(tabpar.value)

				print (files, >>"temp-"//n//"-file.info")
				print (HJD, >>"temp-"//n//"-HJD.info")
				print (exptime, >>"temp-"//n//"-exptime.info")
				print (filter, >>"temp-"//n//"-filter.info")

				if ((xshift<=0 && xcoor>xlen+xshift-10) || (xshift>=0 && xcoor<0+xshift+10) || (xcoor>xlen-10) || (xcoor<10)){
					print (3*fwhm, >"star_radi-"//n)
					
					print (3*fwhm, >>"temp-"//n//"-radius.info")
					print ("BAD", >>"temp-"//n//"-quality.info")

					contin=1
				}
				;
								
				if (contin!=1){ 
					if ((yshift<=0 && ycoor>ylen+yshift-10) || (yshift>=0 && ycoor<0+yshift+10) || (ycorr>ylen-10) || (ystar<10)){
						print (3*real(s2), >"star_radi-"//n)
						
						print (3*fwhm, >>"temp-"//n//"-radius.info")
						print ("BAD", >>"temp-"//n//"-quality.info")
						
						contin=1	
					}
					;				
				}
				;
				
				if (contin!=1){
					print ("q", >>"nomoreqs")
					
					clear
					print ("Current file", files)
					print ("Calculating PSF Flux of star: star-",n,".reg")
											
					psfmeasure (files,disp-,level=flux_percent,size="Radius",imagecur="star-"//n//".reg",graphcur="nomoreqs",>"dataradA")
	
					sed -e '/NOAO/d' -e '/Image/d' -e '/Average/d' -e '/flux/d' -e 's/" "/d/g' -e 's/obj-.........../ddddddddddddddd/g' "dataradA" >> "dataradB"
					
					list2="dataradB"
					while (fscan(list2,s12)!=EOF){
						temp=(s12)
						i=strlen(temp)
						if (l!=1 && l<=2){
							temp=substr(temp, 41, i-15)
							print (temp,>>"dataradC")				
						}
						;		
						l=l+1
					}
					l=1	
					
					sed -e 's/d//g' "dataradC" >> "dataradD"
					rename ("dataradD", "star_radi-"//n)

					tabpar ("star_radi-"//n, 1, 1)

					print (tabpar.value, >>"temp-"//n//"-radius.info")
					print ("Flux", >>"temp-"//n//"-quality.info")
				}
				;
			
				if (n==1){
					rename ("star_radi-1", "radius.info")
				}
				;
				if (n!=1){
					concat ("radius.info"//", "//"star_radi-"//n, >"tempradii")
					delete ("radius.info")
					rename ("tempradii", "radius.info")
				}
				;
			
				delete ("datarad*")
				contin=0
			}
			n=1
		
			list2="radius.info"
			while (fscan(list2,s12)!=EOF){
				apsize=real(s12)
				photpars.apertures=apsize
				fitskypars.annulus=apsize+750/(flux_percent)
			
				clear
				print ("Photting: star-"//n//".reg")

				phot (files, output=files//".mag."//n, coords="star-"//n//".reg", interac-, verif-)
				
				txdump (files//".mag."//n, "nsky", yes, >>"nsky.info")
				tabpar ("nsky.info", 1, 1)
				skypix=real(tabpar.value)

				delete ("*sky*")
	
				while (skypix<500){
					dann=dann+1
					fitskypars.dannulu=dann
			
					clear
					print ("Determining proper annulus and dannulus"
					print ("")

					delete (files//".mag."//n)
					phot (files, output=files//".mag."//n, coords="star-"//n//".reg", interac-, verif-)

					txdump (files//".mag."//n, "nsky", yes, >>"nsky.info")
					tabpar ("nsky.info", 1, 1)
					skypix=real(tabpar.value)
			
					delete ("*sky*")
				}
				while (skypix>505){
					dann=dann-0.1
					fitskypars.dannulu=dann
				
					clear
					print ("Determining proper annulus and dannulus"
					print ("")
	
					delete (files//".mag."//n)
					phot (files, output=files//".mag."//n, coords="star-"//n//".reg", interac-, verif-)

					txdump (files//".mag."//n, "nsky", yes, >>"nsky.info")
					tabpar ("nsky.info", 1, 1)
					skypix=real(tabpar.value)

					delete ("*sky*")
				}
				dann=1
						
				if (n==1){
					rename (files//".mag.1", "magfile")
				}
				;
				if (n!=1){
					pconcat ("magfile"//", "//files//".mag."//n, "tempmag")
					delete ("magfile")
					rename ("tempmag", "magfile")
				}
				;
				n=n+1
			}
			n=1
		
			delete (files//".mag*")

			prenumber ("magfile")
		
			rename ("magfile", files//"_NA_flux"//flux_percent//".mag.1")
						
			delete ("star_*")
			delete ("radius.info")
			
			txdump (files//"_NA_flux"//flux_percent//".mag.1", "id, mag, otime, xairmass, ifilter, itime", yes, >>"star-NA.lst")
		}
	
		list1="star-NA.lst"
		while (fscan(list1,s1,s2,s3,s4,s5,s6)!=EOF){
			id=(s1)
			mag=(s2)
			otime=(s3)
			xairmass=(s4)
			filter=(s5)
			itime=(s6)

			print (id,>>"dataid")
			if (mag=="INDEF"){
				print ("99.999",>>"datamag")
			}
			;
			if (mag!="INDEF"){
				print (mag,>>"datamag")
			}
			;			
			print (otime,>>"dataotime")
			print (xairmass,>>"dataxairmass")
			print (filter,>>"datafilter")
			print (itime,>>"dataitime")			
		}
		delete ("star-NA.lst")

		joinlines ("dataid,datamag,dataotime,dataxairmass,datafilter,dataitime", >"star-NA.lst")

		delete ("dataid")
		delete ("datamag")
		delete ("dataotime")
		delete ("dataxairmass")
		delete ("dataitime")

		list1="datafiltertable"
		while (fscan(list2,s1)!=EOF){
			filter=(s1)
			list3="dataexptimetable"
			while (fscan(list2, s2)!=EOF){
				itime=(s2)
				
				match (filter, "star-NA.lst", >"startemp.lst")
				match (itime, "startemp.lst", >"startemp2.lst")
				fields ("startemp2.lst", "1-5", >"star"//filter//"_"//itime//"_NA_flux"//flux_percent//".lst")
				sections ("@star"//filter//"_"//itime//"_NA_flux"//flux_percent//".lst")
				if (sections.nimages==0){
					delete ("star"//filter//"_"//itime//"_NA_flux"//flux_percent//".lst")
				}
				;

				tsort ("star"//filter//"_"//itime//"_NA_flux"//flux_percent//".lst","3,1")	
				sections ("star"//filter//"_"//itime//"_NA_flux"//flux_percent//".lst", >>"datalstfiles")					

				delete ("startemp.lst")
				delete ("startemp2.lst")
			}
		}
		delete ("star-NA.lst")
	}
	;

	clear
	print ("Removing possible duplicates in .lst files")
	sleep (1)

	list1="datalstfiles"
	while (fscan(list1,s1)!=EOF){
		lstfiles=(s1)
		list2=lstfiles
		while (fscan(list2,s2,s3,s4,s5,s6)!=EOF){
			id=(s2)
			mag=(s3)
			HJD=real(s4)
			xairmass=(s5)
			filter=(s6)

			if (id!=checkid){
				print (id,>>"dataid")
				print (mag,>>"datamag")
				print (HJD,>>"dataHJD")
				print (xairmass,>>"dataxairmass")
				print (filter,>>"datafilter")
			}
			;
			checkid=id
		}
		joinlines ("dataid, datamag, dataHJD, dataxairmass, datafilter", >lstfiles//".corr")

		delete ("dataid")
		delete ("datamag")
		delete ("dataHJD")
		delete ("dataxairmass")
		delete ("datafilter")

		delete (lstfiles)
		rename (lstfiles//".corr", lstfiles)
	}

	clear
	print ("Creating .info file")
	print ("")
	sleep (1)

	sections ("@"//(coordinate))
	for (n=1;n<=sections.nimages;n+=1){
		if (phot_meth=="Flux" && pier_side=="Yes"){
			joinlines ("temp-"//n//"-file.info,temp-"//n//"-HJD.info,temp-"//n//"-exptime.info,temp-"//n//"-filter.info,temp-"//n//"-radius.info,temp-"//n//"-quality.info",>"star-"//n//"-flux"//flux_percent//"-EW.info")
		}
		;
		if (phot_meth=="Flux" && pier_side=="No"){
			joinlines ("temp-"//n//"-file.info,temp-"//n//"-HJD.info,temp-"//n//"-exptime.info,temp-"//n//"-filter.info,temp-"//n//"-radius.info,temp-"//n//"-quality.info",>"star-"//n//"-flux"//flux_percent//"-NA.info")
		}
		;
	}
}
;

#deletes possibly incompatible datalists and other files
delete ("*temp*")
delete ("nomoreqs")

#adds date and time of when script was applied to frames to headers
date '+DATE:%m/%d/%y%nTIME:%H:%M:%S' > "datalist"
tabpar ("datalist", 1, 1)
datestring=tabpar.value
tabpar ("datalist", 1, 2)
timestring=tabpar.value

hedit ("*"//searchalignphotometry//"*.fits", "AP_APPHOT", datestring//""//timestring, add+, ver-)

#deletes possibly incompatible datalists
delete ("data*")

beep


The only difference between this version and the previous working version (which did not have memory errors) is the calculation of annulus and dannulus on a per star basis shown here:


list2="radius.info"
			while (fscan(list2,s12)!=EOF){
				apsize=real(s12)
				photpars.apertures=apsize
				fitskypars.annulus=apsize+750/(flux_percent)
			
				clear
				print ("Photting: star-"//n//".reg")

				phot (files, output=files//".mag."//n, coords="star-"//n//".reg", interac-, verif-)
				
				txdump (files//".mag."//n, "nsky", yes, >>"nsky.info")
				tabpar ("nsky.info", 1, 1)
				skypix=real(tabpar.value)

				delete ("*sky*")
	
				while (skypix<500){
					dann=dann+1
					fitskypars.dannulu=dann
			
					clear
					print ("Determining proper annulus and dannulus"
					print ("")

					delete (files//".mag."//n)
					phot (files, output=files//".mag."//n, coords="star-"//n//".reg", interac-, verif-)

					txdump (files//".mag."//n, "nsky", yes, >>"nsky.info")
					tabpar ("nsky.info", 1, 1)
					skypix=real(tabpar.value)
			
					delete ("*sky*")
				}
				while (skypix>505){
					dann=dann-0.1
					fitskypars.dannulu=dann
				
					clear
					print ("Determining proper annulus and dannulus"
					print ("")
	
					delete (files//".mag."//n)
					phot (files, output=files//".mag."//n, coords="star-"//n//".reg", interac-, verif-)

					txdump (files//".mag."//n, "nsky", yes, >>"nsky.info")
					tabpar ("nsky.info", 1, 1)
					skypix=real(tabpar.value)

					delete ("*sky*")
				}
				dann=1


Does IRAF try to store all of the separate annulus and dannulus calculations in RAM? We watched the memory and swap status while we were running the script and it didn't appear that we were using all of the available RAM. Any clue as to what is going on? We're kind of at a loss here, so any ideas would be welcome.

-Craig

Mike Fitzpatrick wrote on Apr 29, 2008

Variable are stored by the CL as just plain operands, until you have a gillion of them you won't use of the CL memory.

What isn't clear is whether the 'out of memory' is coming from the CL or the PHOT task, or if the error message was corrupted somehow. Looking (very briefly) at the script I notice you set 'list' pointers for reading but don't close them at the end of the loop (e.g. doing list="" to close it), this leaks some memory in the CL but doesn't look tragic. Depending on values, a more likely explanation is that as you loop and decrement 'dann' by 0.1 each time the value becomes zero/negative (I don't see a check in the code) and it is doing bad things to PHOT.

Or, it is some unreported bug. If you can run PHOT with the same parameters outside the script and make it fail the same way then we'd have something to check.

-Mike

craigswenson wrote on Apr 29, 2008

Thanks for the reply.

We actually figured out what the problem was. We were trying to calculate a dannulus for stars that had moved off the frame and apparently that was wrecking havoc with the memory.

Also, just for a side note, phot does accept negative values for the dannulus (we had that problem earlier). I'm not sure exactly how it interprets the negative value, but it does it.

-Craig

Last post on Apr 29, 2008