{ "cells": [ { "cell_type": "markdown", "id": "215c6c96-6dde-4e63-b400-42e1733758b8", "metadata": {}, "source": [ "# User defined Loader" ] }, { "cell_type": "code", "execution_count": 1, "id": "spatial-tonight", "metadata": { "execution": { "iopub.execute_input": "2022-09-15T05:11:39.518651Z", "iopub.status.busy": "2022-09-15T05:11:39.518262Z", "iopub.status.idle": "2022-09-15T05:11:41.175026Z", "shell.execute_reply": "2022-09-15T05:11:41.174482Z" } }, "outputs": [], "source": [ "import pystare\n", "import starepandas\n", "\n", "import geopandas\n", "import numpy\n", "\n", "import matplotlib as mpl\n", "import matplotlib.pyplot as plt" ] }, { "cell_type": "code", "execution_count": 2, "id": "roman-recording", "metadata": { "execution": { "iopub.execute_input": "2022-09-15T05:11:41.177552Z", "iopub.status.busy": "2022-09-15T05:11:41.177349Z", "iopub.status.idle": "2022-09-15T05:11:41.180024Z", "shell.execute_reply": "2022-09-15T05:11:41.179641Z" } }, "outputs": [], "source": [ "DEFAULT_DPI = mpl.rcParamsDefault['figure.dpi']\n", "mpl.rcParams['figure.dpi'] = 1.5 * DEFAULT_DPI\n", "mpl.rcParams['legend.fontsize'] = 6" ] }, { "cell_type": "code", "execution_count": 3, "id": "precious-newspaper", "metadata": { "execution": { "iopub.execute_input": "2022-09-15T05:11:41.181985Z", "iopub.status.busy": "2022-09-15T05:11:41.181760Z", "iopub.status.idle": "2022-09-15T05:11:41.191277Z", "shell.execute_reply": "2022-09-15T05:11:41.190732Z" } }, "outputs": [ { "data": { "text/plain": [ "{'MOD09GA|MYD09GA': starepandas.io.granules.modis.Mod09GA,\n", " 'MOD05|MYD05': starepandas.io.granules.modis.Mod05,\n", " 'MOD03|MYD03': starepandas.io.granules.modis.Mod03,\n", " 'MOD09|MYD09': starepandas.io.granules.modis.Mod09,\n", " 'VNP02DNB|VJ102DNB': starepandas.io.granules.viirsl2.VNP02DNB,\n", " 'VNP03DNB|VJ103DNB': starepandas.io.granules.viirsl2.VNP03DNB,\n", " 'VNP03MOD|VJ103MOD': starepandas.io.granules.viirsl2.VNP03MOD,\n", " 'CLDMSKL2VIIRS': starepandas.io.granules.viirsl2.CLDMSKL2VIIRS,\n", " 'SSMIS': starepandas.io.granules.ssmis.SSMIS,\n", " 'ATMS': starepandas.io.granules.atms.ATMS,\n", " 'MODXX': __main__.ModXX}" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "import starepandas.io.granules.modis\n", "\n", "class ModXX(starepandas.io.granules.modis.Modis):\n", "\n", " def __init__(self, file_path, sidecar_path=None):\n", " super(ModXX, self).__init__(file_path, sidecar_path)\n", " self.nom_res = '5km'\n", "\n", " def read_data(self):\n", " dataset_names = ['Scan_Start_Time', 'Solar_Zenith', 'Solar_Azimuth',\n", " 'Sensor_Zenith', 'Sensor_Azimuth', 'Water_Vapor_Infrared']\n", "\n", " dataset_names2 = ['Cloud_Mask_QA', 'Water_Vapor_Near_Infrared',\n", " 'Water_Vaport_Corretion_Factors', 'Quality_Assurance_Near_Infrared', 'Quality_Assurance_Infrared']\n", " for dataset_name in dataset_names:\n", " self.data[dataset_name] = self.hdf.select(dataset_name).get()\n", " \n", "starepandas.io.granules.granule_factory_library['MODXX']=ModXX\n", "\n", "starepandas.io.granules.granule_factory_library" ] }, { "cell_type": "code", "execution_count": 4, "id": "transparent-boston", "metadata": { "execution": { "iopub.execute_input": "2022-09-15T05:11:41.193257Z", "iopub.status.busy": "2022-09-15T05:11:41.193065Z", "iopub.status.idle": "2022-09-15T05:11:41.195413Z", "shell.execute_reply": "2022-09-15T05:11:41.195039Z" } }, "outputs": [], "source": [ "mod=None" ] }, { "cell_type": "code", "execution_count": 5, "id": "worldwide-calcium", "metadata": { "execution": { "iopub.execute_input": "2022-09-15T05:11:41.197307Z", "iopub.status.busy": "2022-09-15T05:11:41.197071Z", "iopub.status.idle": "2022-09-15T05:11:41.199536Z", "shell.execute_reply": "2022-09-15T05:11:41.199167Z" } }, "outputs": [], "source": [ "granule_name=\"s3://eis-dh-fire/mod14/raw/MOD14.A2020214.0520.061.2020340090643.hdf\"" ] }, { "cell_type": "code", "execution_count": 6, "id": "antique-cancer", "metadata": { "execution": { "iopub.execute_input": "2022-09-15T05:11:41.201478Z", "iopub.status.busy": "2022-09-15T05:11:41.201242Z", "iopub.status.idle": "2022-09-15T05:11:41.203621Z", "shell.execute_reply": "2022-09-15T05:11:41.203254Z" } }, "outputs": [], "source": [ "granule_name=\"../starepandas//datasets/MODXX.hdf\"" ] }, { "cell_type": "code", "execution_count": 7, "id": "anonymous-price", "metadata": { "execution": { "iopub.execute_input": "2022-09-15T05:11:41.205352Z", "iopub.status.busy": "2022-09-15T05:11:41.205171Z", "iopub.status.idle": "2022-09-15T05:11:41.252324Z", "shell.execute_reply": "2022-09-15T05:11:41.251482Z" } }, "outputs": [], "source": [ "mod = starepandas.read_granule(granule_name, sidecar=False, latlon=False, add_stare=True)" ] }, { "cell_type": "code", "execution_count": 8, "id": "minimal-hepatitis", "metadata": { "execution": { "iopub.execute_input": "2022-09-15T05:11:41.255032Z", "iopub.status.busy": "2022-09-15T05:11:41.254764Z", "iopub.status.idle": "2022-09-15T05:11:41.324978Z", "shell.execute_reply": "2022-09-15T05:11:41.324436Z" } }, "outputs": [], "source": [ "mod = starepandas.read_granule(granule_name, sidecar=True, latlon=True)" ] }, { "cell_type": "code", "execution_count": 9, "id": "attractive-electricity", "metadata": { "execution": { "iopub.execute_input": "2022-09-15T05:11:41.327447Z", "iopub.status.busy": "2022-09-15T05:11:41.327224Z", "iopub.status.idle": "2022-09-15T05:11:41.349486Z", "shell.execute_reply": "2022-09-15T05:11:41.348834Z" } }, "outputs": [], "source": [ "mod['stare_hex']=mod['sids'].apply(hex)" ] }, { "cell_type": "code", "execution_count": 10, "id": "viral-windows", "metadata": { "execution": { "iopub.execute_input": "2022-09-15T05:11:41.353658Z", "iopub.status.busy": "2022-09-15T05:11:41.352989Z", "iopub.status.idle": "2022-09-15T05:11:41.391656Z", "shell.execute_reply": "2022-09-15T05:11:41.391133Z" } }, "outputs": [], "source": [ "mod['wiv0']=mod['Water_Vapor_Infrared'].apply(lambda x: min(0,x))" ] }, { "cell_type": "code", "execution_count": 11, "id": "incomplete-greeting", "metadata": { "execution": { "iopub.execute_input": "2022-09-15T05:11:41.394003Z", "iopub.status.busy": "2022-09-15T05:11:41.393799Z", "iopub.status.idle": "2022-09-15T05:11:42.390298Z", "shell.execute_reply": "2022-09-15T05:11:42.389734Z" } }, "outputs": [], "source": [ "mod['pod']=mod['sids'].apply(lambda sid: pystare.spatial_clear_to_resolution(pystare.spatial_coerce_resolution(sid,7)))" ] }, { "cell_type": "code", "execution_count": 12, "id": "chief-container", "metadata": { "execution": { "iopub.execute_input": "2022-09-15T05:11:42.392703Z", "iopub.status.busy": "2022-09-15T05:11:42.392491Z", "iopub.status.idle": "2022-09-15T05:11:42.423196Z", "shell.execute_reply": "2022-09-15T05:11:42.422633Z" } }, "outputs": [], "source": [ "mod['pod_hex']=mod['pod'].apply(lambda sid: hex(sid))" ] }, { "cell_type": "code", "execution_count": 13, "id": "exempt-article", "metadata": { "execution": { "iopub.execute_input": "2022-09-15T05:11:42.425151Z", "iopub.status.busy": "2022-09-15T05:11:42.424900Z", "iopub.status.idle": "2022-09-15T05:11:42.442081Z", "shell.execute_reply": "2022-09-15T05:11:42.441650Z" } }, "outputs": [ { "data": { "text/html": [ "
| \n", " | lat | \n", "lon | \n", "sids | \n", "Scan_Start_Time | \n", "Solar_Zenith | \n", "Solar_Azimuth | \n", "Sensor_Zenith | \n", "Sensor_Azimuth | \n", "Water_Vapor_Infrared | \n", "stare_hex | \n", "wiv0 | \n", "pod | \n", "pod_hex | \n", "
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | \n", "53.201778 | \n", "-15.933996 | \n", "4298473764500464809 | \n", "8.493984e+08 | \n", "14709 | \n", "-2296 | \n", "6534 | \n", "-8952 | \n", "-9999 | \n", "0x3ba73f1d5162e4a9 | \n", "-9999 | \n", "4298439553720516615 | \n", "0x3ba7200000000007 | \n", "
| 1 | \n", "53.203171 | \n", "-16.288101 | \n", "4298458168380511209 | \n", "8.493984e+08 | \n", "14700 | \n", "-2354 | \n", "6472 | \n", "-8980 | \n", "-9999 | \n", "0x3ba730ee103253e9 | \n", "-9999 | \n", "4298439553720516615 | \n", "0x3ba7200000000007 | \n", "
| 2 | \n", "53.203518 | \n", "-16.629105 | \n", "4297394569014717897 | \n", "8.493984e+08 | \n", "14692 | \n", "-2410 | \n", "6411 | \n", "-9008 | \n", "-9999 | \n", "0x3ba3699789d0adc9 | \n", "-9999 | \n", "4297384022557851655 | \n", "0x3ba3600000000007 | \n", "
| 3 | \n", "53.202934 | \n", "-16.957928 | \n", "4297300698872999369 | \n", "8.493984e+08 | \n", "14684 | \n", "-2464 | \n", "6351 | \n", "-9034 | \n", "-9999 | \n", "0x3ba31437b15cedc9 | \n", "-9999 | \n", "4297278469441585159 | \n", "0x3ba3000000000007 | \n", "
| 4 | \n", "53.201508 | \n", "-17.275316 | \n", "4297290857922121161 | \n", "8.493984e+08 | \n", "14676 | \n", "-2516 | \n", "6291 | \n", "-9059 | \n", "-9999 | \n", "0x3ba30b446afb4dc9 | \n", "-9999 | \n", "4297278469441585159 | \n", "0x3ba3000000000007 | \n", "
| ... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "
| 109615 | \n", "64.084297 | \n", "-66.281410 | \n", "3727686638370615689 | \n", "8.493987e+08 | \n", "12157 | \n", "-7468 | \n", "6223 | \n", "4800 | \n", "-9999 | \n", "0x33bb673f5a0cf189 | \n", "-9999 | \n", "3727678669695483911 | \n", "0x33bb600000000007 | \n", "
| 109616 | \n", "63.960953 | \n", "-66.591354 | \n", "3727661374545790857 | \n", "8.493987e+08 | \n", "12147 | \n", "-7505 | \n", "6282 | \n", "4772 | \n", "-9999 | \n", "0x33bb504528bf0789 | \n", "-9999 | \n", "3727643485323395079 | \n", "0x33bb400000000007 | \n", "
| 109617 | \n", "63.831799 | \n", "-66.911255 | \n", "3727838256925064969 | \n", "8.493987e+08 | \n", "12137 | \n", "-7544 | \n", "6342 | \n", "4743 | \n", "-9999 | \n", "0x33bbf124cc213f09 | \n", "-9999 | \n", "3727819407183839239 | \n", "0x33bbe00000000007 | \n", "
| 109618 | \n", "63.698635 | \n", "-67.236229 | \n", "3727843063731949801 | \n", "8.493987e+08 | \n", "12126 | \n", "-7583 | \n", "6402 | \n", "4714 | \n", "-9999 | \n", "0x33bbf583f82590e9 | \n", "-9999 | \n", "3727819407183839239 | \n", "0x33bbe00000000007 | \n", "
| 109619 | \n", "63.551617 | \n", "-67.589508 | \n", "3727853163225616425 | \n", "8.493987e+08 | \n", "12115 | \n", "-7625 | \n", "6464 | \n", "4682 | \n", "-9999 | \n", "0x33bbfeb370e11029 | \n", "-9999 | \n", "3727819407183839239 | \n", "0x33bbe00000000007 | \n", "
109620 rows × 13 columns
\n", "