Skip to content

Instantly share code, notes, and snippets.

View weech's full-sized avatar

Alex Weech weech

View GitHub Profile
@weech
weech / cartopy_julia_example.jl
Created January 8, 2019 03:50
Example of using Cartopy in Julia with PyPlot.jl
using PyCall
using PyPlot
@pyimport cartopy.crs as ccrs
plot_proj = ccrs.LambertCylindrical(central_longitude=180)
data_proj = ccrs.PlateCarree()
lons = collect([i for j in -90:90, i in -180:180]) # Important to collect before passing to PyPlot
lats = collect([j for j in -90:90, i in -180:180])
data = sin.((lons .+ lats) ./ 180 .* π)
@weech
weech / npdate_to_pydate.py
Created September 10, 2018 19:14
Convert a numpy datetime64 to a python datetime.datetime
import datetime as dt
import numpy as np
def to_datetime(date: np.datetime64) -> dt.datetime:
""" Converts a numpy datetime64 object to a python datetime object """
timestamp = ((date - np.datetime64('1970-01-01T00:00:00'))
/ np.timedelta64(1, 's'))
return dt.datetime.utcfromtimestamp(timestamp)