{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# pds4_utils example\n",
"\n",
"This is a work-in-progress notebook demonstrating how to use the psd4_utils module."
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"from pds4_utils import read, write, dbase, cdf_utils"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[0;31mSignature:\u001b[0m \u001b[0mdbase\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mindex_products\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mdirectory\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;34m'.'\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mpattern\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;34m'*.xml'\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mrecursive\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mTrue\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;31mDocstring:\u001b[0m\n",
"Accepts a directory containing PDS4 products, indexes the labels and returns a \n",
"Pandas data-frame containng meta-data for each product.\n",
"\u001b[0;31mFile:\u001b[0m ~/Library/CloudStorage/OneDrive-ESA/work/bepi/software/pds4_utils/pds4_utils/dbase.py\n",
"\u001b[0;31mType:\u001b[0m function\n"
]
}
],
"source": [
"dbase.index_products?"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO 2022-10-21 15:33:36,705 (pds4_utils.dbase): 202 PDS4 labels indexed\n"
]
}
],
"source": [
"idx = dbase.index_products(directory='/Users/mbentley/Desktop/bc_mtm_mcam/')"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"
\n",
"\n",
"
\n",
" \n",
" \n",
" | \n",
" filename | \n",
" product_type | \n",
" lid | \n",
" vid | \n",
" start_time | \n",
" stop_time | \n",
" bundle | \n",
" collection | \n",
" product_id | \n",
"
\n",
" \n",
" \n",
" \n",
" 0 | \n",
" /Users/mbentley/Desktop/bc_mtm_mcam/browse/cru... | \n",
" Product_Browse | \n",
" urn:esa:psa:bc_mtm_mcam:browse:cam_raw_sc_cam3... | \n",
" 1.0 | \n",
" NaT | \n",
" NaT | \n",
" bc_mtm_mcam | \n",
" browse | \n",
" cam_raw_sc_cam3_browse_20220822t000002_61_f__t... | \n",
"
\n",
" \n",
" 1 | \n",
" /Users/mbentley/Desktop/bc_mtm_mcam/browse/cru... | \n",
" Product_Browse | \n",
" urn:esa:psa:bc_mtm_mcam:browse:cam_raw_sc_cam3... | \n",
" 1.0 | \n",
" NaT | \n",
" NaT | \n",
" bc_mtm_mcam | \n",
" browse | \n",
" cam_raw_sc_cam3_browse_20220823t000002_61_f__t... | \n",
"
\n",
" \n",
" 2 | \n",
" /Users/mbentley/Desktop/bc_mtm_mcam/browse/cru... | \n",
" Product_Browse | \n",
" urn:esa:psa:bc_mtm_mcam:browse:cam_raw_sc_cam3... | \n",
" 1.0 | \n",
" NaT | \n",
" NaT | \n",
" bc_mtm_mcam | \n",
" browse | \n",
" cam_raw_sc_cam3_browse_20220823t082732_10_f__t... | \n",
"
\n",
" \n",
" 3 | \n",
" /Users/mbentley/Desktop/bc_mtm_mcam/browse/cru... | \n",
" Product_Browse | \n",
" urn:esa:psa:bc_mtm_mcam:browse:cam_raw_sc_cam3... | \n",
" 1.0 | \n",
" NaT | \n",
" NaT | \n",
" bc_mtm_mcam | \n",
" browse | \n",
" cam_raw_sc_cam3_browse_20220823t082744_11_f__t... | \n",
"
\n",
" \n",
" 4 | \n",
" /Users/mbentley/Desktop/bc_mtm_mcam/browse/cru... | \n",
" Product_Browse | \n",
" urn:esa:psa:bc_mtm_mcam:browse:cam_raw_sc_cam3... | \n",
" 1.0 | \n",
" NaT | \n",
" NaT | \n",
" bc_mtm_mcam | \n",
" browse | \n",
" cam_raw_sc_cam3_browse_20220823t094046_20_f__t... | \n",
"
\n",
" \n",
"
\n",
"
"
],
"text/plain": [
" filename product_type \\\n",
"0 /Users/mbentley/Desktop/bc_mtm_mcam/browse/cru... Product_Browse \n",
"1 /Users/mbentley/Desktop/bc_mtm_mcam/browse/cru... Product_Browse \n",
"2 /Users/mbentley/Desktop/bc_mtm_mcam/browse/cru... Product_Browse \n",
"3 /Users/mbentley/Desktop/bc_mtm_mcam/browse/cru... Product_Browse \n",
"4 /Users/mbentley/Desktop/bc_mtm_mcam/browse/cru... Product_Browse \n",
"\n",
" lid vid start_time \\\n",
"0 urn:esa:psa:bc_mtm_mcam:browse:cam_raw_sc_cam3... 1.0 NaT \n",
"1 urn:esa:psa:bc_mtm_mcam:browse:cam_raw_sc_cam3... 1.0 NaT \n",
"2 urn:esa:psa:bc_mtm_mcam:browse:cam_raw_sc_cam3... 1.0 NaT \n",
"3 urn:esa:psa:bc_mtm_mcam:browse:cam_raw_sc_cam3... 1.0 NaT \n",
"4 urn:esa:psa:bc_mtm_mcam:browse:cam_raw_sc_cam3... 1.0 NaT \n",
"\n",
" stop_time bundle collection \\\n",
"0 NaT bc_mtm_mcam browse \n",
"1 NaT bc_mtm_mcam browse \n",
"2 NaT bc_mtm_mcam browse \n",
"3 NaT bc_mtm_mcam browse \n",
"4 NaT bc_mtm_mcam browse \n",
"\n",
" product_id \n",
"0 cam_raw_sc_cam3_browse_20220822t000002_61_f__t... \n",
"1 cam_raw_sc_cam3_browse_20220823t000002_61_f__t... \n",
"2 cam_raw_sc_cam3_browse_20220823t082732_10_f__t... \n",
"3 cam_raw_sc_cam3_browse_20220823t082744_11_f__t... \n",
"4 cam_raw_sc_cam3_browse_20220823t094046_20_f__t... "
]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"idx.head()"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
"\n",
"
\n",
" \n",
" \n",
" | \n",
" filename | \n",
" product_type | \n",
" lid | \n",
" vid | \n",
" start_time | \n",
" stop_time | \n",
" bundle | \n",
" collection | \n",
" product_id | \n",
"
\n",
" \n",
" \n",
" \n",
" 102 | \n",
" /Users/mbentley/Desktop/bc_mtm_mcam/data_raw/c... | \n",
" Product_Observational | \n",
" urn:esa:psa:bc_mtm_mcam:data_raw:cam_raw_sc_ca... | \n",
" 1.0 | \n",
" 2022-08-22 00:00:02.782 | \n",
" 2022-08-22 00:00:02.786 | \n",
" bc_mtm_mcam | \n",
" data_raw | \n",
" cam_raw_sc_cam3_image_20220822t000002_61_f__t0004 | \n",
"
\n",
" \n",
" 103 | \n",
" /Users/mbentley/Desktop/bc_mtm_mcam/data_raw/c... | \n",
" Product_Observational | \n",
" urn:esa:psa:bc_mtm_mcam:data_raw:cam_raw_sc_ca... | \n",
" 1.0 | \n",
" 2022-08-23 00:00:02.783 | \n",
" 2022-08-23 00:00:02.787 | \n",
" bc_mtm_mcam | \n",
" data_raw | \n",
" cam_raw_sc_cam3_image_20220823t000002_61_f__t0004 | \n",
"
\n",
" \n",
" 104 | \n",
" /Users/mbentley/Desktop/bc_mtm_mcam/data_raw/c... | \n",
" Product_Observational | \n",
" urn:esa:psa:bc_mtm_mcam:data_raw:cam_raw_sc_ca... | \n",
" 1.0 | \n",
" 2022-08-23 08:27:32.068 | \n",
" 2022-08-23 08:27:32.083 | \n",
" bc_mtm_mcam | \n",
" data_raw | \n",
" cam_raw_sc_cam3_image_20220823t082732_10_f__t0015 | \n",
"
\n",
" \n",
" 105 | \n",
" /Users/mbentley/Desktop/bc_mtm_mcam/data_raw/c... | \n",
" Product_Observational | \n",
" urn:esa:psa:bc_mtm_mcam:data_raw:cam_raw_sc_ca... | \n",
" 1.0 | \n",
" 2022-08-23 08:27:44.165 | \n",
" 2022-08-23 08:27:44.185 | \n",
" bc_mtm_mcam | \n",
" data_raw | \n",
" cam_raw_sc_cam3_image_20220823t082744_11_f__t0020 | \n",
"
\n",
" \n",
" 106 | \n",
" /Users/mbentley/Desktop/bc_mtm_mcam/data_raw/c... | \n",
" Product_Observational | \n",
" urn:esa:psa:bc_mtm_mcam:data_raw:cam_raw_sc_ca... | \n",
" 1.0 | \n",
" 2022-08-23 09:40:46.594 | \n",
" 2022-08-23 09:40:46.609 | \n",
" bc_mtm_mcam | \n",
" data_raw | \n",
" cam_raw_sc_cam3_image_20220823t094046_20_f__t0015 | \n",
"
\n",
" \n",
"
\n",
"
"
],
"text/plain": [
" filename product_type \\\n",
"102 /Users/mbentley/Desktop/bc_mtm_mcam/data_raw/c... Product_Observational \n",
"103 /Users/mbentley/Desktop/bc_mtm_mcam/data_raw/c... Product_Observational \n",
"104 /Users/mbentley/Desktop/bc_mtm_mcam/data_raw/c... Product_Observational \n",
"105 /Users/mbentley/Desktop/bc_mtm_mcam/data_raw/c... Product_Observational \n",
"106 /Users/mbentley/Desktop/bc_mtm_mcam/data_raw/c... Product_Observational \n",
"\n",
" lid vid \\\n",
"102 urn:esa:psa:bc_mtm_mcam:data_raw:cam_raw_sc_ca... 1.0 \n",
"103 urn:esa:psa:bc_mtm_mcam:data_raw:cam_raw_sc_ca... 1.0 \n",
"104 urn:esa:psa:bc_mtm_mcam:data_raw:cam_raw_sc_ca... 1.0 \n",
"105 urn:esa:psa:bc_mtm_mcam:data_raw:cam_raw_sc_ca... 1.0 \n",
"106 urn:esa:psa:bc_mtm_mcam:data_raw:cam_raw_sc_ca... 1.0 \n",
"\n",
" start_time stop_time bundle collection \\\n",
"102 2022-08-22 00:00:02.782 2022-08-22 00:00:02.786 bc_mtm_mcam data_raw \n",
"103 2022-08-23 00:00:02.783 2022-08-23 00:00:02.787 bc_mtm_mcam data_raw \n",
"104 2022-08-23 08:27:32.068 2022-08-23 08:27:32.083 bc_mtm_mcam data_raw \n",
"105 2022-08-23 08:27:44.165 2022-08-23 08:27:44.185 bc_mtm_mcam data_raw \n",
"106 2022-08-23 09:40:46.594 2022-08-23 09:40:46.609 bc_mtm_mcam data_raw \n",
"\n",
" product_id \n",
"102 cam_raw_sc_cam3_image_20220822t000002_61_f__t0004 \n",
"103 cam_raw_sc_cam3_image_20220823t000002_61_f__t0004 \n",
"104 cam_raw_sc_cam3_image_20220823t082732_10_f__t0015 \n",
"105 cam_raw_sc_cam3_image_20220823t082744_11_f__t0020 \n",
"106 cam_raw_sc_cam3_image_20220823t094046_20_f__t0015 "
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"idx[idx.product_type=='Product_Observational'].head()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "bepi",
"language": "python",
"name": "bepi"
},
"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.10.6"
}
},
"nbformat": 4,
"nbformat_minor": 4
}