ChangeLog for eboxdetect
========================

Version 4.30.1 - 2024-09-16 (IT)
--------------
	+ edetect_io_box.f90: make sure that detector coordinates are
	  recognized when reading the masks before the images, i.e. that
	  "indetcoords" is set properly in any case  (SPR-7758)

Version 4.30 - 2024-08-23 (IT)
--------------
	+ edetect_io_box.f90, ebox_io.f90: Fix an older bug regarding some
	  sub-image coordinates of the detection masks and adjust the
	  determination of the usable area accordingly.
	  Seems to affect cases of coordinate offsets with eg. telemetry issues.

Version 4.29 - 2022-03-04 (IT)
--------------
        + edetect_io_box.f90: use the detection masks to determine the valid
          image areas (-> withimagebuffersize)

Version 4.28.4 - 2021-05-28 (IT)
--------------
        + ebox_io.f90: Changed format of some units (power instead of
	               division slash, cf emldetect & edetect_stack)

Version 4.28.3 - 2019-02-28 (IT)
--------------
	+ eboxdata.f90: increase (double) counter max_sou to handle large
	  mosaic images in the pipeline

Version 4.28.2 - 2018-04-24 (RDS & IT)
--------------
	+ edetect_io_box.f90: To check whether an input image was empty,
	  its total number of counts was determined, which can exceed the
	  numeric range of thedata type and cause an error (example: 256
	  counts in an 8-bit integer image). The sum has been replaced by
	  the maximum pixel value now for all numeric image types (as an
	  int32 variable to cover all possible types), and by a boolean
	  for the masks. (SPR-7441 ctd)


Version 4.28.1 - 2018-03-17 (IT)
--------------
	+ eboxdetect_mod.f90: Updated subimage array indexes
	  (v4.27.6 continued).


Version 4.28 - 2018-02-13 (EO)
------------------------------
	+ This is a new major version of this package including a new GNU
	Public License Text disclaimer required to distribute the SAS source
	code to the Astronomical Community under the terms of the GNU Public
	License. The text as it is shown below is the same that has been 
	included in all SAS source code files.

	ESA (C) 2000-2018 

	This file is part of ESA's XMM-Newton Scientific Analysis System
	(SAS).

	SAS is free software: you can redistribute it and/or modify
	it under the terms of the GNU General Public License as published by
	the Free Software Foundation, either version 3 of the License, or
	(at your option) any later version.

	SAS is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.
	   
	You should have received a copy of the GNU General Public License
	along with SAS.  If not, see <http://www.gnu.org/licenses/>.
	---------------------------------------------------------------------


Version 4.27.6 - 2018-02-09 (IT)
--------------
	+ eboxdetect_mod.f90: Updated loop indexes for subimages.

Version 4.27.5 - 2017-12-20 (IT)
--------------
	+ edetect_io_box.f90: Fixed the number of valid pixels in the
	  input detection masks (SPR-7441)
	+ eboxdetect_mod.f90: further improvements to the new subimage algorithm.

Version 4.27.4 - 2017-01-16 (IT)
--------------
	+ ebox_io.f90: Fixed two typos in the new subimage coordinates of the
	  detection masks (related to SPR-7430).
	+ release memory for CAL pointers
	+ increased some internal array sizes

Version 4.27.3 - 2016-12-03 (IT)
--------------
	+ Removed debugging comments from the code after testing v4.27.2.
	+ Updated documentation: Parameter withoffsets=yes (obsolete
	  eident offsets) yields a warning; no other effect anymore.

Version 4.27.2 - 2016-11-23 (IT)
--------------
	+ New algorithm to determine the subimages, in order to avoid
	  memory leaks which could lead to a large number of spurious
	  detections with the gfortran compiler. Tentatively removed the
	  obsolete support of eident offsets. Test version.

Version 4.27.1 - 2016-10-24 (IT)
--------------
	+ ebox_io.f90: fixed an old bug in the calculation of the degrees
	  of freedom of multiple observations, used for the equivalent
	  likelihoods per instrument and image. Has neither affected single
	  observations nor summary lines of the output table. SPR-7400.

