<jupyter_start><jupyter_text>Visualize river classification system<jupyter_code>import matplotlib.pyplot as plt
import numpy as np
import netCDF4 as nc
import pickle
from matplotlib import colors

%matplotlib inline<jupyter_output><empty_output><jupyter_text>Parameters:<jupyter_code># domain dimensions:
imin, imax = 1479, 2179
jmin, jmax = 159, 799

# runoff period:
rf_year  = 2015
rf_month = 8    # september 

# colours:
c_continent = '#ce9169'
c_glacier   = '#36ab92'
c_other     = 'w'<jupyter_output><empty_output><jupyter_text>Load files: River runoff forcing<jupyter_code># Load river runoff used in ANHA12 from <NAME>' group (http://knossos.eas.ualberta.ca/anha/anhatable.php)
rf_file = nc.Dataset(f'/ocean/brogalla/GEOTRACES/data/runoff/'+\
                     f'ANHA12_runoff_monthly_combined_Dai_Trenberth_Bamber_y{rf_year}.nc','r')
lon_rf  = np.array(rf_file.variables['nav_lon'])
lat_rf  = np.array(rf_file.variables['nav_lat'])
rf      = np.array(rf_file.variables['runoff'][rf_month])

# Place NaNs where there is no runoff
rf[rf == 0]       = np.nan
lon_rf[rf == 0.0] = np.nan
lat_rf[rf == 0.0] = np.nan<jupyter_output><empty_output><jupyter_text>River classification file1. Glaciers2. Continental3. Other<jupyter_code># river classification produced in /forcing/river---create-river-classification
ncd         = nc.Dataset('/ocean/brogalla/GEOTRACES/data/river_class-202005.nc')
river_class = np.array(ncd.variables['rclass'])<jupyter_output><empty_output><jupyter_text>Meshmask<jupyter_code># ANHA12 grid
mesh  = nc.Dataset('/ocean/brogalla/GEOTRACES/data/ANHA12/ANHA12_mesh1.nc')
lon   = np.array(mesh.variables['nav_lon'])
lat   = np.array(mesh.variables['nav_lat'])<jupyter_output><empty_output><jupyter_text>Map with bathymetry background<jupyter_code>fig, ax1, proj1 = pickle.load(open('/ocean/brogalla/GEOTRACES/pickles/surface-land-map.pickle','rb'))

# Sub-domain map: ---------------------------------------------------------------------------
x_sub, y_sub  = proj1(lon, lat) 
x_rf,    y_rf = proj1(lon_rf, lat_rf)

proj1.plot(x_sub[imin:imax,jmax]  , y_sub[imin:imax,jmax],   'w-', lw=1.0, zorder=2)
proj1.plot(x_sub[imin:imax,jmin]  , y_sub[imin:imax,jmin],   'w-', lw=1.0, zorder=2)
proj1.plot(x_sub[imin,jmin:jmax]  , y_sub[imin,jmin:jmax],   'w-', lw=1.0, zorder=2)
proj1.plot(x_sub[imax,jmin:jmax]  , y_sub[imax,jmin:jmax],   'w-', lw=1.0, zorder=2)

colormap = colors.ListedColormap([c_glacier, c_continent, c_other, c_other])
proj1.scatter(x_rf[imin:imax,jmin:jmax], y_rf[imin:imax,jmin:jmax], c=river_class[imin:imax,jmin:jmax],\
              s=rf[imin:imax,jmin:jmax]*1e4, alpha=0.8, cmap=colormap, edgecolor='k', linewidths=0.4, zorder=4)

for a in ['0.001', '0.005', '0.010']:
    proj1.scatter([], [], c=c_continent, alpha=1, s=float(a)*1e4, label=a + ' kg/m$^2$/s', \
                  edgecolors='k', linewidths=0.4, zorder=4)

ax1.legend(scatterpoints=1, frameon=False, labelspacing=0.3, fontsize=6, loc=(0.7,0.8))

fig.savefig('/ocean/brogalla/GEOTRACES/figures/paper1-202110/M3-river-classification.png', bbox_inches='tight', dpi=300)
fig.savefig('/ocean/brogalla/GEOTRACES/figures/paper1-202110/M3-river-classification.svg', bbox_inches='tight', dpi=300, \
            format='svg')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.18209687308399755, 'fraction_numerical': 0.0404659717964439, 'mean_word_length': 4.858168761220826, 'pattern_counts': {'":': 0, '<': 26, '<?xml version=': 0, '>': 26, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '6', 'dir': 'jupyter-structured-clean-dedup', 'id': '181925', 'license': 'Apache-2.0', 'n_tokens_mistral': 1448, 'n_tokens_neox': 1380, 'n_words': 185, 'path': 'paper-materials/M3-river-classification.ipynb', 'repo_name': 'brogalla/Mn-sea-ice-paper', 'size': '3266'}