<jupyter_start><jupyter_text>Welcome to DRpy (derpy)Here is a simple notebook to help you get going.    If you want mapping, please install cartopy<jupyter_code>#first install cartopy
!apt-get -qq install libproj-dev proj-data proj-bin libgeos-dev
!pip install Cython
!pip install cartopy<jupyter_output>Selecting previously unselected package libgeos-dev.
(Reading database ... 135004 files and directories currently installed.)
Preparing to unpack .../libgeos-dev_3.6.2-1build2_amd64.deb ...
Unpacking libgeos-dev (3.6.2-1build2) ...
Selecting previously unselected package libproj-dev:amd64.
Preparing to unpack .../libproj-dev_4.9.3-2_amd64.deb ...
Unpacking libproj-dev:amd64 (4.9.3-2) ...
Selecting previously unselected package proj-bin.
Preparing to unpack .../proj-bin_4.9.3-2_amd64.deb ...
Unpacking proj-bin (4.9.3-2) ...
Setting up libproj-dev:amd64 (4.9.3-2) ...
Setting up libgeos-dev (3.6.2-1build2) ...
Setting up proj-bin (4.9.3-2) ...
Processing triggers for man-db (2.8.3-2ubuntu0.1) ...
Requirement already satisfied: Cython in /usr/local/lib/python3.6/dist-packages (0.29.14)
Collecting cartopy
[?25l  Downloading https://files.pythonhosted.org/packages/e5/92/fe8838fa8158931906dfc4f16c5c1436b3dd2daf83592645b179581403ad/Cartopy-0.17.0.tar.gz (8.9MB)
[K     |██████████████████████[...]<jupyter_text>Ok, now go clone the repository The reason we are cloning the directory is to grab the example file. If you don't need this file, just install this way: !pip install git+https://github.com/dopplerchase/DRpy.git<jupyter_code>#clone repository
!git clone https://github.com/dopplerchase/DRpy.git<jupyter_output>Cloning into 'DRpy'...
remote: Enumerating objects: 82, done.[K
remote: Counting objects:   1% (1/82)[K
remote: Counting objects:   2% (2/82)[K
remote: Counting objects:   3% (3/82)[K
remote: Counting objects:   4% (4/82)[K
remote: Counting objects:   6% (5/82)[K
remote: Counting objects:   7% (6/82)[K
remote: Counting objects:   8% (7/82)[K
remote: Counting objects:   9% (8/82)[K
remote: Counting objects:  10% (9/82)[K
remote: Counting objects:  12% (10/82)[K
remote: Counting objects:  13% (11/82)[K
remote: Counting objects:  14% (12/82)[K
remote: Counting objects:  15% (13/82)[K
remote: Counting objects:  17% (14/82)[K
remote: Counting objects:  18% (15/82)[K
remote: Counting objects:  19% (16/82)[K
remote: Counting objects:  20% (17/82)[K
remote: Counting objects:  21% (18/82)[K
remote: Counting objects:  23% (19/82)[K
remote: Counting objects:  24% (20/82)[K
remote: Counting objects:  25% (21/82)[K
remote: Counting objects:  26% (22/82)[K
remote: Counting obj[...]<jupyter_text>Install it<jupyter_code>import os

#cd into folder
os.chdir('./DRpy/')
#install 
!python setup.py install
#cd into notebooks 
os.chdir('./notebooks/')<jupyter_output>running install
running build
running build_py
creating build
creating build/lib
creating build/lib/drpy
copying drpy/__init__.py -> build/lib/drpy
creating build/lib/drpy/core
copying drpy/core/__init__.py -> build/lib/drpy/core
copying drpy/core/gpmdpr.py -> build/lib/drpy/core
creating build/lib/drpy/graph
copying drpy/graph/graph.py -> build/lib/drpy/graph
copying drpy/graph/__init__.py -> build/lib/drpy/graph
copying drpy/graph/colormaps_drpy.py -> build/lib/drpy/graph
running install_lib
creating /usr/local/lib/python3.6/dist-packages/drpy
creating /usr/local/lib/python3.6/dist-packages/drpy/core
copying build/lib/drpy/core/__init__.py -> /usr/local/lib/python3.6/dist-packages/drpy/core
copying build/lib/drpy/core/gpmdpr.py -> /usr/local/lib/python3.6/dist-packages/drpy/core
copying build/lib/drpy/__init__.py -> /usr/local/lib/python3.6/dist-packages/drpy
creating /usr/local/lib/python3.6/dist-packages/drpy/graph
copying build/lib/drpy/graph/graph.py -> /usr/local/lib/python3.6/d[...]<jupyter_text>Now we can actually use it!<jupyter_code>import drpy
import time
%pylab inline
filename = '../example_file/2A.GPM.DPR.V820180723.20200117-S181128-E184127.V06A.RT-H5'
stime = time.time()
dpr = drpy.core.GPMDPR(filename = filename)
dpr.read()
dpr.toxr()
etime = time.time()

print('time elapsed {} seconds'.format(etime-stime))<jupyter_output>time elapsed 6.245397329330444 seconds<jupyter_text>lets take a gander at the xarray datatset (.xrds)xrds stands for xarray datasetWe can see that the data have the original shape of the GPM-DPR dataalong_track,cross_track,range<jupyter_code>dpr.xrds<jupyter_output><empty_output><jupyter_text>let us plot a map of the data, to see where the swath is in the world<jupyter_code>import cartopy
import cartopy.crs as ccrs
import cartopy.feature as cfeature
import matplotlib.ticker as mticker
from cartopy.mpl.gridliner import LONGITUDE_FORMATTER, LATITUDE_FORMATTER
import matplotlib.patheffects as PathEffects
import cartopy.io.shapereader as shpreader

from cartopy.mpl.geoaxes import GeoAxes
from mpl_toolkits.axes_grid1 import AxesGrid
from cartopy.mpl.ticker import LongitudeFormatter, LatitudeFormatter
import matplotlib.colors as colors
import matplotlib.patheffects as PathEffects

#make figure
fig = plt.figure(figsize=(10, 10))
#add the map
ax = fig.add_subplot(1, 1, 1,projection=ccrs.PlateCarree())

ax.add_feature(cfeature.STATES.with_scale('50m'),lw=0.5)
ax.add_feature(cartopy.feature.OCEAN.with_scale('50m'))
ax.add_feature(cartopy.feature.LAND.with_scale('50m'), edgecolor='black',lw=0.5,facecolor=[0.95,0.95,0.95])
ax.add_feature(cartopy.feature.LAKES.with_scale('50m'), edgecolor='black')
ax.add_feature(cartopy.feature.RIVERS.with_scale('50m'))

ax.pcolormesh(dpr.xrds.lons,dpr.xrds.lats,dpr.xrds.nearsurfaceKu,vmin=12,vmax=50,cmap=drpy.graph.cmaps.HomeyerRainbow)<jupyter_output><empty_output><jupyter_text>you can see that the data is quite spread out. Say you are interested in the data near St. Johns Newfoundland, Canada. Lets cut the data to a box around it. There are two ways to do this, you can reprocess the original file, or you can use the method to cut the box.<jupyter_code>#define box
center_lat =  47.5615
center_lon = -52.7126 
corners = [center_lon - 4,center_lon +4, center_lat-1.8,center_lat+1.8]
#
dpr.corners = corners
#method 2: Cut the exisiting datset 
dpr.setboxcoords()
#drop dead weight (i.e. blank data)
dpr.xrds = dpr.xrds.dropna(dim='along_track',how='all')
import cartopy
import cartopy.crs as ccrs
import cartopy.feature as cfeature
import matplotlib.ticker as mticker
from cartopy.mpl.gridliner import LONGITUDE_FORMATTER, LATITUDE_FORMATTER
import matplotlib.patheffects as PathEffects
import cartopy.io.shapereader as shpreader

from cartopy.mpl.geoaxes import GeoAxes
from mpl_toolkits.axes_grid1 import AxesGrid
from cartopy.mpl.ticker import LongitudeFormatter, LatitudeFormatter
import matplotlib.colors as colors
import matplotlib.patheffects as PathEffects

#make figure
fig = plt.figure(figsize=(10, 10))
#add the map
ax = fig.add_subplot(1, 1, 1,projection=ccrs.PlateCarree())

ax.add_feature(cfeature.STATES.with_scale('50m'),lw=0.5)
ax.add_feature(cartopy.feature.OCEAN.with_scale('50m'))
ax.add_feature(cartopy.feature.LAND.with_scale('50m'), edgecolor='black',lw=0.5,facecolor=[0.95,0.95,0.95])
ax.add_feature(cartopy.feature.LAKES.with_scale('50m'), edgecolor='black')
ax.add_feature(cartopy.feature.RIVERS.with_scale('50m'))

ax.pcolormesh(dpr.xrds.lons,dpr.xrds.lats,dpr.xrds.nearsurfaceKu,vmin=12,vmax=50,cmap=drpy.graph.cmaps.HomeyerRainbow)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1338455317428225, 'fraction_numerical': 0.05270252055533091, 'mean_word_length': 5.352739726027397, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 35, 'https://': 3, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '7', 'dir': 'jupyter-structured-clean-dedup', 'id': '499179', 'license': 'MIT', 'n_tokens_mistral': 3085, 'n_tokens_neox': 2827, 'n_words': 614, 'path': 'notebooks/Example_one.ipynb', 'repo_name': 'swnesbitt/DRpy', 'size': '7419'}