Beispiel #1
0
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.colors as colors
from netCDF4 import Dataset as Ncdf
from netCDF4 import num2date
from mpl_toolkits.basemap import Basemap
import matplotlib
from PIL import Image

matplotlib.use("Agg")
nc = Ncdf('precip_diurnal_mean_d02_2009-2018.nc', 'r')
nc55 = Ncdf('precip_diurnal_mean_d02_2055-2064.nc', 'r')
for i in nc.variables:
    print(i, nc.variables[i].units, nc.variables[i].shape)
lons = nc.variables['lon'][:]
lats = nc.variables['lat'][:]
time = nc.variables['time'][:]
rr = nc.variables['rainfall_rate'][:]
t_units = nc.variables['time'].units
max = -478324
min = 7489324
for j in range(0, 24):
    print(j)
    for k in range(0, 699):
        for d in range(0, 600):
            if rr[j, k, d] >= max:
                max = rr[j, k, d]
            if rr[j, k, d] <= min:
                min = rr[j, k, d]

print(max)
import numpy as np

import matplotlib.pyplot as plt
from netCDF4 import Dataset as Ncdf
import matplotlib.colors as colors
from mpl_toolkits.basemap import Basemap
import matplotlib

matplotlib.use("Agg")
ua = Ncdf('ua_10m_diurnal_mean_d02_2009-2018.nc', 'r')
va = Ncdf('va_10m_diurnal_mean_d02_2009-2018.nc', 'r')
ua55 = Ncdf('ua_10m_diurnal_mean_d02_2055-2064.nc', 'r')
va55 = Ncdf('va_10m_diurnal_mean_d02_2055-2064.nc', 'r')
ua90 = Ncdf('ua_10m_diurnal_mean_d02_2090-2099.nc', 'r')
va90 = Ncdf('va_10m_diurnal_mean_d02_2090-2099.nc', 'r')
print(ua55)
lons = ua.variables['lon'][:]
lats = ua.variables['lat'][:]

time = ua.variables['time'][:]
u10 = np.array(ua.variables['ua_10m'][:])
v10 = np.array(va.variables['va_10m'][:])
ws = np.sqrt(u10[:] ** 2 + v10[:] ** 2)
print("wind speed")
print(np.amax(ws))
print(np.amin(ws))


