ctools
2.1.0.dev
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Macros
Pages
cscript_base.py
Go to the documentation of this file.
1
#! /usr/bin/env python
2
# ==========================================================================
3
# [WHAT] script
4
#
5
# Copyright (C) [YEAR] [AUTHOR]
6
#
7
# This program is free software: you can redistribute it and/or modify
8
# it under the terms of the GNU General Public License as published by
9
# the Free Software Foundation, either version 3 of the License, or
10
# (at your option) any later version.
11
#
12
# This program is distributed in the hope that it will be useful,
13
# but WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU General Public License for more details.
16
#
17
# You should have received a copy of the GNU General Public License
18
# along with this program. If not, see <http://www.gnu.org/licenses/>.
19
#
20
# ==========================================================================
21
import
sys
22
import
gammalib
23
import
ctools
24
25
26
# ================== #
27
# cscript_base class #
28
# ================== #
29
class
cscript_base
(ctools.cscript):
30
"""
31
[WHAT] script
32
"""
33
34
# Constructor
35
def
__init__
(self, *argv):
36
"""
37
Constructor
38
39
Parameters
40
----------
41
argv : list of str
42
List of IRAF command line parameter strings of the form
43
``parameter=3``.
44
"""
45
# Initialise application by calling the base class constructor
46
self._init_cscript(self.__class__.__name__, ctools.__version__, argv)
47
48
# Return
49
return
50
51
# State methods for pickling
52
def
__getstate__
(self):
53
"""
54
Extend ctools.cscript __getstate__ method
55
56
Returns
57
-------
58
state : dict
59
Pickled instance
60
"""
61
# Set pickled dictionary
62
state = {
'base'
: ctools.cscript.__getstate__(self)}
63
64
# Return pickled dictionary
65
return
state
66
67
def
__setstate__
(self, state):
68
"""
69
Extend ctools.cscript __setstate__ method
70
71
Parameters
72
----------
73
state : dict
74
Pickled instance
75
"""
76
# Set state
77
ctools.cscript.__setstate__(self, state[
'base'
])
78
79
# Return
80
return
81
82
83
# Private methods
84
def
_get_parameters
(self):
85
"""
86
Get parameters from parfile
87
"""
88
# TODO: Add code to query all relevant parameters
89
90
# Write input parameters into logger
91
self.
_log_parameters
(gammalib.TERSE)
92
93
# Return
94
return
95
96
97
# Public methods
98
def
process
(self):
99
"""
100
Process the script
101
"""
102
# Get parameters
103
self.
_get_parameters
()
104
105
# TODO: Your code goes here
106
107
# Return
108
return
109
110
def
save
(self):
111
"""
112
Save something
113
"""
114
# Write header
115
self._log_header1(gammalib.TERSE,
'Save something'
)
116
117
# TODO: Your code goes here
118
119
# Return
120
return
121
122
123
# ======================== #
124
# Main routine entry point #
125
# ======================== #
126
if
__name__ ==
'__main__'
:
127
128
# Create instance of application
129
app =
cscript_base
(sys.argv)
130
131
# Execute application
132
app.execute()
cscript_base.cscript_base
Definition:
cscript_base.py:29
cscript_base.cscript_base.save
def save
Definition:
cscript_base.py:110
cscript_base.cscript_base._get_parameters
def _get_parameters
Definition:
cscript_base.py:84
cscript_base.cscript_base.__init__
def __init__
Definition:
cscript_base.py:35
cscript_base.cscript_base.__setstate__
def __setstate__
Definition:
cscript_base.py:67
cscript_base.cscript_base.process
def process
Definition:
cscript_base.py:98
ctools.tools.ctool._log_parameters
def _log_parameters
Definition:
tools.py:1008
cscript_base.cscript_base.__getstate__
def __getstate__
Definition:
cscript_base.py:52
src
template
cscript_base.py
Generated on Tue Jan 14 2025 13:54:27 for ctools by
1.8.5