Version 4.27 - 2016-09-30 (IT)
--------------
        + Parameter constraints: changed lower limit of parameter ecf
          from 0.001 to 0.0. Purpose: Fluxes can be set to zero (e.g. by
          edetect_stack), if no ecfs are defined.
	+ Number of detections in output list as informational output and
	  new fits keyword NDETECT. Minimum detection likelihood: LIKEMIN.
	  Pixel size: XBINSIZE, YBINSIZE.
	+ ebox_io.f90: Write summary line also if only one instrument is
	  active. Adjusted tests.
	+ edetect_io_box.f90: subimages via imagebuffersize: shift
	  reference point by -16 in x and in y (as in emldetect's
	  edetect_io_ml.f90) in order to make sure that subimages have
	  zero values in their edge rows and columns. "Chains" of spurious
	  detections between the subimage and the image edge may arise
	  otherwise.
	+ edetect_io_box.f90: Made determination of imbuff more concise.
        + DEPEND: updated to emldetect-7.0
	+ cf. SCR 7399: source detection on stacked observations


Version 4.26 - 2016-07-18 (AI)
--------------
	+ gfortran compatibiliy changes applied.
	
Version 4.25.2 - 2016-04-25 (IT)
--------------
        + Throw error "TooManyBands" if images for more than six energy
          bands and / or more than six pimin/pimax are provided. Documented
          error message and maximum number of bands and corrected typo in
          the documentation that resulted in a scrambled line on the
          "obsmode" parameter (SPR-7358 and SPR-7359).

Version 4.25.1 - 2015-10-01 (IT)
--------------
	+ Input data in detector coordinates: Use CDELT1L, CDELT2L
	  header keywords instead of CDELT1, CDELT2 in order to determine
	  the pixel size. For pn and MOS images in detector coordinates,
	  CDELT1/2 have different units.


Version 4.25 - 2015-08-21 (IT)
--------------
	+ Allow input data in detector coordinates (SCR 7289). The
	  coordinate system is determined from the keywords CTYPE1/2 (new
	  arguments to the subroutine co_image): detector coordinates, if
	  DETX/Y. No PSF correction is performed in this case. Detector
	  coordinates of the detections are written to new DETX/DETY columns
	  in the output source list (only!) for input images in detector
	  coordinates. Note: Position errors are not converted into detector
	  coordinates. If required, users can derive them from the
	  X_IMA_ERR, Y_IMA_ERR columns.
	+ Documentation updated.


Version 4.24 - 2015-03-31 (IT)
--------------
	+ new parameter "obsmode" to distinguish between pointing and
	  slew-mode data (SCR 7279). Default: pointing.
	+ eboxdetect_mod.f90: use a flat kernel
	+ eboxdetect_mod.f90: Improved detection of faint extended sources.
	  subroutine msrbkg: Calculate preliminary equivalent likelihoods
	                     of the candidate sources.
	  subroutine match: If irun (i.e.: ncom) > 1, check whether a
	    newly detected candidate has a counterpart in the previous
	    version of the source list AND (new:) whether the equivalent
	    likelihood of the counterpart is above the detection threshold
	    likemin. A previous detection with a likelihood below likemin
	    can be overwritten by a new one now. Otherwise, it might be
	    removed from the final source list because of its low
	    detection likelihood, and faint extended sources might be missed.
	+ documentation updated


Version 4.23 - 2014-08-28 (IT)
--------------
	+ DEPEND: updated to emldetect-6.0
	+ edetect_io_box.f90, documentation: fixed typo in error messages.
	+ edetect_io_box.f90: changed syntax of cp_head to be consistent
	  with other source-detections tasks (call setAttributes). No
	  effects on eboxdetect output.


Version 4.22.5 - 2013-03-17 (IT)
--------------
	+ Documentation updated. Minor latex syntax changes to build the
	  package index properly on Ubuntu


Version 4.22.4 - 2012-06-22 (IT)
---------------------------------

	+ eboxdetect_mod.f90: fixed a bug which made eboxdetect crash when
	  a source is detected exactly at the position (image pixels) of
	  the optical axis.


Version 4.22.3 - 2012-06-18 (IT)
---------------------------------

	+ Documentation: Typographical and formal corrections,
	  fixed broken Errors Section.
	

Version 4.22.2 - 2012-03-27 (IT)
-------------------------------                                                                                                                                                                                       
	+ Marked parameter mergedlistset as "not yet implemented" in
	  documentation and parameter file (SPR-6571)
	+ Added parameter descriptions to documentation
	  (withimagebuffersize, imagebuffersize, SPR-6700)
	+ Removed unused imagebuffersizesets entry from parameter file:
          parameter is "imagebuffersize" (SPR-6700)

	
Version 4.22.1 -  2011-02-14 RDS
-------------------------------

	+ src/edetect_io_box.f90

Now checks for the mask in an extension called
MASK and if it doesn't find it, looks in the PRIMARY array.
(SCR-314)


Version 4.22 -  2010-03-11 JR
-------------------------------

