Skip to content

Instantly share code, notes, and snippets.

View jgomezdans's full-sized avatar

José Gómez-Dans jgomezdans

View GitHub Profile
@jgomezdans
jgomezdans / SAR_getVZA.ipynb
Last active January 24, 2024 13:45
Sentinel1 from Planetary Computer: Angle of incidence
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@jgomezdans
jgomezdans / run_me.py
Last active December 29, 2023 21:03
testing_frameworks
import numpy as np
import numba
import jax.numpy as jnp
import jax
import time
import torch
import pandas as pd
from functools import partial
@jgomezdans
jgomezdans / split_me.py
Last active October 25, 2023 18:50
Split polygon
import geopandas as gpd
from shapely.geometry import box
from typing import Union
def split_polygon_into_squares(
gdf: gpd.GeoDataFrame,
square_size_km: float,
epsg_code: int
) -> gpd.GeoDataFrame:
"""
@jgomezdans
jgomezdans / convert_grb2.py
Last active August 11, 2023 11:56
grib_convert
# -*- coding: utf-8 -*-
import pandas as pd
import rioxarray as rio
from cfgrib.xarray_to_grib import to_grib
def geotiff_to_grib2(input_geotiff, output_grib2, var_name="signal_mask"):
ds = rio.open_rasterio(input_geotiff)
# Set up a time coordinate.
"""
Downloads data for a location from CAMS data. Needs cdsapi set-up.
"""
from pathlib import Path
import xarray as xr
import cdsapi
import datetime as dt
import logging
import sys
@jgomezdans
jgomezdans / solar_position.ipynb
Created February 8, 2023 18:41
Solar position calculator
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@jgomezdans
jgomezdans / latexdiff.md
Created September 15, 2022 11:48 — forked from adam-binks/latexdiff.md
How to LaTeX diff your Overleaf project

How to LaTeX diff your Overleaf project

Set up local latex environment

Grab the two versions

  • Download the original version
    • Go to Overleaf > history > find the version > view single version > download project at this version
  • Download the current version
@jgomezdans
jgomezdans / meteogram_tamale.py
Created April 28, 2022 14:56
Meteogram for Tamale
import datetime as dt
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
"""
// Import image collection.
var era5_complete = ee.ImageCollection("ECMWF/ERA5_LAND/MONTHLY");
var era5_subset = era5_complete.filterDate('1990-01-01', '2021-01-01');
@jgomezdans
jgomezdans / gist:bb81152d37cf0b5eb3d3fb9c60203bca
Created June 17, 2021 13:37
Point in polygon SQL sqlite
ogr2ogr -f "GeoJSON" YieldsProvince.geojson CountyYield2000_2018.csv \
-dialect "sqlite" \
-sql "select adm.ADM1_EN, adm.ADM2_EN, yield.* " \
"from CountyYield2000_2018 as yield, 'chn_admbnda_adm2_ocha_2020.shp'.chn_admbnda_adm2_ocha_2020 adm" \
"where ST_contains(adm.geometry, yield.geometry)" \
-oo X_POSSIBLE_NAMES=field_4 -oo Y_POSSIBLE_NAMES=field_5
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.