Skip to content

Instantly share code, notes, and snippets.

View jpswinski's full-sized avatar

JP Swinski jpswinski

  • NASA
  • Goddard Space Flight Center
View GitHub Profile
from sliderule import icesat2
# Configure SlideRule #
icesat2.init("icesat2sliderule.org")
# Setup Datasets to Read
datasets = [ {"dataset": "/gt1l/land_ice_segments/h_li", "col": 0, "startrow": 0, "numrows": -1} ]
# Read Dataset #
heights = icesat2.h5p(datasets, "ATL06_20190626143632_13640310_004_01.h5", "nsidc-s3")
@jpswinski
jpswinski / distance_compare.py
Created June 8, 2022 13:08
Plot photons against SlideRule elevations with the x-axis being distance in order to verify distance alignment.
# Imports
from sliderule import icesat2
import matplotlib.pyplot as plt
import numpy as np
import logging
# Settings
url = "icesat2sliderule.org"
asset = "nsidc-s3"
verbose = True
@jpswinski
jpswinski / kmeans_demo.py
Last active June 8, 2022 13:26
Demonstrate using k means clustering on a GeoDataFrame
# Imports
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
from sklearn.cluster import KMeans
import geopandas as gp
# Read in shapefile
gdf = gp.read_file("01_rgi60_Alaska.shp")
@jpswinski
jpswinski / atl08_missing_track.py
Created June 9, 2022 12:41
Read ATL08 file that is missing track 3
# Imports
from sliderule import icesat2
# Initialize Client
icesat2.init("icesat2sliderule.org", True)
# Setup Datasets to Read
datasets = [ {"dataset": "/gt3r/signal_photons/classed_pc_indx", "col": 0, "startrow": 0, "numrows": -1} ]
# Read Dataset #
@jpswinski
jpswinski / big_yapc.py
Last active July 7, 2022 15:53
Submits a large YAPC request that takes a lot of time to process
# Imports
from sliderule import icesat2
# Settings
url = "icesat2sliderule.org"
asset = "nsidc-s3"
verbose = True
# Initialize Client
icesat2.init(url, verbose=verbose)
@jpswinski
jpswinski / geoparquet.cpp
Last active August 8, 2024 04:23
Minimal example C++ code to write a GeoParquet file using Apache Arrow
/*
* File: geoparquet.cpp
*
* Purpose: A minimal example to build a GeoParquet file using Apache Arrow.
*
* Prerequisites: The Apache Arrow library is needed and can be installed as follows
* $ git clone https://github.com/apache/arrow.git
* $ cd arrow/cpp
* $ mkdir build
* $ cd build