def plot_diagnostics(config, trans): """ Plot volume and heat transport diagnostics against MOVE observations """ # Initialize data name='simulated' outdir='./' date_format='%Y%m%d', lw=4 # Initialize observations obs_trans_f, obs_vel_f = None, None # Get observation file paths time_avg = utils.get_config_opt(config, 'observations', 'time_avg') obs_trans_f = utils.get_config_opt(config, 'observations', 'volume_transports') # Load observations, if specified if obs_trans_f is not None: obs_trans = observations.TransportObs(obs_trans_f, time_avg=time_avg) # Call plot routines outdir = config.get('output', 'outdir') date_format = config.get('output', 'date_format') name = config.get('output', 'name') # Create basename for output files dts = utils.get_ncdates(config, trans) basename = utils.get_savename(outdir, name, dts, date_format,suffix='_') name = name[0:MAX_NAME_LEN] # Plot data plot_volume_components(config, trans, basename=basename, name=name, obs=obs_trans, lw=lw)
def open_ncfile(config, dates): """ Return handle for netcdf file """ outdir = config.get('output', 'outdir') name = config.get('output', 'name') date_format = config.get('output', 'date_format') if not os.path.isdir(outdir): os.makedirs(outdir) if config.getboolean('options', 'td_geo'): if config.getboolean('options', 'endpoint'): suffix = '_natl_meridional_transports_at_34_5S_td_endpoint.nc' else: suffix = '_natl_meridional_transports_at_34_5S_td.nc' else: if config.getboolean('options', 'endpoint'): suffix = '_natl_meridional_transports_at_34_5S_endpoint.nc' else: suffix = '_natl_meridional_transports_at_34_5S.nc' savef = utils.get_savename(outdir, name, dates, date_format, suffix=suffix) dataset = Dataset(savef, 'w', format='NETCDF4_CLASSIC') return dataset