{ "cells": [ { "cell_type": "markdown", "id": "c08f51d2-b4f2-4350-ace3-be4949d41beb", "metadata": {}, "source": [ "## Read HDF5/MintPy file in Python\n", "\n", "The file structure is described in https://mintpy.readthedocs.io/en/latest/api/data_structure/." ] }, { "cell_type": "code", "execution_count": 1, "id": "43e54a14-ff3e-4a56-af4d-4c53698c7745", "metadata": {}, "outputs": [], "source": [ "%matplotlib inline\n", "import os\n", "import h5py\n", "\n", "fdir = os.path.expanduser('~/data/archives/Galapagos/GalapagosSenDT128/mintpy/geo')" ] }, { "cell_type": "markdown", "id": "9e77b7a3-6a00-4785-b107-a83bea828c5e", "metadata": {}, "source": [ "### 1. Time series\n", "\n", "Run `mask.py geo_timeseries_ERA5_ramp_demErr.h5 -m geo_maskTempCoh.h5` to get the masked time series file." ] }, { "cell_type": "code", "execution_count": 2, "id": "5ec1f90d-b179-4a33-b4dc-358d27390186", "metadata": {}, "outputs": [], "source": [ "fname = os.path.join(fdir, 'geo_timeseries_ERA5_ramp_demErr_msk.h5')\n", "with h5py.File(fname,'r') as f:\n", " data = f['timeseries'][:]\n", " date_list = f['date'][:]\n", "date_list = [x.decode('utf8') for x in date_list]" ] }, { "cell_type": "markdown", "id": "0ad2c145-e8d7-4443-bf79-ba42d6102152", "metadata": {}, "source": [ "where:\n", "+ `date_list` is a list of strings in size of num_date in YYYYMMDD for the SAR acquisition date,\n", "+ `data` is a 3D np.ndarray in size of (num_date, length, width) for the cumulative displacement with respect to the 1st acquisition (which has all zero values in the file) in the unit of meters." ] }, { "cell_type": "markdown", "id": "de79931f-f7a1-481c-948f-15db6a93816d", "metadata": { "tags": [] }, "source": [ "### 2. Velocity\n", "\n", "Run `mask.py geo_velocity.h5 -m geo_maskTempCoh.h5` to get the masked velocity file." ] }, { "cell_type": "code", "execution_count": 3, "id": "36115c2c-8a29-4e08-b537-013751c4636f", "metadata": {}, "outputs": [], "source": [ "fname = os.path.join(fdir, 'geo_velocity_msk.h5')\n", "with h5py.File(fname,'r') as f:\n", " data = f['velocity'][:]" ] }, { "cell_type": "markdown", "id": "7e32e937-1c73-4abb-a4c3-aa51b3934eab", "metadata": {}, "source": [ "where `data` is a 2D np.ndarray in size of (length, width) for the average linear velocity in the unit of meters per year." ] }, { "cell_type": "code", "execution_count": null, "id": "7cec6144-9633-404e-8b32-8024d4ea5b33", "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "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.8.12" } }, "nbformat": 4, "nbformat_minor": 5 }