[minor] update README, add check for output dir existence
This commit is contained in:
parent
c723a32274
commit
04371f92c5
@ -26,10 +26,10 @@ to use the GUI:
|
|||||||
|
|
||||||
Configurations of *datapath*, *networks*, *stations* etc. can be done in the **parameters.yaml** input file.
|
Configurations of *datapath*, *networks*, *stations* etc. can be done in the **parameters.yaml** input file.
|
||||||
|
|
||||||
The main program is executed by entering
|
The main program with html output is executed by entering
|
||||||
|
|
||||||
```shell script
|
```shell script
|
||||||
python survBot.py
|
python survBot.py -html path_for_html_output
|
||||||
```
|
```
|
||||||
|
|
||||||
The GUI can be loaded via
|
The GUI can be loaded via
|
||||||
|
@ -7,8 +7,6 @@ ulimit -s 8192
|
|||||||
#$ -pe smp 1
|
#$ -pe smp 1
|
||||||
#$ -N survBot_bg
|
#$ -N survBot_bg
|
||||||
|
|
||||||
export PYTHONPATH="$PYTHONPATH:/home/marcel/git/code_base/"
|
|
||||||
|
|
||||||
source /opt/anaconda3/etc/profile.d/conda.sh
|
source /opt/anaconda3/etc/profile.d/conda.sh
|
||||||
conda activate py37
|
conda activate py37
|
||||||
|
|
||||||
|
20
survBot.py
20
survBot.py
@ -67,6 +67,7 @@ class SurveillanceBot(object):
|
|||||||
self.data = {}
|
self.data = {}
|
||||||
self.print_count = 0
|
self.print_count = 0
|
||||||
self.status_message = ''
|
self.status_message = ''
|
||||||
|
self.html_fig_dir = 'figures'
|
||||||
|
|
||||||
self.cl = Client(self.parameters.get('datapath')) # TODO: Check if this has to be loaded again on update
|
self.cl = Client(self.parameters.get('datapath')) # TODO: Check if this has to be loaded again on update
|
||||||
self.get_stations()
|
self.get_stations()
|
||||||
@ -260,13 +261,23 @@ class SurveillanceBot(object):
|
|||||||
def get_fig_path_abs(self, st_id):
|
def get_fig_path_abs(self, st_id):
|
||||||
return pjoin(self.outpath_html, self.get_fig_path_rel(st_id))
|
return pjoin(self.outpath_html, self.get_fig_path_rel(st_id))
|
||||||
|
|
||||||
def get_fig_path_rel(self, st_id):
|
def get_fig_path_rel(self, st_id, fig_format='png'):
|
||||||
return os.path.join('figures', f'{st_id.rstrip(".")}.png')
|
return os.path.join(self.html_fig_dir, f'{st_id.rstrip(".")}.{fig_format}')
|
||||||
|
|
||||||
|
def check_fig_dir(self):
|
||||||
|
fdir = pjoin(self.outpath_html, self.html_fig_dir)
|
||||||
|
if not os.path.isdir(fdir):
|
||||||
|
os.mkdir(fdir)
|
||||||
|
|
||||||
|
def check_html_dir(self):
|
||||||
|
if not os.path.isdir(self.outpath_html):
|
||||||
|
os.mkdir(self.outpath_html)
|
||||||
|
|
||||||
def write_html_figures(self, check_plot_time=True):
|
def write_html_figures(self, check_plot_time=True):
|
||||||
""" Write figures for html, right now hardcoded hourly """
|
""" Write figures for html, right now hardcoded hourly """
|
||||||
if check_plot_time and not self.check_plot_hour():
|
if check_plot_time and not self.check_plot_hour():
|
||||||
return
|
return
|
||||||
|
self.check_fig_dir()
|
||||||
|
|
||||||
for st_id in self.station_list:
|
for st_id in self.station_list:
|
||||||
fig = plt.figure(figsize=(16, 9))
|
fig = plt.figure(figsize=(16, 9))
|
||||||
@ -280,6 +291,7 @@ class SurveillanceBot(object):
|
|||||||
plt.close(fig)
|
plt.close(fig)
|
||||||
|
|
||||||
def write_html_table(self, default_color='#e6e6e6'):
|
def write_html_table(self, default_color='#e6e6e6'):
|
||||||
|
self.check_html_dir()
|
||||||
fnout = pjoin(self.outpath_html, 'survBot_out.html')
|
fnout = pjoin(self.outpath_html, 'survBot_out.html')
|
||||||
if not fnout:
|
if not fnout:
|
||||||
return
|
return
|
||||||
@ -675,8 +687,8 @@ class StationQC(object):
|
|||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
parser = argparse.ArgumentParser(description='Call survBot')
|
parser = argparse.ArgumentParser(description='Call survBot')
|
||||||
parser.add_argument('-html', dest='html_filename', default=None, help='filename for HTML output')
|
parser.add_argument('-html', dest='html_path', default=None, help='filepath for HTML output')
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
survBot = SurveillanceBot(parameter_path='parameters.yaml', outpath_html=args.html_filename)
|
survBot = SurveillanceBot(parameter_path='parameters.yaml', outpath_html=args.html_path)
|
||||||
survBot.start()
|
survBot.start()
|
||||||
|
Loading…
Reference in New Issue
Block a user