From 4dba1499224268b86f225b1ee36e4dfd73f3c15a Mon Sep 17 00:00:00 2001
From: Ron <rwh@aao.gov.au>
Date: Wed, 27 Jul 2011 09:01:09 +1000
Subject: [PATCH] Local idx files 	Move idx files here; Modernise

---
 2df.idx                                       | 103 ++++++++++++++++++
 2df_1DFIT.idx                                 |   7 ++
 AutoScript.tcl                                |  47 --------
 AutoScriptWScatteredLight.tcl                 |  48 --------
 Makefile                                      |  29 +++--
 ...ered_light_combined.fits => ref_1DFIT.fits |   0
 ref_combined.fits => ref_NONE.fits            |   0
 script.tcl                                    |   3 +
 8 files changed, 130 insertions(+), 107 deletions(-)
 create mode 100644 2df.idx
 create mode 100644 2df_1DFIT.idx
 delete mode 100644 AutoScript.tcl
 delete mode 100644 AutoScriptWScatteredLight.tcl
 rename ref_w_scattered_light_combined.fits => ref_1DFIT.fits (100%)
 rename ref_combined.fits => ref_NONE.fits (100%)
 create mode 100644 script.tcl

diff --git a/2df.idx b/2df.idx
new file mode 100644
index 0000000..c958ca1
--- /dev/null
+++ b/2df.idx
@@ -0,0 +1,103 @@
+DRC_INSTRUMENT "2dF"
+
+DRC_PAGE General
+DRC_PAGE_TITLE "General Data Reduction Options"
+DRC_LOGICAL_PAR USEBIASIM "Subtract Bias Frame" FALSE REDUCE \
+    "Subtract a bias frame from each image if one\nis available"
+DRC_LOGICAL_PAR USEFLATIM "Divide Image by Long Slit Flat Field" FALSE \
+    REDUCE "Divide each image by a\nlong slit flat field if one is available"
+DRC_LOGICAL_PAR USEFFLAT "Divide Spectra by Fibre Flat Field" FALSE \
+    REDUCE "Divide extracted data by a fibre flat field\nif one is available"
+
+DRC_PAGE Extract
+DRC_PAGE_TITLE "Extraction Parameters"
+DRC_MULTI_PAR EXTR_OPERATION "Method" {TRAM FIT} TRAM REDUCE \
+    "Fibre Extraction Method"
+DRC_MULTI_PAR PLTMAP "Plot Tram Map" {YES NO "FLAT ONLY"} YES REDUCE \
+    "Plot the Tram-Line map overlaid\non the image before and after\n\
+the map has been matched with the data"
+DRC_MULTI_PAR MATCH "Rotate/Shift to Match" {YES NO "FLAT ONLY"} YES \
+    REDUCE "Match the Tram-Line map with the\nimage in shift and rotation"
+DRC_LOGICAL_PAR CRFILE "Use Default Correction" TRUE REDUCE \
+    "Use default map of\ntram-line correction"
+DRC_LOGICAL_PAR CORRECT "Fit Tram Map to Data" TRUE REDUCE \
+    "When generating a new tram line map\napply a correction based on a \
+surface fit\nto the deviation from the data"
+DRC_MULTI_PAR SCATSUB "Scattered Light Subtraction" {NONE 1DFIT 2DFILT} \
+    NONE REDUCE "Method for scattered light subtraction"
+DRC_LOGICAL_PAR CHECKDEAD "Check signal in dead fibres" TRUE REDUCE \
+    "In 1DFIT scattered light subtraction\nif specified dead fibres are \
+rejected\nif their signal level deviates from fit." 
+DRC_LOGICAL_PAR SUBSKY "Subtract Scattered Light from Offset Sky Frames" \
+    FALSE REDUCE "Subtract scattered light\nfrom offset skys"
+  
+DRC_PAGE SkySub
+DRC_PAGE_TITLE "Sky Subtraction Parameters"
+DRC_INT_PAR ARCFITORDER "Polynomial order for arc fitting" 4 REDUCE \
+    "Polynomial order for fitting the wavelength solution to the arc frames \
+(1-9)"
+DRC_LOGICAL_PAR THRUPUT "Throughput Calibrate" TRUE REDUCE \
+    "Throughput Calibrate the data\nusing a twilight or offset\nsky \
+observation"
+DRC_LOGICAL_PAR SKYSUB "Subtract Sky" TRUE REDUCE \
+    "Subtract sky from the data\nusing the sky fibres specified\nin the \
+header or in\na skyfibres.dat file" 
+DRC_MULTI_PAR TPMETH "Throughput Calibration Method" \
+    {OFFSKY SKYLINE SKYLINE(KGB) SKYFLUX(MED) SKYFLUX(COR)} OFFSKY REDUCE \
+    "Method used to calibrate\nfibre throughput\nOffset-skys or\n\
+sky lines in data" 
+DRC_MULTI_PAR SKYCOMBINE "Sky Fibre Combination Operation" {MEDIAN MEAN} \
+     MEDIAN REDUCE "Operation used to\ncombine sky fibre"
+DRC_LOGICAL_PAR SKYSCRUNCH "Wavelength calibrate from sky lines" FALSE \
+    REDUCE "Wavelength calibrate from skylines"
+DRC_INT_PAR SKYFITORDER "Polynomial order for sky fitting" 2 REDUCE \
+    "Polynomial order for fitting the wavelength solution to the sky lines \
+(1-9)"
+
+DRC_PAGE Combine
+DRC_PAGE_TITLE "Parameters Controlling Combination of Reduced Files"
+DRC_LOGICAL_PAR AUTO_COMB "Combine Reduced Data" TRUE REDUCE \
+    "Combine the results when all data frames have been reduced"
+DRC_LOGICAL_PAR COMB_ADJUST "Adjust Continuum Levels" TRUE REDUCE \
+    "Adjust continuum levels\nwhen combining\n(always OFF for sky frames)"
+DRC_MULTI_PAR FLUXWT "Flux Weight" {NONE FRAMES OBJECTS} NONE REDUCE \
+    "Flux weighted combination: NONE,\nFRAMES (one weight per frame using \
+brightest objects), or\nOBJECTS (base weights on individual object spectra)"
+DRC_REAL_PAR CSIGREJ "Rejection Threshold" 5.0 REDUCE \
+    "Number of sigma at which\na point will be rejected"
+DRC_INT_PAR CSMOOTH "Smoothing Scale" 101 REDUCE \
+    "Smoothing scale\nfor continuum"
+
+DRC_PAGE Plots
+DRC_PAGE_TITLE "Plot Parameters"
+DRC_LOGICAL_PAR AUTO "95% Scaling?" TRUE PLOT "Scale Data between the \
+points\non the histogram which\ncontain 95% of the values" 
+DRC_MULTI_PAR PLOTTYPE "Plot Type" {GREY COLOUR CONTOUR CVMAG} GREY \
+    PLOT "Specify type of plot\nGreyscale Image,\nFalse Colour Image\nX \
+Cut (Spectra) or Contour"
+DRC_INT_PAR NBIN "Pixels per bin" 1 PLOT \
+    "Binning factor for spectrum plots"
+DRC_LOGICAL_PAR FIXSKY "Remove Residual Sky" FALSE PLOT \
+    "Remove residual 5577 sky line\nby interpolation"
+DRC_LOGICAL_PAR FIXSKY "Remove Residual Sky" FALSE PLOT \
+    "Remove residual 5577 sky line\nby interpolation"
+DRC_MULTI_PAR PLTMAP "Plot Tram Map" {YES NO "FLAT ONLY"} NO \
+    REDUCE "Plot the Tram-Line map overlaid\non the image before and \
+after\nthe map has been matched with the data"
+DRC_LOGICAL_PAR SKYPLOT "Plot Combined Sky" FALSE REDUCE \
+    "Plot the combined sky spectrum\nduring each reduction"
+DRC_LOGICAL_PAR THPLOT "Plot Throughput Map" FALSE REDUCE \
+    "Plot the throughput map\nduring each reduction"
+DRC_LOGICAL_PAR AFFPLOT "Plot Averaged Flat Field" FALSE REDUCE \
+    "Plot averaged fibre flat field"
+DRC_MULTI_PAR BIASPLOT "Plot Overscan Bias Level" {YES NO "FLAT ONLY"} NO \
+    REDUCE "Plot fit of overscan bias level"
+DRC_LOGICAL_PAR BGDPLOT "Plot Background Scattered Light" FALSE REDUCE \
+    "Plot 3 image data columns with derived background overlaid"
+
+DRC_CONST_PAR SHIFTTLM 0.0 REDUCE	;# pixel count to shift tramline map
+DRC_CONST_PAR ROTTLM 0.0 REDUCE		;# rotation angle for tramline map
+DRC_CONST_PAR SCLTLM 0.965 REDUCE	;# scale change for tramline map
+DRC_CONST_PAR BUTTONS 0 PLOT		;# true- put buttons on ??? plot
+DRC_CONST_PAR COLOUR G PLOT		;# colour used for line plots
+DRC_CONST_PAR OPERATION MEDIAN REDUCE	;# cal group operation ???
diff --git a/2df_1DFIT.idx b/2df_1DFIT.idx
new file mode 100644
index 0000000..7e147e0
--- /dev/null
+++ b/2df_1DFIT.idx
@@ -0,0 +1,7 @@
+# 2df_WSLS.idx
+
+# basic defaults
+DRC_INCLUDE 2df.idx
+
+# differences with 2df
+DRC_OVERRIDE_PAR SCATSUB 1DFIT REDUCE
diff --git a/AutoScript.tcl b/AutoScript.tcl
deleted file mode 100644
index bd34e4c..0000000
--- a/AutoScript.tcl
+++ /dev/null
@@ -1,47 +0,0 @@
-AutoScript:InvokeButton .dtcluCommand1.ok 
-eval tixOptionMenu:Invoke ".notebook.nbframe.wExtract.wPLTMAP NO"
-AutoScript:SetAutoUpdate 08may 
-AutoScript:InvokeButton .auto.buttons.update 
-AutoScript:SetGlobalVar DataFilePath "/home/rheald/sampleData/2dfSample"
-AutoScript:SetGlobalVar DataFileClass "MFFFF"
-AutoScript:SetGlobalVar RedFileName "{}"
-AutoScript:SetGlobalVar DataFileStatus "{Not Reduced}"
-AutoScript:SetGlobalVar DataFilePath "/home/rheald/sampleData/2dfSample"
-AutoScript:InvokeButton .auto.buttons.start 
-AutoScript:SetGlobalVar DataFilePath "/home/rheald/sampleData/2dfSample"
-AutoScript:SetGlobalVar DataFileClass "MFFFF"
-AutoScript:SetGlobalVar RedFileName "{}"
-AutoScript:SetGlobalVar DataFileStatus "{Not Reduced}"
-AutoScript:SetGlobalVar DataFilePath "/home/rheald/sampleData/2dfSample"
-AutoScript:SetGlobalVar DataFileClass "MFARC"
-AutoScript:SetGlobalVar RedFileName "{}"
-AutoScript:SetGlobalVar DataFileStatus "{Not Reduced}"
-AutoScript:SetGlobalVar DataFilePath "/home/rheald/sampleData/2dfSample"
-AutoScript:SetGlobalVar DataFileClass "MFARC"
-AutoScript:SetGlobalVar RedFileName "{}"
-AutoScript:SetGlobalVar DataFileStatus "{Not Reduced}"
-AutoScript:SetGlobalVar DataFilePath "/home/rheald/sampleData/2dfSample"
-AutoScript:SetGlobalVar DataFileClass "MFFFF"
-AutoScript:SetGlobalVar RedFileName "08may0001red.fits"
-AutoScript:SetGlobalVar DataFileStatus "{Reduced \[No Scrunch\]}"
-AutoScript:SetGlobalVar DataFilePath "/home/rheald/sampleData/2dfSample"
-AutoScript:SetGlobalVar DataFileClass "MFOBJECT"
-AutoScript:SetGlobalVar RedFileName "{}"
-AutoScript:SetGlobalVar DataFileStatus "{Not Reduced}"
-AutoScript:SetGlobalVar DataFilePath "/home/rheald/sampleData/2dfSample"
-AutoScript:SetGlobalVar DataFileClass "MFOBJECT"
-AutoScript:SetGlobalVar RedFileName "{}"
-AutoScript:SetGlobalVar DataFileStatus "{Not Reduced}"
-AutoScript:SetGlobalVar DataFilePath "/home/rheald/sampleData/2dfSample"
-AutoScript:SetGlobalVar DataFileClass "MFOBJECT"
-AutoScript:SetGlobalVar RedFileName "{}"
-AutoScript:SetGlobalVar DataFileStatus "{Not Reduced}"
-AutoScript:SetGlobalVar DataFilePath "/home/rheald/sampleData/2dfSample"
-AutoScript:SetGlobalVar DataFileClass "MFOBJECT"
-AutoScript:SetGlobalVar RedFileName "{}"
-AutoScript:SetGlobalVar DataFileStatus "{Not Reduced}"
-AutoScript:SetGlobalVar DataFilePath "/home/rheald/sampleData/2dfSample"
-AutoScript:SetGlobalVar DataFileClass "MFOBJECT"
-AutoScript:SetGlobalVar RedFileName "08may0006red.fits"
-AutoScript:SetGlobalVar DataFileStatus "Reduced"
-AutoScript:InvokeButton .recordwin.b 
diff --git a/AutoScriptWScatteredLight.tcl b/AutoScriptWScatteredLight.tcl
deleted file mode 100644
index fea3786..0000000
--- a/AutoScriptWScatteredLight.tcl
+++ /dev/null
@@ -1,48 +0,0 @@
-AutoScript:InvokeButton .dtcluCommand1.cancel 
-eval tixOptionMenu:Invoke ".notebook.nbframe.wExtract.wPLTMAP NO"
-eval tixOptionMenu:Invoke ".notebook.nbframe.wExtract.wSCATSUB 1DFIT"
-AutoScript:SetAutoUpdate 08may 
-AutoScript:InvokeButton .auto.buttons.update 
-AutoScript:SetGlobalVar DataFilePath "/home/rheald/sampleData/2dfSample"
-AutoScript:SetGlobalVar DataFileClass "MFFFF"
-AutoScript:SetGlobalVar RedFileName "{}"
-AutoScript:SetGlobalVar DataFileStatus "{Not Reduced}"
-AutoScript:SetGlobalVar DataFilePath "/home/rheald/sampleData/2dfSample"
-AutoScript:InvokeButton .auto.buttons.start 
-AutoScript:SetGlobalVar DataFilePath "/home/rheald/sampleData/2dfSample"
-AutoScript:SetGlobalVar DataFileClass "MFFFF"
-AutoScript:SetGlobalVar RedFileName "{}"
-AutoScript:SetGlobalVar DataFileStatus "{Not Reduced}"
-AutoScript:SetGlobalVar DataFilePath "/home/rheald/sampleData/2dfSample"
-AutoScript:SetGlobalVar DataFileClass "MFARC"
-AutoScript:SetGlobalVar RedFileName "{}"
-AutoScript:SetGlobalVar DataFileStatus "{Not Reduced}"
-AutoScript:SetGlobalVar DataFilePath "/home/rheald/sampleData/2dfSample"
-AutoScript:SetGlobalVar DataFileClass "MFARC"
-AutoScript:SetGlobalVar RedFileName "{}"
-AutoScript:SetGlobalVar DataFileStatus "{Not Reduced}"
-AutoScript:SetGlobalVar DataFilePath "/home/rheald/sampleData/2dfSample"
-AutoScript:SetGlobalVar DataFileClass "MFFFF"
-AutoScript:SetGlobalVar RedFileName "08may0001red.fits"
-AutoScript:SetGlobalVar DataFileStatus "{Reduced \[No Scrunch\]}"
-AutoScript:SetGlobalVar DataFilePath "/home/rheald/sampleData/2dfSample"
-AutoScript:SetGlobalVar DataFileClass "MFOBJECT"
-AutoScript:SetGlobalVar RedFileName "{}"
-AutoScript:SetGlobalVar DataFileStatus "{Not Reduced}"
-AutoScript:SetGlobalVar DataFilePath "/home/rheald/sampleData/2dfSample"
-AutoScript:SetGlobalVar DataFileClass "MFOBJECT"
-AutoScript:SetGlobalVar RedFileName "{}"
-AutoScript:SetGlobalVar DataFileStatus "{Not Reduced}"
-AutoScript:SetGlobalVar DataFilePath "/home/rheald/sampleData/2dfSample"
-AutoScript:SetGlobalVar DataFileClass "MFOBJECT"
-AutoScript:SetGlobalVar RedFileName "{}"
-AutoScript:SetGlobalVar DataFileStatus "{Not Reduced}"
-AutoScript:SetGlobalVar DataFilePath "/home/rheald/sampleData/2dfSample"
-AutoScript:SetGlobalVar DataFileClass "MFOBJECT"
-AutoScript:SetGlobalVar RedFileName "{}"
-AutoScript:SetGlobalVar DataFileStatus "{Not Reduced}"
-AutoScript:SetGlobalVar DataFilePath "/home/rheald/sampleData/2dfSample"
-AutoScript:SetGlobalVar DataFileClass "MFOBJECT"
-AutoScript:SetGlobalVar RedFileName "08may0006red.fits"
-AutoScript:SetGlobalVar DataFileStatus "Reduced"
-AutoScript:InvokeButton .recordwin.b 
diff --git a/Makefile b/Makefile
index 818257c..26df8cc 100644
--- a/Makefile
+++ b/Makefile
@@ -33,35 +33,39 @@ nothing:
 
 # First run WITHOUT 1D filtered scattered/background light subtraction
 # (default set in idx file), then WITH
