Skip to content

Instantly share code, notes, and snippets.

@anttilipp
anttilipp / trajectoryexample.py
Created December 1, 2023 09:33
Example of a custom trajectory model run for aerosol layers
import numpy as np
import sys
import xarray as xr
from datetime import datetime, timedelta
from scipy.interpolate import RegularGridInterpolator
import os
import time
import joblib
import pandas as pd
import dask
@anttilipp
anttilipp / Blender_ClimateGlassSpheres.py
Created October 25, 2023 05:35
Blender Python script to create the "Climate glass spheres" scene
import bpy
import math
from math import radians
# Use in Blender "Scripting" tab to create a 3D scene with objects, light and camera
# Code mainly written by ChatGPT (GPT-4)
def create_glass_sphere(location, color, radius):
# Deselect all objects
bpy.ops.object.select_all(action='DESELECT')
@anttilipp
anttilipp / plotCovidRiskGraph.py
Created December 19, 2021 09:00
Plots COVID risk graph, probability of infected person present given infection rate in population and number of persons present.
# Antti Lipponen, 18 December 2021
import numpy as np
import matplotlib.pyplot as plt
from scipy.ndimage import zoom
import seaborn as sns
from matplotlib import rcParams
from matplotlib.colors import Normalize
import matplotlib as mpl
from matplotlib.colors import ListedColormap
import matplotlib.patheffects as PathEffects
@anttilipp
anttilipp / Tdata.csv
Created May 19, 2020 18:13
Code and data to reproduce the temperature anomaly animation.
We can make this file beautiful and searchable if this error is corrected: It looks like row 2 should actually have 143 columns, instead of 43 in line 1.
Country,ISOA3,Continent,1880,1881,1882,1883,1884,1885,1886,1887,1888,1889,1890,1891,1892,1893,1894,1895,1896,1897,1898,1899,1900,1901,1902,1903,1904,1905,1906,1907,1908,1909,1910,1911,1912,1913,1914,1915,1916,1917,1918,1919,1920,1921,1922,1923,1924,1925,1926,1927,1928,1929,1930,1931,1932,1933,1934,1935,1936,1937,1938,1939,1940,1941,1942,1943,1944,1945,1946,1947,1948,1949,1950,1951,1952,1953,1954,1955,1956,1957,1958,1959,1960,1961,1962,1963,1964,1965,1966,1967,1968,1969,1970,1971,1972,1973,1974,1975,1976,1977,1978,1979,1980,1981,1982,1983,1984,1985,1986,1987,1988,1989,1990,1991,1992,1993,1994,1995,1996,1997,1998,1999,2000,2001,2002,2003,2004,2005,2006,2007,2008,2009,2010,2011,2012,2013,2014,2015,2016,2017,2018,2019
"Afghanistan","AFG","Asia",-0.325,-0.160,-0.814,-0.773,-0.971,-1.133,-1.123,-0.478,0.088,-0.679,-0.617,-1.107,-0.323,-0.914,-1.006,-0.286,-0.299,-0.759,-0.959,0.192,-0.560,-0.291,0.206,-1.049,-0.403,-0.859,-0.386,-0.973,-0.615,-0.069,-0.620,-0.842,-0.251,-0.432,0.256,0.886,-0.614,-0.067,-0.513,-0.38
@anttilipp
anttilipp / makeSnowdepthFig.py
Last active April 10, 2018 10:27
Python script to construct a snow depth figure
"""
Snow depth figure
version 6 April 2018
by Antti Lipponen
Copyright (c) 2018 Antti Lipponen
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
@anttilipp
anttilipp / readWriteNetCDF.py
Created March 27, 2018 09:09
Demo Python script to write and read netCDF4 files
"""
DEMO TO WRITE AND READ NETCDF FILES
version 27 March 2018
by Antti Lipponen
Copyright (c) 2018 Antti Lipponen
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
@anttilipp
anttilipp / runZonalTempViz.py
Created October 22, 2017 11:12
This is the Python code I used to make the visualization # "Temperature anomalies, zonal means, 1900 - 2016"
#
# Hi all,
# this is the Python code I used to make the visualization
# "Temperature anomalies, zonal means, 1900 - 2016"
# (https://twitter.com/anttilip/status/921809347658895361).
# Please be aware that originally I wrote this just to see how this type
# of visualization would work. The code was not ment to be published
# and therefore has only a couple of/no comments and is most likely
# not written in the most optimal way.
#
@anttilipp
anttilipp / oceanTemperatureAnomalies.py
Created August 20, 2017 18:41
Python / matplotlib code & data to construct the sea surface temperature anomaly visualization
#
# Hi,
# this is the Python code I used to make the sea surface temperature anomaly
# visualization https://twitter.com/anttilip/status/899005930141921280.
# This is a version in which the AREA of the circle represents the temperature
# anomaly (not radius).
# The data is included in this file but I plan to write some kind of tutorial
# in the near future how the average temperatures were computed (using GDAL
# and suitable masks).
# Feel free to improve, modify, do whatever you want with this code. If you decide
@anttilipp
anttilipp / temperatureCircle.py
Created August 2, 2017 21:50
Code to reproduce the "Temperature Circle" visualization.
#
# Hi all,
# this is the Python code I used to make the visualization "Temperature circle"
# (https://twitter.com/anttilip/status/892318734244884480).
# Please be aware that originally I wrote this for my tests only so the
# code was not ment to be published and is a mess and has no comments.
# Feel free to improve, modify, do whatever you want with it. If you decide
# to use the code, make an improved version of it, or it is useful for you
# in some another way I would be happy to know about it. You can contact me
# for example in Twitter (@anttilip). Unchecked demo data (no quarantees)
@anttilipp
anttilipp / solarzenithazimuthdemo.py
Last active April 6, 2024 09:21
Demo code to compute + visualize solar zenith angle and solar azimuth angle in Python
"""
DEMO TO COMPUTE SOLAR ZENITH ANGLE
version 6 April 2017
by Antti Lipponen
Copyright (c) 2017 Antti Lipponen
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including