-
Notifications
You must be signed in to change notification settings - Fork 4
QC data filtering and non-standard product loading #79
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
3b581b8
Test of a basic QC filter
thomasteisberg 2d35954
Basic support for loading unlisted data products
thomasteisberg dca2cce
Add new notebooks to docs listing
thomasteisberg bdd5241
Add new QC checks
thomasteisberg c193dbd
Ruff fixes
thomasteisberg 7c177d6
Temporarily pin duckdb to workaround test failures
thomasteisberg 80d83ec
Claude-generated unit tests
thomasteisberg 37cf032
Ruff fixes
thomasteisberg 410ae81
Individual image loading support
thomasteisberg f82e520
Ruff fixes
thomasteisberg eeffb6f
Revert "Temporarily pin duckdb to workaround test failures"
thomasteisberg 65e64e7
Fix whitespace
thomasteisberg e4a4d52
Demo of repicking options
thomasteisberg e4e156f
Add repicking notebook to TOC
thomasteisberg db41c4f
Fix callout formatting
thomasteisberg f939df4
Vectorized bed picks and notebook format fixes
thomasteisberg File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,201 @@ | ||
| { | ||
| "cells": [ | ||
| { | ||
| "cell_type": "markdown", | ||
| "id": "1772a2d7", | ||
| "metadata": {}, | ||
| "source": [ | ||
| "---\n", | ||
| "title: Loading non-standard data products\n", | ||
| "description: How to use xOPR to load unlisted (non-standard) data products\n", | ||
| "date: 2026-04-23\n", | ||
| "---\n", | ||
| "\n", | ||
| ":::{warning}\n", | ||
| "This is an advanced feature and most users can probably ignore it. If you want to load non-standard data products, such as either a custom processing type or individual \"images\" (often corresponding to high and low gain channels), read on.\n", | ||
| ":::\n", | ||
| "\n", | ||
| "By default, xOPR uses a pre-generated STAC catalog of radar data segments and loads certain pre-defined data product types into it, assuming they are available. These include OPR data products such as `CSARP_qlook` (unfocused SAR) and `CSARP_standard` (focused SAR). If you want to work with another data product that is publicly available from the OPR servers but hasn't been indexed by the xOPR STAC catalog (either because you just created it or because it's a non-standard data product that we don't index), you can do this by setting the `allow_unlisted_products=True` flag when loading frames.\n", | ||
| "\n", | ||
| "This is a bit of a your-mileage-may-vary feature. xOPR makes a best effort and will probably load most non-standard data products just fine, but a non-standard data product with a completely different format will certainly break things.\n", | ||
| "\n", | ||
| "Feel free to reach out if you have a use case that we don't support (or put in a pull request!).\n", | ||
| "\n", | ||
| "Keep in mind that any data product must be available on the public side of the OPR data website. If you can't find your desired data product at https://data.cresis.ku.edu/data/rds/, then xOPR can't load it either." | ||
| ] | ||
| }, | ||
| { | ||
| "cell_type": "code", | ||
| "execution_count": null, | ||
| "id": "1d5a6e4b", | ||
| "metadata": {}, | ||
| "outputs": [], | ||
| "source": [ | ||
| "%load_ext autoreload\n", | ||
| "%autoreload 2\n", | ||
| "\n", | ||
| "import numpy as np\n", | ||
| "import xarray as xr\n", | ||
| "import geoviews as gv\n", | ||
| "import geoviews.feature as gf\n", | ||
| "import cartopy.crs as ccrs\n", | ||
| "import matplotlib.pyplot as plt\n", | ||
| "\n", | ||
| "import xopr\n", | ||
| "\n", | ||
| "import holoviews as hv\n", | ||
| "import hvplot.xarray\n", | ||
| "import hvplot.pandas\n", | ||
| "hvplot.extension('bokeh')" | ||
| ] | ||
| }, | ||
| { | ||
| "cell_type": "code", | ||
| "execution_count": null, | ||
| "id": "9a567aae", | ||
| "metadata": {}, | ||
| "outputs": [], | ||
| "source": [ | ||
| "# Establish an OPR session\n", | ||
| "opr = xopr.OPRConnection(cache_dir=\"radar_cache\")" | ||
| ] | ||
| }, | ||
| { | ||
| "cell_type": "code", | ||
| "execution_count": null, | ||
| "id": "089dd1ac", | ||
| "metadata": {}, | ||
| "outputs": [], | ||
| "source": [ | ||
| "collection, segment = \"2019_Antarctica_GV\", \"20191105_01\"\n", | ||
| "\n", | ||
| "stac_items = opr.query_frames(collections=collection, segment_paths=[segment], max_items=5)\n", | ||
| "stac_items" | ||
| ] | ||
| }, | ||
| { | ||
| "cell_type": "code", | ||
| "execution_count": null, | ||
| "id": "2df228d2", | ||
| "metadata": {}, | ||
| "outputs": [], | ||
| "source": [ | ||
| "background_map = gf.ocean.opts(projection=ccrs.SouthPolarStereo(), scale='50m') * gf.coastline.opts(projection=ccrs.SouthPolarStereo(), scale='50m')\n", | ||
| "background_map * stac_items.to_crs('EPSG:3031').hvplot(aspect='equal')" | ||
| ] | ||
| }, | ||
| { | ||
| "cell_type": "code", | ||
| "execution_count": null, | ||
| "id": "affbb5d2", | ||
| "metadata": {}, | ||
| "outputs": [], | ||
| "source": [ | ||
| "frames = opr.load_frames(stac_items, data_product=\"CSARP_mvdr\", allow_unlisted_products=True)" | ||
| ] | ||
| }, | ||
| { | ||
| "cell_type": "code", | ||
| "execution_count": null, | ||
| "id": "4d075dd2", | ||
| "metadata": {}, | ||
| "outputs": [], | ||
| "source": [ | ||
| "# Inspect an individual frame\n", | ||
| "frames[0].xopr" | ||
| ] | ||
| }, | ||
| { | ||
| "cell_type": "code", | ||
| "execution_count": null, | ||
| "id": "b65d9bf4", | ||
| "metadata": {}, | ||
| "outputs": [], | ||
| "source": [ | ||
| "flight_line = xopr.merge_frames(frames)\n", | ||
| "\n", | ||
| "stacked = flight_line.resample(slow_time='2s').mean()\n", | ||
| "stacked.xopr\n", | ||
| "\n", | ||
| "fig, ax = plt.subplots(figsize=(15, 4))\n", | ||
| "radargram = 10*np.log10(np.abs(stacked['Data']))\n", | ||
| "radargram.plot.imshow(x='slow_time', cmap='gray', ax=ax)\n", | ||
| "ax.invert_yaxis()\n", | ||
| "\n", | ||
| "ax.set_title(f\"{stacked.attrs['collection']} - {stacked.attrs['segment_path']} - {stacked.attrs['data_product']}\")\n", | ||
| "plt.show()" | ||
| ] | ||
| }, | ||
| { | ||
| "cell_type": "markdown", | ||
| "id": "03ad795e", | ||
| "metadata": {}, | ||
| "source": [ | ||
| "## Loading individual images\n", | ||
| "\n", | ||
| "The `allow_unlisted_products` flag can also be used to enable loading individual \"images\".\n", | ||
| "\n", | ||
| ":::{note}\n", | ||
| "\"Images\" are views of the same segment made from different channels and/or waveforms. They are generally used to capture the full dynamic range between the surface and the bed across different parameters. When you load a default data product, you're actually loading the \"combined\" image, which has been stitched together to build a (hopefully) radiometrically consistent data product.\n", | ||
| "\n", | ||
| "Depending on the system, images usually correspond to either a high and low gain channel and/or a set of different transmit waveforms optimized for shallow or deep sounding.\n", | ||
| ":::" | ||
| ] | ||
| }, | ||
| { | ||
| "cell_type": "code", | ||
| "execution_count": null, | ||
| "id": "aef81f32", | ||
| "metadata": {}, | ||
| "outputs": [], | ||
| "source": [ | ||
| "ds_images = {}\n", | ||
| "for img_idx in range(5):\n", | ||
| " try:\n", | ||
| " if img_idx == 0:\n", | ||
| " img_idx = None\n", | ||
| " img_key = \"combined\"\n", | ||
| " else:\n", | ||
| " img_key = f\"img_{img_idx:02d}\"\n", | ||
| " \n", | ||
| " ds_images[img_key] = opr.load_frame(stac_items.iloc[0], data_product=\"CSARP_qlook\", image=img_idx, allow_unlisted_products=True)\n", | ||
| " except FileNotFoundError:\n", | ||
| " break\n", | ||
| "\n", | ||
| "slow_time_idx = 100\n", | ||
| "\n", | ||
| "fig, ax = plt.subplots(figsize=(12, 4))\n", | ||
| "\n", | ||
| "for img_key, ds_img in ds_images.items():\n", | ||
| " img = 10*np.log10(np.abs(ds_img['Data'].isel(slow_time=slow_time_idx)))\n", | ||
| " img.plot(x='twtt', ax=ax, label=img_key, alpha=0.6)\n", | ||
| "\n", | ||
| "ax.legend()\n", | ||
| "ax.grid()\n", | ||
| "ax.set_ylabel(\"return power [dB]\")\n", | ||
| "plt.show()" | ||
| ] | ||
| } | ||
| ], | ||
| "metadata": { | ||
| "kernelspec": { | ||
| "display_name": "xopr", | ||
| "language": "python", | ||
| "name": "python3" | ||
| }, | ||
| "language_info": { | ||
| "codemirror_mode": { | ||
| "name": "ipython", | ||
| "version": 3 | ||
| }, | ||
| "file_extension": ".py", | ||
| "mimetype": "text/x-python", | ||
| "name": "python", | ||
| "nbconvert_exporter": "python", | ||
| "pygments_lexer": "ipython3", | ||
| "version": "3.13.12" | ||
| } | ||
| }, | ||
| "nbformat": 4, | ||
| "nbformat_minor": 5 | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
:::{info}block directive isn't valid and doesn't render properly -- we need either:tip,warning,important,caution,danger,error,hint,attention,seealso, or the genericadmonition(with a user-supplied title). Guessing either{note}or{tip}...