-1

I am trying to do a contour plot using data from excel. But I am getting error as "MemoryError: Unable to allocate 55.6 GiB for an array with shape (86400, 86400) and data type float64". If anybody can help me by showing how to solve this and plot the data it will be appreciated. Below I am attaching my code and also a link to the excel data.

import numpy as np
from netCDF4 import num2date
import matplotlib.pyplot as plt
from mpl_toolkits.basemap import Basemap,shiftgrid
import seaborn as sns
import pandas as pd

df = pd.read_excel('E:/Super_cyclone/Datasets/tchp/2007_tchp/tchp_2007.xlsx')
x = df.Lon.values
y = df.Lat.values
plt_data = df.TCHP.values

fig = plt.figure(figsize=[7.5,7.5])  # a new figure window
ax = fig.add_subplot(1, 1, 1)
map = Basemap(projection='merc',llcrnrlat=5,urcrnrlat=30,\
        llcrnrlon=50,urcrnrlon=80, resolution='i', ax=ax)
map.drawcoastlines()
map.fillcontinents(color='#ffe2ab')

map.drawparallels(np.arange(5.,31.,5.),labels=[1,0,0,0])
map.drawmeridians(np.arange(50.,81.,5.),labels=[1,1,0,1])

#data,lons = shiftgrid(180.,data,lons,start=False)
llons, llats = np.meshgrid(x, y)
lon,lat = map(llons,llats)

plt.style.use('seaborn-white')
#clevels=np.arange(24,32.1,0.5)
cs = map.contourf(x,y,plt_data,cmap=plt.cm.jet)#,clevels,cmap=plt.cm.jet)

TCHP

Debashis Paul
  • 67
  • 1
  • 10
  • Show us the traceback too. Which line yields the MemoryError? – AKX Aug 05 '20 at 13:30
  • @AKX the traceback as follows:"Traceback (most recent call last): File "", line 24, in llons, llats = np.meshgrid(x, y) File "<__array_function__ internals>", line 6, in meshgrid File "C:\Users\Debashis Paul\Anaconda3\lib\site-packages\numpy\lib\function_base.py", line 4209, in meshgrid output = [x.copy() for x in output] File "C:\Users\Debashis Paul\Anaconda3\lib\site-packages\numpy\lib\function_base.py", line 4209, in output = [x.copy() for x in output] – Debashis Paul Aug 05 '20 at 13:39
  • Right, so passing those numbers to `meshgrid` it's trying to make a... pretty large array. There's probably something wrong with your algorithm there. – AKX Aug 05 '20 at 13:41
  • @AKX can you please help me with how to plot it, I am new to python. – Debashis Paul Aug 05 '20 at 13:43

1 Answers1

-2

Try splitting the dataset into multiple smaller Excel files.