# datevar = num2date(time[:], units='hours since 1970-01-01 00:00:00', calendar='standard')
# print(datevar[:])
map = Basemap(projection='merc', llcrnrlon=lons[0], llcrnrlat=lats[0], urcrnrlon=lons[599], urcrnrlat=lats[698],
import numpy as np
import matplotlib.pyplot as plt
from netCDF4 import Dataset as Ncdf
from netCDF4 import num2date
import datetime
from mpl_toolkits.basemap import Basemap
import matplotlib
import palettable
matplotlib.use("Agg")
nc = Ncdf('ta_2m_diurnal_mean_d02_2009-2018.nc', 'r')
nc90 = Ncdf('ta_2m_diurnal_mean_d02_2090-2099.nc', 'r')
# for i in nc.variables:
#     print(i, nc.variables[i].units, nc.variables[i].shape)
lons = nc.variables['lon'][:]
lats = nc.variables['lat'][:]
time = nc.variables['time'][:]
t2 = nc.variables['ta_2m'][:]
t_units = nc.variables['time'].units
temp_c = t2
lons90 = nc90.variables['lon'][:]
lats90 = nc90.variables['lat'][:]
time90 = nc90.variables['time'][:]
t290 = nc90.variables['ta_2m'][:]
t_units90 = nc90.variables['time'].units
temp_c90 = t290
diff = t2
max = -43892184
min = 843924
for j in range(0, 24):
    print(j)
    for k in range(0, 699):
Beispiel #4
0
import numpy as np
import matplotlib.pyplot as plt
from netCDF4 import Dataset as Ncdf
from netCDF4 import num2date
import datetime
from mpl_toolkits.basemap import Basemap
import matplotlib

matplotlib.use("Agg")
nc = Ncdf('ta_2m_1hr_20090101_d02.nc', 'r')
print(nc)
for i in nc.variables:
    print(i, nc.variables[i].units, nc.variables[i].shape)
lons = nc.variables['lon'][:]
lats = nc.variables['lat'][:]
time = nc.variables['time'][:]
t2 = nc.variables['ta_2m'][:]
t_units = nc.variables['time'].units
add = 0.0
avg = 0
# avg_temps = []
# for i in lons:
#     for j in lats:
#         for x in t2[:]:
#             add += x
#             if x % 24 == 0:
#                 break
#         avg_temps.append(add / 24)
#         add = 0
# print(avg_temps)
import numpy as np
import matplotlib.pyplot as plt
from netCDF4 import Dataset as Ncdf
from netCDF4 import num2date
import datetime
from mpl_toolkits.basemap import Basemap
import matplotlib

matplotlib.use("Agg")
nc = Ncdf('VPD_monthly_mean_d02_2009-2018.nc', 'r')
print(nc)
for i in nc.variables:
    print(i, nc.variables[i].units, nc.variables[i].shape)
lons = nc.variables['lon'][:]
lats = nc.variables['lat'][:]
time = nc.variables['time'][:]
vpd = nc.variables['VPD'][:]
t_units = nc.variables['time'].units
datevar = num2date(time[:],
                   units='hours since 1970-01-01 00:00:00',
                   calendar='standard')
print(datevar[:])
map = Basemap(projection='merc',
              llcrnrlon=lons[0],
              llcrnrlat=lats[0],
              urcrnrlon=lons[599],
              urcrnrlat=lats[698],
              resolution='i')

lon2, lat2 = np.meshgrid(lons, lats)
x, y = map(lon2, lat2)
import numpy as np
import matplotlib.pyplot as plt
from netCDF4 import Dataset as Ncdf
from netCDF4 import num2date
from mpl_toolkits.basemap import Basemap
import matplotlib

matplotlib.use("Agg")
nc = Ncdf('precip_diurnal_mean_d02_2009-2018.nc', 'r')
nc90 = Ncdf('precip_diurnal_mean_d02_2090-2099.nc', 'r')
for i in nc.variables:
    print(i, nc.variables[i].units, nc.variables[i].shape)
lons = nc.variables['lon'][:]
lats = nc.variables['lat'][:]
time = nc.variables['time'][:]
rr = nc.variables['rainfall_rate'][:]
t_units = nc.variables['time'].units
lons90 = nc90.variables['lon'][:]
lats90 = nc90.variables['lat'][:]
time90 = nc90.variables['time'][:]
rr55 = nc90.variables['rainfall_rate'][:]
t_units55 = nc90.variables['time'].units
diff = rr
max = -478324
min = 7489324
for j in range(0, 24):
    print(j)
    for k in range(0, 699):
        for d in range(0, 600):
            diff[j, k, d] = rr55[j, k, d] - rr[j, k, d]
            if diff[j, k, d] >= max:
Beispiel #7
0
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.colors as colors
from netCDF4 import Dataset as Ncdf
from mpl_toolkits.basemap import Basemap
import matplotlib
# CREATE DIRECTORIES /precip_amnt_freq_month_2055_2064_cat0_maps/ for cat0 - cat3
matplotlib.use("Agg")
nc = Ncdf('precip_exc_freq_d02_2090-2099.nc', 'r')
print(nc)
print(nc.variables["category"][:])
lons = nc.variables['lon'][:]
lats = nc.variables['lat'][:]
month = nc.variables['month'][:]
precip = nc.variables['precip_amnt_freq_month'][:]
cat = nc.variables["category"][:]

mapp = Basemap(projection='merc',
               llcrnrlon=lons[0],
               llcrnrlat=lats[0],
               urcrnrlon=lons[599],
               urcrnrlat=lats[698],
               resolution='i')
lon2, lat2 = np.meshgrid(lons, lats)
x, y = mapp(lon2, lat2)
plt.figure(figsize=(601 / 100, 700 / 100))
plt.gca().set_axis_off()
plt.subplots_adjust(top=1, bottom=0, right=1, left=0, hspace=0, wspace=0)
plt.margins(0, 0)
cmap = plt.get_cmap('gist_rainbow')
cmapr = plt.get_cmap('gist_rainbow_r')
Beispiel #8
0
import numpy as np
import matplotlib.pyplot as plt
from netCDF4 import Dataset as Ncdf
from mpl_toolkits.basemap import Basemap
import matplotlib

matplotlib.use("Agg")
nc = Ncdf('daily_temperature_month_d02_2009-2018.nc', 'r')
nc55 = Ncdf('daily_temperature_month_d02_2055-2064.nc', 'r')

month = nc.variables['month'][:]
lons = nc.variables['lon'][:]
lats = nc.variables['lat'][:]

month55 = nc.variables['month'][:]
lons55 = nc.variables['lon'][:]
lats55 = nc.variables['lat'][:]

# temp_max_daily = nc.variables['Tmax_daily'][:]
# temp55_max_daily = nc55.variables['Tmax_daily'][:]

# temp_min_daily = nc.variables['Tmin_daily'][:]
# temp55_min_daily = nc55.variables['Tmin_daily'][:]

temp_mean_daily = nc.variables['Tmean_daily'][:]
temp55_mean_daily = nc55.variables['Tmean_daily'][:]

# temp_min_daily_c = temp_min_daily
# temp55_min_daily_c = temp55_min_daily

# temp_max_daily_c = temp_max_daily
Beispiel #9
0
import numpy as np
import matplotlib.pyplot as plt
from netCDF4 import Dataset as Ncdf
from mpl_toolkits.basemap import Basemap
import matplotlib
from netCDF4 import num2date

matplotlib.use("Agg")
nc = Ncdf('daily_temperature_month_d02_2009-2018.nc', 'r')
n90 = Ncdf('daily_temperature_month_d02_2090-2099.nc', 'r')
for i in nc.variables:
    print(i, nc.variables[i])
for x in n90.variables:
    print(x, n90.variables[x])
month = nc.variables['month'][:]
lons = nc.variables['lon'][:]
lats = nc.variables['lat'][:]

month90 = nc.variables['month'][:]
lons90 = nc.variables['lon'][:]
lats90 = nc.variables['lat'][:]

datevar = num2date(month[:],
                   units='hours since 1970-01-01 00:00:00',
                   calendar='standard')
print(datevar[:])

temp_max_daily = nc.variables['Tmax_daily'][:]
temp90_max_daily = n90.variables['Tmax_daily'][:]

# temp_min_daily = nc.variables['Tmin_daily'][:]
Beispiel #10
0
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.colors as colors
from netCDF4 import Dataset as Ncdf
from netCDF4 import num2date
import datetime
from mpl_toolkits.basemap import Basemap
import matplotlib

matplotlib.use("Agg")
nc = Ncdf('VPD_monthly_mean_d02_2009-2018.nc', 'r')
nc99 = Ncdf('VPD_monthly_mean_d02_2090-2099.nc', 'r')
print(nc)
for i in nc.variables:
    print(i, nc.variables[i].units, nc.variables[i].shape)
lons = nc.variables['lon'][:]
lats = nc.variables['lat'][:]
time = nc.variables['time'][:]
vpd = nc.variables['VPD'][:]

lons99 = nc99.variables['lon'][:]
lats99 = nc99.variables['lat'][:]
time99 = nc99.variables['time'][:]
vpd99 = nc99.variables['VPD'][:]

diff99 = vpd99

for j in range(0, 12):
    print(j)
    for k in range(0, 699):
        for d in range(0, 600):
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.colors as colors
from netCDF4 import Dataset as Ncdf
from mpl_toolkits.basemap import Basemap
import matplotlib

matplotlib.use("Agg")
nc = Ncdf('precip_exc_freq_d02_2009-2018.nc', 'r')
nc55 = Ncdf('precip_exc_freq_d02_2055-2064.nc', 'r')
nc90 = Ncdf('precip_exc_freq_d02_2090-2099.nc', 'r')
print(nc)
lons = nc.variables['lon'][:]
lats = nc.variables['lat'][:]
month = nc.variables['month'][:]
mean = nc.variables['mean_daily_precip'][:]
lons55 = nc55.variables['lon'][:]
lats55 = nc55.variables['lat'][:]
month55 = nc55.variables['month'][:]
mean55 = nc55.variables['mean_daily_precip'][:]
diff55 = mean55
lons90 = nc90.variables['lon'][:]
lats90 = nc90.variables['lat'][:]
month90 = nc90.variables['month'][:]
mean90 = nc90.variables['mean_daily_precip'][:]
diff90 = mean90
for j in range(0, 12):
    print(j)
    for k in range(0, 699):
        for d in range(0, 600):
            diff55[j, k, d] = mean55[j, k, d] - mean[j, k, d]
Beispiel #12
0
import numpy as np
import matplotlib.pyplot as plt
from netCDF4 import Dataset as Ncdf
from netCDF4 import num2date
from mpl_toolkits.basemap import Basemap
import matplotlib

matplotlib.use("Agg")
nc = Ncdf('daily_temperature_month_d02_2055-2064.nc', 'r')
print(nc)

month = nc.variables['month'][:]
lons = nc.variables['lon'][:]
lats = nc.variables['lat'][:]

# time = nc.variables['time'][:]
# t_units = nc.variables['time'].units

temp_max_daily = nc.variables['Tmax_daily'][:]
# temp_min_daily = nc.variables['Tmin_daily'][:]
# temp_mean_daily = nc.variables['Tmean_daily'][:]

temp_max_daily_c = temp_max_daily
# temp_min_daily_c = temp_min_daily
# temp_mean_daily_c = temp_mean_daily

for i in range(0, 12):
    print(i)
    for j in range(0, 699):
        for k in range(0, 600):
            temp_max_daily_c[i, j, k] = temp_max_daily[i, j, k] - 273.15
Beispiel #13
0
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.colors as colors
from netCDF4 import Dataset as Ncdf
from mpl_toolkits.basemap import Basemap
import matplotlib
# CREATE DIRECTORIES /precip_amnt_freq_month_2055_2064_cat0_maps/ for cat0 - cat3
matplotlib.use("Agg")
nc = Ncdf('precip_exc_freq_d02_2055-2064.nc', 'r')
print(nc)
print(nc.variables["category"][:])
lons = nc.variables['lon'][:]
lats = nc.variables['lat'][:]
month = nc.variables['month'][:]
precip = nc.variables['precip_amnt_freq_month'][:]
cat = nc.variables["category"][:]

mapp = Basemap(projection='merc',
               llcrnrlon=lons[0],
               llcrnrlat=lats[0],
               urcrnrlon=lons[599],
               urcrnrlat=lats[698],
               resolution='i')
lon2, lat2 = np.meshgrid(lons, lats)
x, y = mapp(lon2, lat2)
plt.figure(figsize=(601 / 100, 700 / 100))
plt.gca().set_axis_off()
plt.subplots_adjust(top=1, bottom=0, right=1, left=0, hspace=0, wspace=0)
plt.margins(0, 0)
cmap = plt.get_cmap('gist_rainbow')
cmapr = plt.get_cmap('gist_rainbow_r')
Beispiel #14
0
import numpy as np
import matplotlib.pyplot as plt
from netCDF4 import Dataset as Ncdf
from netCDF4 import num2date, date2num
import datetime
from mpl_toolkits.basemap import Basemap
import matplotlib

matplotlib.use("Agg")
nc = Ncdf('ta_2m_1hr_20090101_d02.nc', 'r')
#print(nc)
# for i in nc.variables:
#     print(i, nc.variables[i].units, nc.variables[i].shape)
#     print(nc.dimensions)
lons = nc.variables['lon'][:]
lats = nc.variables['lat'][:]
time = nc.variables['time'][:]
t2 = nc.variables['ta_2m'][:]
t_units = nc.variables['time'].units
datevar = num2date(time[:],
                   units='hours since 1970-01-01 00:00:00',
                   calendar='standard')
another = Ncdf("ta_max_1day.nc", "w", format="NETCDF4")
temp_dim = another.createDimension("max temp")
day_dim = another.createDimension("days in jan")
lat_dim = another.createDimension("lat")
lon_dim = another.createDimension("lon")
temp = another.createVariable("max temp", 'f4', ("max temp", ))
day = another.createVariable("day", "u1", ("days in jan", ))
another_latitude = another.createVariable("lat", 'f4', ("lon", ))
another_longitude = another.createVariable("lon", 'f4', ("lat", ))
Beispiel #15
0
import numpy as np
import matplotlib.pyplot as plt
from netCDF4 import Dataset as Ncdf
from netCDF4 import num2date, date2num
import datetime
from mpl_toolkits.basemap import Basemap
import matplotlib

matplotlib.use("Agg")
max = Ncdf("ta_max_1day.nc", "r")
print(max)
max_latitude = max.variables["lat"][:]
max_longitude = max.variables["lon"][:]
max_temps = max.variables["max temp"][:]
days = max.variables["day"][:]
datevar = num2date(days[:],
                   units='hours since 1970-01-01 00:00:00',
                   calendar='standard')
avg = 0
for j in range(0, 599):
    for k in range(0, 698):
        for d in range(0, len(days[:])):
            avg += max_temps[:][d][k][j]
        if j % 25 == 0 & k % 25 == 0:
            domain = []
            fig = plt.figure()
            ax = plt.axes()
            ax.plot(datevar, avg)
            plt.show()
max.close()
print("done")
Beispiel #16
0
import numpy as np
import matplotlib.pyplot as plt
from netCDF4 import Dataset as Ncdf
from netCDF4 import num2date
import datetime
from mpl_toolkits.basemap import Basemap
import matplotlib
matplotlib.use("Agg")
nc = Ncdf('ta_2m_diurnal_mean_d02_2009-2018.nc', 'r')
nc55 = Ncdf('ta_2m_diurnal_mean_d02_2055-2064.nc', 'r')
# for i in nc.variables:
#     print(i, nc.variables[i].units, nc.variables[i].shape)
lons = nc.variables['lon'][:]
lats = nc.variables['lat'][:]
time = nc.variables['time'][:]
t2 = nc.variables['ta_2m'][:]
t_units = nc.variables['time'].units
temp_c = t2
lons55 = nc55.variables['lon'][:]
lats55 = nc55.variables['lat'][:]
time55 = nc55.variables['time'][:]
t255 = nc55.variables['ta_2m'][:]
t_units55 = nc55.variables['time'].units
temp_c55 = t255
diff = t2
max = -478324
min = 7489324
# for j in range(0, 24):
#     print(j)
#     for k in range(0, 699):
#         for d in range(0, 600):
Beispiel #17
0
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.colors as colors
from netCDF4 import Dataset as Ncdf
from netCDF4 import num2date
import datetime
from mpl_toolkits.basemap import Basemap
import matplotlib

matplotlib.use("Agg")
nc = Ncdf('qv_2m_monthly_mean_d02_2009-2018.nc', 'r')
nc55 = Ncdf('qv_2m_monthly_mean_d02_2090-2099.nc', 'r')
print(nc)
for i in nc.variables:
    print(i, nc.variables[i].units, nc.variables[i].shape)
lons = nc.variables['lon'][:]
lats = nc.variables['lat'][:]
time = nc.variables['time'][:]
qv2m = nc.variables['qv_2m'][:]

lons55 = nc55.variables['lon'][:]
lats55 = nc55.variables['lat'][:]
time55 = nc55.variables['time'][:]
qv2m55 = nc55.variables['qv_2m'][:]

diff55 = qv2m55

for j in range(0, 12):
    print(j)
    for k in range(0, 699):
        for d in range(0, 600):
Beispiel #18
0
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.colors as colors
from netCDF4 import Dataset as Ncdf
from netCDF4 import num2date
import datetime
from mpl_toolkits.basemap import Basemap
import matplotlib

matplotlib.use("Agg")
nc = Ncdf('VPD_monthly_mean_d02_2009-2018.nc', 'r')
nc55 = Ncdf('VPD_monthly_mean_d02_2055-2064.nc', 'r')
print(nc)
for i in nc.variables:
    print(i, nc.variables[i].units, nc.variables[i].shape)
lons = nc.variables['lon'][:]
lats = nc.variables['lat'][:]
time = nc.variables['time'][:]
vpd = nc.variables['VPD'][:]

lons55 = nc55.variables['lon'][:]
lats55 = nc55.variables['lat'][:]
time55 = nc55.variables['time'][:]
vpd55 = nc55.variables['VPD'][:]

diff55 = vpd55

for j in range(0, 12):
    print(j)
    for k in range(0, 699):
        for d in range(0, 600):
Beispiel #19
0
import numpy as np
import matplotlib.pyplot as plt
from netCDF4 import Dataset as Ncdf
from netCDF4 import num2date
import datetime
from mpl_toolkits.basemap import Basemap
import matplotlib

matplotlib.use("Agg")
nc = Ncdf('qv_2m_monthly_mean_d02_2009-2018.nc', 'r')
print(nc)
for i in nc.variables:
    print(i, nc.variables[i].units, nc.variables[i].shape)
lons = nc.variables['lon'][:]
lats = nc.variables['lat'][:]
time = nc.variables['time'][:]
qv2m = nc.variables['qv_2m'][:]
t_units = nc.variables['time'].units
datevar = num2date(time[:], units='hours since 1970-01-01 00:00:00', calendar='standard')
print(datevar[:])
map = Basemap(projection='merc', llcrnrlon=lons[0], llcrnrlat=lats[0], urcrnrlon=lons[599], urcrnrlat=lats[698],
          resolution='i')

lon2, lat2 = np.meshgrid(lons, lats)
x, y = map(lon2, lat2)
my_cmap = plt.get_cmap('rainbow')
plt.gca().set_axis_off()
plt.subplots_adjust(top=1, bottom=0, right=1, left=0,
                    hspace=0, wspace=0)
plt.margins(0, 0)
map.pcolormesh(x, y, qv2m[0, :, :], cmap='rainbow_r')