procedure tonecal (fluxConst, applyAp, saveAp, corrFile1, calExtn, outExtn, modIDs, fld, plc, keepScr, scriptN, keepTemp) real fluxConst {1.0e-19, prompt="Flux constant to apply (determined previously)"} bool applyAp {yes, prompt="Apply aperture corrections to these fluxes?"} bool saveAp {yes, prompt=" -> Save apert corrections file?"} string corrFile1 {"fldA.apcorr1", prompt=" -> File of corrections"} string calExtn {"tst", prompt="Input extension: flux files for calibration"} string outExtn {"d13c8", 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 {"tone.exec", prompt=" -> Name to save script under?"} bool keepTemp {yes, prompt=" Keep temporary data files created by script?"} begin # Variable Declarations: string awkLine1 # awk command line string awkLine2 # awk command line int p if (! defpac ("images")) { print("Package IMAGES needs to be loaded.") bye } # Cleaning-up old files and ones about to be created: delete (files="temp_tone*",go_ahea+,ver-) # Extracting flux scaling constant and applying to catalogues # through the creation and execution of an awk script: -------------- print (" ") print ("Applying flux scaling constant to oneRed/oneID data (."//calExtn//"->."//outExtn//") ...") print (" ") printf (" Flux Scaling Constant: %11.5e",fluxConst) printf (" erg/s/cm^2/band /ADU\n") print (" ") print ("-> Applied to all slices, since fluxes previously normalised to a common slice") print (" ") # temp_tone10 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 oneRed."//calExtn//" temp_tone10a", >> "temp_tone10") print ("awk '{if ($1!=\"#\") print $0}' temp_tone10a > temp_tone11a", >> "temp_tone10") 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_tone11a > temp_tone14a", >> "temp_tone10") } 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_tone11a > temp_tone14a", >> "temp_tone10") } print ("awk '{printf(\"%7.2f %7.2f %6.3f %4.1f\\n\",$14,$15,$16,$17)}' temp_tone11a > temp_tone15a", >> "temp_tone10") print (" ", >> "temp_tone10") printf ("awk '{f=%11.5e", fluxConst, >> "temp_tone10") if (applyAp==yes) { printf ("; p=log(2)*$4*$4/($7*$7); c=1/(1-exp(-1*p)); f=f*c", >> "temp_tone10") } print ("; printf(\"%11.5e %11.5e\\n\", ($12*f), ($13*f))}' temp_tone11a > temp_tone12a", >> "temp_tone10") print (" ", >> "temp_tone10") if (applyAp==yes) { print ("awk '{p=log(2)*$4*$4/($7*$7); c=1/(1-exp(-1*p)); printf(\"%7.5f\\n\",c)}' temp_tone11a > temp_tone13a\n", >> "temp_tone10") } print (" ", >> "temp_tone10") print ("paste temp_tone14a temp_tone12a temp_tone15a > temp_tone16a", >> "temp_tone10") print ("/bin/rm oneID."//outExtn, >> "temp_tone10") print ("cp oneID."//calExtn//" oneID."//outExtn, >> "temp_tone10") print ("/bin/rm oneRed."//outExtn, >> "temp_tone10") print ("mv temp_tone16a oneRed."//outExtn, >> "temp_tone10") print ("echo \"\"", >> "temp_tone10") print ("echo \" -> oneRed."//outExtn//"\"", >> "temp_tone10") # Saving aperture correction values (2 files) if requested: ------- if ((applyAp==yes)&&(saveAp==yes)) { print (" ", >> "temp_tone10") print ("/bin/rm "//corrFile1, >> "temp_tone10") print ("mv temp_tone13a "//corrFile1, >> "temp_tone10") # print ("mv temp_tone19b "//corrFile2, >> "temp_tone10") print ("echo \"\"", >> "temp_tone10") print ("echo \" -> aperture corrections: "//corrFile1//"\"", >> "temp_tone10") } print (" ") print ("Executing awk script (please wait) ...") !chmod 777 temp_tone10 !temp_tone10 print (" ") if (keepScr==yes) { delete (files=scriptN,go_ahea+,ver-) type (input_fi="temp_tone10", map_cc+, dev="terminal", >> scriptN) print("Keeping shell script (as "//scriptN//") ...") print(" ") } # Cleaning up: ------------------------------------------------------ delete (files="temp_tone.jnk",go_ahea+,ver-) if (keepTemp==yes) { delete (files="temp_tone??",go_ahea+,ver-) print("Keeping temporary data files (temp_tone??a),") print("deleting remainder ...") print(" ") } else { delete (files="temp_tone*",go_ahea+,ver-) } # ------------------------------------------------------------------- print (" ") print ("============================================================") print (" ") print (" ") print ("Done.") print (" ") end