question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Documentation on modifying events table

See original GitHub issue

Since it is not possible to rewrite Observation.events, we should show some documentation on how to modify the events list.

  1. The minimal solution would be to provide a HowTo entry with maybe the following lines of code
import numpy as np
from gammapy.data import DataStore, Observation, EventList

datastore = DataStore.from_dir("$GAMMAPY_DATA/hess-dl3-dr1/")
obs = datastore.obs(23523)

# compute the phase separately, using, eg: PINT
phase = np.random.random(len(obs.events.table))

# attach the phase column to the events table
table = obs.events.table
table["PHASE"] = phase
events_new = EventList(table)

# create a new observation
irfs = {}
for _ in obs.available_irfs:
    irfs[_]= getattr(obs,_)
obs_new = = Observation.create(pointing=obs.pointing_radec, 
                  location=obs.observatory_earth_location,
                  obs_id=obs.obs_id,
                  tstart=obs.tstart,
                  tstop=obs.tstop,
                  irfs=irfs)
  1. We can modify Observation.create() or add a Observation.copy() to simplify this. One of the problems with the above lines of code is that most of the information contained in obs.fixed_pointing_info.meta is lost in obs_new

I can implement either. Preference @registerrier @maxnoe @adonath ?

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:9 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
maxnoecommented, Jul 6, 2022

One point regarding pulsar phase: DL3 files are source agnotic and phase is a property of an assumed source. There could even be the case where you have two pulsars in the same FoV, which will probably be the case for CTA observations of the galactic plane?

So having a single phase column in dl3 event lists does not really match the data model. You’d need a phase column per assumed object.

Of course, in most current cases, there is only one.

But at least CTA will very probably not have phase information prefilled in DL3 files, since the only relevant information from CTA is the timestamp of the events and the rest has to come from external information about the assumed object(s)…

0reactions
adonathcommented, Jul 20, 2022

I think having a convenience method to load data from an observation into memory might be useful here. So either:

  • Observation.to_in_memory() or similar
  • data_store.obs(12346, in_memory=True)
Read more comments on GitHub >

github_iconTop Results From Across the Web

Editing events in the selection table—ArcGIS Pipeline ...
ArcGIS Event Editor allows you to edit event records individually or in bulk. ... feature class and the Destination table must be in...
Read more >
[GA4] Modify and create events via the user interface
You can create and modify events in two ways: In code, using Google Tag Manager or APIs such as gtag.js or Firebase; In...
Read more >
Create an events table - OSIsoft Documentation
In the Events pane, click Create Events Table to create an events table on the display. The table shows all the events listed...
Read more >
Creating, updating, and deleting the event table views from ...
To edit an events table view · To remove a column from the event table view, click in the corresponding row. A gray...
Read more >
Modifying Guild Events | Discord.Net Documentation
Name Type Description ChannelId ulong? Gets or sets the channel id of the event. string string Gets or sets the location of this event. Name string...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found