def main(argv=None): """Main processing script for all maps """ elog.elog_init(sys.argv) elog.elog_notify("Start of script") verbose, debug, year, month, maptype, deploytype, size = process_command_line(argv) if debug: elog.elog_notify("*** DEBUGGING ON ***") elog.elog_notify("*** No grd or grad files - just single color for speed ***") common_pf = 'common.pf' stations_pf = 'stations.pf' elog.elog_notify(" - Creating **%s** maps" % deploytype) if verbose: elog.elog_notify(" - Parse configuration parameter file (%s)" % common_pf) elog.elog_notify(" - Parse stations parameter file (%s)" % stations_pf) wet_rgb = '202/255/255' pfupdate(common_pf) pfupdate(stations_pf) dbmaster = pfget(common_pf, 'USARRAY_DBMASTER') networks = pfget_arr(stations_pf, 'network') infrasound = pfget_arr(stations_pf, 'infrasound') colors = pfget_arr(stations_pf, 'colors') # Force the tmp dir environmental variable tmp = pfget(common_pf, 'TMP') os.environ['TMPDIR'] = os.environ['TEMP'] = os.environ['TMP'] = tmp gmtbindir = pfget(common_pf, 'GMT_BIN') usa_coords = pfget_arr(common_pf, 'USACOORDS') ak_coords = pfget_arr(common_pf, 'AKCOORDS') web_output_dir = pfget(common_pf, 'CACHE_MONTHLY_DEPLOYMENT') web_output_dir_infra = pfget(common_pf, 'CACHE_MONTHLY_DEPLOYMENT_INFRA') infrasound_mapping = pfget(common_pf, 'INFRASOUND_MAPPING') output_dir = '/var/tmp' # FOR TESTING sys.path.append(gmtbindir) if size == 'wario': paper_orientation = 'landscape' paper_media = 'b0' symsize = '0.3' else: paper_orientation = 'portrait' paper_media = 'a1' symsize = '0.15' # Make sure execution occurs in the right directory cwd = os.getcwd() path_parts = cwd.split('/') if path_parts[-1] == 'deployment_history' and path_parts[-2] == 'bin': if verbose or debug: elog.elog_notify(' - Already in the correct current working directory %s' % cwd) else: cwd = os.getcwd() + '/bin/deployment_history' if verbose or debug: elog.elog_notify (' - Changed current working directory to %s' % cwd) os.chdir(cwd) # Make sure we set some GMT parameters for just this script # GMTSET try: set_gmt_params(paper_orientation, paper_media) except Exception, e: elog.elog_complain("An error occurred setting GMT params %s") raise
for m in maptype: if size == 'wario': ps = tempfile.mkstemp(suffix='.ps', prefix='deployment_history_map_%s_%d_%02d_%s_WARIO_' % (deploytype, year, month, m)) png = 'PNG not created for tiled display wario. Create by hand in Photoshop' else: ps = tempfile.mkstemp(suffix='.ps', prefix='deployment_history_map_%s_%d_%02d_%s_' % (deploytype, year, month, m)) if deploytype == 'inframet': finalfile = 'deploymap_%s_%d_%02d.%s.png' % (deploytype, year, month, m) else: finalfile = 'deploymap_%d_%02d.%s.png' % (year, month, m) png = '%s/%s' % (output_dir, finalfile) if verbose or debug or size: elog.elog_notify (' - Working on maptype: %s' % m) elog.elog_notify (' - Temp postscript file: %s' % ps[1]) elog.elog_notify (' - Output target: %s' % png) # Determine region of interest and center of plot # The lat and lon padding ensures we get full topo and bathy. minlon = int(usa_coords['MINLON']) maxlon = int(usa_coords['MAXLON']) minlat = int(usa_coords['MINLAT']) maxlat = int(usa_coords['MAXLAT']) region = '%s/%s/%s/%s' % (minlon, minlat, maxlon, maxlat) + 'r' centerlat = (maxlat - minlat)/2 + minlat centerlon = (maxlon - minlon)/2 + minlon ak_minlon = int(ak_coords['MINLON']) ak_maxlon = int(ak_coords['MAXLON'])