Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DL1 checks fix and updates #881

Merged
merged 55 commits into from
Feb 1, 2022
Merged

DL1 checks fix and updates #881

merged 55 commits into from
Feb 1, 2022

Conversation

moralejo
Copy link
Collaborator

@moralejo moralejo commented Jan 21, 2022

  • Solved issue with non-updating histograms when moving the run number slider
  • extend run slider bar in case of more than 300 runs
  • added RA and dec info in dl1 data check tables to allow selection by sky region
  • added pixel-wise counting of nearby bright stars, and use that info for excluding some pixels/subruns from the calculations of averages, so that we avoid mistaking them for e.g. noisy pixels

@moralejo moralejo requested a review from rlopezcoto January 21, 2022 13:45
@codecov
Copy link

codecov bot commented Jan 21, 2022

Codecov Report

Merging #881 (a990c7b) into master (b22332d) will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #881   +/-   ##
=======================================
  Coverage   83.83%   83.83%           
=======================================
  Files          77       77           
  Lines        5968     5968           
=======================================
  Hits         5003     5003           
  Misses        965      965           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b22332d...a990c7b. Read the comment docs.

@moralejo moralejo marked this pull request as draft January 21, 2022 16:17
@moralejo moralejo marked this pull request as ready for review January 21, 2022 18:07
@moralejo moralejo marked this pull request as draft January 21, 2022 18:30
@moralejo moralejo marked this pull request as ready for review January 21, 2022 19:28
@moralejo moralejo marked this pull request as draft January 23, 2022 19:21
@moralejo moralejo changed the title Solved issue with non-updating histograms DL1 checks fix and updates Jan 23, 2022
setup.py Outdated Show resolved Hide resolved
@moralejo
Copy link
Collaborator Author

from lstchain.reco.utils import location should be ok, right? No need to use EarthLocation explicitly

@maxnoe
Copy link
Member

maxnoe commented Jan 24, 2022

from lstchain.reco.utils import location should be ok, right? No need to use EarthLocation explicitly

Yes, that is the correct position for LST-1

@moralejo moralejo marked this pull request as ready for review January 28, 2022 09:45

Usage
-----
.. argparse::
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TIL! nice

@@ -35,6 +40,8 @@ class DL1DataCheckContainer(Container):
num_ucts_jumps = Field(-1, 'Number of observed (and corrected) UCTS jumps')
mean_alt_tel = Field(None, 'Mean telescope altitude')
mean_az_tel = Field(None, 'Mean telescope azimuth')
tel_ra = Field(None, 'Telescope pointing RA (deg)')
tel_dec = Field(None, 'Telescope pointing declination')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

container fields should have the correct defaults, so that if a default container is written, the correct tables are setup. None will result in the column being skipped. I think these (and the above) should be np.nan * u.deg and ucts_trigger_type and trigger_type should probably be 0 (they are bitfields of which at least one bit must be set to be a valid trigger type, so 0 would make sense as invalid value marker.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I comment here because I cannot comment on the old code. But to setup a logger related to ctapipe.instrument.camera in a container class definition is really strange and should probably be (re)moved.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having this in the class body get's executed at import time. So this will set it for the whole of lstchain, as soon as lstchain/datachecks/container is imported. If you need this for some reason, I guess connected to cta-observatory/ctapipe#1828, you should set this in the main method of the script, not here.

Copy link
Collaborator Author

@moralejo moralejo Jan 28, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I comment here because I cannot comment on the old code. But to setup a logger related to ctapipe.instrument.camera in a container class definition is really strange and should probably be (re)moved.

I don't remember why I put that there in the first place... gone!

I "remembered":

Coordinate (nan m, nan m) lies outside camera
Coordinate (nan m, nan m) lies outside camera
Coordinate (nan m, nan m) lies outside camera
Coordinate (nan m, nan m) lies outside camera
Coordinate (nan m, nan m) lies outside camera
....
etc etc

In this way I don't get a warning when I try to get the pixel id which corresponds to certain coordinates, some of which turn out to be nans (I know there would be other solutions, but this one is simple).

Copy link
Collaborator Author

@moralejo moralejo Jan 28, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having this in the class body get's executed at import time. So this will set it for the whole of lstchain, as soon as lstchain/datachecks/container is imported. If you need this for some reason, I guess connected to cta-observatory/ctapipe#1828, you should set this in the main method of the script, not here.

Ok, understood. I moved the geometry warning suppressing to the beginning of the script lstchain_check_dl1.py

This also made me realize I was still projecting wrongly some rare events outside the camera (=> index -1) onto the last pixel, so I fixed that also.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This logging setup

time_utc = Time(table['dragon_time'][int(len(table)/2)],
format="unix", scale="utc")
# Calculate telescope pointing in sky coordinates
telescope_pointing = SkyCoord(alt=self.mean_alt_tel*u.rad,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do self.mean_alt_tel / self.mean_az_tel not already have units?

az=self.mean_az_tel*u.rad,
frame=AltAz(obstime=time_utc,
location=location))
self.tel_ra = telescope_pointing.icrs.ra.to(u.deg).value
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to_value(u.deg)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why strip the unit away at all?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, this does the altaz → icrs transformation twice I believe. Transform once, than access the result.

I would probably only store self.pointing_icrs = self.pointing_altaz.transform_to('icrs') and not the individual values without units.

obstime = Time(sampled_times[int(len(sampled_times)/2)],
scale='utc', format='unix')
horizon_frame = AltAz(location=location, obstime=obstime)
pointing = SkyCoord(az=self.mean_az_tel*u.rad,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See? just store the coordinate as astropy coordinate above and you don't have to reconstruct the same object here.

# currently (as of lstchain 0.5.3) event numbers are post-cleaning!:
'min_azimuth': [],
'max_azimuth': [],
'mean_azimuth': [],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe nothing to change now, but this approach of dict of lists seems rather clumsy as you have multiple locations where you have to update if you add a new column.

I think a list of dicts would be much easier to maintain:

subrunwise_data = []

for subrun in subruns:
     data = {}

     data['charge_mean'] = ....
     

     subrunwise_data.append(data)

Like this, you only have a single place and much less to setup and pandas and astropy tables understand the format the same (its the difference between DataFrame.to_dict() and DataFrame.to_dict(orient='records') in pandas.

@moralejo
Copy link
Collaborator Author

@maxnoe I think your suggestions are now implemented, and I have tested this with a few hours of DL1 files.

@moralejo moralejo requested a review from maxnoe February 1, 2022 09:47
Copy link
Member

@maxnoe maxnoe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's merge this as is now.

We should break this up into manageable and reviewable parts, but that can be done at a later stage together with the rest of lstchain.

@moralejo
Copy link
Collaborator Author

moralejo commented Feb 1, 2022

Let's merge this as is now.

Ok, thanks!

We should break this up into manageable and reviewable parts, but that can be done at a later stage together with the rest of lstchain.

Absolutely... but at least this PR, besides adding quite some functionality, goes in the right direction of doing some simplifications (e.g. use of astropy tables).

@moralejo moralejo merged commit 9fa55dd into master Feb 1, 2022
@moralejo moralejo deleted the update_dl1checks branch February 1, 2022 10:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants