https://github.com/hrbrmstr/albersusa
specifically:
This file contains 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
# Various tests with Common Alert Protocal (CAP) feeds at https://severeweather.wmo.int/v2/ | |
from datetime import datetime, timedelta | |
import requests | |
import re | |
#import xmltodict | |
import feedparser | |
from capparselib.parsers import CAPParser |
This file contains 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
# Built-in modules | |
import os | |
import datetime | |
import itertools | |
from glob import glob | |
from aenum import MultiValueEnum | |
# Basics of Python data handling and visualization | |
import numpy as np |
This file contains 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) | |
timing_results = tribble( | |
~treatment, ~object, ~mouse_id, ~time, | |
'vehicle', 'familiar', '1', 15, | |
'vehicle', 'novel', '1', 55, | |
'vehicle', 'familiar', '2', 19, | |
'vehicle', 'novel', '2', 60, |
This file contains 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
def processSpecies(speciesName): | |
#do stuff for this species | |
return(result) | |
speciesList=['a','b','c','d'] | |
############################################# | |
#how stuff is typically done | |
results=[] | |
for species in speciesList: |
This file contains 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
conda create --name geo python=3.8 | |
conda activate geo | |
# with a spyder install outside the geo environment, but | |
# pointing to the geo environment bin/python, the following | |
# must be installed in the geo env to get the spyder ipython console working | |
pip install spyder-kernels~=2.0.0 | |
# primary geospatial things | |
pip install xarray rasterio geopandas numpy pandas scipy netcdf4 dask |
This file contains 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) | |
identify_continuous_non_zero_series = function(df, min_sequence_size =5){ | |
# adds a new column called 'continuous_series' to the df data.frame | |
# identifying where 'value' column is >0 for at least min_sequence_size | |
# filter to only continous chunks > 0, assign each an ID, | |
# and flag each chunk >= min_sequence_size. | |
# the cumsum() trick is from https://stackoverflow.com/a/42734207/6615512 | |
temp_df = df %>% |
This file contains 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) | |
#------------------------------------ | |
# Have x-axis labels offset slightly for clarity using guide_axis(n.dodge = 2), | |
# but also have different length tickmarks to make it look nicer. | |
# See https://twitter.com/ecologyofgavin/status/1344102509585997824 | |
# Derived from https://stackoverflow.com/a/51312611/6615512 | |
# Requires ggplot 3.0.0 or greater | |
#------------------------------------ |
This file contains 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) | |
# Create a "date bin" data.frame with columns c('start','end') | |
# start_date, and last_date are dates | |
# time_bin_size should be string like '1 year','6 month', etc. see ?seq.Date for more examples | |
bin_dates = function(first_date, last_date, time_bin_size='1 year'){ | |
if(!(lubridate::is.Date(first_date) & lubridate::is.Date(last_date))) stop('first_date and last_date must be dates') | |
if(first_date>=last_date) stop('first_date must come before last date') | |
full_range = seq.Date(first_date,last_date, by=time_bin_size) |
This file contains 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(sf) | |
# where lon, lat are columns for longitude, latitude, respectively. | |
# Any other columns are retained in the sf data.frame. | |
read_csv('site_list.csv') %>% | |
st_as_sf(coords = c('lon','lat'), crs=4326) | |
NewerOlder