{ "cells": [ { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "%load_ext autoreload\n", "%autoreload 2\n", "\n", "import os\n", "from pathlib import Path\n", "\n", "import numpy as np\n", "import xarray as xr\n", "from dask.diagnostics import ProgressBar\n", "\n", "from polsarpro.io import open_netcdf_beam\n", "from polsarpro.util import pauli_rgb\n", "\n", "# change to your local C-PolSARpro install dir\n", "# Kept for consistency with the other dev notebooks, but unused in this\n", "# UAVSAR-only variant.\n", "c_psp_dir = \"/home/c_psp/Soft/bin/\"\n", "os.environ[\"PATH\"] += os.pathsep + f\"{c_psp_dir}/data_process_sngl/\"\n", "os.environ[\"PATH\"] += os.pathsep + f\"{c_psp_dir}/data_convert/\"\n", "\n", "input_uavsar_nc = Path(\"/data/psp/test_files/blackw_20801_22010_006_220507_L090_CX_02_ML5X5.nc\")\n", "incidence_angle_file = Path(\n", " \"/data/psp/test_files/blackw_20801_22010_006_220507_L090_CX_02.inc\"\n", ")\n", "file_out = Path(\"/data/psp/res/test_dubois_surface_inversion_uavsar.nc\")\n", "\n", "with xr.open_dataset(input_uavsar_nc) as raw_ds:\n", " center_wavelength_cm = raw_ds[\"metadata\"].attrs[\"Annotation:CenterWavelength\"]\n", "\n", "# Dubois expects GHz; UAVSAR metadata stores the center wavelength in cm.\n", "freq_ghz = 29.9792458 / float(center_wavelength_cm)\n", "\n", "# Leave thresholds as-is for now.\n", "thresh1_db = 0.0\n", "thresh2_db = -10.0\n", "calibration_coeff = 1.0\n", "\n", "print(f\"Derived radar frequency: {freq_ghz:.6f} GHz\")\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Load UAVSAR data and incidence angle raster" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "C3 = open_netcdf_beam(input_uavsar_nc)\n", "row_dim, col_dim = C3.dims\n", "# nlines = C3.sizes[row_dim]\n", "# ncols = C3.sizes[col_dim]\n", "\n", "# use lines from .ann file\n", "# inc.set_rows (pixels) = 12344 ; INC Lines\n", "# inc.set_cols (pixels) = 11248 ; INC Samples\n", "\n", "nlines = 12344\n", "ncols = 11248\n", "\n", "# The incidence-angle file is a little-endian float32 stream in radians.\n", "# Read only the raster-sized prefix and reshape it to the UAVSAR grid.\n", "incidence_angle_values = np.fromfile(\n", " incidence_angle_file,\n", " dtype=\"