Skip to content

Instantly share code, notes, and snippets.

View prl900's full-sized avatar

Pablo Rozas Larraondo prl900

View GitHub Profile
@prl900
prl900 / add_topo.py
Created August 7, 2019 21:46
Adding ERA5 topography
import numpy as np
import netCDF4
x = netCDF4.Dataset("/datasets/work/D61_CPSR_A_INPUT/ERA5_global/press_levels_201501.nc")["z"][:]
x = np.moveaxes(x,1,-1)
topo = netCDF4.Dataset("/datasets/work/D61_CPSR_A_INPUT/ERA5_global/ERA5_orography.nc")['z'][:]
topo = np.tile(topo, (x.shape[0],1,1,1))
from __future__ import print_function, division
from keras.layers import concatenate, Input, Concatenate, BatchNormalization
from keras.layers.convolutional import UpSampling2D, Conv2D
from keras.models import Model
from keras.optimizers import Adam
import xarray as xr
import numpy as np
import pickle
import tensorflow as tf
import numpy as np
import pandas as pd
import imageio
im_orig = imageio.imread("cameraman.jpg")[::4,::4].astype(np.float32) / 255
im_orig_df = pd.DataFrame(im_orig)
im_df_masked = im_orig_df.copy()
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
import datacube
from datacube.storage import masking
import matplotlib.pyplot as plt
import numpy as np
dc = datacube.Datacube(app='load-data-example')
query = {
'lat': (-35.27, -35.33),
'lon': (149.07, 149.15),
import numpy as np
import xarray as xr
# Load ERA5 geopotential levels
era5_ds1 = xr.open_dataset("./datasets/GEOP1000_GAN_2017.nc")
era5_ds2 = xr.open_dataset("./datasets/GEOP800_GAN_2017.nc")
era5_ds3 = xr.open_dataset("./datasets/GEOP500_GAN_2017.nc")
era5_times = era5_ds1.time[:].data
# Load ERA5 total precipitation
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
from pyproj import Proj, transform
import math
xExtentModis = 1111950.519666
yExtentModis = 1111950.519667
sinu_proj = "+proj=sinu +lon_0=0 +x_0=0 +y_0=0 +a=6371007.181 +b=6371007.181 +units=m +no_defs "
wgs84_proj = "+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs "
def xy2tile(x, y):
return int(math.floor(x/xExtentModis)) + 18, -1*int(math.ceil(y/yExtentModis)) + 9
from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import BatchNormalization, Conv2D
from tensorflow.keras.optimizers import Adam
from tensorflow.keras.callbacks import CSVLogger
from matplotlib import pyplot as plt
import numpy as np
def GetModel(conv1_size):
model = Sequential()