This file contains hidden or 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 nctoolkit as nc | |
ds = nc.open_data("IASI_METOPA_L2_CO_20190921_ULB-LATMOS_V6.4.0.nc") | |
ds.assign(mask = lambda x: x.longitude > 0 and x.longitude < 180 and x.latitude > 77 and x.latitude < 80, drop = True) | |
# ds.set_missing(0) | |
time_steps = list(ds.to_dataframe().reset_index().reset_index(drop = True).query("mask == 1").index) | |
time_steps = [x for x in time_steps] | |
ds.select(time = time_steps) | |
ds.to_nc("cropped.nc") |
This file contains hidden or 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 os | |
from collections import OrderedDict | |
# Function to read line and then replace words based on what is in the dictionary ### | |
def replace_all(text, dic): | |
for i, j in dic.iteritems(): | |
text = text.replace(i, j) | |
return text | |
This file contains hidden or 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
library(tidyverse) | |
library(ggthemes) | |
library(animation) | |
library(cowplot) | |
library(ggpub) | |
library(readxl) | |
library(geonames) | |
This file contains hidden or 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
# simple function to left join countries based on country names. Works with varients; UK/United Kingdom etc. | |
country_join <- function(x,y, by = "Country"){ | |
col_2use <- sym(by) | |
dplyr::mutate(x, country_code54321 = countrycode::countrycode(!!col_2use, "country.name", "iso3c")) %>% | |
left_join( |
This file contains hidden or 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
library(tidyverse) | |
library(ncdf4) | |
bin_value <- function(x, bin_res) { | |
floor((x + bin_res / 2) / bin_res + 0.5) * bin_res - bin_res / 2 | |
} | |
This file contains hidden or 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
library(tidyverse) | |
library(ncdf4) | |
bin_value <- function(x, bin_res) { | |
floor((x + bin_res / 2) / bin_res + 0.5) * bin_res - bin_res / 2 | |
} | |
This file contains hidden or 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 os | |
rootdir = '.' | |
# List of possible mirrors. This potentially needs to be updated over time as they update the mirrors | |
import urllib2 |
This file contains hidden or 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
library(pryr) | |
library(tidyverse) | |
x <- data.frame(x = 1:1000) | |
y <- x | |
object_size(x)+ object_size(y) | |
object_size(x,y) |
This file contains hidden or 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
library(tidyverse) | |
order_conflicts <- function(fun, df){ | |
find(fun) %>% | |
stringr::str_replace_all("package:", "") | |
} | |
conflictr <- function(){ |
This file contains hidden or 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
x <- 1:10^4 | |
sum_all <- function(x){ | |
sum_all <- 0 | |
for(i in 1:length(x)) | |
sum_all <- sum_all + x[i] | |
sum_all | |
} | |
sum_all_cmp <- compiler::cmpfun(sum_all) |
NewerOlder