Skip to content

Commit

Permalink
copy pngs
Browse files Browse the repository at this point in the history
  • Loading branch information
StFroese committed Sep 8, 2023
1 parent cae8dd3 commit 1cf97b9
Show file tree
Hide file tree
Showing 17 changed files with 170 additions and 238 deletions.
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ def setup(app):
"tutorials",
], # path to where to save gallery generated output
"nested_sections": True,
"copyfile_regex": r"index.rst",
"copyfile_regex": r"index.rst|.*\.png",
}


Expand Down
6 changes: 6 additions & 0 deletions examples/examples/README.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.. _examples_gallery:

Examples gallery
================

The examples gallery provides an overview of different ctapipe modules and how to use them.
2 changes: 0 additions & 2 deletions examples/examples/algorithms/convert_images_to_2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@

from ctapipe.image.toymodel import Gaussian
from ctapipe.instrument import SubarrayDescription
from ctapipe.io import EventSource
from ctapipe.utils import get_dataset_path
from ctapipe.visualization import CameraDisplay

# get the subarray from an example file
Expand Down
2 changes: 0 additions & 2 deletions examples/examples/algorithms/dilate_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@
# Now dialte the mask a few times:
#

from ctapipe.image.cleaning import dilate


def show_dilate(mask, times=1):
m = mask.copy()
Expand Down
4 changes: 2 additions & 2 deletions examples/examples/algorithms/nd_interpolation.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@
)
plt.title("Raw table, uninterpolated {0}".format(energy_table.hist.T.shape))
cb = plt.colorbar()
cb.set_label("$\log_{10}(E/\mathrm{TeV})$")
cb.set_label(r"$\log_{10}(E/\mathrm{TeV})$")

# the interpolated table
plt.subplot(1, 2, 2)
Expand All @@ -130,7 +130,7 @@
plt.ylabel("Impact Dist(m)")
plt.title("Interpolated to a ({0}, {0}) grid".format(N))
cb = plt.colorbar()
cb.set_label("$\log_{10}(E/\mathrm{TeV})$")
cb.set_label(r"$\log_{10}(E/\mathrm{TeV})$")

plt.tight_layout()
plt.show()
Expand Down
7 changes: 2 additions & 5 deletions examples/examples/core/InstrumentDescription.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@
"""

import numpy as np
from astropy.coordinates import SkyCoord

from ctapipe.io import EventSource
from ctapipe.utils.datasets import get_dataset_path
from ctapipe.visualization import CameraDisplay

filename = get_dataset_path("gamma_prod5.simtel.zst")

Expand Down Expand Up @@ -71,7 +72,6 @@
tel.camera.geometry.pix_x

# %matplotlib inline
from ctapipe.visualization import CameraDisplay

CameraDisplay(tel.camera.geometry)

Expand Down Expand Up @@ -106,9 +106,6 @@

subarray.optics_types

from astropy.coordinates import SkyCoord

from ctapipe.coordinates import GroundFrame

center = SkyCoord("10.0 m", "2.0 m", "0.0 m", frame="groundframe")
coords = subarray.tel_coords # a flat list of coordinates by tel_index
Expand Down
11 changes: 1 addition & 10 deletions examples/examples/core/Tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,17 @@
"""

import logging
from time import sleep

from astropy import units as u

from ctapipe.core import Component, TelescopeComponent, Tool
from ctapipe.core.traits import (
Dict,
Float,
FloatTelescopeParameter,
Integer,
List,
Path,
TraitError,
Unicode,
observe,
)
from ctapipe.instrument import SubarrayDescription
from ctapipe.utils import get_dataset_path

GAMMA_FILE = get_dataset_path("gamma_prod5.simtel.zst")
Expand Down Expand Up @@ -52,8 +46,6 @@ def do_thing(self):
class SecondaryMyComponent(MyComponent):
"""A second component"""

pass


class AdvancedComponent(Component):
"""An advanced technique"""
Expand Down Expand Up @@ -100,7 +92,6 @@ class TelescopeWiseComponent(TelescopeComponent):
# one:
#

from ctapipe.instrument import SubarrayDescription, TelescopeDescription

subarray = SubarrayDescription.read(GAMMA_FILE)
subarray.info()
Expand Down
46 changes: 24 additions & 22 deletions examples/examples/core/containers.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@
import numpy as np
from astropy import units as u

from ctapipe.containers import SimulatedShowerContainer
from ctapipe.core import Container, Field, Map

######################################################################
# Let’s define a few example containers with some dummy fields in them:
#
#


class SubContainer(Container):
junk = Field(-1, "Some junk")
Expand Down Expand Up @@ -59,14 +61,14 @@ class EventContainer(Container):
######################################################################
# Basic features
# --------------
#
#

ev = EventContainer()


######################################################################
# Check that default values are automatically filled in
#
#

print(ev.event_id)
print(ev.sub)
Expand All @@ -79,23 +81,21 @@ class EventContainer(Container):

######################################################################
# print the dict representation
#
#

print(ev)


######################################################################
# We also get docstrings “for free”
#

?EventContainer

?SubContainer
#
help(EventContainer)

help(SubContainer)

######################################################################
# values can be set as normal for a class:
#
#

ev.event_id = 100
ev.event_id
Expand All @@ -108,7 +108,7 @@ class EventContainer(Container):
######################################################################
# and we can add a few of these to the parent container inside the tel
# dict:
#
#

ev.tel[10] = TelContainer()
ev.tel[5] = TelContainer()
Expand All @@ -121,12 +121,15 @@ class EventContainer(Container):
######################################################################
# Be careful to use the ``default_factory`` mechanism for mutable fields,
# see this **negative** example:
#
#


class DangerousContainer(Container):
image = Field(
np.zeros(10),
description="Attention!!!! Globally mutable shared state. Use default_factory instead",
description=(
"Attention!!!! Globally mutable shared state. Use default_factory instead"
),
)


Expand All @@ -145,7 +148,7 @@ class DangerousContainer(Container):
######################################################################
# Converion to dictionaries
# -------------------------
#
#

ev.as_dict()

Expand All @@ -155,15 +158,15 @@ class DangerousContainer(Container):
######################################################################
# for serialization to a table, we can even flatten the output into a
# single set of columns
#
#

ev.as_dict(recursive=True, flatten=True)


######################################################################
# Setting and clearing values
# ---------------------------
#
#

ev.tel[5].image[:] = 9
print(ev)
Expand All @@ -175,11 +178,10 @@ class DangerousContainer(Container):
######################################################################
# look at a pre-defined Container
# -------------------------------
#
#

from ctapipe.containers import SimulatedShowerContainer

?SimulatedShowerContainer
help(SimulatedShowerContainer)

shower = SimulatedShowerContainer()
shower
Expand All @@ -188,15 +190,15 @@ class DangerousContainer(Container):
######################################################################
# Container prefixes
# ------------------
#
#
# To store the same container in the same table in a file or give more
# information, containers support setting a custom prefix:
#
#

c1 = SubContainer(junk=5, value=3, prefix="foo")
c2 = SubContainer(junk=10, value=9001, prefix="bar")

# create a common dict with data from both containers:
d = c1.as_dict(add_prefix=True)
d.update(c2.as_dict(add_prefix=True))
d
d
Loading

0 comments on commit 1cf97b9

Please sign in to comment.