def _read_data(self): """ Read data and apply time averaging """ self._read_dates() if self.time_avg is None: self.dates = self.original_dates self.ekman = self._readnc('t_ek10') self.umo = self._readnc('t_umo10') self.fc = self._readnc('t_gs10') self.moc = self._readnc('moc_mar_hc10') elif self.time_avg == 'monthly': self.dates = self._mm_dates() self.ekman = self._calc_mm(self._readnc('t_ek10')) self.umo = self._calc_mm(self._readnc('t_umo10')) self.fc = self._calc_mm(self._readnc('t_gs10')) self.moc = self._calc_mm(self._readnc('moc_mar_hc10')) elif self.time_avg == 'yearly': self.dates = self._ym_dates() self.ekman = self._calc_ym(self._readnc('t_ek10')) self.umo = self._calc_ym(self._readnc('t_umo10')) self.fc = self._calc_ym(self._readnc('t_gs10')) self.moc = self._calc_ym(self._readnc('moc_mar_hc10')) else: print self.time_avg raise ValueError('time_avg must be "monthly" or "yearly"') if (self.mindt is not None) and (self.maxdt is not None): tind = utils.get_dateind(self.dates, self.mindt, self.maxdt) self.ekman = self.ekman[tind] self.umo = self.umo[tind] self.fc = self.fc[tind] self.moc = self.moc[tind] self.dates = self.dates[tind]
def _read_data(self): """ Read data and apply time averaging """ self._read_dates() if self.time_avg is None: self.fc = self._readnc('florida_current_transport') elif self.time_avg == 'monthly': self.dates = self._mm_dates() self.fc = self._calc_mm(self._readnc('florida_current_transport')) elif self.time_avg == 'yearly': self.dates = self._ym_dates() self.fc = self._calc_ym(self._readnc('florida_current_transport')) else: print self.time_avg raise ValueError('time_avg must be "monthly" or "yearly"') if (self.mindt is not None) and (self.maxdt is not None): tind = utils.get_dateind(self.dates, self.mindt, self.maxdt) self.fc = self.fc[tind] self.dates = self.dates[tind]
def _read_data(self): """ Read data and apply time averaging """ self._read_dates() self.z = self._readnc('depth') if self.time_avg is None: self.dates = self.original_dates self.sf = self._readnc('stream_function_mar').transpose() elif self.time_avg == 'monthly': self.dates = self._mm_dates() self.sf = self._calc_mm( self._readnc('stream_function_mar').transpose(), profile=True) elif self.time_avg == 'yearly': self.dates = self._ym_dates() self.sf = self._calc_ym( self._readnc('stream_function_mar').transpose(), profile=True) else: print self.time_avg raise ValueError('time_avg must be "monthly" or "yearly"') if (self.mindt is not None) and (self.maxdt is not None): tind = utils.get_dateind(self.dates, self.mindt, self.maxdt) self.sf = self.sf[tind, :] self.dates = self.dates[tind]
def plot_vol_vs_heat_transports(trans, basename='', name='simulated', obs_vol=None, obs_oht=None): """ Plot total overturning vs geometric heat transports """ # Extract model variables from data objects dts = utils.get_ncdates(trans) fc = trans.variables['fc'][:] ek = trans.variables['ekman'][:] umo = trans.variables['umo'][:] q_ek = trans.variables['q_ek'][:] q_fc = trans.variables['q_fc'][:] q_mo = trans.variables['q_mo'][:] q_fc_lin, q_fc_label = linreg_vol_vs_oht(fc, q_fc) q_ek_lin, q_ek_label = linreg_vol_vs_oht(ek, q_ek) q_mo_lin, q_mo_label = linreg_vol_vs_oht(umo, q_mo) # Extract obs variables from data objects if (obs_vol is not None) and (obs_oht is not None): mindt, maxdt = utils.get_daterange(obs_vol.dates, obs_oht.dates) vol_ind = utils.get_dateind(obs_vol.dates, mindt, maxdt) oht_ind = utils.get_dateind(obs_oht.dates, mindt, maxdt) ek_obs = obs_vol.ekman[vol_ind] fc_obs = obs_vol.fc[vol_ind] umo_obs = obs_vol.umo[vol_ind] q_ek_obs = obs_oht.q_ek[oht_ind] q_fc_obs = obs_oht.q_fc[oht_ind] q_mo_obs = obs_oht.q_mo[oht_ind] q_fc_obs_lin, q_fc_obs_label = linreg_vol_vs_oht(fc_obs, q_fc_obs) q_ek_obs_lin, q_ek_obs_label = linreg_vol_vs_oht(ek_obs, q_ek_obs) q_mo_obs_lin, q_mo_obs_label = linreg_vol_vs_oht(umo_obs, q_mo_obs) # Plot ekman fig = plt.figure(figsize=(15, 5)) fig.add_subplot(1, 3, 1) plt.plot(ek, q_ek, 'x', color=c1) plt.plot(ek, q_ek_lin, '-', color=c1, label='%s (%s)' % (name, q_ek_label)) if (obs_vol is not None) and (obs_oht is not None): plt.plot(ek_obs, q_ek_obs, 'x', color='k') plt.plot(ek_obs, q_ek_obs_lin, '-', color='k', label='RAPID observations (%s)' % q_ek_obs_label) plt.xlabel('Volume transport (Sv)') plt.ylabel('Heat transport (PW)') plt.title('Ekman volume vs heat transport') plt.legend(loc='best', fontsize=8) # Plot florida current fig.add_subplot(1, 3, 2) plt.plot(fc, q_fc, 'x', color=c1) plt.plot(fc, q_fc_lin, '-', color=c1, label='%s (%s)' % (name, q_fc_label)) if (obs_vol is not None) and (obs_oht is not None): plt.plot(fc_obs, q_fc_obs, 'x', color='k') plt.plot(fc_obs, q_fc_obs_lin, '-', color='k', label='RAPID observations (%s)' % q_fc_obs_label) plt.xlabel('Volume transport (Sv)') plt.ylabel('Heat transport (PW)') plt.title('Florida current volume vs heat transport') plt.legend(loc='best', fontsize=8) # Plot mid-ocean fig.add_subplot(1, 3, 3) plt.plot(umo, q_mo, 'x', color=c1) plt.plot(umo, q_mo_lin, '-', color=c1, label='%s (%s)' % (name, q_mo_label)) if (obs_vol is not None) and (obs_oht is not None): plt.plot(umo_obs, q_mo_obs, 'x', color='k') plt.plot(umo_obs, q_mo_obs_lin, '-', color='k', label='RAPID observations (%s)' % q_mo_obs_label) plt.xlabel('Volume transport (Sv)') plt.ylabel('Heat transport (PW)') plt.title('Mid-ocean volume vs heat transport') plt.legend(loc='best', fontsize=8) # Save plot plt.tight_layout() savef = basename + 'volume_vs_heat_transports_at_26n.png' print 'SAVING: %s' % savef fig.savefig(savef, resolution=300) plt.close()
def plot_moc_vs_oht(trans, basename='', name='simulated', obs_vol=None, obs_oht=None): """ Plot total overturning vs geometric heat transports """ # Add model data to axis (model v) fig = plt.figure(figsize=(15, 5)) fig.add_subplot(1, 3, 1) dts = utils.get_ncdates(trans) moc_model = trans.variables['moc_rapid'][:] q_sum_model = trans.variables['q_sum_model'][:] q_gyre_model = trans.variables['q_gyre_model'][:] q_ot_model = trans.variables['q_ot_model'][:] q_sum_model_lin, q_sum_model_label = linreg_vol_vs_oht( moc_model, q_sum_model) q_gyre_model_lin, q_gyre_model_label = linreg_vol_vs_oht( moc_model, q_gyre_model) q_ot_model_lin, q_ot_model_label = linreg_vol_vs_oht(moc_model, q_ot_model) plt.plot(moc_model, q_sum_model, 'x', color='k') plt.plot(moc_model, q_sum_model_lin, '-', color='k', label='total (%s)' % q_sum_model_label) plt.plot(moc_model, q_ot_model, 'x', color=c1) plt.plot(moc_model, q_ot_model_lin, '-', color=c1, label='overturning (%s)' % q_ot_model_label) plt.plot(moc_model, q_gyre_model, 'x', color=c2) plt.plot(moc_model, q_gyre_model_lin, '-', color=c2, label='gyre (%s)' % q_gyre_model_label) plt.xlabel('MOC (Sv)') plt.ylabel('Heat transport (PW)') plt.title('MOC vs OHT in %s (model velocities)' % name) plt.legend( loc='best', fontsize=8, ) # Add model data to axis (RAPID approx) fig.add_subplot(1, 3, 2) moc_rapid = trans.variables['moc_rapid'][:] q_sum_rapid = trans.variables['q_sum_rapid'][:] q_gyre_rapid = trans.variables['q_gyre_rapid'][:] q_ot_rapid = trans.variables['q_ot_rapid'][:] q_sum_rapid_lin, q_sum_rapid_label = linreg_vol_vs_oht( moc_rapid, q_sum_rapid) q_gyre_rapid_lin, q_gyre_rapid_label = linreg_vol_vs_oht( moc_rapid, q_gyre_rapid) q_ot_rapid_lin, q_ot_rapid_label = linreg_vol_vs_oht(moc_rapid, q_ot_rapid) plt.plot(moc_rapid, q_sum_rapid, 'x', color='k') plt.plot(moc_rapid, q_sum_rapid_lin, '-', color='k', label='total (%s)' % q_sum_rapid_label) plt.plot(moc_rapid, q_ot_rapid, 'x', color=c1) plt.plot(moc_rapid, q_ot_rapid_lin, '-', color=c1, label='overturning (%s)' % q_ot_rapid_label) plt.plot(moc_rapid, q_gyre_rapid, 'x', color=c2) plt.plot(moc_rapid, q_gyre_rapid_lin, '-', color=c2, label='gyre (%s)' % q_gyre_rapid_label) plt.xlabel('MOC (Sv)') plt.ylabel('Heat transport (PW)') plt.title('MOC vs OHT in %s (RAPID approx)' % name) plt.legend( loc='best', fontsize=8, ) # Add optional obs data to axis if (obs_oht is not None) and (obs_vol is not None): fig.add_subplot(1, 3, 3) mindt, maxdt = utils.get_daterange(obs_vol.dates, obs_oht.dates) vol_ind = utils.get_dateind(obs_vol.dates, mindt, maxdt) oht_ind = utils.get_dateind(obs_oht.dates, mindt, maxdt) q_sum_obs = obs_oht.q_sum[oht_ind] q_gyre_obs = obs_oht.q_gyre[oht_ind] q_ot_obs = obs_oht.q_ot[oht_ind] moc_obs = obs_vol.moc[vol_ind] q_sum_obs_lin, q_sum_obs_label = linreg_vol_vs_oht(moc_obs, q_sum_obs) q_gyre_obs_lin, q_gyre_obs_label = linreg_vol_vs_oht( moc_obs, q_gyre_obs) q_ot_obs_lin, q_ot_obs_label = linreg_vol_vs_oht(moc_obs, q_ot_obs) plt.plot(moc_obs, q_sum_obs, 'x', color='k') plt.plot(moc_obs, q_sum_obs_lin, '-', color='k', label='total (%s)' % q_sum_obs_label) plt.plot(moc_obs, q_ot_obs, 'x', color=c1) plt.plot(moc_obs, q_ot_obs_lin, '-', color=c1, label='overturning (%s)' % q_ot_obs_label) plt.plot(moc_obs, q_gyre_obs, 'x', color=c2) plt.plot(moc_obs, q_gyre_obs_lin, '-', color=c2, label='gyre (%s)' % q_gyre_obs_label) plt.xlabel('MOC (Sv)') plt.ylabel('Heat transport (PW)') plt.title('MOC vs OHT in RAPID observations') plt.legend( loc='best', fontsize=8, ) # Save plot plt.tight_layout() savef = basename + 'moc_vs_heat_transports_at_26n.png' print 'SAVING: %s' % savef fig.savefig(savef, resolution=300) plt.close()
def _read_data(self): """ Read data at original frequency or calculate a time-average """ self._read_dates() self.z = self._readnc('z') if self.time_avg is None: self.dates = self.original_dates self.q_eddy = self._readnc('Q_eddy') / 1e15 self.q_ek = self._readnc('Q_ek') / 1e15 self.q_fc = self._readnc('Q_fc') / 1e15 self.q_gyre = self._readnc('Q_gyre') / 1e15 self.q_geoint = self._readnc('Q_int') / 1e15 self.q_mo = self._readnc('Q_mo') / 1e15 self.q_ot = self._readnc('Q_ot') / 1e15 self.q_sum = self._readnc('Q_sum') / 1e15 self.q_wbw = self._readnc('Q_wedge') / 1e15 self.t_basin = self._readnc('T_basin') self.v_basin = self._readnc('V_basin') self.v_fc = self._readnc('V_fc') elif self.time_avg == 'monthly': self.dates = self._mm_dates() self.q_eddy = self._calc_mm(self._readnc('Q_eddy')) / 1e15 self.q_ek = self._calc_mm(self._readnc('Q_ek')) / 1e15 self.q_fc = self._calc_mm(self._readnc('Q_fc')) / 1e15 self.q_gyre = self._calc_mm(self._readnc('Q_gyre')) / 1e15 self.q_geoint = self._calc_mm(self._readnc('Q_int')) / 1e15 self.q_mo = self._calc_mm(self._readnc('Q_mo')) / 1e15 self.q_ot = self._calc_mm(self._readnc('Q_ot')) / 1e15 self.q_sum = self._calc_mm(self._readnc('Q_sum')) / 1e15 self.q_wbw = self._calc_mm(self._readnc('Q_wedge')) / 1e15 self.t_basin = self._calc_mm(self._readnc('T_basin'), profile=True) self.v_basin = self._calc_mm(self._readnc('V_basin'), profile=True) self.v_fc = self._calc_mm(self._readnc('V_fc'), profile=True) elif self.time_avg == 'yearly': self.dates = self._ym_dates() self.q_eddy = self._calc_ym(self._readnc('Q_eddy')) / 1e15 self.q_ek = self._calc_ym(self._readnc('Q_ek')) / 1e15 self.q_fc = self._calc_ym(self._readnc('Q_fc')) / 1e15 self.q_gyre = self._calc_ym(self._readnc('Q_gyre')) / 1e15 self.q_geoint = self._calc_ym(self._readnc('Q_int')) / 1e15 self.q_mo = self._calc_ym(self._readnc('Q_mo')) / 1e15 self.q_ot = self._calc_ym(self._readnc('Q_ot')) / 1e15 self.q_sum = self._calc_ym(self._readnc('Q_sum')) / 1e15 self.q_wbw = self._calc_ym(self._readnc('Q_wedge')) / 1e15 self.t_basin = self._calc_ym(self._readnc('T_basin'), profile=True) self.v_basin = self._calc_ym(self._readnc('V_basin'), profile=True) self.v_fc = self._calc_ym(self._readnc('V_fc'), profile=True) else: print self.time_avg raise ValueError('time_avg must be "monthly" or "yearly"') if (self.mindt is not None) and (self.maxdt is not None): tind = utils.get_dateind(self.dates, self.mindt, self.maxdt) self.q_eddy = self.q_eddy[tind] self.q_ek = self.q_ek[tind] self.q_fc = self.q_fc[tind] self.q_gyre = self.q_gyre[tind] self.q_geoint = self.q_geoint[tind] self.q_mo = self.q_mo[tind] self.q_ot = self.q_ot[tind] self.q_sum = self.q_sum[tind] self.q_wbw = self.q_wbw[tind] self.t_basin = self.t_basin[tind, :] self.v_basin = self.v_basin[tind, :] self.v_fc = self.v_fc[tind, :] self.dates = self.dates[tind]
def plot_moc_vs_oft(trans, basename='', name='simulated', obs_vol=None, obs_oft=None): """ Plot total overturning vs geometric freshwater transports """ # Add model data to axis (model v) fig = plt.figure(figsize=(15, 5)) fig.add_subplot(1, 3, 1) dts = utils.get_ncdates(trans) moc_model = trans.variables['moc_model'][:] fw_sum_model = trans.variables['fw_sum_model'][:] fw_gyre_model = trans.variables['fw_gyre_model'][:] fw_ot_model = trans.variables['fw_ot_model'][:] fw_sum_model_lin, fw_sum_model_label = linreg(moc_model, fw_sum_model, units='Sv/Sv') fw_gyre_model_lin, fw_gyre_model_label = linreg(moc_model, fw_gyre_model, units='Sv/Sv') fw_ot_model_lin, fw_ot_model_label = linreg(moc_model, fw_ot_model, units='Sv/Sv') plt.plot(moc_model, fw_sum_model, 'x', color='k', label='total %s' % fw_sum_model_label) plt.plot(moc_model, fw_ot_model, 'x', color=c1, label='overturning %s' % fw_ot_model_label) plt.plot(moc_model, fw_gyre_model, 'x', color=c2, label='gyre %s' % fw_gyre_model_label) if fw_sum_model_lin is not None: plt.plot(moc_model, fw_sum_model_lin, '-', color='k') plt.plot(moc_model, fw_ot_model_lin, '-', color=c1) plt.plot(moc_model, fw_gyre_model_lin, '-', color=c2) plt.xlabel('MOC (Sv)') plt.ylabel('Equivalent freshwater transport (Sv)') plt.title('MOC vs FWT in %s (model velocities)' % name) plt.legend( loc='best', fontsize=8, ) # Add model data to axis (RAPID approx) fig.add_subplot(1, 3, 2) moc_rapid = trans.variables['moc_rapid'][:] fw_sum_rapid = trans.variables['fw_sum_rapid'][:] fw_gyre_rapid = trans.variables['fw_gyre_rapid'][:] fw_ot_rapid = trans.variables['fw_ot_rapid'][:] fw_sum_rapid_lin, fw_sum_rapid_label = linreg(moc_rapid, fw_sum_rapid, units='Sv/Sv') fw_gyre_rapid_lin, fw_gyre_rapid_label = linreg(moc_rapid, fw_gyre_rapid, units='Sv/Sv') fw_ot_rapid_lin, fw_ot_rapid_label = linreg(moc_rapid, fw_ot_rapid, units='Sv/Sv') plt.plot(moc_rapid, fw_sum_rapid, 'x', color='k', label='total %s' % fw_sum_rapid_label) plt.plot(moc_rapid, fw_ot_rapid, 'x', color=c1, label='overturning %s' % fw_ot_rapid_label) plt.plot(moc_rapid, fw_gyre_rapid, 'x', color=c2, label='gyre %s' % fw_gyre_rapid_label) if fw_sum_rapid_lin is not None: plt.plot(moc_rapid, fw_sum_rapid_lin, '-', color='k') plt.plot(moc_rapid, fw_ot_rapid_lin, '-', color=c1) plt.plot(moc_rapid, fw_gyre_rapid_lin, '-', color=c2) plt.xlabel('MOC (Sv)') plt.ylabel('Equivalent freshwater transport (Sv)') plt.title('MOC vs OFT in %s (RAPID approx)' % name) plt.legend( loc='best', fontsize=8, ) # Add optional obs data to axis if (obs_oft is not None) and (obs_vol is not None): fig.add_subplot(1, 3, 3) mindt, maxdt = utils.get_daterange(obs_vol.dates, obs_oft.dates) vol_ind = utils.get_dateind(obs_vol.dates, mindt, maxdt) oft_ind = utils.get_dateind(obs_oft.dates, mindt, maxdt) fw_sum_obs = obs_oft.fw_sum[oft_ind] fw_gyre_obs = obs_oft.fw_gyre[oft_ind] fw_ot_obs = obs_oft.fw_ot[oft_ind] moc_obs = obs_vol.moc[vol_ind] fw_sum_obs_lin, fw_sum_obs_label = linreg(moc_obs, fw_sum_obs, units='Sv/Sv') fw_gyre_obs_lin, fw_gyre_obs_label = linreg(moc_obs, fw_gyre_obs, units='Sv/Sv') fw_ot_obs_lin, fw_ot_obs_label = linreg(moc_obs, fw_ot_obs, units='Sv/Sv') plt.plot(moc_obs, fw_sum_obs, 'x', color='k', label='total %s' % fw_sum_obs_label) plt.plot(moc_obs, fw_ot_obs, 'x', color=c1, label='overturning %s' % fw_ot_obs_label) plt.plot(moc_obs, fw_gyre_obs, 'x', color=c2, label='gyre %s' % fw_gyre_obs_label) if fw_sum_obs_lin is not None: plt.plot(moc_obs, fw_sum_obs_lin, '-', color='k') plt.plot(moc_obs, fw_ot_obs_lin, '-', color=c1) plt.plot(moc_obs, fw_gyre_obs_lin, '-', color=c2) plt.xlabel('MOC (Sv)') plt.ylabel('Equivalent freshwater transport (Sv)') plt.title('MOC vs OFT in RAPID observations') plt.legend( loc='best', fontsize=8, ) # Save plot plt.tight_layout() savef = basename + 'moc_vs_freshwater_transports_at_26n.png' print 'SAVING: %s' % savef fig.savefig(savef, resolution=300) plt.close()
def plot_vol_vs_fw_transports(trans, basename='', name='simulated', obs_vol=None, obs_oft=None): """ Plot volume vs freshwater transport for RAPID components """ # Extract model variables from data objects dts = utils.get_ncdates(trans) fc = trans.variables['fc'][:] ek = trans.variables['ekman'][:] umo = trans.variables['umo'][:] fw_ek = trans.variables['fw_ek'][:] fw_fc = trans.variables['fw_fc'][:] fw_mo = trans.variables['fw_mo'][:] fw_fc_lin, fw_fc_label = linreg(fc, fw_fc, units='Sv/Sv') fw_ek_lin, fw_ek_label = linreg(ek, fw_ek, units='Sv/Sv') fw_mo_lin, fw_mo_label = linreg(umo, fw_mo, units='Sv/Sv') # Extract obs variables from data objects if (obs_vol is not None) and (obs_oft is not None): mindt, maxdt = utils.get_daterange(obs_vol.dates, obs_oft.dates) vol_ind = utils.get_dateind(obs_vol.dates, mindt, maxdt) oft_ind = utils.get_dateind(obs_oft.dates, mindt, maxdt) ek_obs = obs_vol.ekman[vol_ind] fc_obs = obs_vol.fc[vol_ind] umo_obs = obs_vol.umo[vol_ind] fw_ek_obs = obs_oft.fw_ek[oft_ind] fw_fc_obs = obs_oft.fw_fc[oft_ind] fw_mo_obs = obs_oft.fw_mo[oft_ind] fw_fc_obs_lin, fw_fc_obs_label = linreg(fc_obs, fw_fc_obs, units='Sv/Sv') fw_ek_obs_lin, fw_ek_obs_label = linreg(ek_obs, fw_ek_obs, units='Sv/Sv') fw_mo_obs_lin, fw_mo_obs_label = linreg(umo_obs, fw_mo_obs, units='Sv/Sv') # Plot ekman fig = plt.figure(figsize=(15, 5)) fig.add_subplot(1, 3, 1) plt.plot(ek, fw_ek, 'x', color=c1, label='%s %s' % (name, fw_ek_label)) if fw_ek_lin is not None: plt.plot(ek, fw_ek_lin, '-', color=c1) if (obs_vol is not None) and (obs_oft is not None): plt.plot(ek_obs, fw_ek_obs, 'x', color='k', label='RAPID observations %s' % fw_ek_obs_label) if fw_ek_obs_lin is not None: plt.plot(ek_obs, fw_ek_obs_lin, '-', color='k') plt.xlabel('Volume transport (Sv)') plt.ylabel('Equivalent freshwater transport (Sv)') plt.title('Ekman volume vs freshwater transport') plt.legend(loc='best', fontsize=8) # Plot florida current fig.add_subplot(1, 3, 2) plt.plot(fc, fw_fc, 'x', color=c1, label='%s %s' % (name, fw_fc_label)) if fw_fc_lin is not None: plt.plot(fc, fw_fc_lin, '-', color=c1) if (obs_vol is not None) and (obs_oft is not None): plt.plot(fc_obs, fw_fc_obs, 'x', color='k', label='RAPID observations %s' % fw_fc_obs_label) if fw_fc_obs_lin is not None: plt.plot(fc_obs, fw_fc_obs_lin, '-', color='k') plt.xlabel('Volume transport (Sv)') plt.ylabel('Equivalent freshwater transport (Sv)') plt.title('Florida Current volume vs freshwater transport') plt.legend(loc='best', fontsize=8) # Plot mid-ocean fig.add_subplot(1, 3, 3) plt.plot(umo, fw_mo, 'x', color=c1, label='%s %s' % (name, fw_mo_label)) if fw_mo_lin is not None: plt.plot(umo, fw_mo_lin, '-', color=c1) if (obs_vol is not None) and (obs_oft is not None): plt.plot(umo_obs, fw_mo_obs, 'x', color='k', label='RAPID observations %s' % fw_mo_obs_label) if fw_mo_obs_lin is not None: plt.plot(umo_obs, fw_mo_obs_lin, '-', color='k') plt.xlabel('Volume transport (Sv)') plt.ylabel('Equivalent freshwater transport (Sv)') plt.title('Mid-ocean volume vs freshwater transport') plt.legend(loc='best', fontsize=8) # Save plot plt.tight_layout() savef = basename + 'volume_vs_freshwater_transports_at_26n.png' print 'SAVING: %s' % savef fig.savefig(savef, resolution=300) plt.close()