Published
Edited
Oct 14, 2021
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
header_1 = md `# Basic Statistics`
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
table_codejson_released_since_X_months_ago = Inputs.Table(code_released_since_date)
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
licenses_in_last_x_months = makeListStringWithCommas(licenses_in_last_x_months_array)
Insert cell
licenses_in_last_x_months_array = getUniqueValesOfSomeKeyFromCodeJSON(code_released_since_date,"permissions_license")
Insert cell
Insert cell
Insert cell
codejson = d3.json('https://raw.githubusercontent.com/nasa/Open-Source-Catalog/master/code.json')
Insert cell
catalogjson0 = d3.json('https://raw.githubusercontent.com/nasa/code-nasa-gov/master/data/catalog.json')
Insert cell
table_catalog_json = Inputs.Table(catalogjson0)
Insert cell
table_code_json = Inputs.Table(flatten_code_json(codejson.releases))
Insert cell
code_dot_json_additions = flatten_code_json(codejson.releases)
Insert cell
// Plot.dot(catalogjson0, {x: "Update_Date", y: "Labor_Hours", title: "species"}).plot()
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
codejson_filter_by_date_and_source
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
function filterCodeJSONByDate(codejson,date){
return codejson_array.filter(codejson_array => codejson_array["date"]["metadataLastUpdated"] > date);
}
Insert cell
Insert cell
function filterCodeJSONBySourceNoButton(code_json_array,source){
return code_json_array.filter(code_json_array => code_json_array["permissions"]["usageType"] == source)
}
Insert cell
function getUniqueValesOfSomeKeyFromCodeJSON(code_datasets,key_name){
// function onlyUnique(value, index, self) {
// return self.indexOf(value) === index;
// }
function uniqueArray2(arr) {
var a = [];
for (var i=0, l=arr.length; i<l; i++)
if (a.indexOf(arr[i]) === -1 && arr[i] !== '')
a.push(arr[i]);
return a;
}
var values = []
for (var i = 0; i < code_datasets.length; i++) {
values.push(code_datasets[i][key_name])
}
// var unique_values = values.filter(onlyUnique)
var unique_values = uniqueArray2(values)

return unique_values
}
Insert cell
function makeListStringWithCommas(list){
var phrase = " "
var list_length = list.length
for( var i in list){
if (i < list_length){
phrase = phrase + list[i] + ", "
}
if (i == list_length-1){
phrase = phrase + "and "+list[i]
}
}
return phrase
}
Insert cell
function flatten_code_json(code_dot_json){
// new_array_of_objects = []
for (var i = 0; i < code_dot_json.length; i++) {
var first_human_tag = code_dot_json[i]["tags"][0];
var date_updated = code_dot_json[i]["date"]["metadataLastUpdated"];
try{
var first_sti_keyword = code_dot_json[i]["sti_keywords_passed_thresholds"][0].replace("nlp:","");
}
catch{
var first_sti_keyword = "";
}
var first_language = code_dot_json[i]["languages"][0];
var permissions_license = code_dot_json[i]["permissions"]["licenses"][0]["name"];
code_dot_json[i]["first_human_tag"] = first_human_tag
code_dot_json[i]["first_sti_keyword"] = first_sti_keyword
code_dot_json[i]["first_language"] = first_language
code_dot_json[i]["permissions_license"] = permissions_license
code_dot_json[i]["date_updated"] = date_updated
}
return code_dot_json
}
Insert cell
Insert cell
Insert cell
moment = require('moment')
Insert cell
Insert cell
import {slider} from "@jashkenas/inputs"
Insert cell
Insert cell
import {radio} from "@jashkenas/inputs"
Insert cell
import {date} from "@jashkenas/inputs"
Insert cell
Plot = require("@observablehq/plot@0.1")
Insert cell

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more