Skip to content

Instantly share code, notes, and snippets.

@schwehr
schwehr / xdrposix.c
Last active January 7, 2023 00:22
hdf4 xdrposix.c cleanup ideas
/*
* XDR implementation on POSIX file interface, with buffering
*
* Copyright (C) 1992, University Corp for Atmospheric Research
*
* This set of routines implements a XDR on a POSIX file descriptor.
* XDR_ENCODE serializes onto the descriptor, XDR_DECODE de-serializes
* from the descriptor. As in stdio, we buffer i/o. This XDR is most
* useful when the descriptor actually represents a file. It
* corrects some performance problems with xdrstdio_getpos() and
@schwehr
schwehr / hdf_file_fuzzer.cc
Created December 24, 2022 18:31
An hdf4 fuzzer. This is way too simple, but it has found at least one bug.
#include <stddef.h>
#include <stdint.h>
#include <stdlib.h>
// Copyright 2019 Google LLC.
// SPDX-License-Identifier: Apache-2.0
#include "fuzzer_temp_file.h"
#include "third_party/hdf4/hdf/src/hdf.h"
@schwehr
schwehr / all_keys.py
Last active May 3, 2022 22:43
List all of the variables found across the entire set of ICOADS netcdf ICOADS R3.0.0 data
#!/usr/bin/env python3
# Copyright 2022 Google LLC.
# SPDX-License-Identifier: Apache-2.0
import pathlib
import pprint
import xarray as xr
ignore_attrs = [
@schwehr
schwehr / ORG_SUBORG_dataset_v5.json
Created April 18, 2022 21:13
Example STAC JSON output from Earth Engine catalog entry
{
"description": "Contents of `description.md`.\n",
"gee:type": "image",
"id": "ORG/SUBORG/dataset/v5",
"keywords": [
"coral",
"ocean"
],
"license": "CC-BY-4.0",
"links": [
@schwehr
schwehr / ORG_SUBORG_dataset_v5.jsonnet
Last active April 18, 2022 21:58
Example Earth Engine catalog entry
// Copyright 2022 Google LLC.
// SPDX-License-Identifier: Apache-2.0
local id = 'ORG/SUBORG/dataset/v5';
local subdir = 'ORG';
local ee_const = import 'earthengine_const.libsonnet';
local ee = import 'earthengine.libsonnet';
local spdx = import 'spdx.libsonnet';
local version = 'v5';
@schwehr
schwehr / earthengine.libsonnet
Last active April 18, 2022 20:12
Example helper functions for STAC Jsonnet as of Apr 2022
// Copyright 2022 Google LLC.
// SPDX-License-Identifier: Apache-2.0
local ee_const = import 'earthengine_const.libsonnet';
{
producer_provider(name, url):
{ name: name, roles: ['producer', 'licensor'], url: url },
processor_provider(name, url):
{ name: name, roles: ['processor'], url: url },
extent(xmin, ymin, xmax, ymax, start, end):: {
@schwehr
schwehr / earthengine_const.libsonnet
Last active April 18, 2022 20:07
Example constant definition for STAC Jsonnet as of Apr 2022
// Copyright 2022 Google LLC.
// SPDX-License-Identifier: Apache-2.0
{
stac_version: '1.0.0',
stac_type: {
catalog: 'Catalog',
collection: 'Collection',
item: 'Item',
},
media_type: {
@schwehr
schwehr / ccom.bash
Created April 8, 2022 22:10
CCOM Law of the Sea (LOTS) Extended Continental Shelf (ECS) data
#!/bin/bash
if [[ ! -f orig/Atlantic_ESRI_MOS.zip ]]
then
mkdir orig
pushd orig
# https://ccom.unh.edu/theme/law-sea
@schwehr
schwehr / demo_stac_json_file_validation.py
Created March 23, 2022 20:21
Prototype code to investigate strategies for validating EE STAC
// Copyright 2022 Google LLC.
// SPDX-License-Identifier: Apache-2.0
def check_stac_collection(collection: Dict[str, Any]):
# Field that must always be present
assert jp.parse('$.id').find(collection)
assert jp.parse('$.extent').find(collection)
assert jp.parse('$.extent.spatial').find(collection)
assert jp.parse('$.extent.temporal').find(collection)
assert jp.parse('$.\'gee:terms_of_use\'').find(collection)
@schwehr
schwehr / hycom_demo.js
Created March 15, 2022 16:03
HYCOM Velocity in Google Earth Engine
// Copyright 2019 Google LLC.
// SPDX-License-Identifier: Apache-2.0
//
// Hycom in Earth Engine demo by Kurt Schwehr
//
// https://code.earthengine.google.com/b475a38642624aca72fecafaa3f311ab
var extent = ee.Geometry.Polygon([-180, 80.48, -180, -80.48, 180, -80.48, 180, 80.48], null, false);
// var date_range = ee.Filter.date('2018-08-01', '2018-08-10');