Skip to content

Instantly share code, notes, and snippets.

View prl900's full-sized avatar

Pablo Rozas Larraondo prl900

View GitHub Profile
#!/usr/bin/env python
from ecmwfapi import ECMWFDataServer
from datetime import timedelta, date
def monthly_range(start_date, end_date):
start_date = start_date.replace(day=1)
while start_date < end_date:
last_day_month = start_date + timedelta(days=33)
last_day_month = last_day_month.replace(day=1)
package main
import (
"fmt"
"image"
"io/ioutil"
"log"
"os"
"unsafe"
@prl900
prl900 / vae.py
Created November 14, 2018 00:48
Variational Autoencoder Keras
'''This script demonstrates how to build a variational autoencoder with Keras.
Reference: "Auto-Encoding Variational Bayes" https://arxiv.org/abs/1312.6114
'''
import numpy as np
import matplotlib
matplotlib.use('agg')
import matplotlib.pyplot as plt
from scipy.stats import norm
from keras.layers import Input, Dense, Lambda
@prl900
prl900 / gdal_merge.py
Created November 7, 2018 23:34
Our gdal_merge
#!/g/data/xc0/software/python/miniconda2/bin/python
###############################################################################
# $Id: gdal_merge.py 33790 2016-03-26 12:42:12Z goatbar $
#
# Project: InSAR Peppers
# Purpose: Module to extract data from many rasters into one output.
# Author: Frank Warmerdam, [email protected]
#
###############################################################################
# Copyright (c) 2000, Atlantis Scientific Inc. (www.atlsci.com)
#!/g/data/v10/public/modules/dea-env/20181015/bin/python
import argparse
import os
locations = """'Yanco',-34.9878,146.2908,2012,2017
'WombatStateForest',-37.4222,144.0944,2010,2017
'Whroo',-36.6732,145.0294,2011,2017
'Warra',-43.09502,146.65452,2015,2017
'WallabyCreek',-34.00206,140.58912,2005,2013
#!/g/data/v10/public/modules/dea-env/20181015/bin/python
import datacube as dc
from datacube.helpers import ga_pq_fuser
from datacube.storage import masking
import pyproj
import numpy as np
import xarray as xr
import datetime
import warnings
@prl900
prl900 / agdc_extractor.py
Created October 29, 2018 02:01
This script allows extracting Landsat data from the AGDC for a selected location
#!/g/data/v10/public/modules/dea-env/20181015/bin/python
import datacube as dc
from datacube.helpers import ga_pq_fuser
from datacube.storage import masking
import pyproj
import numpy as np
import xarray as xr
import datetime
import warnings
@prl900
prl900 / awdc.py
Last active October 23, 2018 03:14
#!/g/data/v10/public/modules/agdc-py3-env/20171214/envs/agdc/bin/python
import pyproj
import argparse
import glob
import os
import sys
import shutil
import uuid
import subprocess
from keras.models import load_model, Sequential
from keras import layers
from keras.layers import Layer
from keras import models
import numpy as np
import matplotlib.pyplot as plt
import sys
x = np.load("/datasets/10zlevels.npy")
y = 1000*np.expand_dims(np.load("/datasets/1980-2016/full_tp_1980_2016.npy"), axis=3)
import pickle
import matplotlib
matplotlib.use('agg')
import matplotlib.pyplot as plt
#hist = pickle.load(open("trainHistoryDict_0-5-7", 'rb'))
hist = pickle.load(open("trainHistoryDict_9", 'rb'))
print hist.keys()
plt.plot(hist['loss'])
plt.plot(hist['val_loss'])