Welcome to iraf.net Monday, May 20 2024 @ 06:35 AM GMT


 Forum Index > Archives > Sitemail Archives
 `dict. full' script file from hsu
   
Anonymous: Guest
 05/24/1989 07:52PM (Read 615 times)  



Date: Wed, 24 May 89 11:17:23 MST
From: hsu%6559.span@draco (J-C x4973)
To: rooke@dracoSteve:Thank you for your reply. Here I include the script which produced the
problem. It is a long script but I don't see packages been loaded inside
loops. The task failed when we run 10 files with 20 wavelength intervals
for each file. It went through 4 segaments but failed at 4th file at
segament 5. This task has been run before with 2 files and 10 wavelengths
and succeeded.jc
---------------------------------------------------------------------------
procedure olt08_fos(inlist1,inlist2,outtab,alfa,delta,box,medsize)# Script name: olt08_fos
#
#
# Functional Summary/Operational Purpose:
#
# IRAF script to process series of spectra acquired during the execution of
# OLT08 test
#
#
# Operational Requirements (assumptions about input data):
#
#
# Version 1 Release Nov 7, 1986
# Revised on: Mar 24, 1989 (B.Simon) Conform with IRAF changes
# May 2, 1989 (H.Hasan) .c0=>.c1,.c1=>.c0;APER_ID;
# LIVETIME units
# Programmer: J. Kaluzny
#
#
#
# Warnings and current remarks:
#
# SDAS defines data quality mask differently than RSDP (at least
# in the case of FOS). This task uses SDAS definition!
#
# Task "nearneigh" does not put information message in the case it is
# imposible to find nearest good pixel.
#
# Fake relations between aperture name and size are assumed in SEGMENT ONE.
# They should be replaced by a real numbers before task execution.
#
# Normalisation in SEGMENT THREE should be checked
#
#
#
# The following name conventions are assumed:
#
# rootname.c1h - flux array (calibrated data file)
# rootname.c0h - wavelenghth calibration file
# rootname.q0h - data quality mask
#
#
#
file inlist1=" " {prompt="list of root names of input files"}file inlist2=" " {\
prompt="list specifying wavelength ranges to integrate over"}string outtab=" " {prompt=\
"name of output table and output file (without extension)"}real alfa {prompt="right ascension of target in degrees"}
real delta {prompt="declination of target in degrees"}int box=1 {min=1,max=15,\
prompt="value of parameter srchbox in sdas.dataedit.nearneigh task"}int medsize=1 {min=1,max=15,\
prompt="size of median window filter in sdas.filter.median task"}struct *flist1=" " {mode="h"}
struct *flist2=" " {mode="h"}string mode="al"beginfile infile # working name of input file with spectrum
file inmask # working name of input data quality mask
file calib # working name wavelength calibration file
file outfile # output file from sdas tasks
file wfile # working file name (used in STEP FOUR)
file scratch # scratch file ( used in STEEP FOUR)string outtable # name of output table and output fileint srchbox # "srchbox" parameter in "nearneigh" task
int xextent # "xextent" parameter in "median" taskstruct ss1 # local variable used in "fscan"
struct ss2 # local variable used in "fscan"
real xx,yy # local scratch variables
int ii # loop index
int jj # loop indexint nfiles # number of spectra to be processed
char infiles[50] # root-names of input filesreal alfa_target # right ascension of target
real delta_target # declination of target
real alfa_ap # right ascension of aperture
real delta_ap # declination of aperture
real dist[50] # distance from target for given spectrum
real deg_rad=1.745329252e-2 # converting factor from degrees to radians
real pi=3.141592654 #real lambda_beg[20] # lambda1 and lambda2 specify wavelength range over
real lambda_end[20] # which each spectrum will be integrated; up to 20
# intervals can be specified
int nlambda # number of wavelengths intervals specified by user
real integral[50,20] # array storing results of integration of i-th spectrum
# over n-th wavelength intervalchar aper[50] # aperture name ( probaby should be changed to
# an ID number in a future)
real aperture[50]=-1 # aperture surface in arcsec**2char detector[50] # name of FOS detectorreal livetime[50] # effective exposure timechar meserror=" succesful completion " # message about possible error mode="ql" # assign values to local variables
ss1=inlist1
ss2=inlist2
outtable=outtab
flist1=ss1
flist2=ss2
alfa_target=alfa*deg_rad # convert to radians
delta_target=delta*deg_rad #
srchbox=box
xextent=medsize
# Check if input files containing list of spectra and list of wavelengths existif (!access(ss1)) {
meserror=" input file inlist1 do not exist; execution aborted"
goto err
}
if (!access(ss2)) {
meserror=" input file inlist2 do not exist; execution aborted"
goto err
}ii=0. # reads root names of input files and
while (fscan(flist1,s1)!=EOF) { # stores them in character infiles[]
ii+=1
infiles[ii]=s1
}
nfiles=ii # number of lines in input file list
print(" ")
print (" number of input spectra= ",nfiles)
print (" ")# Script does not check if all input files exist. It will be done by SDAS
# tasks.
# accept wavelength ranges over which each spectrum will be integrated

ii=0
while (fscan(flist2,xx,yy)!=EOF) {
ii+=1
lambda_beg[ii]=xx
lambda_end[ii]=yy
}nlambda=ii # number of wavelength intervals specified on input listprint (" ")
print (nlambda, "wavelengths intervals have been specified")
print (" ")sdas >"dev$null" # loads "dataedit" from SDAS
dataedit >"dev$null" # "ttools" from STSDAS
images >"dev$null" # "images" from standard IRAF
stsdas >"dev$null"
ttools >"dev$null"unlearn median # task from images package
unlearn nearneigh # task from dataedit package
unlearn imarith # task from images package
unlearn tcreate # taks from ttools package# SEGMENT ONE
# Read parameters defining observational conditions (uses "keypar"
# task from CDBS package "cdbsut"). Assign value of aperture area
# to each spectrum. Calculate distance from target for each spectrum.
print ("**************************************************************"
print ("PROCESSING SEGMENT ONE")
print ("**************************************************************"
print (" ")
print ("read the observational conditions from the header files"for (ii=1; ii<=nfiles; ii+=1) {
infile=infiles[ii]//".c1h" # science data file
print (" ")# get value of keyword "APER_ID" from the header of input file imgets(infile,"APER_ID")
aper[ii]=imgets.value

aperture[ii]=0. if (aper[ii]=="A-1") # assign aperture size in arcsec**2
aperture[ii]=18.49 if (aper[ii]=="A-2")
aperture[ii]=.25

if (aper[ii]=="A-3")
aperture[ii]=.0625

if (aper[ii]=="A-4")
aperture[ii]=.01

if (aper[ii]=="B-1")
aperture[ii]=.25

if (aper[ii]=="B-2")
aperture[ii]=.09

if (aper[ii]=="B-3")
aperture[ii]=1.0

if (aper[ii]=="B-4")
aperture[ii]=0.

if (aper[ii]=="C-1")
aperture[ii]=1.0

if (aper[ii]=="C-2")
aperture[ii]=.0625

if (aper[ii]=="C-3")
aperture[ii]=4.0

if (aper[ii]=="C-4")
aperture[ii]=1.4

#
if (aperture[ii]<=0) {
print (" ")
print (" undefined aperture size: file= ",infile)
meserror=" undefined aperture, execution aborted"
goto err
}# get value of keyword "LIVETIME" from the header of input file
imgets(infile,"LIVETIME") # get value of exposure time
livetime[ii]=real(imgets.value)*7.8125*.000001
# livetime="exposure time in sec." # get value of keyword "DETECTOR" from the headr of input file
imgets(infile,"DETECTOR")
detector[ii]=imgets.value# Read right asscension and declination in degrees. Subsequently calculate
# distance from the target. imgets(infile,"CRVAL2") # gets value of right ascension
alfa_ap=real(imgets.value)*deg_rad # converts from deg. to radians imgets(infile,"CRVAL3") # gets value of declination
delta_ap=real(imgets.value)*deg_rad # converts from deg. to radians xx=abs(alfa_ap-alfa_target)
if (xx>pi)
xx=2.*pi-xx
xx=cos(pi/2.-delta_ap)*cos(pi/2.-delta_target)+sin(pi/2.-delta_ap)*\
sin(pi/2.-delta_target)*cos(xx)# at this point xx is a cosinous of the angular distance between target
# and aperture xx=(sqrt(1-xx*xx))/xx # calculate tangent of distance
dist[ii]=atan2(xx,1) # calculate distance in radians
dist[ii]=dist[ii]*206264.8 # change units to arcsec }print (" ")
print ("**************************************************************"
print ("PROCESSING SEGMENT TWO")
print ("**************************************************************"
print (" ")
# SEGMENT TWO
# fill "bad pixels" using task "nearneigh" from SDAS package "dataedit"
#
print("fill bad pixels using task nearneigh from SDAS package dataedit")for (ii=1; ii<=nfiles; ii+=1) { # assign file names
infile=infiles[ii]//".c1h" # science data file
inmask=infiles[ii]//".q0h" # data quality mask
outfile=infiles[ii]//"_f.c1h" print (" ")
print ("infile: ",infile," inmask: ",inmask," outfile: ",outfile)
#
nearneigh(infile,0,inmask," ",outfile,srchbox)
}
print (" ")
print (" ")print ("**************************************************************"
print ("PROCESSING SEGMENT THREE")
print ("**************************************************************"
print (" ")#
#
#
#
# STEP THREE
# Divide spectra created in SEGMENT TWO by an aperture area (in arcsec**2)
# and by an exposure time.
# Subsequently delete spectra created in SEGMENT TWO -
# uses sdas task "divconst" from package "arrayops", normalized spectra
# are stored in files rootname_fd.c1hprint (" divide spectra by an aperture area and an exposure time")for (ii=1; ii<=nfiles; ii+=1) {
infile=infiles[ii]//"_f.c1h" # science data file
outfile=infiles[ii]//"_fd.c1h" print (" ")
print ("infile: ",infile," outfile: ",outfile)
print (" ")# xx=aperture[ii]# Uncomment above line if it is necessary to normalize spectra by an aperture
# area only. Additionally delete next line (xx=aperture[ii]*livetime[ii]) xx=aperture[ii]*livetime[ii] # xx=(aperture area)*(exposure time)# Uncomment above line if it is necessary to normalize spectra by an aperture
# area and an exposure time. Additionally delete next line (xx=1.)
# # xx=1.
imarith(infile,"/",xx,outfile) #
scratch=infiles[ii]//"_f.*"
delete(scratch,yes) # delete input file }
print (" ")
print (" divided spectra are stored in files rootname_fd.c1h")print (" ")
print ("**************************************************************"
print ("PROCESSING SEGMENT FOUR")
print ("**************************************************************"
print (" ")# SEGMENT FOUR
# Smooth spectra using task "median" from SDAS package "filter"
# - use as an input spectra created in SEGMENT THREE
# Smoothed spectra are stored in files rootname_sm.c1h
print (" ")
print ("smooth spectra using task median from SDAS package filter")
print (" ")for (ii=1; ii<=nfiles; ii+=1) {
infile=infiles[ii]//"_fd.c1h" # science data file created in STEP THREE
outfile=infiles[ii]//"_sm.c1h" print (" ")
print("infile: ",infile," outfile: ",outfile)
print (" ")
#
median(infile,outfile,xextent,1)
}
print (" ")
print ("**************************************************************"
print ("PROCESSING SEGMENT FIVE")
print ("**************************************************************"
print (" ")#
#
# SEGMENT FIVE
# Each spectrum created in SEGMENT THREE is integrated over given
# wavelength interval using task "integfos". Results of integration
# of ii-th spectrum over jj-th wavelenght interval are stored in
# parameter integral[ii,jj]
#print (" integrate over specified wavelength intervals")
print (" results of the integration will be divided by the",\
"lengths of intervals")
print (" ")

outfile=outtable//".dat"
print(" file.c1 camera exp-time aperture distance interval",\
" lambda_beg lambda_end photons/cm**2/arcsec**2/sec/A",>>outfile)
print(" ",>>outfile)for (ii=1; ii<=nfiles; ii+=1) { # loops over all spectra

infile=infiles[ii]//"_fd.c1h" # file with spectrum created in STEP THREE
calib=infiles[ii]//".c0h" # wavelength calibration file
for (jj=1; jj<=nlambda; jj+=1) { # loops over all wavelenght intervals print ("infile=",infile," lambda_beg=",lambda_beg[jj],\
" lambda_end=",lambda_end[jj])
print (" ") unlearn intfos
intfos(infile,calib,lambda_beg[jj],lambda_end[jj]) integral[ii,jj]=intfos.integral
integral[ii,jj]=integral[ii,jj]/(lambda_end[jj]-lambda_beg[jj])
print (" integral=",integral[ii,jj])
print (" ")
#
print (" ")
print("'",infiles[ii]//"_fd","'"," ","'",detector[ii],"'",\
" ",livetime[ii]," ",aperture[ii]," ",\
dist[ii]," ",jj," ",lambda_beg[jj]," ",\
lambda_end[jj]," ",integral[ii,jj],>>outfile) }
}print ("**************************************************************"
print ("PROCESSING SEGMENT SIX")
print ("**************************************************************"
print (" ")# SEGMENT SIX
# Creates SDAS table containing all data necessary for test completion
# It should be replaced later by a call to CDBS task creating similar table.
#
tcreate(outtable,"olt08dir$olt08.fmt",outfile,nskip=2) print(" ")
print("test output data are stored in table: ", outtable)
print("as well as in file:",outfile)
print(" the units are:")
print(" seconds for the effective exposure time")
print(" arcsec for distance")
print(" angstroms for wavelength")
print(" photons/cm**2/arcsec**2/sec for intensity")
print(" ")
print("****************************************************")
print(" ")err: print (meserror)
end

 
   

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