-test : testDef clean testWSLS
+test :
+	$(MAKE) clean
+	$(MAKE) testNONE
+	$(MAKE) clean
+	$(MAKE) test1DFIT
 
 # run with unchanged 2df.idx
-testDef :
+testNONE :
 	/bin/csh -c ' \
 	  setenv DRCONTROL_DIR ${USE_DRCONTROL_DIR}; \
 	  source $$DRCONTROL_DIR/2dfdr_setup; \
 	  $$DRCONTROL_DIR/2dfdr_run drcontrol 2df.idx \
 	    -AutoScript \
-	    -ScriptName AutoScript.tcl \
+	    -ScriptName script.tcl \
 	    -Timeout 60 \
-	    -Post FitsOps:Compare combined_frames.fits \
-	      ref_combined.fits stderr;'
+	    -Post FitsOps:Compare combined_frames.fits ref_NONE.fits \
+		stderr -failpercent 8;'
 	@echo "Completed 2df.idx unchanged"
 
 # run with 1D filter scattered light subtraction
-testWSLS :
+test1DFIT :
 	/bin/csh -c ' \
 	  setenv DRCONTROL_DIR ${USE_DRCONTROL_DIR}; \
 	  source $$DRCONTROL_DIR/2dfdr_setup; \
-	  $$DRCONTROL_DIR/2dfdr_run drcontrol 2df.idx \
+	  $$DRCONTROL_DIR/2dfdr_run drcontrol 2df_1DFIT.idx \
 	    -AutoScript \
-	    -ScriptName AutoScriptWScatteredLight.tcl \
+	    -ScriptName script.tcl \
 	    -Timeout 60 \
-	    -Post FitsOps:Compare combined_frames.fits \
-	      ref_w_scattered_light_combined.fits stderr;'
-	@echo "Completed 2df.idx with 1D scattered light sub"
+	    -Post FitsOps:Compare combined_frames.fits ref_1DFIT.fits \
+		stderr -failpercent 8;'
+	@echo "Completed 2df with 1D scattered light sub"
 
-# N.B. fibposa0.dat is used to ???, Don't rm it
+# N.B. fibposa0.dat is used to ???, ***do NOT remove it***
 clean :
 	@$(RM) *.sdf *~
 	@$(RM) *im.fits
@@ -73,6 +77,7 @@ clean :
 	@$(RM) background.fits
 	@$(RM) psfmap.fits
 	@$(RM) crmask.fits
+	@$(RM) OPETXBG.fits
 	@$(RM) deadfibres*.dat
 	@$(RM) arclist*.dat
 	@$(RM) TRAMDD_PKS.DAT
diff --git a/ref_w_scattered_light_combined.fits b/ref_1DFIT.fits
similarity index 100%
rename from ref_w_scattered_light_combined.fits
rename to ref_1DFIT.fits
diff --git a/ref_combined.fits b/ref_NONE.fits
similarity index 100%
rename from ref_combined.fits
rename to ref_NONE.fits
diff --git a/script.tcl b/script.tcl
new file mode 100644
index 0000000..4925675
--- /dev/null
+++ b/script.tcl
@@ -0,0 +1,3 @@
+AutoScript:SetAutoUpdate 08may
+AutoScript:InvokeButton .auto.buttons.update 
+AutoScript:InvokeButton .auto.buttons.start
-- 
GitLab