Commit 6e1c8619e68169d9bca5fee76651f20397b0e89e
Merge branch '2305-datapath-before-vhefits' into integration
Showing
6 changed files
with
42 additions
and
31 deletions
cscripts/csfindobs.par
| @@ -16,7 +16,7 @@ | @@ -16,7 +16,7 @@ | ||
| 16 | # | 16 | # |
| 17 | # Input and output parameters | 17 | # Input and output parameters |
| 18 | #============================ | 18 | #============================ |
| 19 | -datapath, s, a, $VHEFITS,,, "Path were data are located" | 19 | +datapath, s, a, NONE,,, "Path were data are located (NONE uses $VHEFITS environment variable)" |
| 20 | prodname, s, a, prod-name,,, "Name of FITS production (Run csiactdata to view your options)" | 20 | prodname, s, a, prod-name,,, "Name of FITS production (Run csiactdata to view your options)" |
| 21 | outfile, f, a, runlist.lis,,, "Output runlist file" | 21 | outfile, f, a, runlist.lis,,, "Output runlist file" |
| 22 | 22 |
cscripts/csfindobs.py
| @@ -2,7 +2,7 @@ | @@ -2,7 +2,7 @@ | ||
| 2 | # ========================================================================== | 2 | # ========================================================================== |
| 3 | # Find observations from an IACT data store | 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 | # This program is free software: you can redistribute it and/or modify | 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 | 8 | # it under the terms of the GNU General Public License as published by |
| @@ -53,32 +53,36 @@ class csfindobs(ctools.cscript): | @@ -53,32 +53,36 @@ class csfindobs(ctools.cscript): | ||
| 53 | 53 | ||
| 54 | # Return | 54 | # Return |
| 55 | return | 55 | return |
| 56 | - | 56 | + |
| 57 | 57 | ||
| 58 | # Private methods | 58 | # Private methods |
| 59 | def _get_parameters(self): | 59 | def _get_parameters(self): |
| 60 | """ | 60 | """ |
| 61 | Get parameters from parfile and setup the observation. | 61 | Get parameters from parfile and setup the observation. |
| 62 | """ | 62 | """ |
| 63 | - # Get parameters | ||
| 64 | - if self._datapath == '': | ||
| 65 | - self._datapath = self['datapath'].string() | ||
| 66 | - | 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 | ||
| 68 | + else: | ||
| 69 | + self._datapath = os.getenv('VHEFITS','') | ||
| 70 | + | ||
| 67 | # Expand environment | 71 | # Expand environment |
| 68 | self._datapath = gammalib.expand_env(self._datapath) | 72 | self._datapath = gammalib.expand_env(self._datapath) |
| 69 | - | 73 | + |
| 70 | # Get production name | 74 | # Get production name |
| 71 | self._prodname = self['prodname'].string() | 75 | self._prodname = self['prodname'].string() |
| 72 | - | 76 | + |
| 73 | # Master index file name | 77 | # Master index file name |
| 74 | master_indx = self['master_indx'].string() | 78 | master_indx = self['master_indx'].string() |
| 75 | - | 79 | + |
| 76 | # Initialise flag if spatial selection is required | 80 | # Initialise flag if spatial selection is required |
| 77 | self._select_radec = True | 81 | self._select_radec = True |
| 78 | - | 82 | + |
| 79 | # Initialise invalid radius | 83 | # Initialise invalid radius |
| 80 | self._radius = 0.0 | 84 | self._radius = 0.0 |
| 81 | - | 85 | + |
| 82 | # Check for validity of spatial parameters | 86 | # Check for validity of spatial parameters |
| 83 | if (self['ra'].is_valid() and | 87 | if (self['ra'].is_valid() and |
| 84 | self['dec'].is_valid() and | 88 | self['dec'].is_valid() and |
cscripts/csiactdata.par
| @@ -16,7 +16,7 @@ | @@ -16,7 +16,7 @@ | ||
| 16 | # | 16 | # |
| 17 | # Input and output parameters | 17 | # Input and output parameters |
| 18 | #============================ | 18 | #============================ |
| 19 | -datapath, s, a, $VHEFITS,,, "Path were data is located" | 19 | +datapath, s, a, NONE,,, "Path were data are located (NONE uses $VHEFITS environment variable)" |
| 20 | master_indx, s, h, master.json,,, "Name of master index file" | 20 | master_indx, s, h, master.json,,, "Name of master index file" |
| 21 | 21 | ||
| 22 | # | 22 | # |
cscripts/csiactdata.py
| @@ -2,7 +2,7 @@ | @@ -2,7 +2,7 @@ | ||
| 2 | # ========================================================================== | 2 | # ========================================================================== |
| 3 | # Inspect an IACT data storage | 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 | # This program is free software: you can redistribute it and/or modify | 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 | 8 | # it under the terms of the GNU General Public License as published by |
| @@ -61,18 +61,21 @@ class csiactdata(ctools.cscript): | @@ -61,18 +61,21 @@ class csiactdata(ctools.cscript): | ||
| 61 | """ | 61 | """ |
| 62 | Get parameters from parfile and setup the observation | 62 | Get parameters from parfile and setup the observation |
| 63 | """ | 63 | """ |
| 64 | - | ||
| 65 | - # Get datapath if not already set | ||
| 66 | - if self._datapath == '': | ||
| 67 | - self._datapath = self['datapath'].string() | ||
| 68 | - | 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 | + else: | ||
| 70 | + self._datapath = os.getenv('VHEFITS','') | ||
| 71 | + | ||
| 69 | # Expand environment | 72 | # Expand environment |
| 70 | self._datapath = gammalib.expand_env(self._datapath) | 73 | self._datapath = gammalib.expand_env(self._datapath) |
| 71 | - | 74 | + |
| 72 | # Get filename of master index file | 75 | # Get filename of master index file |
| 73 | self._master_indx = self['master_indx'].string() | 76 | self._master_indx = self['master_indx'].string() |
| 74 | self._master_file = os.path.join(self._datapath, self._master_indx) | 77 | self._master_file = os.path.join(self._datapath, self._master_indx) |
| 75 | - | 78 | + |
| 76 | # Check for presence of master index file | 79 | # Check for presence of master index file |
| 77 | if not os.path.isfile(self._master_file): | 80 | if not os.path.isfile(self._master_file): |
| 78 | raise RuntimeError('Master index file "'+self._master_file+ | 81 | raise RuntimeError('Master index file "'+self._master_file+ |
cscripts/csiactobs.par
| @@ -16,7 +16,7 @@ | @@ -16,7 +16,7 @@ | ||
| 16 | # | 16 | # |
| 17 | # Input and output parameters | 17 | # Input and output parameters |
| 18 | #============================ | 18 | #============================ |
| 19 | -datapath, s, a, $VHEFITS,,, "Path were data is located" | 19 | +datapath, s, a, NONE,,, "Path were data are located (NONE uses $VHEFITS environment variable)" |
| 20 | prodname, s, a, fits-prod-name,,, "Data storage name" | 20 | prodname, s, a, fits-prod-name,,, "Data storage name" |
| 21 | infile, f, a, runlist.lis,,, "Input runlist file" | 21 | infile, f, a, runlist.lis,,, "Input runlist file" |
| 22 | inmodel, f, h, NONE,,, "Input model definition XML file (optional)" | 22 | inmodel, f, h, NONE,,, "Input model definition XML file (optional)" |
cscripts/csiactobs.py
| @@ -2,7 +2,7 @@ | @@ -2,7 +2,7 @@ | ||
| 2 | # ========================================================================== | 2 | # ========================================================================== |
| 3 | # Generates an IACT observation definition XML file | 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 | # This program is free software: you can redistribute it and/or modify | 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 | 8 | # it under the terms of the GNU General Public License as published by |
| @@ -94,19 +94,23 @@ class csiactobs(ctools.cscript): | @@ -94,19 +94,23 @@ class csiactobs(ctools.cscript): | ||
| 94 | """ | 94 | """ |
| 95 | Get parameters from parfile and setup the observation | 95 | Get parameters from parfile and setup the observation |
| 96 | """ | 96 | """ |
| 97 | - # Set data path | ||
| 98 | - if self._datapath == '': | ||
| 99 | - self._datapath = self['datapath'].string() | ||
| 100 | - | ||
| 101 | - # Query input parameters | ||
| 102 | - self['inmodel'].filename() | 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 | ||
| 102 | + else: | ||
| 103 | + self._datapath = os.getenv('VHEFITS','') | ||
| 103 | 104 | ||
| 104 | # Expand environment | 105 | # Expand environment |
| 105 | self._datapath = gammalib.expand_env(self._datapath) | 106 | self._datapath = gammalib.expand_env(self._datapath) |
| 106 | - | 107 | + |
| 108 | + # Query input parameters | ||
| 109 | + self['inmodel'].filename() | ||
| 110 | + | ||
| 107 | # Read FITS production | 111 | # Read FITS production |
| 108 | self._prodname = self['prodname'].string() | 112 | self._prodname = self['prodname'].string() |
| 109 | - | 113 | + |
| 110 | # Read runlist file if list not already filled | 114 | # Read runlist file if list not already filled |
| 111 | if len(self._runlist) == 0: | 115 | if len(self._runlist) == 0: |
| 112 | 116 |