diff --git a/pds4_utils_example.ipynb b/pds4_utils_example.ipynb new file mode 100644 index 0000000..233498b --- /dev/null +++ b/pds4_utils_example.ipynb @@ -0,0 +1,373 @@ +{ + "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 pds4_utils" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "\u001b[0;31mSignature:\u001b[0m \u001b[0mpds4_utils\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[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 ~/Dropbox/work/bepi/software/pds4_utils/pds4_utils/pds4_utils.py\n", + "\u001b[0;31mType:\u001b[0m function\n" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "pds4_utils.index_products?" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "INFO 2020-05-25 17:36:02 (pds4_utils.pds4_utils): 406 PDS4 labels indexed\n" + ] + } + ], + "source": [ + "idx = pds4_utils.index_products(directory='/home/mbentley/Desktop/bc_mtm_mcam/')" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
filenameproduct_typelidvidstart_timestop_timebundlecollectionproduct_id
0/home/mbentley/Desktop/bc_mtm_mcam/browse/crui...Product_Browseurn:esa:psa:bc_mtm_mcam:browse:cam_raw_sc_cam1...1.0NaTNaTbc_mtm_mcambrowsecam_raw_sc_cam1_browse_20200515t024802_00_f__t...
1/home/mbentley/Desktop/bc_mtm_mcam/browse/crui...Product_Browseurn:esa:psa:bc_mtm_mcam:browse:cam_raw_sc_cam1...1.0NaTNaTbc_mtm_mcambrowsecam_raw_sc_cam1_browse_20200515t025757_00_f__t...
2/home/mbentley/Desktop/bc_mtm_mcam/browse/crui...Product_Browseurn:esa:psa:bc_mtm_mcam:browse:cam_raw_sc_cam1...1.0NaTNaTbc_mtm_mcambrowsecam_raw_sc_cam1_browse_20200515t030752_00_f__t...
3/home/mbentley/Desktop/bc_mtm_mcam/browse/crui...Product_Browseurn:esa:psa:bc_mtm_mcam:browse:cam_raw_sc_cam1...1.0NaTNaTbc_mtm_mcambrowsecam_raw_sc_cam1_browse_20200515t031747_00_f__t...
4/home/mbentley/Desktop/bc_mtm_mcam/browse/crui...Product_Browseurn:esa:psa:bc_mtm_mcam:browse:cam_raw_sc_cam1...1.0NaTNaTbc_mtm_mcambrowsecam_raw_sc_cam1_browse_20200515t032742_00_f__t...
\n", + "
" + ], + "text/plain": [ + " filename product_type \\\n", + "0 /home/mbentley/Desktop/bc_mtm_mcam/browse/crui... Product_Browse \n", + "1 /home/mbentley/Desktop/bc_mtm_mcam/browse/crui... Product_Browse \n", + "2 /home/mbentley/Desktop/bc_mtm_mcam/browse/crui... Product_Browse \n", + "3 /home/mbentley/Desktop/bc_mtm_mcam/browse/crui... Product_Browse \n", + "4 /home/mbentley/Desktop/bc_mtm_mcam/browse/crui... Product_Browse \n", + "\n", + " lid vid start_time \\\n", + "0 urn:esa:psa:bc_mtm_mcam:browse:cam_raw_sc_cam1... 1.0 NaT \n", + "1 urn:esa:psa:bc_mtm_mcam:browse:cam_raw_sc_cam1... 1.0 NaT \n", + "2 urn:esa:psa:bc_mtm_mcam:browse:cam_raw_sc_cam1... 1.0 NaT \n", + "3 urn:esa:psa:bc_mtm_mcam:browse:cam_raw_sc_cam1... 1.0 NaT \n", + "4 urn:esa:psa:bc_mtm_mcam:browse:cam_raw_sc_cam1... 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_cam1_browse_20200515t024802_00_f__t... \n", + "1 cam_raw_sc_cam1_browse_20200515t025757_00_f__t... \n", + "2 cam_raw_sc_cam1_browse_20200515t030752_00_f__t... \n", + "3 cam_raw_sc_cam1_browse_20200515t031747_00_f__t... \n", + "4 cam_raw_sc_cam1_browse_20200515t032742_00_f__t... " + ] + }, + "execution_count": 4, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "idx.head()" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
filenameproduct_typelidvidstart_timestop_timebundlecollectionproduct_id
204/home/mbentley/Desktop/bc_mtm_mcam/data_raw/cr...Product_Observationalurn:esa:psa:bc_mtm_mcam:data_raw:cam_raw_sc_ca...1.02020-05-15 02:48:02.9402020-05-15 02:48:02.960bc_mtm_mcamdata_rawcam_raw_sc_cam1_image_20200515t024802_00_f__t0020
205/home/mbentley/Desktop/bc_mtm_mcam/data_raw/cr...Product_Observationalurn:esa:psa:bc_mtm_mcam:data_raw:cam_raw_sc_ca...1.02020-05-15 02:57:57.9302020-05-15 02:57:57.950bc_mtm_mcamdata_rawcam_raw_sc_cam1_image_20200515t025757_00_f__t0020
206/home/mbentley/Desktop/bc_mtm_mcam/data_raw/cr...Product_Observationalurn:esa:psa:bc_mtm_mcam:data_raw:cam_raw_sc_ca...1.02020-05-15 03:07:52.9302020-05-15 03:07:52.950bc_mtm_mcamdata_rawcam_raw_sc_cam1_image_20200515t030752_00_f__t0020
207/home/mbentley/Desktop/bc_mtm_mcam/data_raw/cr...Product_Observationalurn:esa:psa:bc_mtm_mcam:data_raw:cam_raw_sc_ca...1.02020-05-15 03:17:47.9402020-05-15 03:17:47.960bc_mtm_mcamdata_rawcam_raw_sc_cam1_image_20200515t031747_00_f__t0020
208/home/mbentley/Desktop/bc_mtm_mcam/data_raw/cr...Product_Observationalurn:esa:psa:bc_mtm_mcam:data_raw:cam_raw_sc_ca...1.02020-05-15 03:27:42.9402020-05-15 03:27:42.960bc_mtm_mcamdata_rawcam_raw_sc_cam1_image_20200515t032742_00_f__t0020
\n", + "
" + ], + "text/plain": [ + " filename product_type \\\n", + "204 /home/mbentley/Desktop/bc_mtm_mcam/data_raw/cr... Product_Observational \n", + "205 /home/mbentley/Desktop/bc_mtm_mcam/data_raw/cr... Product_Observational \n", + "206 /home/mbentley/Desktop/bc_mtm_mcam/data_raw/cr... Product_Observational \n", + "207 /home/mbentley/Desktop/bc_mtm_mcam/data_raw/cr... Product_Observational \n", + "208 /home/mbentley/Desktop/bc_mtm_mcam/data_raw/cr... Product_Observational \n", + "\n", + " lid vid \\\n", + "204 urn:esa:psa:bc_mtm_mcam:data_raw:cam_raw_sc_ca... 1.0 \n", + "205 urn:esa:psa:bc_mtm_mcam:data_raw:cam_raw_sc_ca... 1.0 \n", + "206 urn:esa:psa:bc_mtm_mcam:data_raw:cam_raw_sc_ca... 1.0 \n", + "207 urn:esa:psa:bc_mtm_mcam:data_raw:cam_raw_sc_ca... 1.0 \n", + "208 urn:esa:psa:bc_mtm_mcam:data_raw:cam_raw_sc_ca... 1.0 \n", + "\n", + " start_time stop_time bundle collection \\\n", + "204 2020-05-15 02:48:02.940 2020-05-15 02:48:02.960 bc_mtm_mcam data_raw \n", + "205 2020-05-15 02:57:57.930 2020-05-15 02:57:57.950 bc_mtm_mcam data_raw \n", + "206 2020-05-15 03:07:52.930 2020-05-15 03:07:52.950 bc_mtm_mcam data_raw \n", + "207 2020-05-15 03:17:47.940 2020-05-15 03:17:47.960 bc_mtm_mcam data_raw \n", + "208 2020-05-15 03:27:42.940 2020-05-15 03:27:42.960 bc_mtm_mcam data_raw \n", + "\n", + " product_id \n", + "204 cam_raw_sc_cam1_image_20200515t024802_00_f__t0020 \n", + "205 cam_raw_sc_cam1_image_20200515t025757_00_f__t0020 \n", + "206 cam_raw_sc_cam1_image_20200515t030752_00_f__t0020 \n", + "207 cam_raw_sc_cam1_image_20200515t031747_00_f__t0020 \n", + "208 cam_raw_sc_cam1_image_20200515t032742_00_f__t0020 " + ] + }, + "execution_count": 6, + "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.6.10" + } + }, + "nbformat": 4, + "nbformat_minor": 4 +}