Skip to content

Instantly share code, notes, and snippets.

View AlexHilson's full-sized avatar

Alex Hilson AlexHilson

  • Met Office
  • Exeter
View GitHub Profile
@AlexHilson
AlexHilson / regrid.py
Last active July 16, 2020 13:57
Iris regridding spherical vs. ellipsoid
import numpy as np
import iris
spherical_crs = iris.coord_systems.GeogCS(semi_major_axis=6367470)
ellipsoid_crs = iris.coord_systems.GeogCS(semi_major_axis=6378137.0, semi_minor_axis=6356752.314140356)
lambert_azimuthal_crs = iris.coord_systems.LambertAzimuthalEqualArea(
latitude_of_projection_origin=54.9,
longitude_of_projection_origin=-2.5,
false_easting=0.0, false_northing=0.0,
ellipsoid=ellipsoid_crs)
@AlexHilson
AlexHilson / mdda_test.py
Created April 21, 2020 19:38
MDDA + Iris example
'''
this was hacked together sorry if it doesn't work... let me know :)
gdal + iris are best installed with conda
gdal is used for a neat trick to read the grib array straight into memory
that's not strictly necessary - if you wrote the data to a temp file you
could probably use iris-grib instead.
If you're using this seriously set your chunk size with care. e.g. if you
create a big cube with, say, 1x1x2560x1920 chunks, then try to pull 1 point from 33 chunks
@AlexHilson
AlexHilson / directives.json
Created June 20, 2018 10:10
Example Alexa response with directives
{
"version": "1.0",
"response": {
"outputSpeech": {
"type": "SSML",
"ssml": "<speak> <say-as interpret-as=\"interjection\">dun dun dun.</say-as> Check out the big brains over here. Are you ready to begin? </speak>"
},
"directives": [
{
"type": "Display.RenderTemplate",
@AlexHilson
AlexHilson / gist:250b45700ba837803697a4fb7bb50c10
Last active June 18, 2018 14:00
alexa_response_with_card.json
"response":{
"outputSpeech":{
"type":"PlainText",
"text":"In Devon there is an amber weather warning for snow. The weather forecast for Exeter is cloudy and is highly likely to remain dry. There will be a high of 20 degrees Celcius and a low of 16. Would you like to hear more?"
},
"card":{
"type":"Standard",
"title":"Severe Weather Warnings for Devon",
"text":"An amber weather warning for snow has been issued where heavy snow is likely to affect many areas and bring severe disruption to travel.\n\nPlease see the Met Office website for further details.",
"image":{
@AlexHilson
AlexHilson / pad_and_merge_cubes.ipynb
Created September 5, 2017 17:14
Merge 4 model runs of data into one object
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@AlexHilson
AlexHilson / simple_mean.ipynb
Created May 4, 2017 12:25
Simple mean example
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@AlexHilson
AlexHilson / load_and_persist_mogreps.ipynb
Last active May 19, 2018 14:45
Load and Persist MOGREPS-G data
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@AlexHilson
AlexHilson / download_load_and_persist_mogreps.ipynb
Created May 4, 2017 12:23
Download Load and Persist MOGREPS-G data
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@AlexHilson
AlexHilson / iris_dask.ipynb
Last active February 15, 2017 19:36
Working with Dask + Iris
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.