Implemented the withimagebuffersize parameter.
This is for the use or not of the imagebuffersize
parameter, meant to be used in the reduction of 
memory requirements. Default value=no. With the default 
value the imagebuffersize parameter will be read
from the header of the image. This also
fix the edetect_chain problem.

Version 4.21 -  2009-05-06 JR
-------------------------------

Fixed DEPEND file.
Now emldetect 5.0


Version 4.20 -  2009-03-31 JR
-------------------------------

Implemented reduction of memory requirements 
for raster scan data new parameter: 
imagebuffersize, default value=640


Version 4.19.2 -  2008-06-03 GL
-------------------------------

Removed test output

	
Version 4.19.1 -  2008-05-08 GL
-------------------------------	


Increased limits for input images (for mosaicing observations):
    max_ima=240
    max_ins=60


Enable processing of multiple exposures with identical ObsIDs:
    increased lenghts of strings expid, ins, instrume
Close SOC-SPR 5874 (SSC-SPR-3139)

Correct error due to integer variable
'iso', which should be of real type after the changes 
made in v4.16. The error resulted in a slightly
reduced sensitivity for faint sources. 
(this is now identical with  2XMM/reprocessing version 4.15.2)	

	
	
Version 4.19 -  2004-02-02 GL
-------------------------------	

Changed dimension of variable 'double' to max_ima

	
Version 4.18 -  2004-02-01 GL
-------------------------------	

Changed maximum number of input instruments/pointings
and max. number of input images:
max_ins = 12
max_ima = 60
	
	
Version 4.15.1 -  2004-01-20 GL
-------------------------------	

Same as 4.17 - for release track
Removed test output
	
	
Version 4.17 -  2004-12-21 GL
-------------------------------	

Changed ebox_io.f90 (subroutine wr_stab) to enable raster scans.
	
Version 4.16 -  2004-12-02 GL
-------------------------------

Improve resolution of closeby sources in 5x5 box mode:
     - Smooth SN map lfeld with tapered 5x5 kernel instead box average.
     - Always use 3x3 box in soubroutine 'match' to find local maxima.
	

	
Version 4.13.3 -  2004-10-06 GL
-------------------------------

Average input background map over detection box
Close SPR SSC-SPR-3399: Spurious sources near chip gaps.
	
	
Version 4.13.2 -  2004-08-25 GL
------------------------------

Total likelihoods in multi-instrument runs 
are now corrected using the effective number of input images
(where the source is inside the detection mask).

	
Version 4.13.1 -  2004-03-16 GL
------------------------------

Correction in documentation
	
Version 4.13 -  2003-12-08 GL
------------------------------

Make use of param v2 features in .par file.

	
Version 4.12 -  2002-10-30 GL
------------------------------
(development track version)
	
Fixed DEPEND file
Renamed column SIGMA to LIKE
Removed Warning: "CROTA2 missing"
Closed SPRs: 
  +SSC_SCR-2966 Source buffer overflow
  +SSC_SCR-3009 Source buffer overflow (uncomp timing mode)



Version 4.8 - 2002-05-24 GL
-----------------------------

Converted .par file to XML
	
Version 4.7.2 - 2002-05-16 HB
-----------------------------

Closed SPRs:
+SSC-SPR-2836 wrong source counts formula in documentation	
+SSC-SPR-2862 (on eposcorr) inconsistent lii/bii,lii_corr/bii_corr values:
	      constant 'pi' set to double precision (also fixed in
   	      emldetect)
	
Version 4.7.1 (2001-03-08) HB
-----------------------------

EXPIDSTR & ATT_SRC propagated from input

Closed SPR:
+SSC-SPR-2647  Can we have optical axis position please?
+SSC-SPR-2803 	NaNs in multi-camera source lists
	
Version 4.7 (2001-11-21)
------------------------

emldetect 4.7 added to DEPEND	
	
Version 4.6 (2001-11-07)
------------------------

Closed SPR:
+ SSC-SPR-2621: routines common to eboxdetect and emldetect now called
	        from emldetect library. Module edetect_io renamed
	        to edetect_io_box
		
Version 4.5 (2001-10-15)
------------------------

Closed SPR:
+ SSC-SPR-2592 need to account for OOT events
  Rates and fluxes now divided by the following OOT correction factors:
  PN FF mode: 0.9411;  PN eFF mode: 0.97815
  Source counts (SCTS column) and other modes/cameras are left uncorrected	 		
Version 4.4 (2001-09-12)
------------------------

+ test output removed	
	
Version 4.3 (2001-08-28)
------------------------

+ source buffer size increased 	
	
Version 4.2 (2001-07-25)
------------------------

+ detection likelihoods, L, are now calculated such that, independently
  of the number of input images, they always obey the definition L=-ln(p) 
  where p is the probability that the observed counts are due to Poissonian 
  fluctuations of the background	
+ the task now exists with an error message if any of the input
  images are empty	
	
Closed SPR:
+ SSC-SPR-2463 SCR 67: Calibration quantities in output source lists	
	
Version 4.1 (2001-04-10)
------------------------

Fixed bug in calculation of likelihood
Removed diagnostic output
	
	
Version 4.0 (2001-02-28)
-------------------------

Closed SPRs:

+ SSC-SPR-2275 Energy band wanted
+ SSC-SPR-2273 Documentation
+ SSC-SPR-2271 BOX_SIZE should be in units of pixels
+ SSC-SPR-2270 DIST_NN should be in arcseconds
+ SSC-SPR-2132 does not trap detmask from wrong camera
+ SSC-SPR-2065 FITS errors in ouput
+ SSC-SPR-2223 Count rate evaluation with SAS

eboxdetect now uses medium accuracy PSF from CAL 
to correct for out-of-box counts.
Introduced 2 new parameters "pimin" and "pimax".
New columns BOX_CTS, BG_RAW, and EEF in output table.


Version 3.6 (2001-02-13)
--------------------------

Closed SPRs:
+ SSC-SPR-2149 Ignores the BAND keyword	
+ SSC-SPR-2234 definition of hardness ratios	

Version 3.5.2 (2000-11-09)
--------------------------

+ definition of hardness ratio 3 changed (on JOs request).
	
	
Version 3.5.1 (2000-10-20)
--------------------------	

Closed SPR:

+ SSC-SPR-1992 test harness fails on linux
	
Version 3.5 (2000-09-29)
------------------------
	
- Version changed to 3.5
	
	
Version 3.4.1 (2000-09-29)
---------------------------
	
- V3.4 contained an obsolete vesion of module ebox_io. Corrected in v3.4.1.
	
Version 3.4 (2000-09-28)
-------------------------

+ Code to prevent the overflow of the source buffer was added.
	
closed SPRs:

+ SSC-SPR-0730  like_min description	
+ SSC-SPR-0733  errors computation
+ SSC-SPR-0734  General documentation
+ SSC-SPR-0737	Verbosity
+ SSC-SPR-0786  Algorithm description
+ SSC-SPR-1078  Parameter layout file
+ SSC-SPR-1084  Hardness ratios
+ SSC-SPR-1085  Detection over several image
	
	
Version 3.3.4  2000-07-04
----------------------------

+ sla added to DEPEND file	

	
Version 3.3.3  2000-07-03
----------------------------

+ inconsistent .par file and documentation corrected	
	

Version 3.3.2  2000-07-02
----------------------------

+ galacic coordinates now calculated using slalib
+ column DIST_NN filled


Version 3.3.1 (June 28, 2000)
-----------------------------

+ HRs outside [-1,1] range corrected
+ exposure for sources at chip borders corrected 
+ unused fields in output list now contain null values

Closed SPRs:

+ 1235 Task exits without error, message or creating outpu
+ 1470 EBOXDETECT crashes
+ 1638 EBOXDETECT does not create output
+ 1639 Strange false detections
+ 1659 wrong format for errors and warnings in documentation
+ 1750 eboxdetect terminating in extended source field
+ 1886 eboxdetect SEGV with NAG F95 V4.0 on Tru64 Unix


Version 3.3 (March 13, 2000)
----------------------------

- HR3 and hardness ratio errors corrected.
	
	
Version 3.2 (February 22, 2000)
-------------------------------

- Problem related to the error calculation which let the task crash
  if the PN is not the first instrument corrected	 

Version 3.1 (February 18, 2000)
-------------------------------

- DEPEND file corrected
- Error columns in source list filled	

	
Version 3.0 (January 27, 2000)
------------------------------

- Source list format adjusted to comply with recent DCPs.
- Task now can handle several exposures per instrument.
- Task now can handle I1, I2, I4, R4, and R8 input images.
- Offsets between different instruments as determined by task eident
  are now read and applied to the input images. Two command line
  parameters were added to control whether the eident output file
  is read.	   
- The pixel position of the optical axis is now calculated from
  the image keywords (used to be set to the center of the image).  	 

	
Version 2.0 (September 14, 1999)
--------------------------------

- Input parameter boxsize added to control whether 3 x 3 or 5 x 5 pixel
  detection box is used.
- Fraction of PSF in source box and background box is now calculated
  as a function of the off-axis angle.	
