Giter Site home page Giter Site logo

abarbour / yhs.catalog Goto Github PK

View Code? Open in Web Editor NEW
1.0 2.0 1.0 168.38 MB

The Yang, Hauksson, and Shearer (2012) focal mechanism catalog for southern California in R

Home Page: https://zenodo.org/record/807720

Makefile 13.58% Shell 12.51% R 73.91%
earthquakes dataset r california

yhs.catalog's Introduction

yhs.catalog Build Status License DOI

This is an R package which bundles the Yang, Hauksson, and Shearer (2012) relocated focal mechanism catalog together.

A note on the version number: the patch version represents the year and month the dataset was last updated (e.g. 20150301 would be 01-March-2015).

Example

Install the package:

if (!require(devtools)) install.packages("devtools")
devtools::install_github("abarbour/yhs.catalog")

Load the package (lazy loading is enabled, so datasets are attached by default):

library(yhs.catalog)

Inspect the data:

class(yhs)
str(yhs)

Tabulate classifications:

with(yhs,{
    Tsr <- table(Source, Quality)
    Tyr <- table(Year, Quality)
})
plot(Tsr)
plot(Tyr)

Plot in spatial coordinates by year:

library(viridis)
library(raster)

calif <- ggplot2::map_data("state", region = 'california')

r <- raster(xmn=-123, xmx=-114, ymn=31, ymx=37, resolution=0.1)
coordinates(r) %>% as_data_frame %>% dplyr::rename(Lon=x, Lat=y) -> crds
re <- extent(r)

year_raster <- function(DatY){
  DatY %>% dplyr::select(Lon.deg, Lat.deg) -> dmat
  as.data.frame(rasterize(dmat, r, fun='count')) %>% 
	dplyr::rename(Count = layer) %>%
	dplyr::mutate(Density = Count / max(Count, na.rm=TRUE), logCount = log10(Count)) -> .ry.
  cbind(crds, .ry.)
}

yhs %>% dplyr::group_by(Year) %>% dplyr::do(year_raster(.)) -> Allyears

p <- ggplot(Allyears, aes(x=Lon, y=Lat)) + 
  geom_raster(aes(fill = logCount)) +
  coord_quickmap() + 
  facet_wrap(~Year)+
  scale_fill_viridis(option="plasma", direction=-1, na.value="grey90")+
  geom_path(data=calif, aes(x=long, y=lat, group = group), colour="lightgrey")+
  geom_path(data=saltonsea, aes(x=Lon.deg, y=Lat.deg), colour="lightgrey")+
  theme_minimal() +
  theme(axis.text = element_text(size=6),
		axis.title = element_text(size=10, hjust=0),
		plot.title = element_text(size=12,face="bold"),
		legend.position=c(0.83,-0.07),
		legend.direction="horizontal") +
  xlim(re[1], re[2])+
  ylim(re[3], re[4])+
  xlab("Longitude") + 
  ylab("Latitude") +
  ggtitle("Earthquake Densities in Southern California")

alt text

yhs.catalog's People

Contributors

abarbour avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Forkers

dp01101100

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.