open-gamma-ray-astro / gamma-astro-data-formats

Data formats for gamma-ray astronomy
https://gamma-astro-data-formats.readthedocs.io
Creative Commons Attribution 4.0 International
29 stars 27 forks source link

ONTIME in obs index table #131

Closed tony32lin closed 5 years ago

tony32lin commented 5 years ago

The ONTIME, which is listed as optional on the page for Observation index table, seems to be used by gammapy. When I removed the ONTIME filed from VERITAS' DL3 file, I got the following error when running joint-crab script make.py all.

INFO:joint_crab.extract_ogip_spectra:Extracting 1d spectra for veritas dataset
Traceback (most recent call last):
  File "./make.py", line 312, in <module>
    cli()
  File "/Users/tony/anaconda3/envs/joint-crab/lib/python3.6/site-packages/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/Users/tony/anaconda3/envs/joint-crab/lib/python3.6/site-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/Users/tony/anaconda3/envs/joint-crab/lib/python3.6/site-packages/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/Users/tony/anaconda3/envs/joint-crab/lib/python3.6/site-packages/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/Users/tony/anaconda3/envs/joint-crab/lib/python3.6/site-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "./make.py", line 54, in cli_extract_spectra
    extract_spectra(dataset)
  File "/Users/tony/Desktop/VEGAS2DL3/joint-crab/joint_crab/extract_ogip_spectra.py", line 36, in extract_spectra
    extract_spectra_IACT(dataset)
  File "/Users/tony/Desktop/VEGAS2DL3/joint-crab/joint_crab/extract_ogip_spectra.py", line 88, in extract_spectra_IACT
    bkg_estimate.run()
  File "/Users/tony/anaconda3/envs/joint-crab/lib/python3.6/site-packages/gammapy/background/reflected.py", line 308, in run
    temp = self.process(obs=obs)
  File "/Users/tony/anaconda3/envs/joint-crab/lib/python3.6/site-packages/gammapy/background/reflected.py", line 315, in process
    log.debug("Processing observation {}".format(obs))
  File "/Users/tony/anaconda3/envs/joint-crab/lib/python3.6/site-packages/gammapy/data/observations.py", line 149, in __str__
    ss += "- Observation duration: {}\n".format(self.observation_time_duration)
  File "/Users/tony/anaconda3/envs/joint-crab/lib/python3.6/site-packages/astropy/utils/decorators.py", line 711, in __get__
    val = self.fget(obj)
  File "/Users/tony/anaconda3/envs/joint-crab/lib/python3.6/site-packages/gammapy/data/observations.py", line 253, in observation_time_duration
    return Quantity(self.obs_info["ONTIME"], "second")
KeyError: 'ONTIME'

Is this something that is planned to be changed in gammapy?

cdeil commented 5 years ago

We re-started work on the Gammapy observation classes today: https://github.com/gammapy/gammapy/pull/1451#issuecomment-426348845

We're struggling a bit because the CTA DL3 data model isn't really clear yet, what an observation is and how to handle time intervals. The existing solutions of having info in index files, or in EVENTS header aren't great. So I can't tell you yet what we'll do, it's still in the prototyping phase.

But I think we should do changes in Gammapy and then come back with a spec proposal here only later. @tony32lin - Could you please post this issue in the Gammapy issue tracker, and then we'll discuss what to do short- and long-term about it tomorrow.