Skip to content

Commit

Permalink
Add hidden drwmethod parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
jknodlseder committed Mar 26, 2023
1 parent 434bace commit b3076b3
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 12 deletions.
3 changes: 2 additions & 1 deletion modules/comscripts/comobsbin.par
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 49,8 @@ psdmin, i, h, 0,0,110, "Minimum PSD value"
psdmax, i, h, 110,0,110, "Maximum PSD value"
zetamin, r, h, 5.0,0.0,10.0, "Minimum Earth horizon - Phibar (zeta) angle (deg)"
fpmtflag, i, h, 0,0,2, "Handling of D2 modules with failed PMT flag (0: exclude, 1: include, 2: exclude PMT)"
timebin, r, h, 300.0,,, "Internal time bin for DRW computation (sec)"
drwmethod, s, h, PHIBAR,PHIBAR|VETORATE,, "DRW computation method"
timebin, r, h, 300.0,,, "Internal time bin for DRW PHIBAR computation (sec)"
d1use, s, h, 1111111,,, "D1 module usage (1: use, 0: don't use)"
d2use, s, h, 11111111111111,,, "D2 module usage (1: use, 0: don't use)"

Expand Down
33 changes: 22 additions & 11 deletions modules/comscripts/comobsbin.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 86,7 @@ def _get_parameters(self):
self['psdmax'].integer()
self['zetamin'].real()
self['fpmtflag'].integer()
self['drwmethod'].string()
self['timebin'].real()

# Get D1 and D2 module usage strings
Expand Down Expand Up @@ -217,6 218,7 @@ def _set_selection_set(self):
phases = self['phase'].string()
self._dre_suffix = suffix phases.replace(';', '_')
self._drg_suffix = suffix
self._drw_suffix = suffix
self._drx_suffix = suffix

# ... otherwise handle orbital phase selection
Expand Down Expand Up @@ -245,6 247,7 @@ def _set_selection_set(self):
phases = self['phase'].string()
self._dre_suffix = suffix phases.replace(';', '_')
self._drg_suffix = suffix phases.replace(';', '_')
self._drw_suffix = suffix phases.replace(';', '_')
self._drx_suffix = suffix phases.replace(';', '_')

# If PSD interval differs from standard interval then set the interval
Expand All @@ -260,10 263,11 @@ def _set_selection_set(self):
self['psdmax'].integer())

# If zeta angle differs from standard value then append zeta angle to DRE
# and DRG suffix
# DRG and DRW suffix
if self['zetamin'].real() != 5.0:
self._dre_suffix = '_zeta%.1f' % (self['zetamin'].real())
self._drg_suffix = '_zeta%.1f' % (self['zetamin'].real())
self._drw_suffix = '_zeta%.1f' % (self['zetamin'].real())

# If handling of D2 modules with failed PMT flag differs from standard then
# set the flag and append flag to suffix
Expand All @@ -272,9 276,10 @@ def _set_selection_set(self):
# Set handling of D2 modules with failed PMT flag
self._select.fpmtflag(self['fpmtflag'].integer())

# Set DRE and DRG suffix
# Set DRE, DRG and DRW suffix
self._dre_suffix = '_fpmt' % (self['fpmtflag'].integer())
self._drg_suffix = '_fpmt' % (self['fpmtflag'].integer())
self._drw_suffix = '_fpmt' % (self['fpmtflag'].integer())

# If D1 module usage differs from standard value then set module usage
# and append usage to DRE and DRG suffix
Expand All @@ -288,9 293,10 @@ def _set_selection_set(self):
else:
self._select.use_d1(i,False)

# Set DRE and DRG suffix
# Set DRE, DRG and DRW suffix
self._dre_suffix = '_%s' % (d1use)
self._drg_suffix = '_%s' % (d1use)
self._drw_suffix = '_%s' % (d1use)

# If D2 module usage differs from standard value then set module usage
# and append usage to DRE and DRG suffix
Expand All @@ -304,9 310,10 @@ def _set_selection_set(self):
else:
self._select.use_d2(i,False)

# Set DRE and DRG suffix
# Set DRE, DRG and DRW suffix
self._dre_suffix = '_%s' % (d2use)
self._drg_suffix = '_%s' % (d2use)
self._drw_suffix = '_%s' % (d2use)

# Log selection set
self._log_string(gammalib.NORMAL, str(self._select))
Expand Down Expand Up @@ -496,19 503,22 @@ def _generate_dri(self, obs, ebounds):
drwnames = []
engindex = []

# Get DRW method in lower case
drwmethod = gammalib.tolower(self['drwmethod'].string())

# Generate one DRW for each energy boundary
for i in range(ebounds.size()):

# Set DRW filename in output folder
drwname = '%s/%s%s_drw%s_%6.6d-%6.6dkeV.fits' % \
(self['outfolder'].string(), obs.id(), dri_prefix, self._drw_suffix,
ebounds.emin(i).keV(), ebounds.emax(i).keV())
drwname = '%s/%s%s_drw-%s%s_%6.6d-%6.6dkeV.fits' % \
(self['outfolder'].string(), obs.id(), dri_prefix, drwmethod,
self._drw_suffix, ebounds.emin(i).keV(), ebounds.emax(i).keV())
drwfile = gammalib.GFilename(drwname)

# Set DRW filename in global data store
drwname_global = '%s/%s%s_drw%s_%6.6d-%6.6dkeV.fits' % \
(self._global_datastore, obs.id(), dri_prefix, self._drw_suffix,
ebounds.emin(i).keV(), ebounds.emax(i).keV())
drwname_global = '%s/%s%s_drw-%s%s_%6.6d-%6.6dkeV.fits' % \
(self._global_datastore, obs.id(), dri_prefix, drwmethod,
self._drw_suffix, ebounds.emin(i).keV(), ebounds.emax(i).keV())
drwfile_global = gammalib.GFilename(drwname_global)

# Write header
Expand Down Expand Up @@ -553,7 563,8 @@ def _generate_dri(self, obs, ebounds):

# Compute DRWs
drws.compute_drws(obs, self._select, self['zetamin'].real(),
self['timebin'].real())
self['timebin'].real(),
drwmethod)

# Phibar normalise DRWs to DREs
for i in range(drws.size()):
Expand Down

0 comments on commit b3076b3

Please sign in to comment.