Commit 00c0acbb422bdaaee045f0f143a146006c3f6e3a

Authored by Jürgen Knödlseder
1 parent 5670f291

Simplify datapath setting

cscripts/csfindobs.par
... ... @@ -16,7 +16,7 @@
16 16 #
17 17 # Input and output parameters
18 18 #============================
19   -datapath, s, q, NONE,,, "Path were data are located"
  19 +datapath, s, a, NONE,,, "Path were data are located (NONE uses $VHEFITS environment variable)"
20 20 prodname, s, a, prod-name,,, "Name of FITS production (Run csiactdata to view your options)"
21 21 outfile, f, a, runlist.lis,,, "Output runlist file"
22 22  
... ...
cscripts/csfindobs.py
... ... @@ -2,7 +2,7 @@
2 2 # ==========================================================================
3 3 # Find observations from an IACT data store
4 4 #
5   -# Copyright (C) 2016-2017 Michael Mayer
  5 +# Copyright (C) 2016-2018 Michael Mayer
6 6 #
7 7 # This program is free software: you can redistribute it and/or modify
8 8 # it under the terms of the GNU General Public License as published by
... ... @@ -53,38 +53,36 @@ class csfindobs(ctools.cscript):
53 53  
54 54 # Return
55 55 return
56   -
  56 +
57 57  
58 58 # Private methods
59 59 def _get_parameters(self):
60 60 """
61 61 Get parameters from parfile and setup the observation.
62 62 """
63   - # Get datapath if not already set
64   - if self['datapath'].current_value() != 'NONE':
65   - # Evaluate earlier user input
66   - self._datapath = self['datapath'].current_value()
  63 + # Query datapath. If the parameter is not NONE then use it, otherwise
  64 + # use the datapath from the VHEFITS environment variable
  65 + datapath = self['datapath'].string()
  66 + if gammalib.toupper(datapath) != 'NONE':
  67 + self._datapath = datapath
67 68 else:
68   - if self._datapath == '':
69   - # Query user. Mode has to be re-set from hidden to query.
70   - self['datapath'].mode( 'q' )
71   - self._datapath = self['datapath'].string()
72   -
  69 + self._datapath = os.getenv('VHEFITS','')
  70 +
73 71 # Expand environment
74 72 self._datapath = gammalib.expand_env(self._datapath)
75   -
  73 +
76 74 # Get production name
77 75 self._prodname = self['prodname'].string()
78   -
  76 +
79 77 # Master index file name
80 78 master_indx = self['master_indx'].string()
81   -
  79 +
82 80 # Initialise flag if spatial selection is required
83 81 self._select_radec = True
84   -
  82 +
85 83 # Initialise invalid radius
86 84 self._radius = 0.0
87   -
  85 +
88 86 # Check for validity of spatial parameters
89 87 if (self['ra'].is_valid() and
90 88 self['dec'].is_valid() and
... ...
cscripts/csiactdata.par
... ... @@ -16,7 +16,7 @@
16 16 #
17 17 # Input and output parameters
18 18 #============================
19   -datapath, s, q, NONE,,, "Path were data is located"
  19 +datapath, s, a, NONE,,, "Path were data are located (NONE uses $VHEFITS environment variable)"
20 20 master_indx, s, h, master.json,,, "Name of master index file"
21 21  
22 22 #
... ...
cscripts/csiactdata.py
... ... @@ -2,7 +2,7 @@
2 2 # ==========================================================================
3 3 # Inspect an IACT data storage
4 4 #
5   -# Copyright (C) 2015-2017 Michael Mayer
  5 +# Copyright (C) 2015-2018 Michael Mayer
6 6 #
7 7 # This program is free software: you can redistribute it and/or modify
8 8 # it under the terms of the GNU General Public License as published by
... ... @@ -61,24 +61,21 @@ class csiactdata(ctools.cscript):
61 61 """
62 62 Get parameters from parfile and setup the observation
63 63 """
64   -
65   - # Set datapath if not already set
66   - if self['datapath'].current_value() != 'NONE':
67   - # Evaluate earlier user input
68   - self._datapath = self['datapath'].current_value()
  64 + # Query datapath. If the parameter is not NONE then use it, otherwise
  65 + # use the datapath from the VHEFITS environment variable
  66 + datapath = self['datapath'].string()
  67 + if gammalib.toupper(datapath) != 'NONE':
  68 + self._datapath = datapath
69 69 else:
70   - if self._datapath == '':
71   - # Query user. Mode has to be re-set from hidden to query.
72   - self['datapath'].mode( 'q' )
73   - self._datapath = self['datapath'].string()
74   -
  70 + self._datapath = os.getenv('VHEFITS','')
  71 +
75 72 # Expand environment
76 73 self._datapath = gammalib.expand_env(self._datapath)
77   -
  74 +
78 75 # Get filename of master index file
79 76 self._master_indx = self['master_indx'].string()
80 77 self._master_file = os.path.join(self._datapath, self._master_indx)
81   -
  78 +
82 79 # Check for presence of master index file
83 80 if not os.path.isfile(self._master_file):
84 81 raise RuntimeError('Master index file "'+self._master_file+
... ...
cscripts/csiactobs.par
... ... @@ -16,7 +16,7 @@
16 16 #
17 17 # Input and output parameters
18 18 #============================
19   -datapath, s, q, NONE,,, "Path were data is located"
  19 +datapath, s, a, NONE,,, "Path were data are located (NONE uses $VHEFITS environment variable)"
20 20 prodname, s, a, fits-prod-name,,, "Data storage name"
21 21 infile, f, a, runlist.lis,,, "Input runlist file"
22 22 inmodel, f, h, NONE,,, "Input model definition XML file (optional)"
... ...
cscripts/csiactobs.py
... ... @@ -2,7 +2,7 @@
2 2 # ==========================================================================
3 3 # Generates an IACT observation definition XML file
4 4 #
5   -# Copyright (C) 2015-2017 Michael Mayer
  5 +# Copyright (C) 2015-2018 Michael Mayer
6 6 #
7 7 # This program is free software: you can redistribute it and/or modify
8 8 # it under the terms of the GNU General Public License as published by
... ... @@ -94,25 +94,23 @@ class csiactobs(ctools.cscript):
94 94 """
95 95 Get parameters from parfile and setup the observation
96 96 """
97   - # Set datapath if not already set
98   - if self['datapath'].current_value() != 'NONE':
99   - # Evaluate earlier user input
100   - self._datapath = self['datapath'].current_value()
  97 + # Query datapath. If the parameter is not NONE then use it, otherwise
  98 + # use the datapath from the VHEFITS environment variable
  99 + datapath = self['datapath'].string()
  100 + if gammalib.toupper(datapath) != 'NONE':
  101 + self._datapath = datapath
101 102 else:
102   - if self._datapath == '':
103   - # Query user. Mode has to be re-set from hidden to query.
104   - self['datapath'].mode( 'q' )
105   - self._datapath = self['datapath'].string()
106   -
107   - # Query input parameters
108   - self['inmodel'].filename()
  103 + self._datapath = os.getenv('VHEFITS','')
109 104  
110 105 # Expand environment
111 106 self._datapath = gammalib.expand_env(self._datapath)
112   -
  107 +
  108 + # Query input parameters
  109 + self['inmodel'].filename()
  110 +
113 111 # Read FITS production
114 112 self._prodname = self['prodname'].string()
115   -
  113 +
116 114 # Read runlist file if list not already filled
117 115 if len(self._runlist) == 0:
118 116  
... ...