diff --git a/atdb_statistics/atdb_plot.py b/atdb_statistics/atdb_plot.py index 63fd461806fbfbfffd991972cf6b59cbbccf0afb..002681f3fa57f389e0d9b741848ba071bcf31664 100644 --- a/atdb_statistics/atdb_plot.py +++ b/atdb_statistics/atdb_plot.py @@ -5,6 +5,7 @@ Description: atdb plot module """ +import os import datetime import plotly import plotly.graph_objs as go @@ -543,4 +544,39 @@ def do_time_used_science_pie_plot(title, subtitle, data): plt.grid(True,alpha=0.3) plt.legend(loc='upper right') - plt.show() \ No newline at end of file + plt.show() + + +def fits_to_png_apercal(input_file_name,output_file_name): + import matplotlib.pyplot as plt + from astropy.wcs import WCS + from astropy.io import fits + import matplotlib.colors as mc + output = output_file_name + fits_file = input_file_name + # open continuum image + fits_hdulist = fits.open(fits_file) + # get WCS header of cube + wcs = WCS(fits_hdulist[0].header) + # remove unnecessary axis + if wcs.naxis == 4: + wcs = wcs.dropaxis(3) + wcs = wcs.dropaxis(2) + img = fits_hdulist[0].data[0][0] + elif wcs.naxis == 3: + wcs = wcs.dropaxis(2) + img = fits_hdulist[0].data[0] + else: + img = fits_hdulist[0].data + # set up plot + ax = plt.subplot(projection=wcs) + # add image using sym-log scaling + fig = ax.imshow(img * 1.e3, norm=mc.SymLogNorm(1.e-9, vmin=0.03, vmax=200), origin='lower') + # add colorbar + cbar = plt.colorbar(fig) + cbar.set_label('Flux Density [mJy/beam]') + ax.coords[0].set_axislabel('Right Ascension') + ax.coords[1].set_axislabel('Declination') + ax.coords[0].set_major_formatter('hh:mm') + ax.set_title("{0:s}".format(os.path.basename(fits_file))) + plt.savefig(output, overwrite=True, bbox_inches='tight', dpi=300) \ No newline at end of file diff --git a/atdb_stats.py b/atdb_stats.py index 79d8cd6684fa9ef486a37ba877ae8178af358907..a5439f9dd688617eed4a274ace646907a6f9da21 100644 --- a/atdb_stats.py +++ b/atdb_stats.py @@ -310,8 +310,9 @@ def do_times(args): if result['ingest_speed'] is not None and result['ingest_speed'] > 0: datapoint = {} datapoint['taskid'] = result['taskID'] - nofrag,frag = result['timestamp_ingesting'].split('.') - timestamp = datetime.datetime.strptime(nofrag, '%Y-%m-%dT%H:%M:%S') + # nofrag,frag = result['timestamp_ingesting'].split('.') + # timestamp = datetime.datetime.strptime(nofrag, '%Y-%m-%dT%H:%M:%S') + timestamp = datetime.datetime.strptime(result['timestamp_ingesting'], '%Y-%m-%dT%H:%M:%SZ') datapoint['timestamp'] = timestamp datapoint['type'] = 'ingesting' datapoint['duration'] = result['ingest_duration'] @@ -325,8 +326,9 @@ def do_times(args): if result['timestamp_ingest_error'] is not None: datapoint = {} datapoint['taskid'] = result['taskID'] - nofrag,frag = result['timestamp_ingest_error'].split('.') - timestamp = datetime.datetime.strptime(nofrag, '%Y-%m-%dT%H:%M:%S') + # nofrag,frag = result['timestamp_ingest_error'].split('.') + # timestamp = datetime.datetime.strptime(nofrag, '%Y-%m-%dT%H:%M:%S') + timestamp = datetime.datetime.strptime(result['timestamp_ingest_error'], '%Y-%m-%dT%H:%M:%SZ') datapoint['timestamp'] = timestamp datapoint['type'] = 'ingest_error' datapoint['speed_bps'] = prev_ingest_speed @@ -515,6 +517,12 @@ def main(): parser.add_argument("--interval", default="day", help="Shows bars per interval. Possible options: minute, hour, day, month") + parser.add_argument("--input_filename","-i", + default="", + help="input filename") + parser.add_argument("--output_filename","-o", + default="", + help="output filename") # plot parameters parser.add_argument("--title", default="Title", @@ -534,6 +542,12 @@ def main(): parser.add_argument("--colormap", default="viridis", help="see: https://matplotlib.org/examples/color/colormaps_reference.html") + + # commands + parser.add_argument("--fits2png", + default=False, + help="convert FITS to PNG.", + action="store_true") # All parameters in a file parser.add_argument('--argfile', nargs='?', @@ -544,15 +558,16 @@ def main(): help="Show current version of this program.", action="store_true") + args = get_arguments(parser) # -------------------------------------------------------------------------------------------------------- if (args.version): - print('--- atdb_stats.py - version 1.0.0 - 9 jun 2019 ---') + print('--- atdb_stats.py - version 1.1.0 - 25 nov 2019 ---') print('Copyright (C) 2019 - Nico Vermaas - ASTRON. This program comes with ABSOLUTELY NO WARRANTY;') return - print('--- atdb_stats.py - version 1.0.0 - 9 jun 2019 ---') + print('--- atdb_stats.py - version 1.1.0 - 25 nov 2019 ---') print('Copyright (C) 2019 - Nico Vermaas - ASTRON. This program comes with ABSOLUTELY NO WARRANTY;') if args.starttime != None: starttime = datetime.datetime.strptime(args.starttime, TIME_FORMAT) @@ -604,6 +619,9 @@ def main(): elif presentation=="time_used": do_time_used(args) + elif args.fits2png: + atdb_plot.fits_to_png_apercal(args.input_filename,args.output_filename) + if args.remote_post_command != None: execute_remote_command(args.atdb_host, args.remote_post_command) diff --git a/data/fits_to_png.args b/data/fits_to_png.args new file mode 100644 index 0000000000000000000000000000000000000000..8a56bf5a777f5e2f23377ff156592f3393dd2b3a --- /dev/null +++ b/data/fits_to_png.args @@ -0,0 +1,3 @@ +--fits2png +--input_file=D:\my_happili\image_mf_04.fits +--output_file=D:\my_happili\image_mf_04.png diff --git a/data/sky.args b/data/sky.args index f5437f2d862db93d36b17f66c17dee0d83c3d8ec..54d4042836db3dec1a44edd3b603689f0050c401 100644 --- a/data/sky.args +++ b/data/sky.args @@ -7,4 +7,4 @@ --plot_type=scatter --colormap=viridis --starttime=2018-01-01 00:00 ---endtime=2019-06-17 00:00 +--endtime=2019-11-12 00:00 diff --git a/data/time_used_science_pie_aug2019_prod.args b/data/time_used_science_pie_aug2019_prod.args new file mode 100644 index 0000000000000000000000000000000000000000..8dae508bb6530522174c7ca5cfbed6c33d8d266e --- /dev/null +++ b/data/time_used_science_pie_aug2019_prod.args @@ -0,0 +1,4 @@ +--presentation=time_used +--atdb_host=http://192.168.22.22/atdb +--title=APERTIF Science Pie - Aug 2019 +--query=from=2019-08-01T00:01:00Z&to=2019-09-01T00:00:00Z&report_type=time_used_science_pie \ No newline at end of file diff --git a/data/time_used_science_pie_aug2019_vm.args b/data/time_used_science_pie_aug2019_vm.args new file mode 100644 index 0000000000000000000000000000000000000000..8dae508bb6530522174c7ca5cfbed6c33d8d266e --- /dev/null +++ b/data/time_used_science_pie_aug2019_vm.args @@ -0,0 +1,4 @@ +--presentation=time_used +--atdb_host=http://192.168.22.22/atdb +--title=APERTIF Science Pie - Aug 2019 +--query=from=2019-08-01T00:01:00Z&to=2019-09-01T00:00:00Z&report_type=time_used_science_pie \ No newline at end of file diff --git a/data/time_used_system_pie_aug2019_prod.args b/data/time_used_system_pie_aug2019_prod.args new file mode 100644 index 0000000000000000000000000000000000000000..230a8f11c38ea91291884eaf8a55be400da91cba --- /dev/null +++ b/data/time_used_system_pie_aug2019_prod.args @@ -0,0 +1,4 @@ +--presentation=time_used +--atdb_host=http://atdb.astron.nl/atdb +--title=APERTIF System Pie - Aug 2019 +--query=from=2019-08-01T00:01:00Z&to=2019-09-01T00:00:00Z&report_type=time_used_system_pie \ No newline at end of file diff --git a/data/time_used_system_pie_jul2019_prod.args b/data/time_used_system_pie_jul2019_prod.args new file mode 100644 index 0000000000000000000000000000000000000000..473a22490bb0443f2429d5002ea54773a05d6710 --- /dev/null +++ b/data/time_used_system_pie_jul2019_prod.args @@ -0,0 +1,4 @@ +--presentation=time_used +--atdb_host=http://atdb.astron.nl/atdb +--title=APERTIF System Pie - Aug 2019 +--query=from=2019-08-01T00:01:00Z&to=2019-08-31T00:08:00Z&report_type=time_used_system_pie \ No newline at end of file diff --git a/data/times_today_prod.args b/data/times_today_prod.args index 7d2dc725578a7b0b81e750a646c281b771ac2335..4bc4a3a3e4b9ff0eaef80411534c095cfb3465f7 100644 --- a/data/times_today_prod.args +++ b/data/times_today_prod.args @@ -1,6 +1,6 @@ --presentation=times --atdb_host=http://atdb.astron.nl/atdb --title=I/O speeds from ATDB ---subtitle=18 - 23 july 2019 +--subtitle=29/30 aug 2019 --y_axis_title=I/O Speed in Gbps ---query=starttime__gt=2019-07-18T00:00:00Z&starttime__lt=2019-07-23T00:00:00Z +--query=starttime__gt=2019-08-29T00:00:00Z&starttime__lt=2019-09-02T00:00:00Z diff --git a/dist/atdb_plot-1.0.0.tar.gz b/dist/atdb_plot-1.0.0.tar.gz index f295e205a10fd66827184cf2702917da251893c5..2ee7381f7c37a53cb77e46153e9d6b7361e6bbca 100644 Binary files a/dist/atdb_plot-1.0.0.tar.gz and b/dist/atdb_plot-1.0.0.tar.gz differ