Commit 63fe865c4154cd4b3d682209fd1aa1b5648388e7

Authored by Jürgen Knödlseder
1 parent 80854348

Correct bad indentation in obsutils

Showing 1 changed file with 72 additions and 72 deletions
cscripts/obsutils.py
... ... @@ -690,78 +690,78 @@ def set_obs_patterns(pattern, ra=83.6331, dec=22.0145, offset=1.5):
690 690 # Set model for TS fitting #
691 691 # ======================== #
692 692 def set_ts_model(models, srcname, ra=None, dec=None, fitspat=False, fitspec=False):
693   - """
694   - Set model for TS fitting
695   -
696   - Parameters
697   - ----------
698   - models : `~gammalib.GModels`
699   - Input model container
700   - srcname : str
701   - Test source name
702   - ra : float, optional
703   - Right Ascension of test source (deg)
704   - dec : float, optional
705   - Declination of test source (deg)
706   - fitspat : bool, optional
707   - Fit spatial parameter?
708   - fitspec : bool, optional
709   - Fit spectral parameters?
710   -
711   - Returns
712   - -------
713   - model : `~gammalib.GModels`
714   - Model container for TS fitting
715   - """
716   - # Create a clone of the input model
717   - outmodels = models.copy()
718   -
719   - # Disable TS computation for all model components (will enable the
720   - # test source later)
721   - for model in outmodels:
722   - model.tscalc(False)
723   -
724   - # Get source model and enable TS computation
725   - model = outmodels[srcname]
726   - model.tscalc(True)
727   -
728   - # If source model has no "Prefactor" parameter then raise an exception
729   - if not model.has_par('Prefactor'):
730   - msg = ('Model "%s" has no parameter "Prefactor". Only spectral '
731   - 'models with a "Prefactor" parameter are supported.' %
732   - srcname)
733   - raise RuntimeError(msg)
734   -
735   - # Set position of test source
736   - if ra != None and dec != None:
737   - if model.has_par('RA') and model.has_par('DEC'):
738   - model['RA'].value(ra)
739   - model['DEC'].value(dec)
740   -
741   - # Set possible spatial and spectral parameters
742   - spatial = ['RA', 'DEC', 'Sigma', 'Radius', 'Width', 'PA',
743   - 'MinorRadius', 'MajorRadius']
744   - spectral = ['Index', 'Index1', 'Index2', 'BreakEnergy', 'CutoffEnergy',
745   - 'InverseCutoffEnergy']
746   -
747   - # Fit or fix spatial parameters
748   - for par in spatial:
749   - if model.has_par(par):
750   - if fitspat:
751   - model[par].free()
752   - else:
753   - model[par].fix()
754   -
755   - # Fit or fix spectral parameters
756   - for par in spectral:
757   - if model.has_par(par):
758   - if fitspec:
759   - model[par].free()
760   - else:
761   - model[par].fix()
762   -
763   - # Return model container
764   - return outmodels
  693 + """
  694 + Set model for TS fitting
  695 +
  696 + Parameters
  697 + ----------
  698 + models : `~gammalib.GModels`
  699 + Input model container
  700 + srcname : str
  701 + Test source name
  702 + ra : float, optional
  703 + Right Ascension of test source (deg)
  704 + dec : float, optional
  705 + Declination of test source (deg)
  706 + fitspat : bool, optional
  707 + Fit spatial parameter?
  708 + fitspec : bool, optional
  709 + Fit spectral parameters?
  710 +
  711 + Returns
  712 + -------
  713 + model : `~gammalib.GModels`
  714 + Model container for TS fitting
  715 + """
  716 + # Create a clone of the input model
  717 + outmodels = models.copy()
  718 +
  719 + # Disable TS computation for all model components (will enable the
  720 + # test source later)
  721 + for model in outmodels:
  722 + model.tscalc(False)
  723 +
  724 + # Get source model and enable TS computation
  725 + model = outmodels[srcname]
  726 + model.tscalc(True)
  727 +
  728 + # If source model has no "Prefactor" parameter then raise an exception
  729 + if not model.has_par('Prefactor'):
  730 + msg = ('Model "%s" has no parameter "Prefactor". Only spectral '
  731 + 'models with a "Prefactor" parameter are supported.' %
  732 + srcname)
  733 + raise RuntimeError(msg)
  734 +
  735 + # Set position of test source
  736 + if ra != None and dec != None:
  737 + if model.has_par('RA') and model.has_par('DEC'):
  738 + model['RA'].value(ra)
  739 + model['DEC'].value(dec)
  740 +
  741 + # Set possible spatial and spectral parameters
  742 + spatial = ['RA', 'DEC', 'Sigma', 'Radius', 'Width', 'PA',
  743 + 'MinorRadius', 'MajorRadius']
  744 + spectral = ['Index', 'Index1', 'Index2', 'BreakEnergy', 'CutoffEnergy',
  745 + 'InverseCutoffEnergy']
  746 +
  747 + # Fit or fix spatial parameters
  748 + for par in spatial:
  749 + if model.has_par(par):
  750 + if fitspat:
  751 + model[par].free()
  752 + else:
  753 + model[par].fix()
  754 +
  755 + # Fit or fix spectral parameters
  756 + for par in spectral:
  757 + if model.has_par(par):
  758 + if fitspec:
  759 + model[par].free()
  760 + else:
  761 + model[par].fix()
  762 +
  763 + # Return model container
  764 + return outmodels
765 765  
766 766  
767 767 # ==================== #
... ...