0
I’m a beginner in python and work with Data Analysis applied to Oceanography and I’m having difficulty working with reading files . nc ! Is the following:
I have 30 . nc satellite data files, each data corresponds to 1 day of data that the satellite collected. My intention is to use all this data and plot the Mid-sea Level Anomaly in a certain region in those 30 days. The code I used to plot 1 data equivalent to 1 day was this:
from netCDF4 import Dataset
data = Dataset('/home/maou/Área de Trabalho/Victor/Estágio/Dados de Satelite/01.09.2015 Antartica.nc', mode='r') **#Aqui eu gostaria de colocar outros 29 dados e não sei como.**
lons = data.variables['longitude'][:]
lats = data.variables['latitude'][:]
sla = data.variables['sla'][:,:,:]
sla = sla[0,:,:]
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.cm as cm
from mpl_toolkits.basemap import Basemap
map = Basemap(projection='spaeqd',boundinglat=-55,lon_0=90,resolution='h')
lons, lats = np.meshgrid(lons, lats)
xi, yi = map(lons, lats)
cs = map.pcolor(xi,yi,np.squeeze(sla), vmin=np.min(sla), vmax=np.max(sla), cmap=cm.jet)
cs.set_edgecolor('face')
map.drawparallels(np.arange(-80.,81.,20.), labels=[1,0,0,0], fontsize=5)
map.drawmeridians(np.arange(-180.,181.,20.), labels=[0,0,0,1], fontsize=4)
map.drawcoastlines()
map.drawstates()
map.drawcountries()
cbar = map.colorbar(cs, location='right', pad="10%")
cbar.set_label('(m)')
cbar.ax.tick_params(labelsize=10)
plt.rcParams['figure.figsize'] = (11,7)
plt.title(' Sea Level Anomaly (2015/09/01-30) ')
plt.savefig('Sea Level Anomaly', format='pdf', dpi=600)
Thank you so much! It worked Perfectly!
– Victor Huggo Lessa Rosolem
I am happy to have helped. If the answer is correct, mark it as the answer accepts help and help other users who have the same problem ;)
– luigibertaco