procedure tcalibrate (nScans, impref1, impref2, impref3, start1, end1, start2, end2, start3, end3, inExtn, skipSY, skipNuY, waveFile, effFile, ZDkeywd1, ZDkeywd2, EXPkeywd, normSlice, A, B, combNum, combOver, gn, mirrArea, applGal, Av_val, Rv_val, applyAp, saveAp, corrFile1, corrFile2, writeFile, outFile1, outFile2, outFile3, labCol, calExtn, outExtn, modIDs, fld, plc, keepScr, scriptN, keepTemp) int nScans {3,prompt="Number of image scans (<=3)"} string impref1 {"g", prompt=" Scan 1: Image name prefix"} string impref2 {"g", prompt=" Scan 2: Image name prefix"} string impref3 {"g",prompt=" Scan 3: Image name prefix"} int start1 {211, prompt=" Scan 1: Image start number (BEFORE combined)"} int end1 {217, prompt=" Scan 1: Image finish number (BEFORE combined)"} int start2 {218, prompt=" Scan 2: Image start number (BEFORE combined)"} int end2 {224, prompt=" Scan 2: Image finish number (BEFORE combined)"} int start3 {225, prompt=" Scan 3: Image start number (BEFORE combined)"} int end3 {231, prompt=" Scan 3: Image finish number (BEFORE combined)"} string inExtn {"r", prompt="Extension for all input images? (BEFORE combined)"} bool skipSY {no, prompt="Skip over one of the slices?"} int skipNuY {1, prompt=" -> Slice number to skip"} string waveFile {"wave.fldA", prompt="Wavelengths file (indiv slices)"} string effFile {"avgeff.10sep", prompt="System efficiency file (indiv slices)"} string ZDkeywd1 {"ZDSTART", prompt="Header Keyword: Zenith Distance, start"} string ZDkeywd2 {"ZDEND", prompt="Header Keyword: Zenith Distance, end"} string EXPkeywd {"EXPOSED", prompt="Header Keyword: Exposure time"} int normSlice {1, prompt=" Slice number for stellar flux normalisations"} real A {0.056, prompt="Extinction: grey term"} real B {9.54e-3, prompt="Extinction: Rayleigh Coefficient"} int combNum {1, prompt="Combining data: 2 or 1 combined images output slice"} bool combOver {no, prompt="Combining data: Overlap adjacent images?"} real gn {1.36, prompt=" Instrument gain (e-/ADU)"} real mirrArea {4.74e4, prompt=" Area of primary mirror (in cm^2)"} bool applGal {yes, prompt="Apply a galactic extinction correction?"} real Av_val {0.02, prompt=" -> Av in the direction of this field"} real Rv_val {3.1, prompt=" -> Rv constant to use"} bool applyAp {yes, prompt="Apply aperture corrections to these fluxes?"} bool saveAp {yes, prompt=" -> Save apert corrections to 2 files?"} string corrFile1 {"fldA.apcorr1", prompt=" -> File 1 (long) of corrections"} string corrFile2 {"fldA.apcorr2", prompt=" -> File 1 (short) of corrections"} bool writeFile {yes, prompt="Write flux calibration details to file?"} string outFile1 {"fldA.tcalib1", prompt=" -> Output file of indiv frames"} string outFile2 {"fldA.tcalib2", prompt=" -> Output file of combined frames"} string outFile3 {"fldA.tcalib3", prompt=" -> Full summary of combined frames"} bool labCol {yes, prompt=" -> Label columns om these files?"} string calExtn {"out2", prompt="Input extension: flux files for calibration"} string outExtn {"out3", prompt="Output extension: flux files for calibration"} bool modIDs {yes, prompt=" *** Update IDs with field number?"} real fld {0.01, prompt=" -> Field No. string (**NO ZERO ON END)"} int plc {2, prompt=" -> Decimal place-value to hold Fld No."} bool keepScr {yes, prompt=" Keep shell script when done?"} string scriptN {"tcal.exec", prompt=" -> Name to save script under?"} bool keepTemp {yes, prompt=" Keep temporary data files created by script?"} struct *flist1a # list-directed structure to go thru scan 1 struct *flist1b # list-directed structure to go thru scan 1 struct *flist2a # list-directed structure to go thru scan 2 struct *flist2b # list-directed structure to go thru scan 2 struct *flist3a # list-directed structure to go thru scan 3 struct *flist3b # list-directed structure to go thru scan 3 struct *flist # list-directed structure to go thru filenames struct *wlist # list-directed structure to got through wavelengths struct *elist # list-directed structure to go thru efficiencies begin # Variable Declarations: struct im1b # 2nd image from list 1 (if combining in pairs) # or 1st image (if combining individually) struct im1a # 1st image from list 1 (if combining in pairs) struct im2b struct im2a struct im3b struct im3a string itemp # temporary image name; not used for anything string outIm # name of output image string fullName # full image name string abbName # abbreviated image name real ZD1, ZD2, ZDavg, airm, eff, k, atmK, tdivK, Ephot real tdivKSUM, EphotSUM, waveLSUM, effSUM int texp # image parameters (self explan) int texpSUM string jnkstr1, jnkstr2 real waveL, lam4, jnknum, galCorrn string currFrame real j # counter real Const, Fcal # constants involved in the final calculation int q # counter of lines scanned int lineLimit # limit to the number of lines scanned string awkLine1 # awk command line string awkLine2 # awk command line int numSlices # number of combined frames in the scan real fluxConst # flux scaling const, taken from 1st slice int p if (! defpac ("images")) { print("Package IMAGES needs to be loaded.") bye } if ((fld<=0)||(fld>=1)||(plc<1)) { print("** ERROR in fld (0=1)") bye } # Cleaning-up old files and ones about to be created: delete (files="temp_tcal*",go_ahea+,ver-) if (writeFile==yes) { delete (files=outFile1,go_ahea+,ver-) delete (files=outFile2,go_ahea+,ver-) delete (files=outFile3,go_ahea+,ver-) } # Creating individual scan lists: # temp_tcal1 - 1st scan # temp_tcal2 - 2nd scan # temp_tcal3 - 3rd scan # temp_tcal4 - all scans concatenated print (" ") print (" ") print ("Creating image lists (please wait) ...") print (" ") # ** Note use of tnewmake instead of tmakefile here ... if ((nScans>=1)&&(nScans<=3)) { tnewmake (file_out="temp_tcal1",startNum=start1,stopNum=end1, prefixOU=impref1,anyExtn-,extnOU="",padOU+,listImgs-, skipSl=skipSY, skipNum=skipNuY) !cp temp_tcal1 temp_tcal4 copy (input=effFile, output="temp_tcal4e") copy (input=effFile, output="temp_tcal4ee") copy (input=waveFile, output="temp_tcal4w") copy (input=waveFile, output="temp_tcal4ww") # N.B.: the "ee' and "ww" files are duplicates reqd for cat to work } if ((nScans>=2)&&(nScans<=3)) { tnewmake (file_out="temp_tcal2",startNum=start2,stopNum=end2, prefixOU=impref2,anyExtn-,extnOU="",padOU+,listImgs-, skipSl=skipSY, skipNum=skipNuY) ! cat -s temp_tcal4 temp_tcal2 >> temp_tcal4 ! cat -s temp_tcal4e temp_tcal4ee >> temp_tcal4e ! cat -s temp_tcal4w temp_tcal4ww >> temp_tcal4w } if (nScans==3) { tnewmake (file_out="temp_tcal3",startNum=start3,stopNum=end3, prefixOU=impref3,anyExtn-,extnOU="",padOU+,listImgs-,skipSl=skipSY, skipNum=skipNuY) ! cat -s temp_tcal4 temp_tcal3 >> temp_tcal4 ! cat -s temp_tcal4e temp_tcal4ee >> temp_tcal4e ! cat -s temp_tcal4w temp_tcal4ww >> temp_tcal4w } if (nScans>3) { print (" ") print (" *** ERROR: Invalid number of scans *** ") bye } if (nScans<1) { print (" ") print (" *** ERROR: Invalid number of scans *** ") bye } # Extracting params from INDIV frames: ---------------------------- print (" ") print ("============================================================") print (" ") print ("Extracting INDIVIDUAL-frame parameters ...") print (" ") flist = "temp_tcal4" elist = "temp_tcal4e" wlist = "temp_tcal4w" lineLimit=0 while ( fscan(flist, abbName) != EOF) { lineLimit=lineLimit+1 fullName = abbName//inExtn jnkstr1=fscan(elist, jnknum, eff) jnkstr2=fscan(wlist, waveL) imgets (image=fullName, param=ZDkeywd1) ZD1 = real(imgets.value) imgets (image=fullName, param=ZDkeywd2) ZD2 = real(imgets.value) imgets (image=fullName, param=EXPkeywd) texp = int(imgets.value) ZDavg=(ZD1+ZD2)/2.0 airm=1/(cos(ZDavg/180*3.1415927)) lam4=waveL/1e4 Ephot=1.986e-16/(lam4*1e-4) lam4=lam4*lam4*lam4*lam4 k=A+(B/lam4) atmK=10**(0.4*k*airm) tdivK=texp/atmK printf ("%s %8.2f %6.2f %6.3f %5.0f %7.4f %7.4f %6.3f %9.3f %11.5e\n", fullName, waveL, ZDavg, airm, texp, eff, k, atmK, tdivK, Ephot, >> "temp_tcal5") printf ("%s %8.2f %5.0f %9.3f %11.5e %7.4f\n", fullName, waveL, texp, tdivK, Ephot, eff, >> "temp_tcal6") # i.e. temp_tcal5 contains frame no., mean ZD, mean airmass, # exp time, system efficiency at that wavlength, k at that # wavelength, atmospheric correction factor K, (t/K) # parameter, and energy of a photon at that wavelength. # # temp_tcal6 is an abbreviated version (frame no., texp, # (t/K), Ephot, eff) } print (" ") type (input_fi="temp_tcal5", map_cc+, dev="terminal") # print (" ") # type (input_fi="temp_tcal6", map_cc+, dev="terminal") print ("#") print ("# Frame waveL ZDavg airm texp effic k atmK (t/K) Ephot") print (" ") print (" --> Number of lines in file: "//lineLimit) print (" ") # end of single-frame params -------------------------------------- # COMBINED-frame calculations: ------------------------------------ if ((combNum==1)&&(combOver==yes)) { print (" ") print (" *** Can not overlap single-slice COMBINED frames *** ") print (" --> resetting combOver to no") print (" ") combOver=no } print (" ") print ("============================================================") print (" ") print ("Calculating COMBINED-frame data ...") print (" ") print ("Input slices per output slice: "//combNum) if (combOver==yes) { print ("Overlapping slices: Yes") } if (combOver==no) { print ("Overlapping slices: No") } print (" ") if (applGal==yes) { print ("Galactic extinction corrections applied to Fcal: Yes") } else { print ("Galactic extinction corrections applied to Fcal: No") } print (" ") # Initialising scan position of the second image scan variable # (or first image scan variable in the case of individual combination) if ((nScans>=1)&&(nScans<=3)) { flist1a = "temp_tcal1" flist1b = "temp_tcal1" itemp = fscan(flist1b, im1b) # delete(files="temp_tcal.jnk",verify-,default+,go_ahead+) print(im1b//inExtn, > "temp_tcal.jnk") } if ((nScans>=2)&&(nScans<=3)) { flist2a = "temp_tcal2" flist2b = "temp_tcal2" itemp = fscan(flist2b, im2b) print(im2b//inExtn, >> "temp_tcal.jnk") } if (nScans==3) { flist3a = "temp_tcal3" flist3b = "temp_tcal3" itemp = fscan(flist3b, im3b) print(im3b//inExtn, >> "temp_tcal.jnk") } if (combNum==1) { outIm = im1b//inExtn # type (input_fi="temp_tcal.jnk") # print (" --> combined to make image: "//outIm) # print ("--------------------------------------") # print (" ") # Summation loop: +++++++++++++++++++++++++++++++++++++++++++ flist="temp_tcal.jnk" # type (input_fi="temp_tcal.jnk", map_cc+, dev="terminal") # print(" ") j=0.0 print (outIm//":", >> "temp_tcal8") texpSUM=0 tdivKSUM=0.0 EphotSUM=0.0 waveLSUM=0.0 effSUM=0.0 while (fscan(flist,fullName) != EOF) { wlist="temp_tcal6" q=0 jnkstr1=fscan(wlist,currFrame,waveL,texp,tdivK,Ephot, eff) q=q+1 while ((currFrame!=fullName)&&(q<=lineLimit)) { jnkstr1=fscan(wlist,currFrame,waveL, texp,tdivK,Ephot, eff) q=q+1 } printf (" -> %s %8.2f %5.0f %10.3f %11.5e %7.3f\n", currFrame, waveL, texp, tdivK, Ephot, eff, >> "temp_tcal8") # i.e. temp_tcal8 archives frame data as it is co-added j=j+1.0 texpSUM=texpSUM+texp tdivKSUM=tdivKSUM+tdivK EphotSUM=EphotSUM+Ephot waveLSUM=waveLSUM+waveL effSUM=effSUM+eff if (q>lineLimit) { print (" ********************************") print (" *** ERROR: q>lineLimit in scanning") print (" *** for "//fullName) } } print (" ", >> "temp_tcal8") EphotSUM=EphotSUM/j # i.e. average photon energy involved waveLSUM=waveLSUM/j effSUM=effSUM/j Const=(gn*EphotSUM)/(mirrArea*effSUM*tdivKSUM) if (applGal==yes) { tgalactic (Av=Av_val, waveL=waveL, Rv=Rv_val, Arat-, extinMag-, extinFra+, labCols-, >> "temp_tcal9") elist="temp_tcal9" jnkstr1=fscan(elist, galCorrn) delete (files="temp_tcal9", ver-, def+, allver+, subfil+, go_ahead+) } else { galCorrn=1.0 } Fcal=Const*galCorrn printf ("%s %8.2f %5.0f %10.3f %11.5e %9.4f %8.4f %11.5e\n", outIm, waveLSUM, texpSUM, tdivKSUM, EphotSUM, effSUM, galCorrn, Fcal, >> "temp_tcal7") # ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ } # Main COMBINED-frame loop: while ( fscan(flist1b, im1b) != EOF) { if (combNum==2) { delete(files="temp_tcal.jnk",verify-,default+,go_ahead+) if ((nScans>=1)&&(nScans<=3)) { itemp = fscan(flist1a, im1a) print(im1a//inExtn, > "temp_tcal.jnk") } if ((nScans>=2)&&(nScans<=3)) { itemp = fscan(flist2a, im2a) print(im2a//inExtn, >> "temp_tcal.jnk") } if (nScans==3) { itemp = fscan(flist3a, im3a) print(im3a//inExtn, >> "temp_tcal.jnk") } } # i.e. only obtain previous images if combining in pairs # Writing the image defining this main loop (2 cases depending # on whether the above routine was used or bypassed): if (combNum==1) { delete(files="temp_tcal.jnk",verify-,default+,go_ahead+) print(im1b//inExtn, > "temp_tcal.jnk") outIm = im1b//inExtn } if (combNum==2) { print(im1b//inExtn, >> "temp_tcal.jnk") outIm = im1a//inExtn } # scanning other images accordingly (if additional scans exist): if ((nScans>=2)&&(nScans<=3)) { itemp = fscan(flist2b, im2b) print(im2b//inExtn, >> "temp_tcal.jnk") } if (nScans==3) { itemp = fscan(flist3b, im3b) print(im3b//inExtn, >> "temp_tcal.jnk") } # type (input_fi="temp_tcal.jnk") # print (" --> combined to make image: "//outIm) # print ("--------------------------------------") # print (" ") if ((combNum==2)&&(combOver==no)) { if ((nScans>=1)&&(nScans<=3)) { itemp = fscan(flist1a, im1a) itemp = fscan(flist1b, im1b) } if ((nScans>=2)&&(nScans<=3)) { itemp = fscan(flist2a, im2a) itemp = fscan(flist2b, im2b) } if (nScans==3) { itemp = fscan(flist3a, im3a) itemp = fscan(flist3b, im3b) } } # extra bit of scanning forward for non-overlap of pairs # Summation loop: +++++++++++++++++++++++++++++++++++++++++++ flist="temp_tcal.jnk" # type (input_fi="temp_tcal.jnk", map_cc+, dev="terminal") # print(" ") j=0.0 print (outIm//":", >> "temp_tcal8") texpSUM=0 tdivKSUM=0.0 EphotSUM=0.0 waveLSUM=0.0 effSUM=0.0 while (fscan(flist,fullName) != EOF) { wlist="temp_tcal6" q=0 jnkstr1=fscan(wlist,currFrame,waveL,texp,tdivK, Ephot, eff) q=q+1 while ((currFrame!=fullName)&&(q<=lineLimit)) { jnkstr1=fscan(wlist,currFrame,waveL, texp,tdivK,Ephot, eff) q=q+1 } printf (" -> %s %8.2f %5.0f %10.3f %11.5e %7.3f\n", currFrame, waveL, texp, tdivK, Ephot, eff, >> "temp_tcal8") # i.e. temp_tcal8 archives frame data as it is co-added j=j+1.0 texpSUM=texpSUM+texp tdivKSUM=tdivKSUM+tdivK EphotSUM=EphotSUM+Ephot waveLSUM=waveLSUM+waveL effSUM=effSUM+eff if (q>lineLimit) { print (" ********************************") print (" *** ERROR: q>lineLimit in scanning") print (" *** for "//fullName) } } print (" ", >> "temp_tcal8") EphotSUM=EphotSUM/j # i.e. average photon energy involved waveLSUM=waveLSUM/j effSUM=effSUM/j Const=(gn*EphotSUM)/(mirrArea*effSUM*tdivKSUM) if (applGal==yes) { tgalactic (Av=Av_val, waveL=waveL, Rv=Rv_val, Arat-, extinMag-, extinFra+, labCols-, >> "temp_tcal9") elist="temp_tcal9" jnkstr1=fscan(elist, galCorrn) delete (files="temp_tcal9", ver-, def+, allver+, subfil+, go_ahead+) } else { galCorrn=1.0 } Fcal=Const*galCorrn printf ("%s %8.2f %5.0f %10.3f %11.5e %9.4f %8.4f %11.5e\n", outIm, waveLSUM, texpSUM, tdivKSUM, EphotSUM, effSUM, galCorrn, Fcal, >> "temp_tcal7") # ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ } print (" ") type (input_fi="temp_tcal7", map_cc+, dev="terminal") print ("#") print ("# Frame Texp (t/K) galCorrn Fcal") print ("#") if (applGal==yes) { print ("# Galactic extinction correction: APPLIED") } else { print ("# Galactic extinction correction: NOT APPLIED") } print (" ") print ("============================================================") # end of COMBINED-frame analysis ---------------------------------- # Writing these data to file if requested: ------------------------ if (writeFile==yes) { type (input_fi="temp_tcal5", map_cc+, dev="terminal", >> outFile1) type (input_fi="temp_tcal7", map_cc+, dev="terminal", >> outFile2) type (input_fi="temp_tcal8", map_cc+, dev="terminal", >> outFile3) if (labCol==yes) { print ("#", >> outFile1) print ("# Frame waveL ZDavg airm texp effic k atmK (t/K) Ephot", >> outFile1) print ("#", >> outFile2) print ("# Frame Texp (t/K) galCorrn Fcal", >> outFile2) print ("#", >> outFile2) if (applGal==yes) { print ("# Galactic extinction correction: APPLIED", >> outFile2) } else { print ("# Galactic extinction correction: NOT APPLIED", >> outFile2) } } print (" ") print (" Writing data to the files "//outFile1//", "//outFile2//" and "//outFile3//" ...") print (" ") print ("============================================================") } # Extracting flux scaling constant and applying to catalogues # through the creation and execution of an awk script: -------------- print (" ") print ("Applying flux scaling constant to data (."//calExtn//"->."//outExtn//") ...") flist="temp_tcal7" numSlices=0 while (fscan(flist, outIm, waveLSUM, texpSUM, tdivKSUM, EphotSUM, effSUM, galCorrn, Fcal) != EOF) { numSlices=numSlices+1 if (numSlices==normSlice) { fluxConst=Fcal } } print (" ") printf (" Flux Scaling Constant (slice "//normSlice//"): %11.5e",fluxConst) printf (" erg/s/cm^2/band /ADU\n") print (" ") print ("-> Applied to all slices, since fluxes previously normalised to slice"//normSlice) print ("Number of slices: "//numSlices) print (" ") # temp_tcal10 is the awk shell script: # ----- elgRed == a # 220 format (f5.0, f8.2, f8.2, f6.1, f9.2, f7.3, f7.2, f6.2, f14.0, # $ f5.1, f5.0, f12.2, f8.2, f8.2, f8.2, f8.3, f5.1, f5.0) # print ("cp elgRed."//calExtn//" temp_tcal10a", >> "temp_tcal10") print ("awk '{if ($1!=\"#\") print $0}' temp_tcal10a > temp_tcal11a", >> "temp_tcal10") if (modIDs==yes) { print ("awk '{printf(\"%8."//plc//"f %7.2f %7.2f %5.1f %8.2f %6.3f %6.2f %5.2f %13.0f %4.1f %4.0f\\n\",($1+"//fld//"),$2,$3,$4,$5,$6,$7,$8,$9,$10,$11)}' temp_tcal11a > temp_tcal14a", >> "temp_tcal10") } else { print ("awk '{printf(\"%4.0f %7.2f %7.2f %5.1f %8.2f %6.3f %6.2f %5.2f %13.0f %4.1f %4.0f\\n\",$1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11)}' temp_tcal11a > temp_tcal14a", >> "temp_tcal10") } print ("awk '{printf(\"%7.2f %7.2f %6.3f %4.1f\\n\",$14,$15,$16,$17)}' temp_tcal11a > temp_tcal15a", >> "temp_tcal10") print (" ", >> "temp_tcal10") printf ("awk '{f=%11.5e", fluxConst, >> "temp_tcal10") if (applyAp==yes) { printf ("; p=log(2)*$4*$4/($7*$7); c=1/(1-exp(-1*p)); f=f*c", >> "temp_tcal10") } print ("; printf(\"%11.5e %11.5e\\n\", ($12*f), ($13*f))}' temp_tcal11a > temp_tcal12a", >> "temp_tcal10") print (" ", >> "temp_tcal10") if (applyAp==yes) { print ("awk '{p=log(2)*$4*$4/($7*$7); c=1/(1-exp(-1*p)); printf(\"%7.5f\\n\",c)}' temp_tcal11a > temp_tcal13a\n", >> "temp_tcal10") } print (" ", >> "temp_tcal10") print ("paste temp_tcal14a temp_tcal12a temp_tcal15a > temp_tcal16a", >> "temp_tcal10") print ("/bin/rm elgRed."//outExtn, >> "temp_tcal10") print ("mv temp_tcal16a elgRed."//outExtn, >> "temp_tcal10") print ("echo \"\"", >> "temp_tcal10") print ("echo \" -> elgRed."//outExtn//"\"", >> "temp_tcal10") # ----- elgLine == b # 260 format (f5.0, f8.2, f8.2, f6.1, f12.8, f7.3, f7.2, f6.2, f14.0, # $ f6.0, f4.0, f12.2, f8.2, f8.2, f7.2, f12.2, f8.2, f4.0) # print (" ", >> "temp_tcal10") print (" ", >> "temp_tcal10") print (" ", >> "temp_tcal10") print ("cp elgLine."//calExtn//" temp_tcal10b", >> "temp_tcal10") print ("awk '{if ($1!=\"#\") print $0}' temp_tcal10b > temp_tcal11b", >> "temp_tcal10") if (modIDs==yes) { print ("awk '{printf(\"%8."//plc//"f %7.2f %7.2f %5.1f %11.8f %6.3f %6.2f %5.2f %13.0f %5.0f %3.0f\\n\",($1+"//fld//"),$2,$3,$4,$5,$6,$7,$8,$9,$10,$11)}' temp_tcal11b > temp_tcal14b", >> "temp_tcal10") } else { print ("awk '{printf(\"%4.0f %7.2f %7.2f %5.1f %11.8f %6.3f %6.2f %5.2f %13.0f %5.0f %3.0f\\n\",$1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11)}' temp_tcal11b > temp_tcal14b", >> "temp_tcal10") } print ("awk '{printf(\"%7.2f %6.2f\\n\",$14,$15)}' temp_tcal11b > temp_tcal15b", >> "temp_tcal10") print ("awk '{printf(\"%3.0f\\n\",$18)}' temp_tcal11b > temp_tcal18b", >> "temp_tcal10") print (" ", >> "temp_tcal10") printf ("awk '{f=%11.5e", fluxConst, >> "temp_tcal10") if (applyAp==yes) { printf ("; p=log(2)*$4*$4/($7*$7); c=1/(1-exp(-1*p)); f=f*c", >> "temp_tcal10") } print ("; printf(\"%11.5e %11.5e\\n\", ($12*f), ($13*f))}' temp_tcal11b > temp_tcal12b", >> "temp_tcal10") print (" ", >> "temp_tcal10") printf ("awk '{f=%11.5e", fluxConst, >> "temp_tcal10") if (applyAp==yes) { printf ("; p=log(2)*$4*$4/($7*$7); c=1/(1-exp(-1*p)); f=f*c", >> "temp_tcal10") } print ("; printf(\"%11.5e %11.5e\\n\", ($16*f), ($17*f))}' temp_tcal11b > temp_tcal17b", >> "temp_tcal10") print (" ", >> "temp_tcal10") if (applyAp==yes) { print ("awk '{p=log(2)*$4*$4/($7*$7); c=1/(1-exp(-1*p)); printf(\"%6.4f\\n\",c)}' temp_tcal11b > temp_tcal19b\n", >> "temp_tcal10") } print (" ", >> "temp_tcal10") print ("paste temp_tcal14b temp_tcal12b temp_tcal15b temp_tcal17b temp_tcal18b > temp_tcal16b", >> "temp_tcal10") print ("/bin/rm elgLine."//outExtn, >> "temp_tcal10") print ("mv temp_tcal16b elgLine."//outExtn, >> "temp_tcal10") print ("echo \"\"", >> "temp_tcal10") print ("echo \" -> elgLine."//outExtn//"\"", >> "temp_tcal10") # ----- elgLnFlx == c # 140 format (f5.0, f8.2, f8.2, 12(f12.3)) # print (" ", >> "temp_tcal10") print (" ", >> "temp_tcal10") print (" ", >> "temp_tcal10") print ("cp elgLnFlx."//calExtn//" temp_tcal10c", >> "temp_tcal10") print ("awk '{if ($1!=\"#\") print $0}' temp_tcal10c > temp_tcal11c", >> "temp_tcal10") if (modIDs==yes) { print ("awk '{printf(\"%8."//plc//"f %7.2f %7.2f\\n\",($1+"//fld//"),$2,$3)}' temp_tcal11c > temp_tcal14c", >> "temp_tcal10") } else { print ("awk '{printf(\"%4.0f %7.2f %7.2f\\n\",$1,$2,$3)}' temp_tcal11c > temp_tcal14c", >> "temp_tcal10") } print (" ", >> "temp_tcal10") awkLine1="" awkLine2="" q=1 while (q<=numSlices) { p=q+3 awkLine1=awkLine1//"%11.3f " awkLine2=awkLine2//",$"//p q=q+1 } print ("awk '{printf(\""//awkLine1//"\\n\""//awkLine2//")}' temp_tcal11c > temp_tcal13c", >> "temp_tcal10") if (applyAp==no) { print ("awk '{print 1.000}' temp_tcal13c > temp_tcal19b", >> "temp_tcal10") } # i.e. generate a file of 1.000's if aperture corrections not req'd print ("paste temp_tcal19b temp_tcal13c > temp_tcal12c\n", >> "temp_tcal10") print (" ", >> "temp_tcal10") awkLine1="" awkLine2="" q=1 while (q<=numSlices) { p=q+1 awkLine1=awkLine1//"%11.5e " awkLine2=awkLine2//",($"//p//"*f)" q=q+1 } printf ("awk '{f=%11.5e", fluxConst, >> "temp_tcal10") printf ("; f=f*$1;", >> "temp_tcal10") print (" printf(\""//awkLine1//"\\n\""//awkLine2//")}' temp_tcal12c > temp_tcal15c", >> "temp_tcal10") print (" ", >> "temp_tcal10") print ("paste temp_tcal14c temp_tcal15c > temp_tcal16c", >> "temp_tcal10") print ("/bin/rm elgLnFlx."//outExtn, >> "temp_tcal10") print ("mv temp_tcal16c elgLnFlx."//outExtn, >> "temp_tcal10") print ("echo \"\"", >> "temp_tcal10") print ("echo \" -> elgLnFlx."//outExtn//"\"", >> "temp_tcal10") # ----- elgLnUnc == d # 160 format (f5.0, f8.2, f8.2, 12(f12.3)) # print (" ", >> "temp_tcal10") print (" ", >> "temp_tcal10") print (" ", >> "temp_tcal10") print ("cp elgLnUnc."//calExtn//" temp_tcal10d", >> "temp_tcal10") print ("awk '{if ($1!=\"#\") print $0}' temp_tcal10d > temp_tcal11d", >> "temp_tcal10") if (modIDs==yes) { print ("awk '{printf(\"%8."//plc//"f %7.2f %7.2f\\n\",($1+"//fld//"),$2,$3)}' temp_tcal11d > temp_tcal14d", >> "temp_tcal10") } else { print ("awk '{printf(\"%4.0f %7.2f %7.2f\\n\",$1,$2,$3)}' temp_tcal11d > temp_tcal14d", >> "temp_tcal10") } print (" ", >> "temp_tcal10") awkLine1="" awkLine2="" q=1 while (q<=numSlices) { p=q+3 awkLine1=awkLine1//"%11.3f " awkLine2=awkLine2//",$"//p q=q+1 } print ("awk '{printf(\""//awkLine1//"\\n\""//awkLine2//")}' temp_tcal11d > temp_tcal13d", >> "temp_tcal10") if (applyAp==no) { print ("awk '{print 1.000}' temp_tcal13d > temp_tcal19b", >> "temp_tcal10") } # i.e. generate a file of 1.000's if aperture corrections not req'd print ("paste temp_tcal19b temp_tcal13d > temp_tcal12d\n", >> "temp_tcal10") print (" ", >> "temp_tcal10") awkLine1="" awkLine2="" q=1 while (q<=numSlices) { p=q+1 awkLine1=awkLine1//"%11.5e " awkLine2=awkLine2//",($"//p//"*f)" q=q+1 } printf ("awk '{f=%11.5e", fluxConst, >> "temp_tcal10") printf ("; f=f*$1;", >> "temp_tcal10") print (" printf(\""//awkLine1//"\\n\""//awkLine2//")}' temp_tcal12d > temp_tcal15d", >> "temp_tcal10") print (" ", >> "temp_tcal10") print ("paste temp_tcal14d temp_tcal15d > temp_tcal16d", >> "temp_tcal10") print ("/bin/rm elgLnUnc."//outExtn, >> "temp_tcal10") print ("mv temp_tcal16d elgLnUnc."//outExtn, >> "temp_tcal10") print ("echo \"\"", >> "temp_tcal10") print ("echo \" -> elgLnUnc."//outExtn//"\"", >> "temp_tcal10") # Saving aperture correction values (2 files) if requested: ------- if ((applyAp==yes)&&(saveAp==yes)) { print (" ", >> "temp_tcal10") print ("/bin/rm "//corrFile1, >> "temp_tcal10") print ("/bin/rm "//corrFile2, >> "temp_tcal10") print ("mv temp_tcal13a "//corrFile1, >> "temp_tcal10") print ("mv temp_tcal19b "//corrFile2, >> "temp_tcal10") print ("echo \"\"", >> "temp_tcal10") print ("echo \" -> aperture corrections: "//corrFile1//", "//corrFile2//"\"", >> "temp_tcal10") } print (" ") print ("Executing awk script (please wait) ...") !chmod 777 temp_tcal10 !temp_tcal10 print (" ") if (keepScr==yes) { delete (files=scriptN,go_ahea+,ver-) type (input_fi="temp_tcal10", map_cc+, dev="terminal", >> scriptN) print("Keeping shell script (as "//scriptN//") ...") print(" ") } # Cleaning up: ------------------------------------------------------ delete (files="temp_tcal.jnk",go_ahea+,ver-) if (keepTemp==yes) { delete (files="temp_tcal??",go_ahea+,ver-) print("Keeping temporary data files (temp_tcal??[a,b,c,d]),") print("deleting remainder ...") print(" ") } else { delete (files="temp_tcal*",go_ahea+,ver-) } # ------------------------------------------------------------------- print (" ") print ("============================================================") print (" ") print (" ") print ("Done.") print (" ") end