Skip to content

Instantly share code, notes, and snippets.

@schwehr
schwehr / explore_enum.py
Created January 30, 2023 21:54
exploring enums in python
#!/usr/bin/env python3
"""Exploring python enum."""
import enum
# from typing import Sequence
class Simple(enum.Enum):
A = 'a'
B = 'b'
@schwehr
schwehr / keywords.txt
Created January 26, 2023 18:20
Earth Engine keywords as of 2023-01-26
16_day
30_year
3_hourly
3dep
4_day
8_day
aafc
aai
abi
aboveground
@schwehr
schwehr / BUILD
Created January 10, 2023 15:18
bazel build of hdf4
# SPDX-License-Identifier: Apache-2.0
# Copyright 2009 Google Inc. All Rights Reserved.
#
# Description:
# NCSA Hierarchical Data Format library
hdf4_copts = [
"-fomit-frame-pointer",
"-DHAVE_CONFIG_H",
"-DBIG_LONGS",
@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: {