This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
def rad2mmh(dbz, a_coeff=200, b_coeff=1.6): | |
Z = 10. ** (dbz / 10) | |
mmh = (Z / a_coeff) ** (1 / b_coeff) | |
return mmh | |
def mmh2rad(mmh, a_coeff=200, b_coeff=1.6): | |
Z = (mmh ** b_coeff) * a_coeff | |
dbz = 10 * np.log10(Z) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import geohash | |
import xarray as xr | |
array = xr.DataArray(np.array([[1, 2, 3], [4, 5, 6]]), coords=[("lat", [36, 37]), ("lon", [12, 13, 14])]) | |
lat_arr, lon_arr = xr.broadcast(array.lat, array.lon) | |
f = lambda y, x: geohash.encode(y, x, 7) | |
array_geohash = xr.apply_ufunc(f, lat_arr, lon_arr, vectorize=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import psycopg2 | |
from rasterio.io import MemoryFile | |
conn = pscopg2.connect("<connection string>") | |
cur = conn.cursor() | |
# ensure that the GTiff driver is available, | |
# see https://postgis.net/docs/postgis_gdal_enabled_drivers.html | |
cur.execute(''' | |
SET postgis.gdal_enabled_drivers TO 'GTiff'; | |
WITH temp as ( |