Skip to content

Instantly share code, notes, and snippets.

@ghalimi
Last active August 29, 2015 14:27
Show Gist options
  • Save ghalimi/4d81fb9de4969cecd3bb to your computer and use it in GitHub Desktop.
Save ghalimi/4d81fb9de4969cecd3bb to your computer and use it in GitHub Desktop.
{
"name" : "Earthquakes",
"id" : "/earthquakes",
"version" : "0.2.0",
"description" : "All recorded earthquakes with a magnitude of 6 or greater from 1900 to 2013.",
"author" : "Ismael Chang Ghalimi @ghalimi",
"license" : "MIT",
"dependencies" : {},
"template" : null,
"sheets" : [
{
"name" : "Recordings",
"id" : "recordings",
"type" : "data",
"link" : null,
"spec" : {
"template" : null,
"columns" : [
{
"name" : "ID",
"id" : "id",
"datatype" : "identifier",
"typology" : "nominal",
"options" : { "size" : 32 }
},
{
"name" : "Network",
"id" : "network",
"datatype" : "category",
"typology" : "nominal",
"options" : {
"categories" : [
{ "name" : "Atlas", "id" : "atlas" },
{ "name" : "Centennial", "id" : "centennial" },
{ "name" : "NC", "id" : "nc" },
{ "name" : "Official", "id" : "official" },
{ "name" : "PDE", "id" : "pde" },
{ "name" : "US", "id" : "us" }
]
}
},
{
"name" : "Country",
"id" : "country",
"datatype" : "string",
"typology" : "nominal",
"options" : { "size" : 64 }
},
{
"name" : "Place",
"id" : "place",
"datatype" : "string",
"typology" : "nominal",
"options" : { "size" : 64 }
},
{
"name" : "Timestamp",
"id" : "timestamp",
"datatype" : "timestamp",
"typology" : "incremental"
},
{
"name" : "Date",
"id" : "date",
"datatype" : "date",
"typology" : "incremental",
"options" : { "format" : "%m/%d/%Y" }
},
{
"name" : "Time",
"id" : "time",
"datatype" : "time",
"typology" : "sectorial"
},
{
"name" : "Updated",
"id" : "updated",
"datatype" : "timestamp",
"typology" : "incremental"
},
{
"name" : "Latitude",
"id" : "latitude",
"datatype" : "number",
"typology" : "directional"
},
{
"name" : "Longitude",
"id" : "longitude",
"datatype" : "number",
"typology" : "directional"
},
{
"name" : "Depth",
"id" : "depth",
"datatype" : "number",
"typology" : "intensive"
},
{
"name" : "Magnitude",
"id" : "magnitude",
"datatype" : "number",
"typology" : "intensive"
},
{
"name" : "Type",
"id" : "type",
"datatype" : "category",
"typology" : "nominal",
"options" : {
"categories" : [
{ "id" : "mb" },
{ "id" : "mj" },
{ "id" : "ms" },
{ "id" : "mt" },
{ "id" : "mw" },
{ "id" : "mwb" },
{ "id" : "mwc" },
{ "id" : "mwp" },
{ "id" : "mwr" },
{ "id" : "mww" },
{ "id" : "uk" }
]
}
},
{
"name" : "Reports",
"id" : "reports",
"datatype" : "integer",
"typology" : "cardinal"
},
{
"name" : "Gap",
"id" : "gap",
"datatype" : "number",
"typology" : "directional"
},
{
"name" : "Distance",
"id" : "distance",
"datatype" : "number",
"typology" : "intensive"
},
{
"name" : "RMS",
"id" : "rms",
"datatype" : "number",
"typology" : "intensive"
}
],
"pipelines" : [
{
"name" : "Network Analysis",
"id" : "analysis",
"parameters" : [
{
"name" : "Equator",
"id" : "equator",
"datatype" : "number",
"typology" : "directional",
"default" : 0
}
],
"operations" : [
{
"method" : "CREATE",
"entity" : "table",
"name" : "Earthquakes",
"id" : "earthquakes",
"once" : true,
"preview" : true,
"spec" : {
"sources" : ["http://localhost:4000/test/earthquakes/data.csv"]
}
},
{
"method" : "CREATE",
"entity" : "table",
"name" : "Magnitude Autocorrelation",
"id" : "autocorrelation",
"once" : true,
"preview" : true,
"spec" : {
"columns" : [
{
"name" : "Lag",
"id" : "lag",
"datatype" : "integer",
"typology" : "arrival",
"equation" : { "plus" : ["row", 1] }
},
{
"name" : "Autocorrelation",
"id" : "autocorrelation",
"datatype" : "number",
"typology" : "intensive",
"equation" : { "autocorrelation" : ["magnitude", { "plus" : ["row", 1] }, false] }
}
],
"from" : "earthquakes",
"rows" : 100
}
},
{
"method" : "CREATE",
"entity" : "column",
"name" : "Hemisphere",
"id" : "hemisphere",
"table" : "earthquakes",
"once" : true,
"preview" : true,
"spec" : {
"name" : "Hemisphere",
"id" : "hemisphere",
"datatype" : "category",
"typology" : "nominal",
"options" : {
"categories" : [
{ "name" : "North", "id" : "north" },
{ "name" : "South", "id" : "south" }
]
},
"equation" : { "if" : [{ "ge" : ["latitude", "equator"] }, "north", "south"] }
}
},
{
"method" : "CREATE",
"entity" : "filter",
"name" : "Recent Earthquakes",
"id" : "recent",
"once" : true,
"preview" : true,
"spec" : {
"facets" : [
{
"column" : "date",
"rules" : [{ "operator" : ">", "value" : "2012-03-31" }]
}
]
}
},
{
"method" : "QUERY",
"query" : "pivot",
"id" : "pivot",
"table" : "earthquakes",
"replace" : false,
"recycle" : true,
"result" : true,
"spec" : {
"dimensions" : {
"cols" : ["network", "hemisphere"],
"rows" : []
},
"measures" : [
{
"column" : "magnitude",
"summary" : "average",
"format" : { "background" : null, "text" : null, "value" : ",.1f", "css" : null }
}
],
"blueprint" : {
"visual" : "bar",
"dimensions" : {
"columns" : {
"visualized" : {
"variable" : "network",
"axis" : "horizontal",
"cohorts" : { "variable" : "hemisphere" }
}
}
},
"measures" : [
{
"variable" : "average_magnitude",
"axis" : "height"
}
],
"options" : {
"description" : {
"html" : "<strong>Description</strong><br>Hemisphere computed with <code>IF(d.latitude >= equator, 'north', 'south')</code>",
"height" : "5em"
},
"note" : {
"html" : "<strong>Source:</strong> USGS (United States Geological Survey)"
}
}
}
}
}
]
},
{
"name" : "Magnitude Drop",
"id" : "drop",
"parameters" : [],
"operations" : [
{
"method" : "CREATE",
"entity" : "table",
"name" : "Earthquakes",
"id" : "earthquakes",
"once" : true,
"preview" : true,
"spec" : {
"sources" : ["https://raw.githubusercontent.com/sutoiku/shiny/master/test/earthquakes.csv"]
}
},
{
"method" : "CREATE",
"entity" : "column",
"name" : "Year",
"id" : "year",
"table" : "earthquakes",
"once" : true,
"preview" : true,
"spec" : {
"name" : "Year",
"id" : "year",
"datatype" : "integer",
"typology" : "incremental",
"equation" : { "left" : ["timestamp", 4] }
}
},
{
"method" : "QUERY",
"query" : "pivot",
"id" : "pivot",
"table" : "earthquakes",
"replace" : false,
"recycle" : true,
"result" : true,
"spec" : {
"dimensions" : {
"cols" : ["year"],
"rows" : []
},
"measures" : [
{
"column" : "magnitude",
"summary" : "average"
}
],
"blueprint" : {
"visual" : "line",
"dimensions" : {
"columns" : {
"visualized" : {
"variable" : "year",
"axis" : "horizontal",
"scale" : "linear",
"format" : "d",
"values" : [1900, 1910, 1920, 1930, 1940, 1950, 1960, 1970, 1980, 1990, 2000, 2010, 2020]
}
}
},
"measures" : [
{
"variable" : "average_magnitude",
"axis" : "vertical",
"values" : [6, 7, 8]
}
],
"options" : {
"description" : {
"html" : "<strong>Description</strong><br>Year computed with <code>LEFT(d.timestamp, 4)</code>",
"height" : "5em"
},
"note" : {
"html" : "<strong>Source:</strong> USGS (United States Geological Survey)"
}
}
}
}
}
]
}
]
}
},
{
"name" : "Notebook",
"id" : "notebook",
"type" : "notebook",
"link" : null,
"spec" : {
"template" : null,
"blocks" : [
{
"name" : "Major Earthquakes from 2012 to 2014",
"id" : "intro",
"type" : "html",
"code" : "All recorded earthquakes with a magnitude of 6 or greater from 1900 to 2013 via the <a href='http://earthquake.usgs.gov/earthquakes/search/'>United States Geological Survey</a>. The dataset includes the method used to calculate the preferred magnitude for the event (Type), the total number of seismic stations which reported arrival times for this earthquake (Reports), the azimuthal gap (Gap), the horizontal distance from the epicenter to the nearest station (Distance), and the root-mean-square travel time residual (RMS).",
"collapsed" : true
},
{
"name" : "Bar Chart of Average Magnitude by Network",
"id" : "bar",
"type" : "javascript",
"code" : "PLOT({ sheet : 'recordings', pipeline : 'analysis' })",
"collapsed" : false
},
{
"name" : "Line Chart of Average Magnitude by Year",
"id" : "line",
"type" : "javascript",
"code" : "PLOT('recordings/drop')",
"collapsed" : false
}
]
}
},
{
"name" : "Dashboard",
"id" : "dashboard",
"type" : "dashboard",
"link" : null,
"spec" : {
"template" : null,
"cells" : {
"0" : {
"0" : {
"text" : "=PLOT('recordings/analysis')",
"colspan" : 4,
"rowspan" : 10
},
"4" : {
"text" : "=PLOT('recordings/drop')",
"colspan" : 4,
"rowspan" : 10
}
}
}
}
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment