Configuring the model and running g-tools
This tutorial shows how to configure the model and how to run Fermipy-LAT g-tools with Fermipy. Many parts of this tutorial are taken directly from the documentation page of Fermipy: fermipy.readthedocs. I suggest to visit it to find further informations.
This tutorial uses the same data as the SMC.ipynb tutorial.
Configuring the model
The model can be configured with a configuration file or directly running Fermipy with your script.
The configuration file defines the data selection and analysis parameters. The configuration file has a hierarchical structure that groups parameters into dictionaries that are keyed to a section name (data, binning, etc.).
When creating a class instance, the configuration is initialized by passing either a configuration dictionary or configuration file path to the class constructor. Keyword arguments can be passed to the constructor to override configuration parameters in the input dictionary. In the following example the config dictionary defines values for the parameters emin and emax. By passing a dictionary for the selection keyword argument, the value of emax in the keyword argument (10000) overrides the value of emax in the input dictionary.
# config = { 'selection' : { 'emin' : 100, 'emax' : 1000 } } gta = GTAnalysis(config,selection={'emax' : 10000})The configuration file can be created also with a yaml file. Below I report a sample of configuration applied for an analysis of the SMC:
data: evfile : 'ft1.fits' scfile : '/u/gl/mdimauro/kipac/workdir/files/SC/P8_104months_ft2.fits' ltcube : '/u/gl/mdimauro/dmcat/workdir/mattia/LogNLogS_Ebins/files_bins/bin13/P8_SOURCE_zmax105_1_3_ltcube.fits' binning: roiwidth : 12.0 binsz : 0.08 binsperdec : 8 coordsys : 'GAL' selection : emin : 1000 emax : 500000 tmin : 239557417 tmax : 512994417 zmax : 105 evclass : 128 evtype : 3 glon: 302.25 glat : -44.37 gtlike: edisp : True irfs : 'P8R2_SOURCE_V6' edisp_disable : ['isodiff','galdiff'] model: src_roiwidth : 12.0 galdiff : '$FERMI_DIFFUSE_DIR/gll_iem_v07.fits' isodiff : '$FERMI_DIFFUSE_DIR/iso_P8R2_SOURCE_V6_v06.txt' catalogs: gll_psc_v16.fit fileio: usescratch: FalseThe configuration file has the same structure as the configuration dictionary such that one can read/write configurations using the load/dump methods of the yaml module:
DATA
The data section defines the input data files for the analysis (FT1, FT2, and livetime cube). evfile and scfile can either be individual files or group of files. The optional ltcube option can be used to choose a pre-generated livetime cube. If ltcube is null a livetime cube will be generated at runtime with gtltcube.
Below an example of the data part:
data : evfile : ft1.lst scfile : ft2.fits ltcube : nullThe options for the data component are the following: * cacheft1: Cache FT1 files when performing binned analysis. If false then only the counts cube is retained. * evfile: Path to FT1 file or list of FT1 files. * ltcube: Path to livetime cube. If none a livetime cube will be generated with gtmktime. * scfile: Path to FT2 (spacecraft) file.
BINNING
Options in the binning section control the spatial and spectral binning of the data.
binning: # Binning roiwidth : 10.0 npix : null binsz : 0.1 # spatial bin size in deg binsperdec : 8 # nb energy bins per decade projtype : WCSThe roiwidth is the ROI width, npix specifies the number of pixels, binsz indicates the pixel size, binsperdec is the number of energy bins per decade and projtype is the type of projection and can be WCS and HEALPIX.
Other options are: * coordsys: for the coordinate system Galactic or Celestial (CEL or GAL), * hpx_order: is the healpix order, hpx_ordering_scheme is the HEALPix Ordering Scheme, * proj: is the Spatial projection for WCS mode, Width of the ROI in degrees. * roiwidth: is the number of pixels in each spatial dimension will be set from roiwidth / binsz (rounded up).
COMPONENTS
The components section can be used to define analysis configurations for independent subselections of the data. Each subselection will have its own binned likelihood instance that is combined in a global likelihood function for the ROI (implemented with the SummedLikelihood class in pyLikelihood). The components section is optional and when set to null (the default) only a single likelihood component will be created with the parameters of the root analysis configuration.
The component section is defined as a list of dictionaries where each element sets analysis parameters for a different subcomponent of the analysis. The component configurations follow the same structure and accept the same parameters as the root analysis configuration. Parameters not defined in a given element will default to the values set in the root analysis configuration.
The following example illustrates how to define a Front/Back analysis with two components. Files associated to each component will be given a suffix according to their order in the list (e.g. file_00.fits, file_01.fits, etc.).
# Component section for Front/Back analysis - { selection : { evtype : 1 } } # Front - { selection : { evtype : 2 } } # BackThe following example illustrates how to define an analysis divided in four components. Each of them has a different zmax and uses a different evtype and isotropic template.
components: - model: {isodiff: $FERMI_DIFFUSE_DIR/iso_P8R2_SOURCE_V6_PSF0_v06.txt} selection: {evtype: 4, zmax: 80} data: {ltcube: ltcube_00.fits} - model: {isodiff: $FERMI_DIFFUSE_DIR/iso_P8R2_SOURCE_V6_PSF1_v06.txt} selection: {evtype: 8, zmax: 85} data: {ltcube: ltcube_01.fits} - model: {isodiff: $FERMI_DIFFUSE_DIR/iso_P8R2_SOURCE_V6_PSF2_v06.txt} selection: {evtype: 16, zmax: 95} data: {ltcube: ltcube_02.fits} - model: {isodiff: $FERMI_DIFFUSE_DIR/iso_P8R2_SOURCE_V6_PSF3_v06.txt} selection: {evtype: 32, zmax: 100} data: {ltcube: ltcube_03.fits}EXTENSION
The options in extension control the default behavior of the extension method. For more information about using this method see the Extension Fitting page. The main options are the following: * fit_ebin: Perform a fit for the angular extension in each analysis energy bin. * fit_position: Perform a simultaneous fit to the source position and extension. * fix_shape: Fix spectral shape parameters of the source of interest. If True then only the normalization parameter will be fit. * free_background: Leave background parameters free when performing the fit. If True then any parameters that are currently free in the model will be fit simultaneously with the source of interest. * free_radius: Free normalizations of background sources within this angular distance in degrees from the source of interest. If None then no sources will be freed. * sqrt_ts_threshold: Threshold on sqrt(TS_ext) that will be applied when update is True. If None then nothreshold is applied. * width: Sequence of values in degrees for the likelihood scan over spatial extension (68% containment radius). If this argument is None then the scan points will be determined from width_min/width_max/width_nstep. * width_max: Maximum value in degrees for the likelihood scan over spatial extent. * width_min: Minimum value in degrees for the likelihood scan over spatial extent. * width_nstep: Number of scan points between width_min and width_max. Scan points will be spaced evenly on a logarithmic scale between width_min and width_max.
There is a notebook dedicated to this analysis.
FILE I/O
The fileio section collects options related to file bookkeeping. The outdir option sets the root directory of the analysis instance where all output files will be written. If outdir is null then the output directory will be automatically set to the directory in which the configuration file is located. Enabling the usescratch option will stage all output data files to a temporary scratch directory created under scratchdir.
Sample fileio Configuration
fileio: outdir : null logfile : null usescratch : False scratchdir : '/scratch'The options for the fileio are the following: * logfile: Path to log file. If None then log will be written to fermipy.log. * outdir: Path of the output directory. If none this will default to the directory containing the configuration file. * outdir_regex: Stage files to the output directory that match at least one of the regular expressions in this list. This option only takes effect when usescratch is True. * savefits: Save intermediate FITS files. * scratchdir: Path to the scratch directory. If usescratch is True then a temporary working directory will be created under this directory. * usescratch: Run analysis in a temporary working directory under scratchdir. * workdir: Path to the working directory. * workdir_regex: Stage files to the working directory that match at least one of the regular expressions in this list. This option only takes effect when usescratch is True.
GTLIKE
Options in the gtlike section control the setup of the likelihood analysis include the IRF name (irfs).
A subsample of options for the gtlike section is listed below: * edisp: Enable the correction for energy dispersion. * edisp_disable: Provide a list of sources for which the edisp correction should be disabled. * use_external_srcmap: Use an external precomputed source map file. * use_scaled_srcmap: Generate source map by scaling an external srcmap file. * wmap: Likelihood weights map.
The Likelihood wights map is created and used in order to account for example for the uncertainty in the interstellar emission.
MODEL
The model section collects options that control the inclusion of point-source and diffuse components in the model. galdiff and isodiff set the templates for the Galactic IEM and isotropic diffuse respectively. catalogs defines a list of catalogs that will be merged to form a master analysis catalog from which sources will be drawn. Valid entries in this list can be FITS files or XML model files. sources can be used to insert additional point-source or extended components beyond those defined in the master catalog. src_radius and src_roiwidth set the maximum distance from the ROI center at which sources in the master catalog will be included in the ROI model.
Sample for the Model section:
model : # Diffuse components galdiff : '$FERMI_DIR/refdata/fermi/galdiffuse/gll_iem_v06.fits' isodiff : '$FERMI_DIR/refdata/fermi/galdiffuse/iso_P8R2_SOURCE_V6_v06.txt' # List of catalogs to be used in the model. catalogs : - '3FGL' - 'extra_sources.xml' sources : - { 'name' : 'SourceA', 'ra' : 60.0, 'dec' : 30.0, 'SpectrumType' : PowerLaw } - { 'name' : 'SourceB', 'ra' : 58.0, 'dec' : 35.0, 'SpectrumType' : PowerLaw } # Include catalog sources within this distance from the ROI center src_radius : null # Include catalog sources within a box of width roisrc. src_roiwidth : 15.0In the sample above the official IEM and isotropic template are used together with the 3FGL catalog given with a fits file and by an additional catalog given with an xml file following the notation of the Fermi Science Tools fermi.fssc.spectralmodel. Then two sources named as SourceA and SourceB are added.
To define two or more galactic diffuse components you can optionally define the galdiff and isodiff parameters as lists. A separate component will be generated for each element in the list with the name galdiffXX or isodiffXX where XX is an integer position in the list.
model: galdiff : - '$FERMI_DIFFUSE_DIR/diffuse_component0.fits' - '$FERMI_DIFFUSE_DIR/diffuse_component1.fits'To explicitly set the name of a component you can define any element as a dictionary containing name and file fields:
model: galdiff : - { 'name' : 'component0', 'file' : '$FERMI_DIFFUSE_DIR/diffuse_component0.fits' } - { 'name' : 'component1', 'file' : '$FERMI_DIFFUSE_DIR/diffuse_component1.fits' }The list of sources for inclusion in the ROI model is set by defining a list of catalogs with the catalogs parameter. Catalog files can be in either XML or FITS format. Sources from the catalogs in this list that satisfy either the src_roiwidth or src_radius selections are added to the ROI model. If a source is defined in multiple catalogs the source definition from the last file in the catalogs list takes precedence.
model: src_radius: 5.0 src_roiwidth: 10.0 catalogs : - 'gll_psc_v16.fit' - 'extra_sources.xml'Fermipy supports four spatial models which are defined with the SpatialModel property:
PointSource : A point source (SkyDirFunction).
RadialGaussian : A symmetric 2D Gaussian with width parameter ‘Sigma’.
RadialDisk : A symmetric 2D Disk with radius ‘Radius’.
SpatialMap : An arbitrary 2D shape with morphology defined by a FITS template.
The spatial extension of RadialDisk and RadialGaussian can be controlled with the SpatialWidth parameter which sets the 68% containment radius in degrees. Note for ST releases prior to 11-01-01, RadialDisk and RadialGaussian sources will be represented with the SpatialMap type.
model: sources : - { name: 'PointSource', glon : 120.0, glat : 0.0, SpectrumType : 'PowerLaw', Index : 2.0, Scale : 1000, Prefactor : !!float 1e-11, SpatialModel: 'PointSource' } - { name: 'DiskSource', glon : 120.0, glat : 0.0, SpectrumType : 'PowerLaw', Index : 2.0, Scale : 1000, Prefactor : !!float 1e-11, SpatialModel: 'RadialDisk', SpatialWidth: 1.0 } - { name: 'GaussSource', glon : 120.0, glat : 0.0, SpectrumType : 'PowerLaw', Index : 2.0, Scale : 1000, Prefactor : !!float 1e-11, SpatialModel: 'RadialGaussian', SpatialWidth: 1.0 } - { name: 'MapSource', glon : 120.0, glat : 0.0, SpectrumType : 'PowerLaw', Index : 2.0, Scale : 1000, Prefactor : !!float 1e-11, SpatialModel: 'SpatialMap', Spatial_Filename : 'template.fits' }OPTIMIZER
This section provides informations for the setup used for the optimization. The list of options are the following: * init_lambda: Initial value of damping parameter for step size calculation when using the NEWTON fitter. A value of zero disables damping. * max_iter: Maximum number of iterations for the Newtons method fitter. * min_fit_quality: Set the minimum fit quality. * optimizer: Set the optimization algorithm to use when maximizing the likelihood function. * retries: Set the number of times to retry the fit when the fit quality is less than min_fit_quality. * tol: Set the optimizer tolerance. * verbosity
PLOTTING
This section selects the options to be used to make the plots: * cmap: Set the colormap for 2D plots. Default magma * cmap_resid: Set the colormap for 2D residual plots. * figsize: Set the default figure size. * format: format of images * interactive: Enable interactive mode. If True then plots will be drawn after each plotting command. * label_ts_threshold: TS threshold for labeling sources in sky maps. If None then no sources will be labeled.
SELECTION
The selection section collects parameters related to the data selection and target definition. The majority of the parameters in this section are arguments to gtselect and gtmktime. The ROI center can be set with the target parameter by providing the name of a source defined in one of the input catalogs (defined in the model section). Alternatively the ROI center can be defined by giving explicit sky coordinates with ra and dec or glon and glat.
selection: # gtselect parameters emin : 100 emax : 100000 zmax : 90 evclass : 128 evtype : 3 tmin : 239557414 tmax : 428903014 # gtmktime parameters filter : 'DATA_QUAL>0 && LAT_CONFIG==1' roicut : 'no' # Set the ROI center to the coordinates of this source target : 'mkn421'A sample of options for this section are the following: * emax/emin: Maximum/Minimum Energy (MeV) * evclass: Event class selection. * evtype: Event type selection. * filter: Filter string for gtmktime selection. * logemax/logemin: Maximum/Minimum Energy (log10(MeV)) * phasemax/phasemin: Maximum/Minimum pulsar phase * radius: Radius of data selection. If none this will be automatically set from the ROI size. * target: Choose an object on which to center the ROI. This option takes precendence over ra/dec or glon/glat. * tmax/tmin: Maximum/Minimum time (MET). * zmax: Maximum zenith angle.
Running g-tools
First of all you need to load the configuration file, create the object gta and run the tool gta.setup that implements the ST gtselect, gtmktime, gtbin, gtexpcube, gtsrcmap tools
With the commands below we import the packages needed to run the script.
[1]:
import os
import numpy as np
from fermipy.gtanalysis import GTAnalysis
from fermipy.plotting import ROIPlotter, SEDPlotter
import matplotlib.pyplot as plt
import matplotlib
from IPython.display import Image
This script uses the same data as the SMC tutorial.
Download the SMC data andd then untar the file ../data/SMC_data.tar.gz. This will copy the config.yaml and ft1 file in the notebook directory.
[2]:
import os
if os.path.isfile('./../data/SMC_data.tar.gz'):
!tar xzf ./../data/SMC_data.tar.gz
else:
!curl -OL --output-dir ./../data/ https://raw.githubusercontent.com/fermiPy/fermipy-extras/master/data/SMC_data.tar.gz
!tar xzf ./../data/SMC_data.tar.gz
The configuration file has the same structure as the configuration dictionary such that one can read/write configurations using the load/dump methods of the yaml module:
[3]:
import yaml
# Load a configuration
config = yaml.load(open('./SMC_data/config.yaml'), Loader=yaml.FullLoader)
# Update a parameter and write a new configuration
config['selection']['emin'] = 1000.
yaml.dump(config, open('new_config.yaml','w'))
[4]:
gta = GTAnalysis('new_config.yaml')
gta.setup()
2024-12-19 20:29:54 INFO GTAnalysis.__init__():
--------------------------------------------------------------------------------
fermipy version 1.3.1+6.g74aa
ScienceTools version 2.2.0
2024-12-19 20:29:55 INFO GTAnalysis.setup(): Running setup.
2024-12-19 20:29:55 INFO GTBinnedAnalysis.setup(): Running setup for component 00
2024-12-19 20:29:55 INFO GTBinnedAnalysis._select_data(): Skipping data selection.
2024-12-19 20:29:55 INFO GTBinnedAnalysis.setup(): Using external LT cube.
{'Prefactor': 0, 'Index1': 1, 'Scale': 2, 'Cutoff': 3, 'Index2': 4}
2024-12-19 20:29:55 INFO GTBinnedAnalysis._create_expcube(): Skipping gtexpcube.
WARNING: FITSFixedWarning: 'datfix' made the change 'Set DATEREF to '2001-01-01T00:01:04.184' from MJDREF.
Set MJD-OBS to 54682.655283 from DATE-OBS.
Set MJD-END to 57847.435324 from DATE-END'. [astropy.wcs.wcs]
2024-12-19 20:29:55 INFO GTBinnedAnalysis._create_srcmaps(): Skipping gtsrcmaps.
2024-12-19 20:29:55 INFO GTBinnedAnalysis.setup(): Finished setup for component 00
2024-12-19 20:29:55 INFO GTBinnedAnalysis._create_binned_analysis(): Creating BinnedAnalysis for component 00.
2024-12-19 20:30:01 INFO GTAnalysis.setup(): Initializing source properties
2024-12-19 20:30:04 INFO GTAnalysis.setup(): Finished setup.
The setup() method performs the data preparation and response calculations needed for the analysis (selecting the data, creating counts and exposure maps, etc.). Depending on the data selection and binning of the analysis this will often be the slowest step in the analysis sequence. The output of setup() is cached in the analysis working directory so subsequent calls to setup() will run much faster.
The g-tools performed with gta.setup() are the following: * gtselect: gtselect_fssc * gtmktime: gtmiktime_fssc * gtbin: gtbin_fssc * gtsrcmaps: gtsrcmaps_fssc
In order to have a summary of the source model you can use the command:
[5]:
gta.print_model()
2024-12-19 20:30:04 INFO GTAnalysis.print_model():
sourcename offset norm eflux index ts npred free
--------------------------------------------------------------------------------
3FGL J0059.0-7242e 0.088 1.059 1.45e-05 2.22 nan 1437.6
3FGL J0112.9-7506 2.572 1.172 1.31e-06 2.17 nan 120.3
3FGL J0023.9-7203 2.662 0.714 9.3e-06 2.65 nan 1679.9
3FGL J0029.1-7045 3.008 0.506 2.49e-06 2.28 nan 270.6
3FGL J0021.6-6835 5.122 1.859 5.27e-07 2.65 nan 84.2
3FGL J2351.9-7601 5.495 1.027 3.74e-06 1.69 nan 117.8
3FGL J2338.7-7401 5.777 0.677 4.38e-06 1.89 nan 213.7
3FGL J0146.4-6746 6.423 0.420 1.03e-06 2.39 nan 124.0
3FGL J2336.5-7620 6.454 0.557 1.66e-06 2.33 nan 187.3
3FGL J0002.0-6722 7.153 0.483 2.07e-06 1.95 nan 113.5
isodiff --- 1.000 0.0313 2.12 nan 9099.9
galdiff --- 1.000 0.132 0.00 nan 16777.6
The table above contains: * sourcename as given in the catalog * offset from the center of the roi. Sources are ranked with respect to this parameter * normalization of the SED * energy flux of the source * index of the SED with a PowerLaw SED * Test Statistics * npred is the number of sources associated to the source * free column that tells if the SED parameter of the sources are free (if the column is filled with an asterix) or fixed without no asterix.
Source dictionary
First of all, let’s make a fit using gta.fit tool. Source fitting with fermipy is generally performed with the optimize and fit methods. fit is a wrapper on the pyLikelihood fit method and performs a likelihood fit of all free parameters of the model. This method can be used to manually optimize of the model by calling it after freeing one or more source parameters.
[6]:
gta.free_sources()
fitresult=gta.fit()
2024-12-19 20:30:04 INFO GTAnalysis.free_source(): Freeing parameters for 3FGL J0059.0-7242e : ['Prefactor', 'Index']
2024-12-19 20:30:04 INFO GTAnalysis.free_source(): Freeing parameters for 3FGL J0112.9-7506 : ['Prefactor', 'Index']
2024-12-19 20:30:04 INFO GTAnalysis.free_source(): Freeing parameters for 3FGL J0023.9-7203 : ['norm', 'alpha', 'beta']
2024-12-19 20:30:04 INFO GTAnalysis.free_source(): Freeing parameters for 3FGL J0029.1-7045 : ['Prefactor', 'Index']
2024-12-19 20:30:04 INFO GTAnalysis.free_source(): Freeing parameters for 3FGL J0021.6-6835 : ['Prefactor', 'Index']
2024-12-19 20:30:04 INFO GTAnalysis.free_source(): Freeing parameters for 3FGL J2351.9-7601 : ['Prefactor', 'Index']
2024-12-19 20:30:04 INFO GTAnalysis.free_source(): Freeing parameters for 3FGL J2338.7-7401 : ['Prefactor', 'Index']
2024-12-19 20:30:04 INFO GTAnalysis.free_source(): Freeing parameters for 3FGL J0146.4-6746 : ['Prefactor', 'Index']
2024-12-19 20:30:04 INFO GTAnalysis.free_source(): Freeing parameters for 3FGL J2336.5-7620 : ['Prefactor', 'Index']
2024-12-19 20:30:04 INFO GTAnalysis.free_source(): Freeing parameters for 3FGL J0002.0-6722 : ['Prefactor', 'Index']
2024-12-19 20:30:04 INFO GTAnalysis.free_source(): Freeing parameters for isodiff : ['Normalization']
2024-12-19 20:30:04 INFO GTAnalysis.free_source(): Freeing parameters for galdiff : ['Prefactor', 'Index']
2024-12-19 20:30:04 INFO GTAnalysis.fit(): Starting fit.
Drm_Cache::update Measured counts < 0 3FGL J0023.9-7203 21 -3.92429e-11 6.86055e-11
508.548 476.301 383.986 267.676 161.68 85.2989 39.7061 16.4355 5.9306 1.87763 0.52174 0.127727 0.0277026 0.00525312 0.00086478 0.000124394 1.56781e-05 1.73055e-06 1.67578e-07 1.42376e-08 1.05942e-09 6.86055e-11
/home/runner/miniconda3/envs/fermipy/lib/python3.9/site-packages/scipy/interpolate/_fitpack2.py:313: UserWarning:
The maximal number of iterations maxit (set to 20 by the program)
allowed for finding a smoothing spline with fp=s has been reached: s
too small.
There is an approximation returned but the corresponding weighted sum
of squared residuals does not satisfy the condition abs(fp-s)/s < tol.
warnings.warn(message)
2024-12-19 20:30:07 INFO GTAnalysis.fit(): Fit returned successfully. Quality: 3 Status: 0
2024-12-19 20:30:07 INFO GTAnalysis.fit(): LogLike: -73815.272 DeltaLogLike: 154.334
[7]:
gta.print_model()
2024-12-19 20:30:07 INFO GTAnalysis.print_model():
sourcename offset norm eflux index ts npred free
--------------------------------------------------------------------------------
3FGL J0059.0-7242e 0.088 1.354 1.02e-05 2.46 631.43 1387.2 *
3FGL J0112.9-7506 2.572 1.133 2.16e-06 1.95 145.27 129.2 *
3FGL J0023.9-7203 2.662 0.594 9.79e-06 2.70 5206.25 1799.4 *
3FGL J0029.1-7045 3.008 0.458 2.07e-06 2.33 269.77 239.2 *
3FGL J0021.6-6835 5.122 2.618 2.57e-07 3.29 16.47 57.1 *
3FGL J2351.9-7601 5.495 1.404 2.85e-06 2.01 243.25 192.1 *
3FGL J2338.7-7401 5.777 0.598 2.91e-06 2.02 294.33 187.1 *
3FGL J0146.4-6746 6.423 0.664 1.76e-06 2.35 256.39 201.6 *
3FGL J2336.5-7620 6.454 0.392 1.28e-06 2.29 112.83 135.9 *
3FGL J0002.0-6722 7.153 0.409 1.63e-06 1.98 94.14 95.4 *
isodiff --- 0.684 0.0214 2.12 713.57 6220.2 *
galdiff --- 1.094 0.134 0.05 7041.53 17811.3 *
Now you see that the ts column is filled and the free column has all asterix because we have freed the sources.
Fermipy gives the possibility to access many informations on the sources in the model. Below a few examples.
NAME AND CHARACTERISTICS OF THE SOURCE
[8]:
print(gta.roi.sources[0]['name']) #name of the source
print(gta.roi.sources[0]['Source_Name']) #name of the source
print(gta.roi.sources[0]['SpatialModel']) #spatial model
print(gta.roi.sources[0]['SpatialWidth']) #spatial size parameter
print(gta.roi.sources[0]['SpatialType']) #spatial size parameter
print(gta.roi.sources[0]['SourceType']) #Source type
print(gta.roi.sources[0]['SpectrumType']) #Spectrum type string
print(gta.roi.sources[0]['Spatial_Filename']) #Path to spatial template
print(gta.roi.sources[0]['Spectrum_Filename']) #Path to the SED source template
print(gta.roi.sources[0]['correlation']) #Dictionary of correlation coefficients.
print(gta.roi.sources[0]['model_counts']) #Vector of predicted counts for this source
3FGL J0059.0-7242e
3FGL J0059.0-7242e
SpatialMap
None
SpatialMap
DiffuseSource
PowerLaw
$FERMIPY_DATA_DIR/catalogs/Extended_archive_v15/Templates/SMC.fits
None
{'3FGL J0002.0-6722': 0.011790148677603435, '3FGL J0021.6-6835': 0.014374005416110978, '3FGL J0023.9-7203': -0.022902679562838098, '3FGL J0029.1-7045': -0.00040861905612040296, '3FGL J0059.0-7242e': 0.9999999999999999, '3FGL J0112.9-7506': -0.006446519317548159, '3FGL J0146.4-6746': 0.014675271224211939, '3FGL J2336.5-7620': 0.022611347556478673, '3FGL J2338.7-7401': 0.012248514056312932, '3FGL J2351.9-7601': 0.006110082031862612, 'galdiff': -0.1891644465120756, 'isodiff': 0.02205283917272138}
[4.46857316e+02 3.08420680e+02 2.09968151e+02 1.41385340e+02
9.41907773e+01 6.24273301e+01 4.15264943e+01 2.77945637e+01
1.84249832e+01 1.22067121e+01 8.08387970e+00 5.38413610e+00
3.61208539e+00 2.40960580e+00 1.59550056e+00 1.05189465e+00
6.93896609e-01 4.56475194e-01 3.01655045e-01 1.99122859e-01
1.30944968e-01 8.47352407e-02]
CHARACTERISTICS OF THE POSITION OF THE SOURCE
[9]:
print(gta.roi.sources[0]['ra']) #ra
print(gta.roi.sources[0]['dec']) #dec
print(gta.roi.sources[0]['glon']) #glon
print(gta.roi.sources[0]['glat']) #glat
print(gta.roi.sources[0]['ra_err']) #error for ra
print(gta.roi.sources[0]['dec_err']) #error for dec
print(gta.roi.sources[0]['glon_err']) #error for glon
print(gta.roi.sources[0]['glat_err']) #error for glat
print(gta.roi.sources[0]['pos_err']) #error for the position in deg
print(gta.roi.sources[0]['pos_r68']) #68% CL error for the position
print(gta.roi.sources[0]['pos_r95']) #95% CL error for the position
print(gta.roi.sources[0]['pos_r99']) #99% CL error for the position
print(gta.roi.sources[0]['pos_err_semimajor']) #1-sigma uncertainty (deg) along major axis of uncertainty ellipse.
print(gta.roi.sources[0]['pos_err_semiminor']) #1-sigma uncertainty (deg) along minor axis of uncertainty ellipse.
print(gta.roi.sources[0]['offset_ra']) #Right ascension offset from ROI center in local celestial projection (deg).
print(gta.roi.sources[0]['offset_dec']) #Declination offset from ROI center in local celestial projection (deg).
print(gta.roi.sources[0]['offset_glon']) #Galactic longitude offset from ROI center in local galactic projection (deg).
print(gta.roi.sources[0]['offset_glat']) #Galactic latitude offset from ROI center in local galactic projection (deg).
print(gta.roi.sources[0]['offset']) #Angular offset from ROI center (deg).
14.75
-72.7
302.14493
-44.416702
nan
nan
nan
nan
nan
nan
nan
nan
nan
nan
-0.07331403829880656
0.04939684436004943
0.07503178772129071
-0.0467496716123047
0.088404864
The error for the position is nan because we have not calculated yet the relocalization. Let’s run the localization for a source with gta.localize tool.
[10]:
gta.free_sources(free=True)
gta.print_model()
gta.free_sources(skydir=gta.roi[gta.roi.sources[2].name].skydir,distance=[3.0],free=True)
gta.print_model()
localsmc = gta.localize(gta.roi.sources[2].name, update=True, make_plots=True)
gta.print_model()
2024-12-19 20:30:07 INFO GTAnalysis.print_model():
sourcename offset norm eflux index ts npred free
--------------------------------------------------------------------------------
3FGL J0059.0-7242e 0.088 1.354 1.02e-05 2.46 631.43 1387.2 *
3FGL J0112.9-7506 2.572 1.133 2.16e-06 1.95 145.27 129.2 *
3FGL J0023.9-7203 2.662 0.594 9.79e-06 2.70 5206.25 1799.4 *
3FGL J0029.1-7045 3.008 0.458 2.07e-06 2.33 269.77 239.2 *
3FGL J0021.6-6835 5.122 2.618 2.57e-07 3.29 16.47 57.1 *
3FGL J2351.9-7601 5.495 1.404 2.85e-06 2.01 243.25 192.1 *
3FGL J2338.7-7401 5.777 0.598 2.91e-06 2.02 294.33 187.1 *
3FGL J0146.4-6746 6.423 0.664 1.76e-06 2.35 256.39 201.6 *
3FGL J2336.5-7620 6.454 0.392 1.28e-06 2.29 112.83 135.9 *
3FGL J0002.0-6722 7.153 0.409 1.63e-06 1.98 94.14 95.4 *
isodiff --- 0.684 0.0214 2.12 713.57 6220.2 *
galdiff --- 1.094 0.134 0.05 7041.53 17811.3 *
2024-12-19 20:30:07 INFO GTAnalysis.print_model():
sourcename offset norm eflux index ts npred free
--------------------------------------------------------------------------------
3FGL J0059.0-7242e 0.088 1.354 1.02e-05 2.46 631.43 1387.2 *
3FGL J0112.9-7506 2.572 1.133 2.16e-06 1.95 145.27 129.2 *
3FGL J0023.9-7203 2.662 0.594 9.79e-06 2.70 5206.25 1799.4 *
3FGL J0029.1-7045 3.008 0.458 2.07e-06 2.33 269.77 239.2 *
3FGL J0021.6-6835 5.122 2.618 2.57e-07 3.29 16.47 57.1 *
3FGL J2351.9-7601 5.495 1.404 2.85e-06 2.01 243.25 192.1 *
3FGL J2338.7-7401 5.777 0.598 2.91e-06 2.02 294.33 187.1 *
3FGL J0146.4-6746 6.423 0.664 1.76e-06 2.35 256.39 201.6 *
3FGL J2336.5-7620 6.454 0.392 1.28e-06 2.29 112.83 135.9 *
3FGL J0002.0-6722 7.153 0.409 1.63e-06 1.98 94.14 95.4 *
isodiff --- 0.684 0.0214 2.12 713.57 6220.2 *
galdiff --- 1.094 0.134 0.05 7041.53 17811.3 *
2024-12-19 20:30:07 INFO GTAnalysis.localize(): Running localization for 3FGL J0023.9-7203
2024-12-19 20:30:11 INFO GTAnalysis._localize(): Localization succeeded.
2024-12-19 20:30:11 INFO GTAnalysis._localize(): Updating source 3FGL J0023.9-7203 to localized position.
2024-12-19 20:30:11 INFO GTAnalysis.delete_source(): Deleting source 3FGL J0023.9-7203
2024-12-19 20:30:11 INFO GTAnalysis.add_source(): Adding source 3FGL J0023.9-7203
/home/runner/miniconda3/envs/fermipy/lib/python3.9/site-packages/scipy/interpolate/_fitpack2.py:313: UserWarning:
The maximal number of iterations maxit (set to 20 by the program)
allowed for finding a smoothing spline with fp=s has been reached: s
too small.
There is an approximation returned but the corresponding weighted sum
of squared residuals does not satisfy the condition abs(fp-s)/s < tol.
warnings.warn(message)
2024-12-19 20:30:12 INFO GTAnalysis._localize(): Localization completed with new position:
( ra, dec) = ( 5.9936 +/- 0.0054, -72.0814 +/- 0.0053)
(glon,glat) = ( 305.9077 +/- 0.0053, -44.8878 +/- 0.0053)
offset = 0.0166 r68 = 0.0081 r95 = 0.0130 r99 = 0.0162
2024-12-19 20:30:12 INFO GTAnalysis._localize(): LogLike: -73810.560 DeltaLogLike: 4.712
2024-12-19 20:30:12 INFO GTAnalysis.localize(): Finished localization.
2024-12-19 20:30:17 WARNING GTAnalysis.localize(): Saving TS maps in .npy files is disabled b/c of incompatibilities in python3, remove the maps from the /home/runner/work/fermipy/fermipy/fermipy-extra/notebooks/SMC_data/3fgl_j0023.9-7203_loc.npy
2024-12-19 20:30:17 INFO GTAnalysis.localize(): Execution time: 9.59 s
2024-12-19 20:30:17 INFO GTAnalysis.print_model():
sourcename offset norm eflux index ts npred free
--------------------------------------------------------------------------------
3FGL J0059.0-7242e 0.088 1.354 1.02e-05 2.46 631.43 1387.2 *
3FGL J0112.9-7506 2.572 1.133 2.16e-06 1.95 145.27 129.2 *
3FGL J0023.9-7203 2.654 0.582 9.37e-06 2.69 5334.39 1799.9 *
3FGL J0029.1-7045 3.008 0.458 2.07e-06 2.33 269.77 239.2 *
3FGL J0021.6-6835 5.122 2.618 2.57e-07 3.29 16.47 57.1 *
3FGL J2351.9-7601 5.495 1.404 2.85e-06 2.01 243.25 192.1 *
3FGL J2338.7-7401 5.777 0.598 2.91e-06 2.02 294.33 187.1 *
3FGL J0146.4-6746 6.423 0.664 1.76e-06 2.35 256.39 201.6 *
3FGL J2336.5-7620 6.454 0.392 1.28e-06 2.29 112.83 135.9 *
3FGL J0002.0-6722 7.153 0.409 1.63e-06 1.98 94.14 95.4 *
isodiff --- 0.684 0.0214 2.12 713.57 6220.2 *
galdiff --- 1.094 0.134 0.05 7041.53 17811.3 *
Using the option make_plots=True a few control plots are created like 3fgl_j0023.9-7203_localize_peak.png with the result for the likelihood analysis for the besy fit position and error for the position.
[11]:
Image(filename='./SMC_data/3fgl_j0023.9-7203_localize_peak.png')
[11]:
[12]:
print(gta.roi.sources[2]['ra']) #ra
print(gta.roi.sources[2]['dec']) #dec
print(gta.roi.sources[2]['glon']) #glon
print(gta.roi.sources[2]['glat']) #glat
print(gta.roi.sources[2]['ra_err']) #error for ra
print(gta.roi.sources[2]['dec_err']) #error for dec
print(gta.roi.sources[2]['glon_err']) #error for glon
print(gta.roi.sources[2]['glat_err']) #error for glat
print(gta.roi.sources[2]['pos_err']) #error for the position in deg
print(gta.roi.sources[2]['pos_r68']) #68% CL error for the position
print(gta.roi.sources[2]['pos_r95']) #95% CL error for the position
print(gta.roi.sources[2]['pos_r99']) #99% CL error for the position
print(gta.roi.sources[2]['pos_err_semimajor']) #1-sigma uncertainty (deg) along major axis of uncertainty ellipse.
print(gta.roi.sources[2]['pos_err_semiminor']) #1-sigma uncertainty (deg) along minor axis of uncertainty ellipse.
print(gta.roi.sources[2]['offset_ra']) #Right ascension offset from ROI center in local celestial projection (deg).
print(gta.roi.sources[2]['offset_dec']) #Declination offset from ROI center in local celestial projection (deg).
print(gta.roi.sources[2]['offset_glon']) #Galactic longitude offset from ROI center in local galactic projection (deg).
print(gta.roi.sources[2]['offset_glat']) #Galactic latitude offset from ROI center in local galactic projection (deg).
print(gta.roi.sources[2]['offset']) #Angular offset from ROI center (deg).
5.993615495562085
-72.08144238813252
305.907656201347
-44.8877902901592
0.005367762783276858
0.005279521016511993
0.005347152023248827
0.005300394768466772
0.005322709640514254
0.008072288845774397
0.01302705320186296
0.016153349535549193
0.005400312049049391
0.005246222377503256
2.609433773478435
0.4827772080733077
-2.59051407908765
-0.5756497058745496
2.653805814818249
SED PARAMETERS FLUX AND SCAN OF FLUX
[13]:
print(gta.roi.sources[0]['param_names']) #Names of spectral parameters.
print(gta.roi.sources[0]['param_values']) #Spectral parameter values.
print(gta.roi.sources[0]['param_errors']) #Spectral parameters errors.
print(gta.roi.sources[0]['ts']) #Source test statistic.
print(gta.roi.sources[0]['loglike']) #Log-likelihood of the model evaluated at the best-fit normalization of the source.
print(gta.roi.sources[0]['flux_scan']) #Flux values for scan of source normalization.
print(gta.roi.sources[0]['norm_scan']) #Normalization parameters values for scan of source normalization.
print(gta.roi.sources[0]['npred']) #Number of predicted counts from this source integrated over the analysis energy range.
print(gta.roi.sources[0]['flux']) #Photon flux (cm−2 s−1) integrated over analysis energy range
print(gta.roi.sources[0]['flux_err']) #Photon flux uncertainty (cm−2 s−1) integrated over analysis energy range
print(gta.roi.sources[0]['flux_ul95']) #95% CL upper limit on the photon Differential photon flux (cm−2 s−1 MeV−1tegrated over analysis energy range
print(gta.roi.sources[0]['dnde']) #Differential photon flux (cm−2 s−1 MeV−1) evaluated at the pivot energy.
[b'Prefactor' b'Index' b'Scale' b'' b'' b'' b'' b'' b'' b'']
[ 1.35369200e-11 -2.45898536e+00 6.65532043e+02 nan
nan nan nan nan
nan nan]
[1.14134479e-12 6.10685033e-02 nan nan
nan nan nan nan
nan nan]
631.4279068165924
-73815.27398292236
[1.54536854e-10 3.09073709e-09 3.13147393e-09 3.17221077e-09
3.21294762e-09 3.25368446e-09 3.29442130e-09 3.33515814e-09
3.37589499e-09 3.41663183e-09 3.45736867e-09 3.49810551e-09
3.53884235e-09 3.57957920e-09 3.62031604e-09 3.66105288e-09
3.70178972e-09 3.74252657e-09 3.78326341e-09 3.82400025e-09]
[0.06140635 1.22812693 1.24431401 1.26050109 1.27668817 1.29287525
1.30906233 1.32524942 1.3414365 1.35762358 1.37381066 1.38999774
1.40618482 1.4223719 1.43855899 1.45474607 1.47093315 1.48712023
1.50330731 1.51949439]
1387.206279433444
3.406737511517394e-09
1.6137540993611978e-10
3.6651650732812706e-09
8.143478440799105e-13
[14]:
gta.write_roi('model_test',make_plots=True,save_model_map=True)
2024-12-19 20:30:17 INFO GTBinnedAnalysis.write_xml(): Writing /home/runner/work/fermipy/fermipy/fermipy-extra/notebooks/SMC_data/model_test_00.xml...
2024-12-19 20:30:17 INFO GTAnalysis.write_fits(): Writing /home/runner/work/fermipy/fermipy/fermipy-extra/notebooks/SMC_data/model_test.fits...
WARNING: Format %s cannot be mapped to the accepted TDISPn keyword values. Format will not be moved into TDISPn keyword. [astropy.io.fits.column]
WARNING: Format %f cannot be mapped to the accepted TDISPn keyword values. Format will not be moved into TDISPn keyword. [astropy.io.fits.column]
WARNING: Format %s cannot be mapped to the accepted TDISPn keyword values. Format will not be moved into TDISPn keyword. [astropy.io.fits.column]
2024-12-19 20:30:23 INFO GTBinnedAnalysis.write_model_map(): Generating model map for component 00.
2024-12-19 20:30:24 INFO GTAnalysis.write_roi(): Writing /home/runner/work/fermipy/fermipy/fermipy-extra/notebooks/SMC_data/model_test.npy...
Customizing your model
As we saw before you can customize your model directly in the config.yaml file. However, sometimes you want to change something in your model directly in your Python script.
You can free or fix sources using gta.free_sources. First let’s fix the SED parameter of all the sources.
[15]:
gta.free_sources(free=False)
gta.print_model()
2024-12-19 20:30:26 INFO GTAnalysis.free_source(): Fixing parameters for 3FGL J0059.0-7242e : ['Prefactor', 'Index']
2024-12-19 20:30:26 INFO GTAnalysis.free_source(): Fixing parameters for 3FGL J0112.9-7506 : ['Prefactor', 'Index']
2024-12-19 20:30:26 INFO GTAnalysis.free_source(): Fixing parameters for 3FGL J0023.9-7203 : ['norm', 'alpha', 'beta']
2024-12-19 20:30:26 INFO GTAnalysis.free_source(): Fixing parameters for 3FGL J0029.1-7045 : ['Prefactor', 'Index']
2024-12-19 20:30:26 INFO GTAnalysis.free_source(): Fixing parameters for 3FGL J0021.6-6835 : ['Prefactor', 'Index']
2024-12-19 20:30:26 INFO GTAnalysis.free_source(): Fixing parameters for 3FGL J2351.9-7601 : ['Prefactor', 'Index']
2024-12-19 20:30:26 INFO GTAnalysis.free_source(): Fixing parameters for 3FGL J2338.7-7401 : ['Prefactor', 'Index']
2024-12-19 20:30:26 INFO GTAnalysis.free_source(): Fixing parameters for 3FGL J0146.4-6746 : ['Prefactor', 'Index']
2024-12-19 20:30:26 INFO GTAnalysis.free_source(): Fixing parameters for 3FGL J2336.5-7620 : ['Prefactor', 'Index']
2024-12-19 20:30:26 INFO GTAnalysis.free_source(): Fixing parameters for 3FGL J0002.0-6722 : ['Prefactor', 'Index']
2024-12-19 20:30:26 INFO GTAnalysis.free_source(): Fixing parameters for isodiff : ['Normalization']
2024-12-19 20:30:26 INFO GTAnalysis.free_source(): Fixing parameters for galdiff : ['Prefactor', 'Index']
2024-12-19 20:30:26 INFO GTAnalysis.print_model():
sourcename offset norm eflux index ts npred free
--------------------------------------------------------------------------------
3FGL J0059.0-7242e 0.088 1.354 1.02e-05 2.46 631.43 1387.2
3FGL J0112.9-7506 2.572 1.133 2.16e-06 1.95 145.27 129.2
3FGL J0023.9-7203 2.654 0.582 9.37e-06 2.69 5334.39 1799.9
3FGL J0029.1-7045 3.008 0.458 2.07e-06 2.33 269.77 239.2
3FGL J0021.6-6835 5.122 2.618 2.57e-07 3.29 16.47 57.1
3FGL J2351.9-7601 5.495 1.404 2.85e-06 2.01 243.25 192.1
3FGL J2338.7-7401 5.777 0.598 2.91e-06 2.02 294.33 187.1
3FGL J0146.4-6746 6.423 0.664 1.76e-06 2.35 256.39 201.6
3FGL J2336.5-7620 6.454 0.392 1.28e-06 2.29 112.83 135.9
3FGL J0002.0-6722 7.153 0.409 1.63e-06 1.98 94.14 95.4
isodiff --- 0.684 0.0214 2.12 713.57 6220.2
galdiff --- 1.094 0.134 0.05 7041.53 17811.3
Now we free all parameters:
[16]:
gta.free_sources(free=True)
gta.print_model()
2024-12-19 20:30:26 INFO GTAnalysis.free_source(): Freeing parameters for 3FGL J0059.0-7242e : ['Prefactor', 'Index']
2024-12-19 20:30:26 INFO GTAnalysis.free_source(): Freeing parameters for 3FGL J0112.9-7506 : ['Prefactor', 'Index']
2024-12-19 20:30:26 INFO GTAnalysis.free_source(): Freeing parameters for 3FGL J0023.9-7203 : ['norm', 'alpha', 'beta']
2024-12-19 20:30:26 INFO GTAnalysis.free_source(): Freeing parameters for 3FGL J0029.1-7045 : ['Prefactor', 'Index']
2024-12-19 20:30:26 INFO GTAnalysis.free_source(): Freeing parameters for 3FGL J0021.6-6835 : ['Prefactor', 'Index']
2024-12-19 20:30:26 INFO GTAnalysis.free_source(): Freeing parameters for 3FGL J2351.9-7601 : ['Prefactor', 'Index']
2024-12-19 20:30:26 INFO GTAnalysis.free_source(): Freeing parameters for 3FGL J2338.7-7401 : ['Prefactor', 'Index']
2024-12-19 20:30:26 INFO GTAnalysis.free_source(): Freeing parameters for 3FGL J0146.4-6746 : ['Prefactor', 'Index']
2024-12-19 20:30:26 INFO GTAnalysis.free_source(): Freeing parameters for 3FGL J2336.5-7620 : ['Prefactor', 'Index']
2024-12-19 20:30:26 INFO GTAnalysis.free_source(): Freeing parameters for 3FGL J0002.0-6722 : ['Prefactor', 'Index']
2024-12-19 20:30:26 INFO GTAnalysis.free_source(): Freeing parameters for isodiff : ['Normalization']
2024-12-19 20:30:26 INFO GTAnalysis.free_source(): Freeing parameters for galdiff : ['Prefactor', 'Index']
2024-12-19 20:30:26 INFO GTAnalysis.print_model():
sourcename offset norm eflux index ts npred free
--------------------------------------------------------------------------------
3FGL J0059.0-7242e 0.088 1.354 1.02e-05 2.46 631.43 1387.2 *
3FGL J0112.9-7506 2.572 1.133 2.16e-06 1.95 145.27 129.2 *
3FGL J0023.9-7203 2.654 0.582 9.37e-06 2.69 5334.39 1799.9 *
3FGL J0029.1-7045 3.008 0.458 2.07e-06 2.33 269.77 239.2 *
3FGL J0021.6-6835 5.122 2.618 2.57e-07 3.29 16.47 57.1 *
3FGL J2351.9-7601 5.495 1.404 2.85e-06 2.01 243.25 192.1 *
3FGL J2338.7-7401 5.777 0.598 2.91e-06 2.02 294.33 187.1 *
3FGL J0146.4-6746 6.423 0.664 1.76e-06 2.35 256.39 201.6 *
3FGL J2336.5-7620 6.454 0.392 1.28e-06 2.29 112.83 135.9 *
3FGL J0002.0-6722 7.153 0.409 1.63e-06 1.98 94.14 95.4 *
isodiff --- 0.684 0.0214 2.12 713.57 6220.2 *
galdiff --- 1.094 0.134 0.05 7041.53 17811.3 *
Now we free all the SED parameters of sources within 3 degrees from 3FGL J0059.0-7242e:
[17]:
gta.free_sources(free=False)
gta.free_sources(skydir=gta.roi['3FGL J0059.0-7242e'].skydir,distance=3.0)
gta.print_model()
2024-12-19 20:30:26 INFO GTAnalysis.free_source(): Fixing parameters for 3FGL J0059.0-7242e : ['Prefactor', 'Index']
2024-12-19 20:30:26 INFO GTAnalysis.free_source(): Fixing parameters for 3FGL J0112.9-7506 : ['Prefactor', 'Index']
2024-12-19 20:30:26 INFO GTAnalysis.free_source(): Fixing parameters for 3FGL J0023.9-7203 : ['norm', 'alpha', 'beta']
2024-12-19 20:30:26 INFO GTAnalysis.free_source(): Fixing parameters for 3FGL J0029.1-7045 : ['Prefactor', 'Index']
2024-12-19 20:30:26 INFO GTAnalysis.free_source(): Fixing parameters for 3FGL J0021.6-6835 : ['Prefactor', 'Index']
2024-12-19 20:30:26 INFO GTAnalysis.free_source(): Fixing parameters for 3FGL J2351.9-7601 : ['Prefactor', 'Index']
2024-12-19 20:30:26 INFO GTAnalysis.free_source(): Fixing parameters for 3FGL J2338.7-7401 : ['Prefactor', 'Index']
2024-12-19 20:30:26 INFO GTAnalysis.free_source(): Fixing parameters for 3FGL J0146.4-6746 : ['Prefactor', 'Index']
2024-12-19 20:30:26 INFO GTAnalysis.free_source(): Fixing parameters for 3FGL J2336.5-7620 : ['Prefactor', 'Index']
2024-12-19 20:30:26 INFO GTAnalysis.free_source(): Fixing parameters for 3FGL J0002.0-6722 : ['Prefactor', 'Index']
2024-12-19 20:30:26 INFO GTAnalysis.free_source(): Fixing parameters for isodiff : ['Normalization']
2024-12-19 20:30:26 INFO GTAnalysis.free_source(): Fixing parameters for galdiff : ['Prefactor', 'Index']
2024-12-19 20:30:26 INFO GTAnalysis.free_source(): Freeing parameters for 3FGL J0059.0-7242e : ['Prefactor', 'Index']
2024-12-19 20:30:26 INFO GTAnalysis.free_source(): Freeing parameters for 3FGL J0112.9-7506 : ['Prefactor', 'Index']
2024-12-19 20:30:26 INFO GTAnalysis.free_source(): Freeing parameters for 3FGL J0023.9-7203 : ['norm', 'alpha', 'beta']
2024-12-19 20:30:26 INFO GTAnalysis.free_source(): Freeing parameters for isodiff : ['Normalization']
2024-12-19 20:30:26 INFO GTAnalysis.free_source(): Freeing parameters for galdiff : ['Prefactor', 'Index']
2024-12-19 20:30:26 INFO GTAnalysis.print_model():
sourcename offset norm eflux index ts npred free
--------------------------------------------------------------------------------
3FGL J0059.0-7242e 0.088 1.354 1.02e-05 2.46 631.43 1387.2 *
3FGL J0112.9-7506 2.572 1.133 2.16e-06 1.95 145.27 129.2 *
3FGL J0023.9-7203 2.654 0.582 9.37e-06 2.69 5334.39 1799.9 *
3FGL J0029.1-7045 3.008 0.458 2.07e-06 2.33 269.77 239.2
3FGL J0021.6-6835 5.122 2.618 2.57e-07 3.29 16.47 57.1
3FGL J2351.9-7601 5.495 1.404 2.85e-06 2.01 243.25 192.1
3FGL J2338.7-7401 5.777 0.598 2.91e-06 2.02 294.33 187.1
3FGL J0146.4-6746 6.423 0.664 1.76e-06 2.35 256.39 201.6
3FGL J2336.5-7620 6.454 0.392 1.28e-06 2.29 112.83 135.9
3FGL J0002.0-6722 7.153 0.409 1.63e-06 1.98 94.14 95.4
isodiff --- 0.684 0.0214 2.12 713.57 6220.2 *
galdiff --- 1.094 0.134 0.05 7041.53 17811.3 *
Now we want to delete the source 3FGL J0021.6-6835:
[18]:
gta.delete_source('3FGL J0021.6-6835')
gta.print_model()
2024-12-19 20:30:26 INFO GTAnalysis.delete_source(): Deleting source 3FGL J0021.6-6835
2024-12-19 20:30:26 INFO GTAnalysis.print_model():
sourcename offset norm eflux index ts npred free
--------------------------------------------------------------------------------
3FGL J0059.0-7242e 0.088 1.354 1.02e-05 2.46 631.43 1387.2 *
3FGL J0112.9-7506 2.572 1.133 2.16e-06 1.95 145.27 129.2 *
3FGL J0023.9-7203 2.654 0.582 9.37e-06 2.69 5334.39 1799.9 *
3FGL J0029.1-7045 3.008 0.458 2.07e-06 2.33 269.77 239.2
3FGL J2351.9-7601 5.495 1.404 2.85e-06 2.01 243.25 192.1
3FGL J2338.7-7401 5.777 0.598 2.91e-06 2.02 294.33 187.1
3FGL J0146.4-6746 6.423 0.664 1.76e-06 2.35 256.39 201.6
3FGL J2336.5-7620 6.454 0.392 1.28e-06 2.29 112.83 135.9
3FGL J0002.0-6722 7.153 0.409 1.63e-06 1.98 94.14 95.4
isodiff --- 0.684 0.0214 2.12 713.57 6220.2 *
galdiff --- 1.094 0.134 0.05 7041.53 17811.3 *
You can also delete all the sources as a function of the npred/ts or position using the options minmax_npred/minmax_ts/skydir options. Finally, you can delete sources in a given list using the option names.
[19]:
help(gta.delete_sources)
Help on method delete_sources in module fermipy.gtanalysis:
delete_sources(cuts=None, distance=None, skydir=None, minmax_ts=None, minmax_npred=None, exclude=None, square=False, names=None) method of fermipy.gtanalysis.GTAnalysis instance
Delete sources in the ROI model satisfying the given
selection criteria.
Parameters
----------
cuts : dict
Dictionary of [min,max] selections on source properties.
distance : float
Cut on angular distance from ``skydir``. If None then no
selection will be applied.
skydir : `~astropy.coordinates.SkyCoord`
Reference sky coordinate for ``distance`` selection. If
None then the distance selection will be applied with
respect to the ROI center.
minmax_ts : list
Select sources that have TS in the range [min,max]. If
either min or max are None then only a lower (upper) bound
will be applied. If this parameter is none no selection
will be applied.
minmax_npred : list
Select sources that have npred in the range [min,max]. If
either min or max are None then only a lower (upper) bound
will be applied. If this parameter is none no selection
will be applied.
square : bool
Switch between applying a circular or square (ROI-like)
selection on the maximum projected distance from the ROI
center.
names : list
Select sources matching a name in this list.
Returns
-------
srcs : list
A list of `~fermipy.roi_model.Model` objects.
In the example below we delete all the sources that have an npred=[0,500]
[20]:
gta.delete_sources(minmax_npred=[0,500])
gta.print_model()
2024-12-19 20:30:26 INFO GTAnalysis.delete_source(): Deleting source 3FGL J0112.9-7506
2024-12-19 20:30:26 INFO GTAnalysis.delete_source(): Deleting source 3FGL J0029.1-7045
2024-12-19 20:30:26 INFO GTAnalysis.delete_source(): Deleting source 3FGL J2351.9-7601
2024-12-19 20:30:26 INFO GTAnalysis.delete_source(): Deleting source 3FGL J2338.7-7401
2024-12-19 20:30:26 INFO GTAnalysis.delete_source(): Deleting source 3FGL J0146.4-6746
2024-12-19 20:30:26 INFO GTAnalysis.delete_source(): Deleting source 3FGL J2336.5-7620
2024-12-19 20:30:26 INFO GTAnalysis.delete_source(): Deleting source 3FGL J0002.0-6722
2024-12-19 20:30:26 INFO GTAnalysis.print_model():
sourcename offset norm eflux index ts npred free
--------------------------------------------------------------------------------
3FGL J0059.0-7242e 0.088 1.354 1.02e-05 2.46 631.43 1387.2 *
3FGL J0023.9-7203 2.654 0.582 9.37e-06 2.69 5334.39 1799.9 *
isodiff --- 0.684 0.0214 2.12 713.57 6220.2 *
galdiff --- 1.094 0.134 0.05 7041.53 17811.3 *
We can aldo add a new source in the model using the gta.add_source function.
[21]:
help(gta.add_source)
Help on method add_source in module fermipy.gtanalysis:
add_source(name, src_dict, free=None, init_source=True, save_source_maps=True, use_pylike=True, use_single_psf=False, **kwargs) method of fermipy.gtanalysis.GTAnalysis instance
Add a source to the ROI model. This function may be called
either before or after `~fermipy.gtanalysis.GTAnalysis.setup`.
Parameters
----------
name : str
Source name.
src_dict : dict or `~fermipy.roi_model.Source` object
Dictionary or source object defining the source properties
(coordinates, spectral parameters, etc.).
free : bool
Initialize the source with a free normalization parameter.
use_pylike : bool
Create source maps with pyLikelihood.
use_single_psf : bool
Use the PSF model calculated for the ROI center. If false
then a new model will be generated using the position of
the source.
In the example below we add a Source called Source_PL with a PLSuperExpCutoff and pointlike and a source called Source_Gauss that is spatial extended with a PowerLaw SED and with a RadialGaussian template with an extension of 1 deg.
[22]:
gta.add_source('Source_PL',{ 'glon' : 300., 'glat' : -46.,'SpectrumType' : 'PLSuperExpCutoff', 'Index1':-1.5, 'Index2' : 1.0,'Scale' : 1000,'Prefactor':1e-9,'SpatialModel' : 'PointSource' })
gta.add_source('Source_Gauss',{ 'glon' : 302., 'glat' : -45.,'SpectrumType' : 'PowerLaw', 'Index':2.0,'Scale' : 1000,'Prefactor':1e-9,'SpatialModel' : 'RadialGaussian', 'SpatialWidth': 1.0 })
gta.print_model()
2024-12-19 20:30:26 INFO GTAnalysis.add_source(): Adding source Source_PL
2024-12-19 20:30:27 INFO GTAnalysis.add_source(): Adding source Source_Gauss
2024-12-19 20:30:32 INFO GTAnalysis.print_model():
sourcename offset norm eflux index ts npred free
--------------------------------------------------------------------------------
3FGL J0059.0-7242e 0.088 1.354 1.02e-05 2.46 631.43 1387.2 *
Source_Gauss 0.655 1.000 0.00621 2.00 nan 427843.4 *
Source_PL 2.274 1.000 0.00319 4.00 nan 483408.5 *
3FGL J0023.9-7203 2.654 0.582 9.37e-06 2.69 5334.39 1799.9 *
isodiff --- 0.684 0.0214 2.12 713.57 6220.2 *
galdiff --- 1.094 0.134 0.05 7041.53 17811.3 *
Now I load the model saved into model_test to have back the intial model.
[23]:
gta.load_roi('model_test')
gta.print_model()
2024-12-19 20:30:32 INFO GTAnalysis.load_roi(): Loading ROI file: /home/runner/work/fermipy/fermipy/fermipy-extra/notebooks/SMC_data/model_test.npy
2024-12-19 20:30:32 INFO GTBinnedAnalysis._create_binned_analysis(): Creating BinnedAnalysis for component 00.
2024-12-19 20:30:37 INFO GTAnalysis.load_roi(): Finished Loading ROI
2024-12-19 20:30:37 INFO GTAnalysis.print_model():
sourcename offset norm eflux index ts npred free
--------------------------------------------------------------------------------
3FGL J0059.0-7242e 0.088 1.354 1.02e-05 2.46 631.43 1387.2 *
3FGL J0112.9-7506 2.572 1.133 2.16e-06 1.95 145.27 129.2 *
3FGL J0023.9-7203 2.654 0.582 9.37e-06 2.69 5334.39 1799.9 *
3FGL J0029.1-7045 3.008 0.458 2.07e-06 2.33 269.77 239.2 *
3FGL J0021.6-6835 5.122 2.618 2.57e-07 3.29 16.47 57.1 *
3FGL J2351.9-7601 5.495 1.404 2.85e-06 2.01 243.25 192.1 *
3FGL J2338.7-7401 5.777 0.598 2.91e-06 2.02 294.33 187.1 *
3FGL J0146.4-6746 6.423 0.664 1.76e-06 2.35 256.39 201.6 *
3FGL J2336.5-7620 6.454 0.392 1.28e-06 2.29 112.83 135.9 *
3FGL J0002.0-6722 7.153 0.409 1.63e-06 1.98 94.14 95.4 *
isodiff --- 0.684 0.0214 2.12 713.57 6220.2 *
galdiff --- 1.094 0.134 0.05 7041.53 17811.3 *
It is also possible to modify the SED parameters using the functions gta.set_norm, gta.set_parameter, gta.set_parameter_bounds, gta.set_parameter_error .
[24]:
help(gta.set_norm)
help(gta.set_parameter)
Help on method set_norm in module fermipy.gtanalysis:
set_norm(name, value, update_source=True) method of fermipy.gtanalysis.GTAnalysis instance
Help on method set_parameter in module fermipy.gtanalysis:
set_parameter(name, par, value, true_value=True, scale=None, bounds=None, error=None, update_source=True) method of fermipy.gtanalysis.GTAnalysis instance
Update the value of a parameter. Parameter bounds will
automatically be adjusted to encompass the new parameter
value.
Parameters
----------
name : str
Source name.
par : str
Parameter name.
value : float
Parameter value. By default this argument should be the
unscaled (True) parameter value.
scale : float
Parameter scale (optional). Value argument is interpreted
with respect to the scale parameter if it is provided.
error : float
Parameter error (optional). By default this argument should be the
unscaled (True) parameter value.
update_source : bool
Update the source dictionary for the object.
[25]:
print(gta.roi['3FGL J0059.0-7242e']['param_names'])
print(gta.roi['3FGL J0059.0-7242e']['param_values'])
print(gta.roi['3FGL J0059.0-7242e']['param_errors'])
[b'Prefactor' b'Index' b'Scale' b'' b'' b'' b'' b'' b'' b'']
[ 1.35369200e-11 -2.45898536e+00 6.65532043e+02 nan
nan nan nan nan
nan nan]
[ 1.14134479e-12 -6.10685033e-02 nan nan
nan nan nan nan
nan nan]
In the example below we fix the normalization to 1e-11 and the slope to 2.0.
[26]:
gta.set_norm('3FGL J0059.0-7242e',value=1.)
gta.set_parameter('3FGL J0059.0-7242e',par='Index',value=2.0)
print(gta.roi['3FGL J0059.0-7242e']['param_names'])
print(gta.roi['3FGL J0059.0-7242e']['param_values'])
print(gta.roi['3FGL J0059.0-7242e']['param_errors'])
/home/runner/miniconda3/envs/fermipy/lib/python3.9/site-packages/scipy/interpolate/_fitpack2.py:313: UserWarning:
A theoretically impossible result was found during the iteration
process for finding a smoothing spline with fp = s: s too small.
There is an approximation returned but the corresponding weighted sum
of squared residuals does not satisfy the condition abs(fp-s)/s < tol.
warnings.warn(message)
[b'Prefactor' b'Index' b'Scale' b'' b'' b'' b'' b'' b'' b'']
[1.00000000e-11 2.00000000e+00 6.65532043e+02 nan
nan nan nan nan
nan nan]
[ 0. 0. nan nan nan nan nan nan nan nan]
It is also possible to set the SED shape of a source using gta.set_source_spectrum tool.
[27]:
help(gta.set_source_spectrum)
Help on method set_source_spectrum in module fermipy.gtanalysis:
set_source_spectrum(name, spectrum_type='PowerLaw', spectrum_pars=None, update_source=True) method of fermipy.gtanalysis.GTAnalysis instance
Set the spectral model of a source. This function can be
used to change the spectral type of a source or modify its
spectral parameters. If called with
spectrum_type='FileFunction' and spectrum_pars=None, the
source spectrum will be replaced with a FileFunction with the
same differential flux distribution as the original spectrum.
Parameters
----------
name : str
Source name.
spectrum_type : str
Spectrum type (PowerLaw, etc.).
spectrum_pars : dict
Dictionary of spectral parameters (optional).
update_source : bool
Recompute all source characteristics (flux, TS, NPred)
using the new spectral model of the source.
[28]:
gta.load_roi('model_test')
gta.print_model()
gta.roi['3FGL J0059.0-7242e']['SpectrumType']
2024-12-19 20:30:38 INFO GTAnalysis.load_roi(): Loading ROI file: /home/runner/work/fermipy/fermipy/fermipy-extra/notebooks/SMC_data/model_test.npy
2024-12-19 20:30:38 INFO GTBinnedAnalysis._create_binned_analysis(): Creating BinnedAnalysis for component 00.
2024-12-19 20:30:43 INFO GTAnalysis.load_roi(): Finished Loading ROI
2024-12-19 20:30:43 INFO GTAnalysis.print_model():
sourcename offset norm eflux index ts npred free
--------------------------------------------------------------------------------
3FGL J0059.0-7242e 0.088 1.354 1.02e-05 2.46 631.43 1387.2 *
3FGL J0112.9-7506 2.572 1.133 2.16e-06 1.95 145.27 129.2 *
3FGL J0023.9-7203 2.654 0.582 9.37e-06 2.69 5334.39 1799.9 *
3FGL J0029.1-7045 3.008 0.458 2.07e-06 2.33 269.77 239.2 *
3FGL J0021.6-6835 5.122 2.618 2.57e-07 3.29 16.47 57.1 *
3FGL J2351.9-7601 5.495 1.404 2.85e-06 2.01 243.25 192.1 *
3FGL J2338.7-7401 5.777 0.598 2.91e-06 2.02 294.33 187.1 *
3FGL J0146.4-6746 6.423 0.664 1.76e-06 2.35 256.39 201.6 *
3FGL J2336.5-7620 6.454 0.392 1.28e-06 2.29 112.83 135.9 *
3FGL J0002.0-6722 7.153 0.409 1.63e-06 1.98 94.14 95.4 *
isodiff --- 0.684 0.0214 2.12 713.57 6220.2 *
galdiff --- 1.094 0.134 0.05 7041.53 17811.3 *
[28]:
'PowerLaw'
[29]:
gta.set_source_spectrum('3FGL J0059.0-7242e',spectrum_type='LogParabola')
gta.roi['3FGL J0059.0-7242e']['SpectrumType']
[29]:
'LogParabola'
[30]:
gta.fit()
2024-12-19 20:30:43 INFO GTAnalysis.fit(): Starting fit.
/home/runner/miniconda3/envs/fermipy/lib/python3.9/site-packages/scipy/interpolate/_fitpack2.py:313: UserWarning:
The maximal number of iterations maxit (set to 20 by the program)
allowed for finding a smoothing spline with fp=s has been reached: s
too small.
There is an approximation returned but the corresponding weighted sum
of squared residuals does not satisfy the condition abs(fp-s)/s < tol.
warnings.warn(message)
2024-12-19 20:30:46 INFO GTAnalysis.fit(): Fit returned successfully. Quality: 3 Status: 0
2024-12-19 20:30:46 INFO GTAnalysis.fit(): LogLike: -73810.277 DeltaLogLike: 1.496
[30]:
{'fit_quality': 3,
'fit_status': 0,
'fit_success': True,
'dloglike': 1.4957104738568887,
'edm': 0.0002737282842093268,
'loglike': -73810.27663600704,
'covariance': array([[ 4.98472198e-03, 4.07309749e-03, -2.59347204e-04,
-5.94243239e-05, 1.76863307e-05, 3.73518577e-05,
-1.20573086e-05, 1.69901941e-05, 1.31487584e-05,
9.48751375e-05, 1.01761367e-05, 4.96385447e-05,
1.55697474e-05, 4.74379588e-05, 2.57847320e-05,
2.75638658e-05, 2.82827052e-05, 2.24006836e-05,
1.78592009e-05, 3.26272350e-05, 1.88822266e-05,
-1.86688310e-05, -3.89211213e-05, -1.07173572e-04],
[ 4.07309749e-03, 1.88514620e-02, -5.02535361e-04,
-7.82619448e-05, 2.37933218e-05, 4.83781547e-05,
-1.25386172e-05, 2.10851407e-05, 2.71420355e-05,
1.76468544e-04, 6.24391269e-05, 7.45041058e-05,
3.38129344e-05, 4.83009394e-05, 3.62127908e-05,
4.90419018e-05, 6.45276884e-05, 2.30276706e-05,
2.98060398e-05, 2.67026535e-05, 3.92312439e-05,
-9.21336317e-05, -8.08303394e-05, -2.55247410e-05],
[-2.59347204e-04, -5.02535361e-04, 2.48164123e+00,
6.90920259e-01, 2.95642043e-04, 6.42660656e-04,
-1.74430037e-04, -3.84577183e-04, -5.19650406e-04,
2.59354534e-03, 9.67453237e-04, 7.61001642e-04,
4.26301599e-04, 1.09389962e-03, 7.55575258e-04,
5.91551061e-04, 8.99190959e-04, 3.94599952e-04,
4.80945831e-04, 2.29961313e-04, 5.39987833e-04,
-7.60626459e-04, -2.09636738e-03, -2.63469995e-03],
[-5.94243239e-05, -7.82619448e-05, 6.90920259e-01,
2.49671711e-01, 3.69199058e-05, 8.49017692e-05,
-1.66651125e-05, -7.20746859e-05, -8.57873509e-05,
3.99704430e-04, 2.49922786e-04, 2.22902424e-05,
6.24974897e-05, 1.33357425e-04, 1.20166697e-04,
6.27962309e-05, 1.51061995e-04, 2.63975962e-05,
7.02117879e-05, -6.45053907e-05, 8.30766267e-05,
-1.46637577e-04, -4.65453026e-04, -3.54319958e-04],
[ 1.76863307e-05, 2.37933218e-05, 2.95642043e-04,
3.69199058e-05, 2.98367088e-03, 9.26955704e-03,
-3.41557596e-03, -1.46825233e-04, -2.03189953e-04,
-1.44145497e-04, -5.33526892e-05, 3.14121028e-05,
1.66121060e-05, 4.06099996e-05, 2.75426486e-05,
1.87699297e-05, 2.89622278e-05, 8.81928139e-06,
9.55476744e-06, 5.66732931e-06, 1.51920427e-05,
-2.32220163e-05, -7.64992236e-05, -1.04272857e-04],
[ 3.73518577e-05, 4.83781547e-05, 6.42660656e-04,
8.49017692e-05, 9.26955704e-03, 3.44802701e-02,
-1.40189166e-02, -2.88522809e-04, -4.60797425e-04,
-3.24484860e-04, -1.35184748e-04, 2.51176145e-05,
2.47131109e-05, 9.76583088e-05, 6.59385673e-05,
2.21197096e-05, 4.90210220e-05, 1.56177891e-05,
1.65438274e-05, -9.21438969e-06, 2.34275519e-05,
-3.68601915e-06, -2.13614572e-04, -3.41528824e-04],
[-1.20573086e-05, -1.25386172e-05, -1.74430037e-04,
-1.66651125e-05, -3.41557596e-03, -1.40189166e-02,
6.27420613e-03, 7.96078834e-05, 1.33208880e-04,
9.68811146e-05, 4.17529357e-05, -8.43422751e-08,
-3.87413355e-06, -3.17125759e-05, -1.98738891e-05,
-2.14141446e-06, -8.84077959e-06, -4.80689456e-06,
-3.36512947e-06, 3.77217550e-06, -3.61661443e-06,
-1.42157647e-05, 6.55651011e-05, 1.31109496e-04],
[ 1.69901941e-05, 2.10851407e-05, -3.84577183e-04,
-7.20746859e-05, -1.46825233e-04, -2.88522809e-04,
7.96078834e-05, 3.31457743e-03, 4.08070216e-03,
-2.74710838e-06, -4.18071266e-06, 5.28110605e-05,
1.99207077e-05, 3.25373475e-05, 2.07593692e-05,
2.87539366e-05, 3.34068938e-05, 1.62776756e-05,
1.66050763e-05, 2.38921771e-05, 2.10347662e-05,
-4.30211070e-05, -3.52671724e-05, -3.49507895e-05],
[ 1.31487584e-05, 2.71420355e-05, -5.19650406e-04,
-8.57873509e-05, -2.03189953e-04, -4.60797425e-04,
1.33208880e-04, 4.08070216e-03, 1.17818437e-02,
3.04027958e-06, 6.95621194e-06, 5.12893662e-05,
2.63339295e-05, 3.18854097e-05, 2.64845152e-05,
3.34345717e-05, 4.81298459e-05, 1.35666034e-05,
2.09993566e-05, 1.10747815e-05, 2.85494611e-05,
-7.02263346e-05, -7.06014076e-05, -1.29109254e-05],
[ 9.48751375e-05, 1.76468544e-04, 2.59354534e-03,
3.99704430e-04, -1.44145497e-04, -3.24484860e-04,
9.68811146e-05, -2.74710838e-06, 3.04027958e-06,
1.30059323e-02, 5.76743440e-03, -1.42043042e-04,
-5.66224454e-05, 1.61949005e-04, 1.31648431e-04,
2.17395617e-04, 2.81941607e-04, 8.71997776e-05,
1.21558848e-04, 1.11497099e-04, 1.67366566e-04,
-4.56449857e-04, -2.83626465e-04, 1.08826763e-04],
[ 1.01761367e-05, 6.24391269e-05, 9.67453237e-04,
2.49922786e-04, -5.33526892e-05, -1.35184748e-04,
4.17529357e-05, -4.18071266e-06, 6.95621194e-06,
5.76743440e-03, 3.73264528e-03, -3.74978323e-05,
-1.41888950e-05, 3.56085283e-05, 4.91492393e-05,
6.32522371e-05, 1.11216371e-04, 1.07779726e-05,
4.19977584e-05, -1.84615898e-05, 6.16511188e-05,
-1.88844378e-04, -1.84622217e-04, 8.59133019e-05],
[ 4.96385447e-05, 7.45041058e-05, 7.61001642e-04,
2.22902424e-05, 3.14121028e-05, 2.51176145e-05,
-8.43422751e-08, 5.28110605e-05, 5.12893662e-05,
-1.42043042e-04, -3.74978323e-05, 3.73077350e-02,
1.32902822e-02, 5.16821556e-05, 3.61738393e-05,
1.31715107e-04, 1.32984265e-04, 5.22577675e-05,
5.50854984e-05, 1.20557322e-04, 8.36808371e-05,
-2.69943400e-04, 4.01544253e-05, 2.85644595e-04],
[ 1.55697474e-05, 3.38129344e-05, 4.26301599e-04,
6.24974897e-05, 1.66121060e-05, 2.47131109e-05,
-3.87413355e-06, 1.99207077e-05, 2.63339295e-05,
-5.66224454e-05, -1.41888950e-05, 1.32902822e-02,
1.22854537e-02, 2.17506263e-05, 2.06179934e-05,
4.95889202e-05, 6.03847163e-05, 1.65268690e-05,
2.41898901e-05, 2.87101877e-05, 3.62190625e-05,
-1.14897031e-04, -2.88348207e-05, 9.80502347e-05],
[ 4.74379588e-05, 4.83009394e-05, 1.09389962e-03,
1.33357425e-04, 4.06099996e-05, 9.76583088e-05,
-3.17125759e-05, 3.25373475e-05, 3.18854097e-05,
1.61949005e-04, 3.56085283e-05, 5.16821556e-05,
2.17506263e-05, 9.37949006e-03, 8.09952451e-03,
3.53462792e-05, 4.65490539e-05, 3.56561931e-05,
3.18534694e-05, 3.18303177e-05, 2.97060784e-05,
-4.73723131e-06, -1.32132522e-04, -2.87887519e-04],
[ 2.57847320e-05, 3.62127908e-05, 7.55575258e-04,
1.20166697e-04, 2.75426486e-05, 6.59385673e-05,
-1.98738891e-05, 2.07593692e-05, 2.64845152e-05,
1.31648431e-04, 4.91492393e-05, 3.61738393e-05,
2.06179934e-05, 8.09952451e-03, 1.31251209e-02,
2.87577334e-05, 4.41062977e-05, 1.98550427e-05,
2.40937606e-05, 1.09701785e-05, 2.65110941e-05,
-3.54133060e-05, -1.05767323e-04, -1.36843812e-04],
[ 2.75638658e-05, 4.90419018e-05, 5.91551061e-04,
6.27962309e-05, 1.87699297e-05, 2.21197096e-05,
-2.14141446e-06, 2.87539366e-05, 3.34345717e-05,
2.17395617e-04, 6.32522371e-05, 1.31715107e-04,
4.95889202e-05, 3.53462792e-05, 2.87577334e-05,
7.11162587e-03, 9.58185432e-03, -4.88606753e-06,
-2.81948672e-06, -4.90734144e-04, -4.53493587e-04,
-1.64162319e-04, -1.93902317e-05, 1.41559193e-04],
[ 2.82827052e-05, 6.45276884e-05, 8.99190959e-04,
1.51061995e-04, 2.89622278e-05, 4.90210220e-05,
-8.84077959e-06, 3.34068938e-05, 4.81298459e-05,
2.81941607e-04, 1.11216371e-04, 1.32984265e-04,
6.03847163e-05, 4.65490539e-05, 4.41062977e-05,
9.58185432e-03, 2.27373190e-02, -8.65554822e-06,
-1.91371293e-06, -4.30443791e-04, -5.67205956e-04,
-2.00652041e-04, -8.87402086e-05, 1.30866065e-04],
[ 2.24006836e-05, 2.30276706e-05, 3.94599952e-04,
2.63975962e-05, 8.81928139e-06, 1.56177891e-05,
-4.80689456e-06, 1.62776756e-05, 1.35666034e-05,
8.71997776e-05, 1.07779726e-05, 5.22577675e-05,
1.65268690e-05, 3.56561931e-05, 1.98550427e-05,
-4.88606753e-06, -8.65554822e-06, 3.90111876e-03,
1.49112879e-03, -1.06787506e-05, -1.49123501e-05,
-3.32470924e-05, -2.15480819e-05, -4.87983992e-05],
[ 1.78592009e-05, 2.98060398e-05, 4.80945831e-04,
7.02117879e-05, 9.55476744e-06, 1.65438274e-05,
-3.36512947e-06, 1.66050763e-05, 2.09993566e-05,
1.21558848e-04, 4.19977584e-05, 5.50854984e-05,
2.41898901e-05, 3.18534694e-05, 2.40937606e-05,
-2.81948672e-06, -1.91371293e-06, 1.49112879e-03,
8.62196937e-03, -1.64123611e-05, -1.34073261e-05,
-6.88936709e-05, -5.00834971e-05, -3.36673668e-06],
[ 3.26272350e-05, 2.67026535e-05, 2.29961313e-04,
-6.45053907e-05, 5.66732931e-06, -9.21438969e-06,
3.77217550e-06, 2.38921771e-05, 1.10747815e-05,
1.11497099e-04, -1.84615898e-05, 1.20557322e-04,
2.87101877e-05, 3.18303177e-05, 1.09701785e-05,
-4.90734144e-04, -4.30443791e-04, -1.06787506e-05,
-1.64123611e-05, 2.55693358e-02, -5.24358053e-03,
-8.15624705e-05, 7.06546747e-05, 7.83275028e-05],
[ 1.88822266e-05, 3.92312439e-05, 5.39987833e-04,
8.30766267e-05, 1.51920427e-05, 2.34275519e-05,
-3.61661443e-06, 2.10347662e-05, 2.85494611e-05,
1.67366566e-04, 6.16511188e-05, 8.36808371e-05,
3.62190625e-05, 2.97060784e-05, 2.65110941e-05,
-4.53493587e-04, -5.67205956e-04, -1.49123501e-05,
-1.34073261e-05, -5.24358053e-03, 9.82190009e-03,
-1.20678473e-04, -4.70555033e-05, 7.79164534e-05],
[-1.86688310e-05, -9.21336317e-05, -7.60626459e-04,
-1.46637577e-04, -2.32220163e-05, -3.68601915e-06,
-1.42157647e-05, -4.30211070e-05, -7.02263346e-05,
-4.56449857e-04, -1.88844378e-04, -2.69943400e-04,
-1.14897031e-04, -4.73723131e-06, -3.54133060e-05,
-1.64162319e-04, -2.00652041e-04, -3.32470924e-05,
-6.88936709e-05, -8.15624705e-05, -1.20678473e-04,
4.48050010e-04, 1.41841920e-05, -6.26288959e-04],
[-3.89211213e-05, -8.08303394e-05, -2.09636738e-03,
-4.65453026e-04, -7.64992236e-05, -2.13614572e-04,
6.55651011e-05, -3.52671724e-05, -7.06014076e-05,
-2.83626465e-04, -1.84622217e-04, 4.01544253e-05,
-2.88348207e-05, -1.32132522e-04, -1.05767323e-04,
-1.93902317e-05, -8.87402086e-05, -2.15480819e-05,
-5.00834971e-05, 7.06546747e-05, -4.70555033e-05,
1.41841920e-05, 4.23667946e-04, 5.18220461e-04],
[-1.07173572e-04, -2.55247410e-05, -2.63469995e-03,
-3.54319958e-04, -1.04272857e-04, -3.41528824e-04,
1.31109496e-04, -3.49507895e-05, -1.29109254e-05,
1.08826763e-04, 8.59133019e-05, 2.85644595e-04,
9.80502347e-05, -2.87887519e-04, -1.36843812e-04,
1.41559193e-04, 1.30866065e-04, -4.87983992e-05,
-3.36673668e-06, 7.83275028e-05, 7.79164534e-05,
-6.26288959e-04, 5.18220461e-04, 1.86268973e-03]]),
'correlation': array([[ 1.00000000e+00, 4.20176555e-01, -2.33180163e-03,
-1.68445382e-03, 4.58608197e-03, 2.84909157e-03,
-2.15600872e-03, 4.17987973e-03, 1.71576437e-03,
1.17831445e-02, 2.35914211e-03, 3.63998110e-03,
1.98959873e-03, 6.93770629e-03, 3.18779581e-03,
4.62951191e-03, 2.65662863e-03, 5.07979535e-03,
2.72419578e-03, 2.89001487e-03, 2.69857802e-03,
-1.24920412e-02, -2.67825589e-02, -3.51719927e-02],
[ 4.20176555e-01, 1.00000000e+00, -2.32340334e-03,
-1.14075780e-03, 3.17253996e-03, 1.89754223e-03,
-1.15291618e-03, 2.66741077e-03, 1.82122359e-03,
1.12700032e-02, 7.44347859e-03, 2.80936551e-03,
2.22185004e-03, 3.63239814e-03, 2.30217228e-03,
4.23555509e-03, 3.11676430e-03, 2.68523874e-03,
2.33791394e-03, 1.21624811e-03, 2.88311393e-03,
-3.17016908e-02, -2.86015178e-02, -4.30743335e-03],
[-2.33180163e-03, -2.32340334e-03, 1.00000000e+00,
8.77755907e-01, 3.43574751e-03, 2.19698396e-03,
-1.39788802e-03, -4.24033269e-03, -3.03903110e-03,
1.44362237e-02, 1.00519918e-02, 2.50101706e-03,
2.44147266e-03, 7.16998687e-03, 4.18655281e-03,
4.45285229e-03, 3.78540896e-03, 4.01044851e-03,
3.28793655e-03, 9.12904943e-04, 3.45873047e-03,
-2.28107038e-02, -6.46524658e-02, -3.87517576e-02],
[-1.68445382e-03, -1.14075780e-03, 8.77755907e-01,
1.00000000e+00, 1.35269678e-03, 9.15054038e-04,
-4.21060198e-04, -2.50543999e-03, -1.58172857e-03,
7.01428727e-03, 8.18677443e-03, 2.30956762e-04,
1.12844996e-03, 2.75576969e-03, 2.09917091e-03,
1.49026828e-03, 2.00493787e-03, 8.45833977e-04,
1.51328987e-03, -8.07330979e-04, 1.67763095e-03,
-1.38642813e-02, -4.52562314e-02, -1.64301182e-02],
[ 4.58608197e-03, 3.17253996e-03, 3.43574751e-03,
1.35269678e-03, 1.00000000e+00, 9.13898983e-01,
-7.89421771e-01, -4.66886328e-02, -3.42704764e-02,
-2.31395483e-02, -1.59872033e-02, 2.97729667e-03,
2.74380749e-03, 7.67658235e-03, 4.40127583e-03,
4.07476661e-03, 3.51630777e-03, 2.58501552e-03,
1.88382877e-03, 6.48848444e-04, 2.80635726e-03,
-2.00845091e-02, -6.80406989e-02, -4.42308775e-02],
[ 2.84909157e-03, 1.89754223e-03, 2.19698396e-03,
9.15054038e-04, 9.13898983e-01, 1.00000000e+00,
-9.53124713e-01, -2.69886236e-02, -2.28622035e-02,
-1.53228081e-02, -1.19160964e-02, 7.00315308e-04,
1.20073312e-03, 5.43043045e-03, 3.09957765e-03,
1.41256890e-03, 1.75076318e-03, 1.34660319e-03,
9.59505401e-04, -3.10328400e-04, 1.27304520e-03,
-9.37797374e-04, -5.58898241e-02, -4.26159106e-02],
[-2.15600872e-03, -1.15291618e-03, -1.39788802e-03,
-4.21060198e-04, -7.89421771e-01, -9.53124713e-01,
1.00000000e+00, 1.74567182e-02, 1.54934151e-02,
1.07247948e-02, 8.62778403e-03, -5.51272691e-06,
-4.41265117e-04, -4.13392425e-03, -2.19003882e-03,
-3.20580343e-04, -7.40187155e-04, -9.71606963e-04,
-4.57529550e-04, 2.97819257e-04, -4.60707268e-04,
-8.47866723e-03, 4.02143025e-02, 3.83516891e-02],
[ 4.17987973e-03, 2.66741077e-03, -4.24033269e-03,
-2.50543999e-03, -4.66886328e-02, -2.69886236e-02,
1.74567182e-02, 1.00000000e+00, 6.53001508e-01,
-4.18399315e-04, -1.18857851e-03, 4.74910052e-03,
3.12172814e-03, 5.83550503e-03, 3.14737443e-03,
5.92241418e-03, 3.84815347e-03, 4.52672090e-03,
3.10615807e-03, 2.59526624e-03, 3.68659856e-03,
-3.53024016e-02, -2.97607419e-02, -1.40660658e-02],
[ 1.71576437e-03, 1.82122359e-03, -3.03903110e-03,
-1.58172857e-03, -3.42704764e-02, -2.28622035e-02,
1.54934151e-02, 6.53001508e-01, 1.00000000e+00,
2.45604404e-04, 1.04895732e-03, 2.44636504e-03,
2.18883709e-03, 3.03316306e-03, 2.12977509e-03,
3.65262161e-03, 2.94061531e-03, 2.00110518e-03,
2.08351256e-03, 6.38070720e-04, 2.65395485e-03,
-3.05654030e-02, -3.16004981e-02, -2.75600805e-03],
[ 1.17831445e-02, 1.12700032e-02, 1.44362237e-02,
7.01428727e-03, -2.31395483e-02, -1.53228081e-02,
1.07247948e-02, -4.18399315e-04, 2.45604404e-04,
1.00000000e+00, 8.27758328e-01, -6.44836748e-03,
-4.47942509e-03, 1.46628342e-02, 1.00761190e-02,
2.26045356e-02, 1.63952785e-02, 1.22419344e-02,
1.14792256e-02, 6.11410792e-03, 1.48081295e-02,
-1.89085874e-01, -1.20826781e-01, 2.21103037e-02],
[ 2.35914211e-03, 7.44347859e-03, 1.00519918e-02,
8.18677443e-03, -1.59872033e-02, -1.19160964e-02,
8.62778403e-03, -1.18857851e-03, 1.04895732e-03,
8.27758328e-01, 1.00000000e+00, -3.17759366e-03,
-2.09529230e-03, 6.01805360e-03, 7.02193466e-03,
1.22767406e-02, 1.20723198e-02, 2.82445155e-03,
7.40311529e-03, -1.88973547e-03, 1.01820411e-02,
-1.46026762e-01, -1.46812420e-01, 3.25823039e-02],
[ 3.63998110e-03, 2.80936551e-03, 2.50101706e-03,
2.30956762e-04, 2.97729667e-03, 7.00315308e-04,
-5.51272691e-06, 4.74910052e-03, 2.44636504e-03,
-6.44836748e-03, -3.17759366e-03, 1.00000000e+00,
6.20782068e-01, 2.76281347e-03, 1.63472049e-03,
8.08633442e-03, 4.56595039e-03, 4.33168458e-03,
3.07138744e-03, 3.90332242e-03, 4.37148325e-03,
-6.60252458e-02, 1.00999952e-02, 3.42654397e-02],
[ 1.98959873e-03, 2.22185004e-03, 2.44147266e-03,
1.12844996e-03, 2.74380749e-03, 1.20073312e-03,
-4.41265117e-04, 3.12172814e-03, 2.18883709e-03,
-4.47942509e-03, -2.09529230e-03, 6.20782068e-01,
1.00000000e+00, 2.02621979e-03, 1.62367514e-03,
5.30523471e-03, 3.61294877e-03, 2.38726373e-03,
2.35036363e-03, 1.61987204e-03, 3.29718905e-03,
-4.89722391e-02, -1.26388876e-02, 2.04966449e-02],
[ 6.93770629e-03, 3.63239814e-03, 7.16998687e-03,
2.75576969e-03, 7.67658235e-03, 5.43043045e-03,
-4.13392425e-03, 5.83550503e-03, 3.03316306e-03,
1.46628342e-02, 6.01805360e-03, 2.76281347e-03,
2.02621979e-03, 1.00000000e+00, 7.29992257e-01,
4.32782448e-03, 3.18751045e-03, 5.89455159e-03,
3.54212506e-03, 2.05537768e-03, 3.09498076e-03,
-2.31084987e-03, -6.62837863e-02, -6.88752143e-02],
[ 3.18779581e-03, 2.30217228e-03, 4.18655281e-03,
2.09917091e-03, 4.40127583e-03, 3.09957765e-03,
-2.19003882e-03, 3.14737443e-03, 2.12977509e-03,
1.00761190e-02, 7.02193466e-03, 1.63472049e-03,
1.62367514e-03, 7.29992257e-01, 1.00000000e+00,
2.97658676e-03, 2.55316757e-03, 2.77475462e-03,
2.26490347e-03, 5.98828299e-04, 2.33495351e-03,
-1.46033189e-02, -4.48525409e-02, -2.76759953e-02],
[ 4.62951191e-03, 4.23555509e-03, 4.45285229e-03,
1.49026828e-03, 4.07476661e-03, 1.41256890e-03,
-3.20580343e-04, 5.92241418e-03, 3.65262161e-03,
2.26045356e-02, 1.22767406e-02, 8.08633442e-03,
5.30523471e-03, 4.32782448e-03, 2.97658676e-03,
1.00000000e+00, 7.53521217e-01, -9.27642052e-04,
-3.60066207e-04, -3.63916797e-02, -5.42611437e-02,
-9.19656792e-02, -1.11708378e-02, 3.88940679e-02],
[ 2.65662863e-03, 3.11676430e-03, 3.78540896e-03,
2.00493787e-03, 3.51630777e-03, 1.75076318e-03,
-7.40187155e-04, 3.84815347e-03, 2.94061531e-03,
1.63952785e-02, 1.20723198e-02, 4.56595039e-03,
3.61294877e-03, 3.18751045e-03, 2.55316757e-03,
7.53521217e-01, 1.00000000e+00, -9.19031435e-04,
-1.36679672e-04, -1.78520090e-02, -3.79553848e-02,
-6.28652589e-02, -2.85915707e-02, 2.01088464e-02],
[ 5.07979535e-03, 2.68523874e-03, 4.01044851e-03,
8.45833977e-04, 2.58501552e-03, 1.34660319e-03,
-9.71606963e-04, 4.52672090e-03, 2.00110518e-03,
1.22419344e-02, 2.82445155e-03, 4.33168458e-03,
2.38726373e-03, 5.89455159e-03, 2.77475462e-03,
-9.27642052e-04, -9.19031435e-04, 1.00000000e+00,
2.57109031e-01, -1.06921769e-03, -2.40909402e-03,
-2.51475592e-02, -1.67610502e-02, -1.81025906e-02],
[ 2.72419578e-03, 2.33791394e-03, 3.28793655e-03,
1.51328987e-03, 1.88382877e-03, 9.59505401e-04,
-4.57529550e-04, 3.10615807e-03, 2.08351256e-03,
1.14792256e-02, 7.40311529e-03, 3.07138744e-03,
2.35036363e-03, 3.54212506e-03, 2.26490347e-03,
-3.60066207e-04, -1.36679672e-04, 2.57109031e-01,
1.00000000e+00, -1.10537109e-03, -1.45693836e-03,
-3.50520032e-02, -2.62046645e-02, -8.40109028e-04],
[ 2.89001487e-03, 1.21624811e-03, 9.12904943e-04,
-8.07330979e-04, 6.48848444e-04, -3.10328400e-04,
2.97819257e-04, 2.59526624e-03, 6.38070720e-04,
6.11410792e-03, -1.88973547e-03, 3.90332242e-03,
1.61987204e-03, 2.05537768e-03, 5.98828299e-04,
-3.63916797e-02, -1.78520090e-02, -1.06921769e-03,
-1.10537109e-03, 1.00000000e+00, -3.30879958e-01,
-2.40972455e-02, 2.14668526e-02, 1.13496978e-02],
[ 2.69857802e-03, 2.88311393e-03, 3.45873047e-03,
1.67763095e-03, 2.80635726e-03, 1.27304520e-03,
-4.60707268e-04, 3.68659856e-03, 2.65395485e-03,
1.48081295e-02, 1.01820411e-02, 4.37148325e-03,
3.29718905e-03, 3.09498076e-03, 2.33495351e-03,
-5.42611437e-02, -3.79553848e-02, -2.40909402e-03,
-1.45693836e-03, -3.30879958e-01, 1.00000000e+00,
-5.75266131e-02, -2.30674646e-02, 1.82163415e-02],
[-1.24920412e-02, -3.17016908e-02, -2.28107038e-02,
-1.38642813e-02, -2.00845091e-02, -9.37797374e-04,
-8.47866723e-03, -3.53024016e-02, -3.05654030e-02,
-1.89085874e-01, -1.46026762e-01, -6.60252458e-02,
-4.89722391e-02, -2.31084987e-03, -1.46033189e-02,
-9.19656792e-02, -6.28652589e-02, -2.51475592e-02,
-3.50520032e-02, -2.40972455e-02, -5.75266131e-02,
1.00000000e+00, 3.25558136e-02, -6.85553338e-01],
[-2.67825589e-02, -2.86015178e-02, -6.46524658e-02,
-4.52562314e-02, -6.80406989e-02, -5.58898241e-02,
4.02143025e-02, -2.97607419e-02, -3.16004981e-02,
-1.20826781e-01, -1.46812420e-01, 1.00999952e-02,
-1.26388876e-02, -6.62837863e-02, -4.48525409e-02,
-1.11708378e-02, -2.85915707e-02, -1.67610502e-02,
-2.62046645e-02, 2.14668526e-02, -2.30674646e-02,
3.25558136e-02, 1.00000000e+00, 5.83353076e-01],
[-3.51719927e-02, -4.30743335e-03, -3.87517576e-02,
-1.64301182e-02, -4.42308775e-02, -4.26159106e-02,
3.83516891e-02, -1.40660658e-02, -2.75600805e-03,
2.21103037e-02, 3.25823039e-02, 3.42654397e-02,
2.04966449e-02, -6.88752143e-02, -2.76759953e-02,
3.88940679e-02, 2.01088464e-02, -1.81025906e-02,
-8.40109028e-04, 1.13496978e-02, 1.82163415e-02,
-6.85553338e-01, 5.83353076e-01, 1.00000000e+00]]),
'values': array([0.40861579, 1.97715111, 2.61901273, 3.28583985, 0.59494962,
1.17663859, 0.58371813, 0.46191178, 2.3315159 , 1.35174521,
2.45868649, 1.13297256, 1.95249163, 0.66401781, 2.35316433,
0.3917108 , 2.28965538, 0.59772866, 2.01586615, 1.40373579,
2.01272488, 1.09410496, 0.0463696 , 0.68374566]),
'errors': array([0.07060256, 0.13730063, 1.57532258, 0.4996716 , 0.05462299,
0.18568864, 0.07920989, 0.05757237, 0.1085442 , 0.11404355,
0.06109538, 0.1931521 , 0.11083977, 0.09684777, 0.11456492,
0.08433046, 0.15078899, 0.06245894, 0.09285456, 0.15990415,
0.0991055 , 0.02116719, 0.0205832 , 0.04315889]),
'indices': array([ 0, 1, 3, 4, 6, 7, 8, 10, 11, 13, 14, 17, 18, 20, 21, 23, 24,
26, 27, 29, 30, 32, 33, 35]),
'is_norm': array([ True, False, True, False, True, False, False, True, False,
True, False, True, False, True, False, True, False, True,
False, True, False, True, False, True]),
'src_names': ['3FGL J0002.0-6722',
'3FGL J0002.0-6722',
'3FGL J0021.6-6835',
'3FGL J0021.6-6835',
'3FGL J0023.9-7203',
'3FGL J0023.9-7203',
'3FGL J0023.9-7203',
'3FGL J0029.1-7045',
'3FGL J0029.1-7045',
'3FGL J0059.0-7242e',
'3FGL J0059.0-7242e',
'3FGL J0112.9-7506',
'3FGL J0112.9-7506',
'3FGL J0146.4-6746',
'3FGL J0146.4-6746',
'3FGL J2336.5-7620',
'3FGL J2336.5-7620',
'3FGL J2338.7-7401',
'3FGL J2338.7-7401',
'3FGL J2351.9-7601',
'3FGL J2351.9-7601',
'galdiff',
'galdiff',
'isodiff'],
'par_names': ['Prefactor',
'Index',
'Prefactor',
'Index',
'norm',
'alpha',
'beta',
'Prefactor',
'Index',
'norm',
'alpha',
'Prefactor',
'Index',
'Prefactor',
'Index',
'Prefactor',
'Index',
'Prefactor',
'Index',
'Prefactor',
'Index',
'Prefactor',
'Index',
'Normalization'],
'config': {'optimizer': 'MINUIT',
'tol': 0.001,
'max_iter': 100,
'init_lambda': 0.0001,
'retries': 3,
'min_fit_quality': 2,
'verbosity': 0,
'covar': True,
'reoptimize': False},
'niter': 1}
[31]:
print(gta.roi['3FGL J0059.0-7242e']['param_names'])
print(gta.roi['3FGL J0059.0-7242e']['param_values'])
print(gta.roi['3FGL J0059.0-7242e']['param_errors'])
[b'norm' b'alpha' b'beta' b'Eb' b'' b'' b'' b'' b'' b'']
[1.35174521e-11 2.45868649e+00 0.00000000e+00 6.65532043e+02
nan nan nan nan
nan nan]
[1.14043554e-12 6.10953785e-02 nan nan
nan nan nan nan
nan nan]
As you can see above the tool gta.set_source_spectrum has modified the SED shape from PowerLaw to LogParabola.
It is also possible to set the spatial morphology of a source using gta.set_source_morphology
[32]:
help(gta.set_source_morphology)
Help on method set_source_morphology in module fermipy.gtanalysis:
set_source_morphology(name, **kwargs) method of fermipy.gtanalysis.GTAnalysis instance
Set the spatial model of a source.
Parameters
----------
name : str
Source name.
spatial_model : str
Spatial model name (PointSource, RadialGaussian, etc.).
spatial_pars : dict
Dictionary of spatial parameters (optional).
use_cache : bool
Generate the spatial model by interpolating the cached source
map.
use_pylike : bool
[33]:
gta.set_source_morphology(name='3FGL J0029.1-7045',spatial_model='RadialGaussian',spatial_pars={'SpatialWidth': 1.0} )
[34]:
gta.print_model()
print(gta.roi['3FGL J0029.1-7045']['SpatialType'])
print(gta.roi['3FGL J0029.1-7045']['SpatialWidth'])
2024-12-19 20:30:51 INFO GTAnalysis.print_model():
sourcename offset norm eflux index ts npred free
--------------------------------------------------------------------------------
3FGL J0059.0-7242e 0.088 1.352 1.02e-05 2.46 630.25 1385.7 *
3FGL J0112.9-7506 2.572 1.133 2.16e-06 1.95 145.28 129.2 *
3FGL J0023.9-7203 2.654 0.595 9.8e-06 2.70 5215.82 1799.6 *
3FGL J0029.1-7045 3.008 0.462 2.07e-06 2.33 271.65 240.6 *
3FGL J0021.6-6835 5.122 2.619 2.57e-07 3.29 16.48 57.2 *
3FGL J2351.9-7601 5.495 1.404 2.85e-06 2.01 243.24 192.1 *
3FGL J2338.7-7401 5.777 0.598 2.91e-06 2.02 294.32 187.1 *
3FGL J0146.4-6746 6.423 0.664 1.76e-06 2.35 256.38 201.6 *
3FGL J2336.5-7620 6.454 0.392 1.28e-06 2.29 112.83 135.9 *
3FGL J0002.0-6722 7.153 0.409 1.63e-06 1.98 94.13 95.4 *
isodiff --- 0.684 0.0214 2.12 713.90 6222.0 *
galdiff --- 1.094 0.134 0.05 7038.55 17808.8 *
RadialGaussian
1.0
[ ]: