Skip to content

Instantly share code, notes, and snippets.

View abhishekmamdapure's full-sized avatar
🦙
llamas taking over the world...

Abhishek Mamdapure abhishekmamdapure

🦙
llamas taking over the world...
View GitHub Profile
@abhishekmamdapure
abhishekmamdapure / PY0101EN-1-1-Types.ipynb
Created March 26, 2019 05:53
Created on Cognitive Class Labs
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@abhishekmamdapure
abhishekmamdapure / PY0101EN-1-1-Types.ipynb
Created March 26, 2019 05:55
Created on Cognitive Class Labs
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@abhishekmamdapure
abhishekmamdapure / PY0101EN-1-2-Strings.ipynb
Created March 26, 2019 05:57
Created on Cognitive Class Labs
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
file = '1966.nc' # mention the path to the downloaded file
data = Dataset(file, mode='r') # read the data
print(type(data)) # print the type of the data
print(data.variables.keys()) # print the variables in the data
lats = data.variables['lat'][:]
longs = data.variables['lon'][:]
time = data.variables['time'][:]
tave = data.variables['tave'][:]
mp = Basemap(projection='merc',
llcrnrlon=68.42, # lower longitude
llcrnrlat=7.45, # lower latitude
urcrnrlon=99.98, # uppper longitude
urcrnrlat=37.78, # uppper latitude
resolution = 'i')
lon, lat = np.meshgrid(long,lats) #this converts coordinates into 2D arrray
x,y = mp(lon,lat) #mapping them together
plt.figure(figsize=(6,8)) #figure size
c_scheme = mp.pcolor(x,y,np.squeeze(tave[0,:,:]),cmap = 'jet') # [0,:,:] is for the first day of the year
# consider this as the outline for the map that is to be created
mp.drawcoastlines()
mp.drawstates()
mp.drawcountries()
# this will create 365 images in the path given
# please set the path before executing
lon, lat = np.meshgrid(long,lats)
x,y = mp(lon,lat)
plt.figure(figsize=(6,8))
# loop for all the days
days = np.arange(0,365) # for considering all days of the year
for i in days:
import PIL
image_frames = [] # creating a empty list to be appended later on
days = np.arange(1,365)
for k in days:
new_fram = PIL.Image.open(r'path\where\images\are\downloaded' + '\\' + str(k) + '.jpg')
image_frames.append(new_fram)
image_frames[0].save('tave_timelapse.gif',format='GIF',