Bug #1967

ctbin throws error for far-away events

Added by Kelley-Hoskins Nathan over 7 years ago. Updated almost 7 years ago.

Status:ClosedStart date:03/16/2017
Priority:HighDue date:
Assigned To:Knödlseder Jürgen% Done:

100%

Category:-
Target version:1.5.0
Duration:

Description

I’m running ctbin in python, but its throwing an error. My ctbin setup:

=== GApplication ===
 Name ......................: ctbin
 Version ...................: 1.2.0
 inobs .....................: events.fits
 outcube ...................: cube.fits
 ebinalg ...................: LIN
 emin ......................: 0.085
 emax ......................: 200
 enumbins ..................: 1
 ebinfile ..................: NONE
 usepnt ....................: no
 nxpix .....................: 30
 nypix .....................: 30
 binsz .....................: 0.2
 coordsys ..................: GAL
 xref ......................: 184.557600325371
 yref ......................: -5.78418071496058
 proj ......................: TAN
 publish ...................: no
 chatter ...................: 2
 clobber ...................: yes
 debug .....................: no
 mode ......................: ql
 logfile ...................: ctbin.log

but in the function ctbin::fill_cube(), on the first event in the first observation

obs:=== GCTAObservation ===
 Name ......................: 
 Identifier ................: VR73991_CH1
 Instrument ................: VERITAS
 Event file ................: /nv/hp11/nkelleyh3/data/software/veripy/cluster/test_profiler2/temp/load/fitsdir/VR73991.ReconMethodDisp.Cut-NTel2-ExtendedSource-Hard.chunk1.fits
 Event type ................: EventList
 Statistics ................: Poisson
 Ontime ....................: 304 s
 Livetime ..................: 276.230424 s
 Deadtime correction .......: 0.908652710526316
 User energy range .........: undefined
=== GCTAPointing ===
 Pointing direction ........: (RA,Dec)=(265.84495543,-29.005751976)
=== GCTAResponseIrf ===
 Caldb mission .............: 
 Caldb instrument ..........: 
 Response name .............: 
 Energy dispersion .........: Not used
 Save energy range .........: undefined
=== GCTAEventList ===
 Number of events ..........: 165 (loaded)
 Time interval .............: 56833.2768518518 - 56833.2803703704 days
 Energy interval ...........: 0.85 - 70 TeV
 Region of interest ........: RA=265.844955432731, DEC=-29.0057519755548 [0,0] Radius=2.24999914622635 deg

event:Dir=RA=266.897430419922, DEC=-29.9585800170898 [0.0112254320541442,-0.0174205200340758] Energy=6.10820293426514 TeV Time=257236727.350771 s (TT)

it throws this error:

Traceback (most recent call last):
  File "./test.py", line 12, in <module>
    veripy.model_counts_profile_2( obs, center, temp_dir=proftemp )
  File "/nv/hp11/nkelleyh3/data/software/veripy/src/obs.py", line 1160, in model_counts_profile_2
    cb.run()
  File "/nv/hp11/nkelleyh3/data/software/ctools/lib/python3.5/site-packages/ctools/tools.py", line 1358, in run
    return _tools.ctbin_run(self)
RuntimeError: *** ERROR in GWcsTAN::prj_s2x(int, int, int, int, double*, double*, double*, double*, int*): 1 (phi,theta) coordinates were invalid.

By inserting couts into ctbin.cpp, I can see that it comes from the line:

GSkyPixel    pixel = m_counts.dir2pix(dir);

in ctbin::fill_cube(GCTAObservation* obs).

After poking around, it turns out that observation is a galactic center observation and ctbin is centered on the crab, so the event it was trying to bin was more than a few degrees outside the counts cube. But, this situation seems like it should result in an empty counts cube, not a (difficult to diagnose) error message. Is this working as expected?


Recurrence

No recurrence.

History

#1 Updated by Knödlseder Jürgen over 7 years ago

  • Status changed from New to In Progress
  • Assigned To set to Knödlseder Jürgen
  • Priority changed from Normal to High
  • Target version set to 1.3.0
  • % Done changed from 0 to 10

I agree that the error message is a bit cryptic and that type of error could be catched and translated into a more understandable message.

The exception comes from the WCS classes which convert sky positions into pixel numbers. An exception occurs if the conversion cannot be done, which can happen when a position very far off the centre of the projection is requested.

I will try to make this more explicit.

#2 Updated by Knödlseder Jürgen over 7 years ago

  • Target version changed from 1.3.0 to 1.4.0

#3 Updated by Knödlseder Jürgen over 7 years ago

  • Target version changed from 1.4.0 to 1.5.0

#4 Updated by Knödlseder Jürgen almost 7 years ago

  • Status changed from In Progress to Closed
  • % Done changed from 10 to 100

This bug is corrected since some time using the following code:

        GSkyPixel pixel;
        try {
            pixel = m_counts.dir2pix(dir);
        }
        catch (std::exception &e) {
            num_invalid_wcs++;
            continue;
        }

Also available in: Atom PDF