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.

plotting `ConstantSpatialModel`

See original GitHub issue

Models.plot_regions()/plot_positions() fails if it contains any ConstantSpatialModel (or ConstantFluxSpatialModel), with a rather complicated error message. I suppose this is because there is no position defined for these models.

It would be nice to have this fixed before the 1.0rc release.

A quick solution can be to simply add an exception for ValueError as well here https://github.com/gammapy/gammapy/blob/a68be851d6523742627ed293aa1122c795680f8e/gammapy/modeling/models/core.py#L918.

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
adonathcommented, May 10, 2022

For compatibility with regions 0.6 we have to remove the np.nan values anyway. So I’ll do the compatibility update with regions 0.6 and the we see whether the plotting issue remains…

0reactions
adonathcommented, May 10, 2022

OK

from gammapy.maps import Map
from gammapy.modeling.models import (
    SkyModel,
    PowerLawSpectralModel,
    ConstantSpatialModel,
    PointSpatialModel,
    GaussianSpatialModel,
    Models
)

m1 = SkyModel(
    spectral_model=PowerLawSpectralModel(),
    spatial_model=ConstantSpatialModel()
)

m2 = SkyModel(
    spectral_model=PowerLawSpectralModel(),
    spatial_model=PointSpatialModel()
)

models = Models([m1, m2])

m = Map.create(width=10)
ax = m.plot()
models.plot_regions(ax=ax);

Triggers:

ValueError: need at least one array to concatenate

Which is raised from matplotlib…

Read more comments on GitHub >

github_iconTop Results From Across the Web

Constant spatial model — gammapy v0.19
Here is an example plot of the model: from gammapy.maps import WcsGeom from gammapy.modeling.models import ( ConstantSpatialModel, Models, ...
Read more >
Chapter 9: Spatial Models - Florida State University
Here we show you how to create a spatial framework for combining cyclone data with spatially continuous climate data. The method tessellates the...
Read more >
Visualising spatial prior models
This topic covers how to visualize spatial models near a coast. The method for visualizing spatial models can be used for other models....
Read more >
8 Plotting spatial data
The base plot method plots data with ellipsoidal coordinates using the equirectangular projection, using a latitude parameter equal to the middle latitude of ......
Read more >
Loading and Plotting Spatial Data - TerpConnect
Spatial data objects in R can be rather complex - broadly, a landscape can be ... Load and plot line and polygon shape...
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