Skip to content

Generates source definitions and model files needed for analysis and simulation with the Fermitools.

License

Notifications You must be signed in to change notification settings

jaulbric/fermimodel

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FermiModel

This package is for use with the Fermitools. The main function of the package is to produce model files for use in analysis with gtlike and simulations with gtobssim. This is essentially an extension of make4FGLxml.py, written by Tyrel Johnson and the command line syntax is nearly identical to that of make4FGLxml.py.

Installation

Download the package (This will save the package to a directory named fermimodel in the user's home directory)

BaSH

# Get the version of the latest release
version=`curl -s https://api.github.com/repos/jaulbric/fermimodel/releases/latest \
| grep "tag_name" \
| cut -d ":" -f 2 \
| tr -d " "-\"-,`
# download and untar the package
wget https://github.com/jaulbric/fermimodel/archive/$version.tar.gz \
&& mkdir ~/fermimodel \
&& tar xvfz $version.tar.gz -C ~/fermimodel --strip-components 1 \
&& rm $version.tar.gz

csh/tcsh

# Get the version of the latest release
set version=`curl -s https://api.github.com/repos/jaulbric/fermimodel/releases/latest \
| grep "tag_name" \
| cut -d ":" -f 2 \
| tr -d " "-\"-,`
# download and untar the package
wget https://github.com/jaulbric/fermimodel/archive/$version.tar.gz \
&& mkdir ~/fermimodel \
&& tar xvfz $version.tar.gz -C ~/fermimodel --strip-components 1 \
&& rm $version.tar.gz

Then move to the package root directory and install

cd ~/fermimodel
python setup.py install

Usage

As Python Module

The following instructions provide a simple example of how to generate a model for use with gtobssim. The roi is centered at the location of the Andromeda galaxy (M31) and will have a radius such that a 10 degree by 10 degree image can be contained within the roi. The Andromeda galaxy will be modeled as an elliptical gaussian with a power law emission spectrum. More information for each command can be found in the Definitions section. The package can be imported in python as usual.

import fermimodel

Models can then be built by creating an instance of the model class

mymodel = fermimodel.model(name='mymodel',
                           out='mymodel.xml',
                           frame='galactic',
                           unit='degree',
                           allsky=False,
                           model_type='simulation')

The same model instance can be used to generate multiple models. The region of interest can be set either when the model instance is created or by directly calling the function setROI.

mymodel.setROI(roi=(10.8229, 41.2415, 7.071), frame='fk5', unit='degree', allsky=False)

Trying to run mission long simulations takes a very long time because the galactic diffuse emission flux is quite large (relatively). It is therefore useful to mask the galactic diffuse model so that pixels outside the region of interest have a very low flux. Also, see the note on using the latest galactic diffuse model.

GDfile, GDflux = fermimodel.maskFits('$(FERMI_DIR)/refdata/fermi/galdiffuse/gll_iem_v07.fits',
                                   out='gll_iem_v07_masked.fits',
                                   mask_type='radial',
                                   radius=7.071 + 10.,
                                   center=(10.8229, 41.2415),
                                   frame='fk5',
                                   unit='degree',
                                   clobber=True)

To add sources from the 4FGL catalog the loadCatalog function is used. For models that will be used by gtobssim it is necessary to have the parameter oldNames = True. This will force all names to begin with an underscore, which is necessary because gtobssim doesn't like source names beginning with '4FGL'. If model_type was set to 'simulation' when the model instance was initialized this will automatically set oldNames = True.

mymodel.loadCatalog(catalog = 'gll_psc_v19.fit',
                    GDfile = GDfile,
                    GDname = 'gll_iem_v07',
                    ISOfile = '$(FERMI_DIR)/refdata/fermi/galdiffuse/iso_P8R3_SOURCE_V2_v01.txt',
                    ISOname = 'iso_P8R3_SOURCE_V2_v01',
                    ISOPath = '$(FERMI_DIR)/refdata/fermi/galdiffuse/isotropic_allsky.fits',
                    extDir = '$(FERMI_DIR)/data/pyBurstAnalysisGUI/templates',
                    ExtraRad = 10.,
                    makeRegion = True,
                    wd='.',
                    emin = 1.e2,
                    emax = 5.e5,
                    frame = 'galactic',
                    extSrcRes = 'force-point',
                    apply_mask = False,
                    GDflux=GDflux)

Additional Sources can be add individually with addSource. As an example we will add the Andromeda galaxy as a spatially extended source with a power law spectrum.

mymodel.addSource('M31',
                  'PowerLaw',
                  ra=10.8229,
                  dec=41.2415,
                  major_axis=0.46,
                  minor_axis=0.11,
                  position_angle=62.,
                  spatial_function='RadialGauss',
                  emin=1.e2,
                  emax=5.e5,
                  pl_flux_density=4.74295524506e-13,
                  pivot_energy=887.615335377,
                  pl_index=2.52349635581)

Sources can also be removed from the model by calling the model class removeSource method. Since we have included a new definition for the Andromeda galaxy we should remove the old source definition (Note that source names in the model are different then how they appear in the 4FGL catalog. 4FGL catalog sources have names begining with an underscore, spaces replaced by underscores, '.' replaced with 'd', '+' replaced with 'p', and '-' replaced by 'm').

mymodel.removeSource("_4FGL_J0043d2p4114")

gtobssim requires a path to an xml file containing the source definitions. We should then export the model to XML using the model class writeXML method. The type of XML output is determined by the model_type parameter when creating an instance of the model class.

xmlfile_path = mymodel.writeXML()

gtobssim also requires a list of source names. This is useful because we may want to simulate a subset of the sources in the XML file. A list of sources in the model can be generated with the model class writeSrcList method.

srcList_path = mymodel.writeSrcList()

Via Command Line

The package installs an executable into the user's bin, fermimodel. Usage of the executable can be viewed using the -h or --help flags.

fermimodel -h
usage: fermimodel [-h] [-v] {buildmodel,maskfits} ...

Command line interface to the fermimodel tools.

positional arguments:
  {buildmodel,maskfits}
    buildmodel          Creates an xml model from the 4FGL catalog (FITS or
                        xml version) for a specific ROI. Coordinates of the
                        ROI center are taken from an input event file or
                        defined on the command line. For likelihood models
                        sources with free parameters within the original
                        extraction radius are chosen based on nearness to
                        center, significance, and variability. For simulation
                        models all sources within radLim + ExtraRad are
                        included in the model. Optionally, a file can be input
                        on the command line by using the '@' prefix.
                        Parameters inside this file should be one per line and
                        are read in order.
    maskfits            Mask fits image. The data HDU of the FITS file should
                        be a 2D image or a 3D cube with the 3rd axis being
                        energy (0 axis numpy indexing).

optional arguments:
  -h, --help            show this help message and exit
  -v, --version         show program's version number and exit

There are two commands for the executable: buildmodel and maskfits. For more information on these commands use the -h or --help flags.

fermimodel buildmodel -h
usage: fermimodel buildmodel [-h] [-n NAME] [-t {likelihood,simulation}]
                             [-o OUTPUTXML] [-G GALFILE] [-g GALNAME]
                             [-I ISOFILE] [-i ISONAME] [-e EXTDIR]
                             [-roi C1, C2, RADIUS] [-xc HORIZONTAL_CENTER]
                             [-yc VERTICAL_CENTER] [-icrs | -gal | -fk5]
                             [-u UNIT] [-r RADLIM] [-ER EXTRARAD] [-p] [-E2C]
                             [-m] [-wd WRITEDIR] [-ON] [-AS] [-N] [-R MAXRAD]
                             [-s SIGFREE] [-GIF] [--emin EMIN] [--emax EMAX]
                             [--isopath ISOPATH]
                             [--extSrcRes {force-point,skip,raise}] [-am]
                             [-gf GALFLUX] [-if ISOFLUX]
                             catalog [ev]

positional arguments:
  catalog               Catalog file to use, can be FITS or xml.
  ev                    Event file with ROI information in header.

optional arguments:
  -h, --help            show this help message and exit
  -n NAME, --name NAME  Name of the model. This will be used for output
                        filenames if no other name is specified. Default is
                        'mymodel'.
  -t {likelihood,simulation}, --model-type {likelihood,simulation}
                        Type of model to generate. For likelihood analysis
                        this should be 'likelihood'. If the model is intended
                        for use with gtobssim this should be 'simulation'.
  -o OUTPUTXML, --outputxml OUTPUTXML
                        Name of output xml file, is set to overwrite files of
                        same name.
  -G GALFILE, --galfile GALFILE
                        Path to Galactic diffuse model. Default is $(FERMI_DIR
                        )/refdata/fermi/galdiffuse/gll_iem_v07.fits.
  -g GALNAME, --galname GALNAME
                        Name of Galactic diffuse component in output model.
                        Default is gll_iem_v07.
  -I ISOFILE, --isofile ISOFILE
                        Path to isotropic diffuse template for output model,
                        will default to P8R3 SOURCE class model.
  -i ISONAME, --isoname ISONAME
                        Name of isotropic diffuse component in output model,
                        default is for P8R3 SOURCE class.
  -e EXTDIR, --extDir EXTDIR
                        Path to directory with LAT extended source templates,
                        will default to STs default.
  -roi (C1, C2, RADIUS), --Region (C1, C2, RADIUS)
                        Region of Interest. This will override values taken
                        from event file if one is supplied.
  -xc HORIZONTAL_CENTER, --horizontal-center HORIZONTAL_CENTER
                        Horizontal coordinate of ROI center.
  -yc VERTICAL_CENTER, --vertical-center VERTICAL_CENTER
                        Vertical coordinate of ROI center.
  -icrs, --celestial    Flag sets coordinates of roi to RA, DEC.
  -gal, --galactic      Flag sets coordinates of roi to GLON, GLAT.
  -fk5, --J2000         Flag sets coordinates of roi to RAJ2000, DECJ2000.
  -u UNIT, --unit UNIT  Units for coordinates of roi using astropy units
                        convention. Default is 'degree'.
  -r RADLIM, --radLim RADLIM
                        Radius, in degrees, from ROI center beyond which all
                        source parameters should be fixed, will default to
                        selection radius. If --obssim flag is set this is used
                        as the radius of the ROI.
  -ER EXTRARAD, --ExtraRad EXTRARAD
                        Radius beyond event file ROI out to which sources will
                        be included in the model with all parameters fixed,
                        default is 10, good for analyses starting around a few
                        hundred MeV, can be decreased for high energy only
                        fits. If --obssim flag is set ExtraRad is added to
                        radLim when including sources.
  -p, --psForce         Flag to cast extended sources as point sources.
                        Default is False.
  -E2C, --E2CAT         Flag to use catalog names for extended sources.
                        Default is False.
  -m, --makeRegion      Flag to create ds9 region file as well as the xml
                        model. Default is False.
  -wd WRITEDIR, --writeDir WRITEDIR
                        Directory in which to write output files. Default is
                        the current directory.
  -ON, --oldNames       Flag to use the make2FGLxml style naming convention,
                        underscore before name and no spaces. Default is False
  -AS, --allsky         Generate model with all sources from the catalog.
                        Overides region of interest parameters.

Likelihood:
  These parameters only affect models intended for use in likelihood
  analysis.

  -N, --normsonly       Flag to only let the normalizations of parameters be
                        free, default is False.
  -R MAXRAD, --maxRad MAXRAD
                        Absolute maximum radius, in degrees, from ROI center
                        beyond which all source parameters should be fixed,
                        even variable sources will not be freed beyond this
                        radius, defaults to radLim value.
  -s SIGFREE, --sigFree SIGFREE
                        Average significance below which all source parameters
                        are fixed, defaults to 5. Note, if using the 3FGL
                        catalog xml file as input, this is actually a cut on
                        TS, so adjust accordingly.
  -GIF, --GIndexFree    Flag to use a power-law modification to the Galactic
                        diffuse model, spectrum and have the index be free.
                        Default is False

Simulation:
  These parameters only affect models intended for use with gtobssim.

  --emin EMIN           Minimum energy for integrated flux.
  --emax EMAX           Maximum energy for integrated flux.
  --isopath ISOPATH     Path to isotropic spatial file (a FITS image
                        containing pixels all set to 1.). Default is $(FERMI_D
                        IR)/refdata/fermi/galdiffuse/isotropic_allsky.fits
  --extSrcRes {force-point,skip,raise}
                        Resolution method for adding an extended source when
                        no extended template is found.
  -am, --apply-mask     Apply a region of interest mask to the diffuse models.
  -gf GALFLUX, --galflux GALFLUX
                        Integrated flux (photons/cm^2/s) to use for galactic
                        diffuse emmision model. Default is 0.00084631675.
  -if ISOFLUX, --isoflux ISOFLUX
                        Integrated flux (photons/cm^2/s) to use for isotropic
                        diffuse emission. Default is 0. (If 0. gtobssim will
                        integrate the spectrum)

The maskfits functionallity is also accessable via the command line by invoking the fermimodel executable with the command maskfits.

fermimodel maskfits -h
usage: fermimodel maskfits [-h] [-o OUTPUT] [-m {radial,square}]
                           [-ih IMAGE_HDU] [-cl] [-fk5 | -icrs | -gal | -pix]
                           [-u UNIT] [-roi C1, C2, RADIUS] [-r RADIUS]
                           [-r2 RADIUS2] [-a ANGLE] [-xc HORIZONTAL_CENTER]
                           [-yc VERTICAL_CENTER] [-xmin HORIZONTAL_MIN]
                           [-xmax HORIZONTAL_MAX] [-ymin VERTICAL_MIN]
                           [-ymax VERTICAL_MAX]
                           input

positional arguments:
  input                 Fits file containing the image to which a mask will be
                        applied.

optional arguments:
  -h, --help            show this help message and exit
  -o OUTPUT, --output OUTPUT
                        Optional filename to save the masked data. Default is
                        masked.fits
  -m {radial,square}, --mask {radial,square}
                        Shape of the mask.
  -ih IMAGE_HDU, --image_hdu IMAGE_HDU
                        HDU containing the image to be masked. If none is
                        input it is assumed to live in the PRIMARY HDU.
  -cl, --clobber        Flag to overwrite a file of the same name. Default is
                        false.
  -fk5, --J2000         Flag sets coordinates of mask center to RAJ2000,
                        DECJ2000
  -icrs, --celestial    Flag sets coordinates of mask center to RA, DEC
  -gal, --galactic      Flag sets coordinates of mask center to GLON, GLAT
  -pix, --pixel         Flag sets coordinates of mask center to PIXEL1, PIXEL2
  -u UNIT, --unit UNIT  Units of mask coordinates. Default is degrees.

radial:
  Parameters for radial mask

  -roi (C1, C2, RADIUS), --Region (C1, C2, RADIUS)
                        Region of Interest
  -r RADIUS, --radius RADIUS
                        Radius of the mask.
  -r2 RADIUS2, --radius2 RADIUS2
                        Second radius of ellipse. Not yet implemented
  -a ANGLE, --angle ANGLE
                        Angle of radius with respect to the horizontal axis.
                        not yet implemented.
  -xc HORIZONTAL_CENTER, --horizontal-center HORIZONTAL_CENTER
                        Horizontal coordinate of mask center.
  -yc VERTICAL_CENTER, --vertical-center VERTICAL_CENTER
                        Vertical coordinate of mask center.

square:
  Parameters for square mask

  -xmin HORIZONTAL_MIN, --horizontal-min HORIZONTAL_MIN
                        Minimum horizontal coordinate value.
  -xmax HORIZONTAL_MAX, --horizontal-max HORIZONTAL_MAX
                        Maximum horizontal coorindate value.
  -ymin VERTICAL_MIN, --vertical-min VERTICAL_MIN
                        Minimum vertical coordinate value.
  -ymax VERTICAL_MAX, --vertical-max VERTICAL_MAX
                        Maximum vertical coordinate value.

Notes

Using the Latest Galactic Diffuse Model for Simulations

The latest galactic diffuse model gll_iem_v07.fits is missing some headers that gtobssim requires. Therefore if one intends to run simulations using this model the FITS file must be edited so that it includes all the necessary headers. This can be accomplished in python with

import astropy.io.fits as pyfits
import datetime

with pyfits.open('gll_iem_v07.fits', mode='update') as gd_model:
    gd_model[0].header['CRPIX3'] = 1.0
    gd_model[0].header['CTYPE3'] = 'Energy'
    gd_model[0].header['CUNIT3'] = 'MeV'
    gd_model[0].header['history'] = 'File updated {0} to include additional headers'.format(datetime.datetime.today().strftime('%m/%d/%Y'))
    gd_model.flush()

This will update the header for the model file. Alternatively one might prefer to save revised model to a different file

import astropy.io.fits as pyfits
import datetime

gd_model = pyfits.open('gll_iem_v07.fits')
gd_model[0].header['CRPIX3'] = 1.0
gd_model[0].header['CTYPE3'] = 'Energy'
gd_model[0].header['CUNIT3'] = 'MeV'
gd_model[0].header['history'] = 'File created {0}'.format(datetime.datetime.today().strftime('%m/%d/%Y'))

gd_model.writeto('gll_iem_v07_updated.fits')

This will create a new file gll_iem_v07_updated.fits that contains the necessary headers for simulations.

Definitions

model

fermimodel.model(name='mymodel', eventsfile=None, catalog=None, out=None, roi=None, frame='fk5', unit='degree', allsky=False, model_type='likelihood')

Model class containing methods and attributes for building models for use with Fermitools

Parameters

name : str (Optional)
Name of the model.
Default is 'mymodel'.
eventsfile : str (Optional)
Path to file containing events data. This is only used for region of interest information.
catalog : str (Optional)
Path to source catalog.
out : str (Optional)
Name of the output model files.
roi : tuple (Optional)
Tuple defining ROI (horizontal center, vertical center, radius).
frame : str (Optional)
Coordinate frame to use for region of interest argument, e.g. galactic, icrs. Any astropy frame is allowed.
Default is 'fk5'.
unit : str (Optional)
Units for region of interest argument. Any astropy unit is allowed.
Default is 'degree'
allsky : bool (Optional)
Flag to set region of interest to the entire sky. By default this sets the region of interest center to the galactic center (l=0, b=0).
Default is False.
model_type : str (Optional)
Model type. Choices are 'simulation' or 'likelihood'. Input parameters are identical for both model types but the output model will vary depending on whether the model will be used by gtlike or gtobssim.
Default is 'likelihood'.

model.setROI

fermimodel.model.setROI(roi=None, frame='fk5', unit='degree', allsky=False)

Set the Region of Interest for the model.

Parameters

roi : tuple
(C1, C2, RADIUS)
frame : string
Coordinate frame for roi center coordinates C1 and C2
unit : str
Units of roi center coordinates, e.g. 'degree'
allsky : bool
Flag to set roi to GLAT = 0, GLON = 0, RADIUS = 180.

Returns

maskFits

fermimodel.maskFits(fitsfile, out='maskedimage.fits', img_hdu=None, mask_type=None, radius=180., radius2=None, angle=0., center=(0., 0.), extent=[-180., 180., -90., 90.], frame='galactic', unit='degree', clobber=False, float_min=1.17549e-38)

Mask the fits image

Parameters

fitsfile : str
Path to the FITS file containing the the image which will be masked.
out : str (Optional)
Name of the output FITS file for which the mask wiil be applied
img_hud : int or float (Optional)
Name or integer for the FITS hdu containing the image.
Default is 'Primary'.
mask_type : str
The geometry of the mask to be applied. Choices are 'radial' or 'square'.
radius : float (Optional)
Radius of the mask if mask_type is radial.
Default is 180.
radius2 : float (Optional)
Second radius of the mask if the mask is not symmetric.
Default is to use a symmetric mask.
angle : float (Optional)
Rotation angle of the ellipse.
Default is 0.
center : tuple (Optional)
Center coordinates (C1, C2) of the radial mask.
Default is (0., 0.).
extent : list (Optional)
[xmin, xmax, ymin, ymax] extent of the square mask.
Default is [-180., 180., -90., 90.].
frame : str (Optional)
Coordinate frame to use with mask coordinates. Choices are 'galactic', 'icrs', 'fk5', 'pixel'.
Default is 'galactic'.
unit : str (Optional)
Units of coordinates.
Default is 'degree'.
clobber : bool
Flag to overwrite a file of the same name if it exists.
Default is False.
float_min : float
Minimum float value to use for pixels in the image after masking. gtobssim doesn't like pixel values <= 0.
Default is 1.17549e-38.

Returns

out : str or tuple
If the input fits image is 2D the output is the full path to the masked fits image. If the input fits image is 3D the output is a tuple whose first entry is the full path to the masked fits image and whose second entry is the integrated flux of the masked fits image.

model.loadCatalog

fermimodel.model.loadCatalog(catalog=None, GDfile=None, GDname='GalacticDiffuse', ISOfile=None, ISOname='IsotropicDiffuse', ISOpath="$(FERMI_DIR)/refdata/fermi/galdiffuse/isotropic_allsky.fits", normsOnly=False, extDir='', radLim=-1, maxRad=None, ExtraRad=10., sigFree=5., varFree=True, psForce=False, E2CAT=False, makeRegion=False, GIndexFree=False, wd=None, oldNames=False, emin=1.e2, emax=5.e5, frame='fk5', extSrcRes='force-point', apply_mask=False, GDflux=0.00084631675, ISOflux=0.)

Include sources in the catalog to the model. Optionaly include a galactic and isotropic diffuse models.

Parameters

catalog : str
Path to source catalog
GDfile : str (Optional)
Path to galactic diffuse emission file
GDname : str (Optional)
Name of galactic diffuse emission model
ISOfile : str (Optional)
Path to isotropic diffuse emission spectrum file
ISOname : str (Optional)
Name of isotropic diffuse emission file
ISOpath : str (Optional)
Path to isotropic diffuse spatial file
normsOnly : bool (Optional)
Flag to only set normalization parameters free
extDir : str (Optional)
Directory with extended source templates
radLim : float (Optional)
Radius in degrees from center of ROI beyond which source parameters are fixed
maxRad : float (Optional)
Absolute maximum radius beyond which sources are fixed. This may be necessary when doing binned analysis and a variable source beyond radLim would be set free but this source is beyond the boundaries of the square region used for the binned likelihood
ExtraRad : float (Optional)
Radius beyond ROI radius out to which sources will be included with fixed parameters. Default of 10 degrees is good for analysis starting around 100 MeV, but for higher energy fits this can be decreased.
sigFree : float (Optional)
Significance below which source parameters are fixed, even if within radLim.
varFree : float (Optional)
Variability index above which source parameters are free. If beyond radLim and/or below sigFree only the normalization parameters is set free. Currently not implemented for building from xml catalog.
psForce : bool (Optional)
Flag to force exentended sources to be point sources
E2CAT : bool (Optional)
Flag to force use of catalog names for extended sources (only matters is using catalog FITS file).
makeRegion : bool (Optional)
Flag to also generate ds9 region file.
GIndexFree : bool (Optional)
The galactic diffuse is given a power-law spectral shape but by default the index is frozen. Setting this flag to True allows that to be free for additional freedom in diffuse fit.
wd : str (Optional)
Path to directory in which output files will be saved. If an absolute path for the output file names is given it will override this argument.
oldNames : bool (Optional)
Sets use of old naming convention. Underscore before name and no spaces. Default is False for likelihood models. This is automatically set to true for simulation models.
emin : float (Optional)
Minimum energy in MeV for source simulation. This should match simulation criteria.
Default is 100 MeV.
emax : float (Optional)
Maximum energy in MeV for source simulation. This should match simulation criteria.
Default is 5.e5 MeV.
GDflux : float (Optional)
Integrated flux to use for the galactic diffuse emission model in photons/cm^2/s.
Default is 0.00084631675.
ISOflux : float (Optional)
Integrated flux to use for the isotropic diffuse emission model in photons/cm^2/s. If 0.0 flux is calculated on the fly by the simulator.
Default is 0.0.

Returns

model.addSource

fermimodel.model.addSource(name, spectrum_type, ra=None, dec=None, glon=None, glat=None, major_axis=None, minor_axis=None, position_angle=None, spatial_function=None, extended_template=None, emin=1.e2, emax=5.e5, frame='galactic', specFile=None, **spectrumargs)

Add a single source to the model.

Parameters

name : str
Name of the source to add.
spectrum_type : str
Spectral type of the source. Options: Monochromatic, PowerLaw, BrokenPowerLaw, LogParabola, PLSuperExpCutoff, MapCube, FileSpectrum
ra : float (Optional)
Right Ascension of source in degrees
dec : float (Optional)
Decilination of source in degrees
glon : float (Optional)
Galactic longitude of source in degrees
glat : float (Optional)
Galactic latitude of source in degrees
major_axis : float (Optional)
The semi-major axis of the error ellipse at 95% confidence, in degrees.
minor_axis : float (Optional)
The semi-minor axis of the error ellipse at 95% confidence, in degrees.
position_angle : float (Optional)
The position angle of the 95%-confidence semi-major axis, from celestial North, positive toward increasing R.A. (eastward), in degrees.
spatial_function : str (Optional)
Spatial function describing source extension. Options: None, SpatialMap, RadialDisk, RadialGauss, Isotropic
extended_template : str (Optional)
Full path to extended template.
emin : float (Optional)
Minimum energy for integrated flux.
Default is 1.e2 MeV
emax : float (Optional)
Maximum energy for integrated flux.
Default is 5.e5 MeV
frame : str (Optional)
Coordinate frame to use for source directions.
specFile : str Optional
Name (and path) to ASCII file containing spectrum. The first column contains the energies, and second column contains the differential flux at those energies. Energy scale should be in MeV.

**spectrumargs

pl_flux_density : float (Optional)
The differential flux at pivot_energy for the PowerLaw fit, in photons/cm2/MeV/s.
lp_flux_density : float (Optional)
The differential flux at pivot_energy for the LogParabola fit, in photons/cm2/MeV/s.
plec_flux_density : float (Optional)
The differential flux at pivot_energy for the PLSuperExpCutoff fit, in photons/cm^2/MeV/s.
pivot_energy : float (Optional)
The energy, in MeV, at which the error in the differential photon flux is minimal (i.e., the decorrelation energy for the power-law fit).
pl_index : float (Optional)
The photon index for the PowerLaw fit.
lp_index : float (Optional)
Photon Index at Pivot Energy for LogParabola fit.
lp_beta : float (Optional)
The curvature parameter (beta) for LogParabola spectrum types.
plec_index : float (Optional)
The low energy photon index for PLSuperExpCutoff fit.
plec_expfactor : float (Optional)
The exponential factor for PLSuperExpCutoff fit.
plec_exp_index : float (Optional)
The exponential index for PLSuperExpCutoff fit.
flux : float (Optional)
Integrated flux in photons/cm^2/s.
Default is to calculate the flux from spectral parameters.

Returns

model.removeSource

fermimodel.model..removeSource(self, *name)

Parameters

name : str
Variable number of source names to remove.

Returns

model.writeXML

fermimodel.model.writeXML(directory=None, out=None)

Write the model to XML.

Parameters

directory : str (Optional)
Path to directory in which the XML file will be saved.
Defaults is the work directory of the model class.
out : str (Optional)
Name of the XML file.
Default is output name of model class.

Returns

filename : str
Full path to output XML file.

model.writeSrcList

fermimodel.model.writeSrcList(directory=None, out=None)

Write source list to file.

Parameters

directory : str (Optional)
Path to directory in which the file will be saved.
Default is the work directory of the model class.
out : str (Optional)
Name of the file
Default is the name of the model.

Returns

filename : str
Full path to output file.

About

Generates source definitions and model files needed for analysis and simulation with the Fermitools.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages