Skip to content

Commit

Permalink
commit docs dev version
Browse files Browse the repository at this point in the history
  • Loading branch information
actions-user committed Jan 26, 2024
1 parent e21a1e4 commit 72a70df
Show file tree
Hide file tree
Showing 937 changed files with 3,278 additions and 1,476 deletions.
Binary file modified docs/dev/.doctrees/environment.pickle
Binary file not shown.
Binary file modified docs/dev/.doctrees/index.doctree
Binary file not shown.
Binary file modified docs/dev/.doctrees/tutorials/analysis-1d/cta_sensitivity.doctree
Binary file not shown.
Binary file not shown.
Binary file modified docs/dev/.doctrees/tutorials/analysis-1d/sed_fitting.doctree
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified docs/dev/.doctrees/tutorials/analysis-2d/detect.doctree
Binary file not shown.
Binary file modified docs/dev/.doctrees/tutorials/analysis-2d/modeling_2D.doctree
Binary file not shown.
Binary file modified docs/dev/.doctrees/tutorials/analysis-2d/ring_background.doctree
Binary file not shown.
Binary file not shown.
Binary file modified docs/dev/.doctrees/tutorials/analysis-3d/analysis_3d.doctree
Binary file not shown.
Binary file modified docs/dev/.doctrees/tutorials/analysis-3d/analysis_mwl.doctree
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified docs/dev/.doctrees/tutorials/analysis-3d/event_sampling.doctree
Binary file not shown.
Binary file not shown.
Binary file modified docs/dev/.doctrees/tutorials/analysis-3d/flux_profiles.doctree
Binary file not shown.
Binary file not shown.
Binary file modified docs/dev/.doctrees/tutorials/analysis-3d/simulate_3d.doctree
Binary file not shown.
Binary file modified docs/dev/.doctrees/tutorials/analysis-time/light_curve.doctree
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified docs/dev/.doctrees/tutorials/api/astro_dark_matter.doctree
Binary file not shown.
Binary file modified docs/dev/.doctrees/tutorials/api/catalog.doctree
Binary file not shown.
Binary file modified docs/dev/.doctrees/tutorials/api/datasets.doctree
Binary file not shown.
Binary file modified docs/dev/.doctrees/tutorials/api/fitting.doctree
Binary file not shown.
Binary file modified docs/dev/.doctrees/tutorials/api/makers.doctree
Binary file not shown.
Binary file modified docs/dev/.doctrees/tutorials/api/maps.doctree
Binary file not shown.
Binary file modified docs/dev/.doctrees/tutorials/api/mask_maps.doctree
Binary file not shown.
Binary file modified docs/dev/.doctrees/tutorials/api/model_management.doctree
Binary file not shown.
Binary file modified docs/dev/.doctrees/tutorials/api/models.doctree
Binary file not shown.
Binary file modified docs/dev/.doctrees/tutorials/api/observation_clustering.doctree
Binary file not shown.
Binary file modified docs/dev/.doctrees/tutorials/api/sg_execution_times.doctree
Binary file not shown.
Binary file modified docs/dev/.doctrees/tutorials/data/cta.doctree
Binary file not shown.
Binary file modified docs/dev/.doctrees/tutorials/data/fermi_lat.doctree
Binary file not shown.
Binary file modified docs/dev/.doctrees/tutorials/data/hawc.doctree
Binary file not shown.
Binary file modified docs/dev/.doctrees/tutorials/data/hess.doctree
Binary file not shown.
Binary file modified docs/dev/.doctrees/tutorials/data/sg_execution_times.doctree
Binary file not shown.
Binary file modified docs/dev/.doctrees/tutorials/scripts/sg_execution_times.doctree
Binary file not shown.
Binary file modified docs/dev/.doctrees/tutorials/starting/analysis_1.doctree
Binary file not shown.
Binary file modified docs/dev/.doctrees/tutorials/starting/analysis_2.doctree
Binary file not shown.
Binary file modified docs/dev/.doctrees/tutorials/starting/overview.doctree
Binary file not shown.
Binary file modified docs/dev/.doctrees/tutorials/starting/sg_execution_times.doctree
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file modified docs/dev/_downloads/432ee3a608125ae95df2e8d950f07716/dl3-1.pdf
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
333 changes: 332 additions & 1 deletion docs/dev/_downloads/5f320bc7e76a524223d801abe9ef46e6/maps.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
},
"outputs": [],
"source": [
"import os\n\n# %matplotlib inline\nimport numpy as np\nfrom astropy import units as u\nfrom astropy.convolution import convolve\nfrom astropy.coordinates import SkyCoord\nfrom astropy.io import fits\nfrom astropy.table import Table\nimport matplotlib.pyplot as plt\nfrom gammapy.data import EventList\nfrom gammapy.maps import Map, MapAxis, WcsGeom, WcsNDMap"
"import os\n\n# %matplotlib inline\nimport numpy as np\nfrom astropy import units as u\nfrom astropy.convolution import convolve\nfrom astropy.coordinates import SkyCoord\nfrom astropy.io import fits\nfrom astropy.table import Table\nfrom astropy.time import Time\nimport matplotlib.pyplot as plt\nfrom IPython.display import display\nfrom gammapy.data import EventList\nfrom gammapy.maps import (\n LabelMapAxis,\n Map,\n MapAxes,\n MapAxis,\n TimeMapAxis,\n WcsGeom,\n WcsNDMap,\n)"
]
},
{
Expand Down Expand Up @@ -349,6 +349,337 @@
"print(energy_axis.center)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Adding Non-contiguous axes\n\nNon-spatial map axes can also be handled through two other objects known as the `~gammapy.maps.TimeMapAxis`\nand the `~gammapy.maps.LabelMapAxis`.\n\n\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### TimeMapAxis\n\nThe `~gammapy.maps.TimeMapAxis` object provides an axis for non-adjacent\ntime intervals.\n\n\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"time_map_axis = TimeMapAxis(\n edges_min=[1, 5, 10, 15] * u.day,\n edges_max=[2, 7, 13, 18] * u.day,\n reference_time=Time(\"2020-03-19\"),\n)\n\nprint(time_map_axis)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"This ``time_map_axis`` can then be utilised in a similar way to the previous implementation to create\na `~gammapy.maps.Map`.\n\n\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"map_4d = Map.create(\n binsz=0.02, width=(10, 5), frame=\"galactic\", axes=[energy_axis, time_map_axis]\n)\nprint(map_4d.geom)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"It is possible to utilise the `~gammapy.maps.TimeMapAxis.slice` attrribute\nto create new a `~gammapy.maps.TimeMapAxis`. Here we are slicing\nbetween the first and third axis to extract the subsection of the axis\nbetween indice 0 and 2.\n\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"print(time_map_axis.slice([0, 2]))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"It is also possible to `~gammapy.maps.TimeMapAxis.squash` the axis,\nwhich squashes the existing axis into one bin. This creates a new axis\nbetween the extreme edges of the initial axis.\n\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"print(time_map_axis.squash())"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The `~gammapy.maps.TimeMapAxis.is_contiguous` method returns a boolean\nwhich indicates whether the `~gammapy.maps.TimeMapAxis` is contiguous or not.\n\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"print(time_map_axis.is_contiguous)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"As we have a non-contiguous axis we can print the array of bin edges for both\nthe minimum axis edges (`~gammapy.maps.TimeMapAxis.edges_min`) and the maximum axis\nedges (`~gammapy.maps.TimeMapAxis.edges_max`).\n\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"print(time_map_axis.edges_min)\n\nprint(time_map_axis.edges_max)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Next, we use the `~gammapy.maps.TimeMapAxis.to_contiguous` functionality to\ncreate a contiguous axis and expose `~gammapy.maps.TimeMapAxis.edges`. This\nmethod returns a `~astropy.units.Quantity` with respect to the reference time.\n\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"time_map_axis_contiguous = time_map_axis.to_contiguous()\n\nprint(time_map_axis_contiguous.is_contiguous)\n\nprint(time_map_axis_contiguous.edges)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The `~gammapy.maps.TimeMapAxis.time_edges` will return the `~astropy.time.Time` object directly\n\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"print(time_map_axis_contiguous.time_edges)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"`~gammapy.maps.TimeMapAxis` also has both functionalities of\n`~gammapy.maps.TimeMapAxis.coord_to_pix` and `~gammapy.maps.TimeMapAxis.coord_to_idx`.\nThe `~gammapy.maps.TimeMapAxis.coord_to_idx` attribute will give the index of the\n``time`` specified, similarly for `~gammapy.maps.TimeMapAxis.coord_to_pix` which returns\nthe pixel. A linear interpolation is assumed.\n\nStart by choosing a time which we know is within the `~gammapy.maps.TimeMapAxis` and see the results.\n\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"time = Time(time_map_axis.time_max.mjd[0], format=\"mjd\")\n\nprint(time_map_axis.coord_to_pix(time))\n\nprint(time_map_axis.coord_to_idx(time))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"This functionality can also be used with an array of `~astropy.time.Time` values.\n\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"times = Time(time_map_axis.time_max.mjd, format=\"mjd\")\n\nprint(time_map_axis.coord_to_pix(times))\n\nprint(time_map_axis.coord_to_idx(times))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Note here we take a `~astropy.time.Time` which is outside the edges.\nA linear interpolation is assumed for both methods, therefore for a time\noutside the ``time_map_axis`` there is no extrapolation and -1 is returned.\n\nNote: due to this, the `~gammapy.maps.TimeMapAxis.coord_to_pix` method will\nreturn ``nan`` and the `~gammapy.maps.TimeMapAxis.coord_to_idx` method returns -1.\n\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"print(time_map_axis.coord_to_pix(Time(time.mjd + 1, format=\"mjd\")))\n\nprint(time_map_axis.coord_to_idx(Time(time.mjd + 1, format=\"mjd\")))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### LabelMapAxis\n\nThe `~gammapy.maps.LabelMapAxis` object allows for handling of labels for map axes.\nIt provides an axis for non-numeric entries.\n\n\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"label_axis = LabelMapAxis(\n labels=[\"dataset-1\", \"dataset-2\", \"dataset-3\"], name=\"dataset\"\n)\n\nprint(label_axis)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The labels can be checked using the `~gammapy.maps.LabelMapAxis.center` attribute:\n\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"print(label_axis.center)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"To obtain the position of the label, one can utilise the `~gammapy.maps.LabelMapAxis.coord_to_pix` attribute\n\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"print(label_axis.coord_to_pix([\"dataset-3\"]))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"To adapt and create new axes the following attributes can be utilised:\n`~gammapy.maps.LabelMapAxis.concatenate`, `~gammapy.maps.LabelMapAxis.slice` and\n`~gammapy.maps.LabelMapAxis.squash`.\n\nCombining two different `~gammapy.maps.LabelMapAxis` is done in the following way:\n\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"label_axis2 = LabelMapAxis(labels=[\"dataset-a\", \"dataset-b\"], name=\"dataset\")\n\nprint(label_axis.concatenate(label_axis2))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"A new `~gammapy.maps.LabelMapAxis` can be created by slicing an already existing one.\nHere we are slicing between the second and third bins to extract the subsection.\n\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"print(label_axis.slice([1, 2]))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"A new axis object can be created by squashing the axis into a single bin.\n\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"print(label_axis.squash())"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Mixing the three previous axis types (`~gammapy.maps.MapAxis`,\n`~gammapy.maps.TimeMapAxis` and `~gammapy.maps.LabelMapAxis`)\nwould be done like so:\n\n\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"axes = MapAxes(axes=[energy_axis, time_map_axis, label_axis])\nhdu = axes.to_table_hdu(format=\"gadf\")\ntable = Table.read(hdu)\ndisplay(table)"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified docs/dev/_downloads/84424d59ec624940199b69d87a792d50/index-1.pdf
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading

0 comments on commit 72a70df

Please sign in to comment.