- Smallest permitted distance between sources now depends on the
  respective detection likelihoods.	
- Error in analytical PSF corrected. 	

	
Version 1.12 (August 4, 1999)
-----------------------------

- task now accepts one detection mask per instrument
	
Closed SPRs:

  - 1076: exposure map use (sentence removed from agorithm description)
  - 1079: parameter type for boxlistset changed.	
  - 1081: exposure values if withexpimage=false
  - 1083: ID_BAND now always 0 for summary bands.
  - 1081: 0.5 pixel source position offset corrected
  - 1161: with the above change (one detection mask per instrument)
	  the task now handes up to 3 instruments with up to 
	  6 energy bands each.

Open SPRs: 0733,0735,0737,0742,0762,1078,1084,1085

	
Version 1.11 (August 3, 1999)
-----------------------------

- one more error in RA, DEC calculation corrected
- task now looks for CROTA2 keyword and assumes 0 of not present	
- max. filename length changed to 1024 (this didn't work in v1.10)	

Closed SPRs:

  - 1077: program now requires one exposuremap per band
	  and complains if less than the required number of
	  maps are supplied.

	
Version 1.10 (July 29, 1999)
----------------------------

- error in RA, DEC calculation corrected
- partial update of description (more to follow)
	
Closed SPRs:
 
  - 0730: description of likelihood parameter	  
  - 1114: filename length changed to 1024	

Open SPRs: 0733,0735,0737,0742,0762,1076-1085

	
Version 1.9 (July 12, 1999)
---------------------------

- paramter names changed to conform to convention

Closed SPRs:

  - 0726: expimagesets and withexpimage parameters (renamed) 
	  are now in the documentation 	
  - 0731 & 0735: ecf paramter now in documentation and 
	         wrong type of ecf parameter in .par file corrected	
	
Open SPRs: 

  - 0730,0786: items missing from the documentation
  - 0733,0735,0737,0742,0762:  algorithmic issues
	

Version 1.8 (July 8, 1999)
--------------------------
	
Closed SPRs:

  - 0551: Smaller test files	
  - 0742: BOX_SIZE column in source table filled
  - 0744: BG_MAP negative
  - 0785: WCS keywords and RA, DEC calculation	
  - 0981: taskmain added to DEPEND	

Open SPRs:

  - 0726,0730,0731,0734,0786: items missing from documentation 
  - 0733,0735,0737,0742,0762:  algorithmic issues

	
Version 1.7 (June 18, 1999)
---------------------------
	
 - now performs simultaneous source detection in multiple energy bands
 - accepts arbitrarily sized input images
		
Version 1.5
----------------------	

To do list added

Closed SPRs:
 
 - 0071 & 0072: get_files and cp_head were moved to module edetect_io
	 which is used by all AIP SAS tasks
 - 0073: DAL used to read parameter lists
 - 0504: *.f code changed to *.f90; date and time calls removed 
 - 0516: "checkoutput" changed to "./checkoutput" and cp command
         removed from test/eboxdetect_test	
	
Version 1.4
----------------------	

 error in routine exdmin corrrected.	
	
Version 1.3
----------------------
	
 test harness changed: A f90 program is used to compare the output source 
	               parameters with a reference dataset.
	
Version 1.2
----------------------

 test harness changed: Three different parameter settings are tested.  	
 eboxdetect.par changed: ecf (energy conversion factors) added to list
	                 of parameters. 
	
Closed SPRs:

 - 0292: Test files are now gzip'ed to save disk space.	
 - 0298: CLEANFILES in eboxdetct/test/Makefile edited.
 - 0323: Functionality added: taks now perfomrs source detection
	 on single fields in both local and map mode.
 - 0324: Makefile on eboxdetect/test edited	
 - 0462: HDUCLASS and HDUCLAS1 added	
 - 0463: EXTNAME changed to SRCLIST
 - 0467: "draft" in task description deleted	
	
Version 1.1
----------------------

ChangeLog added

Closed SPRs:

 - 0065: test harness is more robust now
 - 0074: "
 - 0067: .par file provided instead of .prm
 - 0068: fatal changed to error	

Open SPRs: (will be treated in next task version)

 - 0066: test_plan
 - 0069: dataset opened twice	
 - 0071: get_files to be replaced by generic mechanism
 - 0072: cp_head to be replaced by generic mechanism 	
 - 0073: generic mechanism for parsing lists

Version 1.0
----------------------------

- Original version submitted to the SOC

To do list:
------------	

- add multi band option (done: V1.7)
- add matched filter option
- add error handling and verbosity control