;Color bar added. 4/24/2008 Hyomin Kim ;Modified to incorporate UNH web service. 4/24/2008 Hyomin Kim ;A code to generate survey plots from the UNH ULF data which are saved in MUD format. 4/13/2007 Hyojin Kim ; ;Modified: ;May 30, 2018 MWC now use ulf_tick_labels to make labels for X axis ;Jul 19, 2019 MWC commented out application of digital filter and ; added plot_stamp ;example: ulf_make_plot, database_dir, '20161031', '000000', '240000', plot_dir, 'ps', 'NAL' pro raw_mud_plot, $ database_dir, $ date, $ start_time, $ end_time, $ plot_dir, $ file_format, $ station_in ;;====== The followings will be located in batchprocess.pro database_dir = '/mirl/ULF/Database_new' database_dir_old = '/mirl/ULF/Database' plot_dir = '/mirl/ULF/raw_plot/' + station_in max_B_field = 0.2 ;nT/sec ;====== Create station names for file name if station_in eq 'NAL' then begin station_code_one_letter = 'N' endif if station_in eq 'LYR' then begin station_code_one_letter = 'L' endif if station_in eq 'HOR' then begin station_code_one_letter = 'H' endif if station_in eq 'SDY' then begin station_code_one_letter = 'S' endif if station_in eq 'POK' then begin station_code_one_letter = 'P' endif if station_in eq 'IQA' then begin station_code_one_letter = 'I' endif if station_in eq 'ISR' then begin station_code_one_letter = 'R' endif if station_in eq 'GAK' then begin station_code_one_letter = 'G' endif if station_in eq 'SNK' then begin station_code_one_letter = 'Y' endif if station_in eq 'MNE' then begin station_code_one_letter = 'Z' endif ;====== Extracting the date and time yyyy = strmid(date, 0, 4) mm = strmid(date, 4, 2) dd = strmid(date, 6, 2) start_hour = strmid(start_time, 0, 2) start_min = strmid(start_time, 2, 2) start_second = strmid(start_time, 4, 2) end_hour = strmid(end_time, 0, 2) end_min = strmid(end_time, 2, 2) end_second = strmid(end_time, 4, 2) spm = 60.0 mph = 60.0 hpd = 24.0 sph = 3600.0 start_time_sec = start_hour*sph+start_min*mph+start_second ;start time in seconds end_time_sec = end_hour*sph+end_min*mph+end_second ;end time in seconds duration_sec = end_time_sec - start_time_sec duration = duration_sec/sph ;in decimal hour. ;====== Set up X axis (time scale) ulf_tick_labels, double(start_time_sec), double(end_time_sec), xtick_count, tick_values, xtick_labels ;====== Specify MUD sources database_path = database_dir + '/' + station_in + '_' + $ strtrim(string(yyyy), 1) + '_' + $ strtrim(string(mm), 1) + '.newMUD' database_path_old = database_dir_old + '/' + station_in + '_' + $ strtrim(string(yyyy), 1) + '_' + $ strtrim(string(mm), 1) + '.MUD' ;====== Initialize data variables sample_rate = 10. ;Hz period = 1./sample_rate ;sec datacount = long(duration * sph * sample_rate);double(float(duration * sph * sample_rate)) times = findgen(datacount) * period/sph ;====== Read in data (stored in database) from the stations selected to be plotted plot_array_Bx = dblarr(datacount) plot_array_By = dblarr(datacount) fromSecond = (long(dd) - 1) * 86400 + (long(start_hour)*3600) + (long(start_min)*60) + start_second toSecond = long(fromSecond) + long(duration_sec) file_array = ulf_read_mud_new(database_path, fromSecond, toSecond, sample_rate) ;file_array_old = readmud(database_path, fromSecond, toSecond, sample_rate) stop ;====== Specify graphic format if file_format eq 'x' then begin graphic_type = '.jpg' set_plot,'X' endif else begin graphic_type = '.ps' set_plot,'PS' endelse ;====== Specify directory and filename where plots will be saved file_subdir_plot = file_subdir_plot file_name_plot = date + '_' + start_time + '_' + end_time +'_' + $ station_code_one_letter + graphic_type file_path_plot = plot_dir + '/' + file_name_plot file_path_base = plot_dir + '/' + $ date + '_' + start_time + '_' + end_time +'_' + $ station_code_one_letter ;====== Setup graphic device and plot loadct, 39 !p.background=255 !p.color=0 if !d.name eq 'PS' then begin device, filename=file_path_plot, bits=8, /color, /inches, $ xoffset=0., yoffset=0., xsize=11, ysize=8.5 print, 'Device:', !d.name endif if !d.name eq 'X' then begin device, true = 24, decomposed = 0, retain = 2 window, 0, retain=2, xsize=640, ysize=828, title=title print, 'Device:', !d.name endif ;====== Plot time-series (Bx) plot, times, file_array, $ xstyle=1, xticklen=-0.05, xcharsize=charsize1, $ xticks=xtick_count, xminor=xminor_count, xtickname=xtick_labels, $ ystyle=1, yticklen=-0.01, ycharsize=charsize1, $ yrange=[-max_B_field, max_B_field], $ ytitle = station_in + ' V' x_title = 'IQA 20191206' xyouts, 0.45, 0.95, x_title, /normal, alignment=0.5, charsize=charsize2 plot_stamp ;========================================================================== ; Reset graphic device print, file_path_base if !d.name eq 'PS' then begin device, /close cmd_str = '/usr/bin/convert ' + file_path_base + '.ps '+ file_path_base + '.jpg' spawn, cmd_str endif end