<jupyter_start><jupyter_text>The IPSL data<jupyter_code>grid=Dataset('gridInfoIPSL.nc')
lat = grid['nav_lat'][:]
lon = grid['nav_lon'][:]
H = grid['deptho'][:]
#IPSLpredictHist = np.load("/home/jovyan/DNN4Cli/THOR/ApplicationOnCMIPModels/bathm_lat_lon.npz")
#lat=IPSLpredictHist["x"]
#lon=IPSLpredictHist["y"]
#H = IPSLpredictHist["z"]
H.shape
IPSLHist = np.load('/home/jovyan/DNN4Cli/THOR/ApplicationOnCMIPModels/IPSL-Historical-198701-201112-EnsembleMLP.npy')
IPSL1pct = np.load('/home/jovyan/DNN4Cli/THOR/ApplicationOnCMIPModels/IPSL-1pctCO2-198701-201112-EnsembleMLP.npy')
IPSLabrupt4pct = np.load('/home/jovyan/DNN4Cli/THOR/ApplicationOnCMIPModels/IPSL-abrupt4pctCO2-198701-201112-EnsembleMLP.npy')
IPSLHist.shape, IPSL1pct.shape, IPSLabrupt4pct.shape, H.shape

def makeFig(data, cMin, cMax, cStep, title, ColMap, saveName):
    plt.figure(figsize=(20,12))
    #lons = lon[:,1]
    #lats = lat[1,:]
    #llons, llats = np.roll(lon,100,axis=1),lat
    fig = plt.figure()
    ax = fig.add_axes([0.05,0.05,0.9,0.9])
    m = Basemap(projection='kav7',lon_0=-60,resolution='l')
    im1 = m.contourf(lon,lat,data,np.arange(cMin, cMax, cStep),shading='flat',cmap=ColMap,latlon=True, extend='both')
    m.drawmapboundary(fill_color='0.9')
    m.drawparallels(np.arange(-90.,99.,30.),labels=[1,1,0,1])
    m.drawmeridians(np.arange(-180.,180.,60.),labels=[1,1,0,1])
    m.drawcoastlines()
    m.fillcontinents()
    ax.set_title(title)
    cb = m.colorbar(im1,"right", size="5%", pad="9%")
    cb.set_ticks([-0.5,0.5, 1.5, 2.5, 3.5, 4.5])
    cb.set_ticklabels(["MD", "S-SV", "N-Sv", "TR", "SO", "NL"])
    #plt.savefig(saveName, format='png', dpi=500, bbox_inches='tight')
    
def makeFigZoomBathymetry(data,cMin, cMax, cStep, title, saveName, label, labelSpot, llcrnrlon=-65, urcrnrlon=-20, llcrnrlat=35, urcrnrlat=65):
    fig = plt.figure(figsize=(8,8))
    map2 = Basemap(llcrnrlon,llcrnrlat,urcrnrlon,urcrnrlat, lon_0=-90, projection='merc', resolution='l')
    map2.drawmapboundary(fill_color='0.9')
    map2.fillcontinents(color='#ddaa66', lake_color='#7777ff', zorder=0)
    map2.drawcoastlines()
    map2.fillcontinents()
    map2.drawcountries()
    map2.drawparallels(np.arange(-90.,99.,5.),labels=[1,1,0,1], fontsize=15)
    map2.drawmeridians(np.arange(-180.,180.,20.),labels=[1,1,0,1], fontsize=15)
    im2=map2.contourf(lon,lat,data,np.arange(cMin, cMax, cStep),shading='flat',cmap=my_cmap,latlon=True)
   
    plt.title(title, fontsize=20)
    display(plt.gca().get_ylim())
    #cb = map2.colorbar(im2,"right", size="5%", pad="9%")
    cb = map2.colorbar(im2,"right", size="5%", pad="12%")
    cb.ax.tick_params(labelsize=20) 
    cb.set_ticks([-0.5,0.5, 1.5, 2.5, 3.5, 4.5])
    cb.set_ticklabels(["MD", "S-SV", "N-SV", "TR", "SO", "NL"]) 
    
    im2=map2.contour(lon,lat,H, colors='k',latlon=True, linethickness=2, levels=np.linspace(0,6000,10))
    #plt.clabel(im2,fontsize=14,fmt='%1.1f', inline=1)
    yL=plt.gca().get_ylim()
    xL=plt.gca().get_xlim()
    plt.text(xL[1]*0.01, yL[1]*0.1, label, fontsize=50, size=40, weight='bold', bbox={'facecolor':'white', 'alpha':0.7})
    plt.text(xL[1]*0.02, yL[1]*0.9, labelSpot, fontsize=50, size=40, weight='bold', bbox={'facecolor':'white', 'alpha':0.7})

    plt.savefig(saveName, format='png', dpi=100, bbox_inches='tight')

plt.imshow(lat)
plt.figure()
plt.imshow(IPSLHist[0])
plt.figure()
plt.imshow(lon)
makeFigZoomBathymetry(IPSLHist[0], -1,6,1,'', 'IPSL_historical_NAtl_EnsembleMLP_prez.png', r'ISPL Historical', 'a',llcrnrlon=-80, urcrnrlon=10, llcrnrlat=10, urcrnrlat=70)
natVar1pct=np.zeros(IPSLHist[0].shape)*np.nan
for n in np.arange(0,8):
    natVar1pct[np.count_nonzero(IPSL1pct[4:7] == n, axis = 0)>2]=n

natVar4=np.zeros(IPSLHist[0].shape)*np.nan
for n in np.arange(0,8):
    natVar4[np.count_nonzero(IPSLabrupt4pct[3:7] == n, axis = 0)>2]=n
makeFigZoomBathymetry(natVar1pct, -1,6,1,'', 'IPSL_1%CO2_NAtl_noNatVar_EnsembleMLP_prez.png', r'IPSL 1% CO$_4$', 'b', llcrnrlon=-80, urcrnrlon=10, llcrnrlat=10, urcrnrlat=70)

makeFigZoomBathymetry(natVar4, -1,6,1,'', 'IPSL_abrupt4xO2_NAtl_noNatVar_EnsembleMLP_prez.png', r'IPSL 4$\times$CO$_2$', 'c', llcrnrlon=-80, urcrnrlon=10, llcrnrlat=10, urcrnrlat=70)<jupyter_output><ipython-input-27-b749ee050b61>:31: UserWarning: The following kwargs were not used by contour: 'shading'
  im2=map2.contourf(lon,lat,data,np.arange(cMin, cMax, cStep),shading='flat',cmap=my_cmap,latlon=True)
{'fraction_non_alphanumeric': 0.20630957784838855, 'fraction_numerical': 0.0728551974580118, 'mean_word_length': 5.984152139461172, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '309586', 'license': 'MIT', 'n_tokens_mistral': 2170, 'n_tokens_neox': 2036, 'n_words': 228, 'path': 'figures/CESM2/.ipynb_checkpoints/CESM2-Basemap_cleaned_18May--checkpoint.ipynb', 'repo_name': 'zouberou-sayibou/DNN4Cli', 'size': '4406'}