-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit b7dc0f1
Showing
168 changed files
with
21,604 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Sphinx build info version 1 | ||
# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done. | ||
config: 8e7163b5b3794a6ee80f01233ccf82a6 | ||
tags: 645f666f9bcd5a90fca523b33c5a78b7 |
Empty file.
Binary file not shown.
43 changes: 43 additions & 0 deletions
43
_downloads/1079a3390f344e04cc17426a5c8b1192/get_3_tropomicoards.ipynb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"\n# Get COARDS formatted NetCDF TropOMI NO2\n\nShows how to get TropOMI as an xarray Dataset. This example downloads a NetCDF\nfile with COARDS compliant metadata, which is opened and returned.\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": { | ||
"collapsed": false | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"# sphinx_gallery_thumbnail_path = '_static/tropomicoards.png'\n\nimport pyrsig\n\nrsigapi = pyrsig.RsigApi(bdate='2022-03-01', overwrite=True)\nds = rsigapi.to_netcdf('tropomi.offl.no2.nitrogendioxide_tropospheric_column')\nprint(ds.data_vars)\n# Data variables:\n# longitude (points) float32 ...\n# latitude (points) float32 ...\n# nitrogendioxide_tropospheric_column (points) float32 ...\n# Longitude_SW (points) float32 ...\n# Longitude_SE (points) float32 ...\n# Longitude_NW (points) float32 ...\n# Longitude_NE (points) float32 ...\n# Latitude_SW (points) float32 ...\n# Latitude_SE (points) float32 ...\n# Latitude_NW (points) float32 ...\n# Latitude_NE (points) float32 ...\n# yyyyddd (points) int32 ...\n# hhmmss (points) int32 ...\n# time (points) datetime64[ns] ...\nrsigapi = pyrsig.RsigApi(bdate='2022-03-02', overwrite=True)\nds = rsigapi.to_netcdf(\n 'tropomi.offl.no2.nitrogendioxide_tropospheric_column', grid=True\n)\nprint(ds.data_vars)\n# Data variables:\n# column (points) int32 ...\n# row (points) int32 ...\n# count (points) int32 ...\n# longitude (points) float32 ...\n# latitude (points) float32 ...\n# no2 (points) float32 ...\n# time (points) datetime64[ns] ..." | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3", | ||
"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.12.3" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 0 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
""" | ||
NYC VIIRS AOD vs TropOMI NO2 | ||
============================ | ||
Timeseries comparison of VIIRS AOD and TropOMI in NYC. | ||
""" | ||
|
||
import matplotlib.pyplot as plt | ||
import pyrsig | ||
import os | ||
|
||
os.makedirs('nyc', exist_ok=True) | ||
|
||
# Create an RSIG api isntance | ||
# Define a Time and Space Scope: here end of February around Phoenix | ||
rsigapi = pyrsig.RsigApi( | ||
bdate='2022-01-20', edate='2022-01-25', | ||
bbox=(-74.8, 40.32, -71.43, 41.4), workdir='nyc' | ||
) | ||
|
||
# Get TropOMI NO2 | ||
tomino2df = rsigapi.to_dataframe( | ||
'tropomi.offl.no2.nitrogendioxide_tropospheric_column', | ||
unit_keys=False, parse_dates=True | ||
) | ||
|
||
# Get VIIRS AOD | ||
viirsaoddf = rsigapi.to_dataframe( | ||
'viirsnoaa.jrraod.AOD550', unit_keys=False, parse_dates=True | ||
) | ||
|
||
# Create spatial medians for TropOMI and AQS | ||
tomids = ( | ||
tomino2df.groupby('time').median(numeric_only=True)['nitrogendioxide_tropospheric_column'] | ||
) | ||
viirsds = ( | ||
viirsaoddf.groupby('time').median(numeric_only=True)['AOD550'] | ||
) | ||
|
||
# Create axes with shared x | ||
fig, ax = plt.subplots(figsize=(12, 4), | ||
gridspec_kw=dict(bottom=0.25, left=0.15, right=0.95)) | ||
ax.tick_params(axis='x', labelrotation = 90) | ||
tax = ax.twinx() | ||
|
||
# Add VIIRS AOD | ||
ax.plot(viirsds.index.values, viirsds.values, marker='o', color='g') | ||
|
||
# Add TropOMI NO2 | ||
tax.plot(tomids.index.values, tomids.values, marker='s', color='r') | ||
|
||
# Configure axes | ||
ax.set(ylabel='VIIRS AOD') | ||
tax.set(ylim=(0, 1.7e16), ylabel='TropOMI NO2 molecules/cm$^2$') | ||
|
||
plt.show() | ||
# Or save out figure | ||
# fig.savefig('nyc.png') |
43 changes: 43 additions & 0 deletions
43
_downloads/1a06601ce4b68892b2b3938fb90fa85c/plot_nyc.ipynb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"\n# NYC VIIRS AOD vs TropOMI NO2\n\nTimeseries comparison of VIIRS AOD and TropOMI in NYC.\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": { | ||
"collapsed": false | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"import matplotlib.pyplot as plt\nimport pyrsig\nimport os\n\nos.makedirs('nyc', exist_ok=True)\n\n# Create an RSIG api isntance\n# Define a Time and Space Scope: here end of February around Phoenix\nrsigapi = pyrsig.RsigApi(\n bdate='2022-01-20', edate='2022-01-25',\n bbox=(-74.8, 40.32, -71.43, 41.4), workdir='nyc'\n)\n\n# Get TropOMI NO2\ntomino2df = rsigapi.to_dataframe(\n 'tropomi.offl.no2.nitrogendioxide_tropospheric_column',\n unit_keys=False, parse_dates=True\n)\n\n# Get VIIRS AOD\nviirsaoddf = rsigapi.to_dataframe(\n 'viirsnoaa.jrraod.AOD550', unit_keys=False, parse_dates=True\n)\n\n# Create spatial medians for TropOMI and AQS\ntomids = (\n tomino2df.groupby('time').median(numeric_only=True)['nitrogendioxide_tropospheric_column']\n)\nviirsds = (\n viirsaoddf.groupby('time').median(numeric_only=True)['AOD550']\n)\n\n# Create axes with shared x\nfig, ax = plt.subplots(figsize=(12, 4),\n gridspec_kw=dict(bottom=0.25, left=0.15, right=0.95))\nax.tick_params(axis='x', labelrotation = 90)\ntax = ax.twinx()\n\n# Add VIIRS AOD\nax.plot(viirsds.index.values, viirsds.values, marker='o', color='g')\n\n# Add TropOMI NO2\ntax.plot(tomids.index.values, tomids.values, marker='s', color='r')\n\n# Configure axes\nax.set(ylabel='VIIRS AOD')\ntax.set(ylim=(0, 1.7e16), ylabel='TropOMI NO2 molecules/cm$^2$')\n\nplt.show()\n# Or save out figure\n# fig.savefig('nyc.png')" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3", | ||
"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.12.3" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 0 | ||
} |
15 changes: 15 additions & 0 deletions
15
_downloads/23e0056b2581a790873eefe981e48542/get_5_purpleairpm.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
""" | ||
Get DataFrame for PurpleAir PM25 | ||
================================ | ||
Shows how to get PurpleAir measurements as a DataFrame. PurpleAir, unlike other | ||
coverages, requires an api_key that you must get from PurpleAir. | ||
""" | ||
|
||
# sphinx_gallery_thumbnail_path = '_static/purpleairpm.png' | ||
|
||
import pyrsig | ||
|
||
rsigapi = pyrsig.RsigApi(bdate='2022-03-01') | ||
rsigapi.purpleair_kw['api_key'] = '<put your api key here>' | ||
df = rsigapi.to_dataframe('purpleair.pm25_corrected') |
43 changes: 43 additions & 0 deletions
43
_downloads/2ee99caa0f4848f38343be8075158f79/plot_cmaqpandora.ipynb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"\n# CMAQ vs Pandora\n\nTimeseries comparison of NO2 columns from CMAQ and Pandora over a small window\nover New York/New Jersey for 2018-07-01.\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": { | ||
"collapsed": false | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"import pyrsig\n\n\nbbox = (-74.5, 40., -73.5, 41)\ncmaqkey = 'cmaq.equates.conus.integrated.NO2_COLUMN'\ndatakey = 'pandora.L2_rnvs3p1_8.nitrogen_dioxide_vertical_column_amount'\n# Or use TropOMI or any other NO2 columns data\n# datakey = 'tropomi.offl.no2.nitrogendioxide_tropospheric_column'\n\n# Get a CMAQ file from RSIG\napi = pyrsig.RsigApi(\n bbox=bbox, bdate='2018-07-01T12', edate='2018-07-01T23:59:59'\n)\nds = api.to_ioapi(cmaqkey)\n\n# pair_rsigcmaq will match the CMAQ bbox, bdate, and edate\ndf = pyrsig.cmaq.pair_rsigcmaq(ds, 'NO2_COLUMN', datakey)\n\npdf = df.groupby(['time']).mean(numeric_only=True)\nz1 = pdf['nitrogen_dioxide_vertical_column_amount']\nz2 = (pdf['CMAQ_NO2_COLUMN'] * 1e15)\nax = z1.plot(marker='+', linestyle='none', label='Pandora')\nax = z2.plot(ax=ax, color='green', label='CMAQ')\nax.legend()\nax.set(ylim=(0, None), ylabel='NO2 [molecules/cm2]', xlabel='Time [UTC]')\nax.figure.savefig('cmaq_pandora.png')" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3", | ||
"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.12.3" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 0 | ||
} |
43 changes: 43 additions & 0 deletions
43
_downloads/4935b96615792edd8dbdbf9c7eb4cffb/get_5_purpleairpm.ipynb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"\n# Get DataFrame for PurpleAir PM25\n\nShows how to get PurpleAir measurements as a DataFrame. PurpleAir, unlike other\ncoverages, requires an api_key that you must get from PurpleAir.\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": { | ||
"collapsed": false | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"# sphinx_gallery_thumbnail_path = '_static/purpleairpm.png'\n\nimport pyrsig\n\nrsigapi = pyrsig.RsigApi(bdate='2022-03-01')\nrsigapi.purpleair_kw['api_key'] = '<put your api key here>'\ndf = rsigapi.to_dataframe('purpleair.pm25_corrected')" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3", | ||
"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.12.3" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 0 | ||
} |
18 changes: 18 additions & 0 deletions
18
_downloads/4a24e9f33b8a80bdc0c720dad6cd2193/get_1_aqsno2.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
""" | ||
Get DataFrame for AQS ozone | ||
=========================== | ||
Shows how to get AQS observations as a Pandas DataFrame. Replace aqs.ozone | ||
with airnow.ozone to get near-real-time data. | ||
""" | ||
|
||
import pyrsig | ||
|
||
# sphinx_gallery_thumbnail_path = '_static/aqsozone.png' | ||
|
||
rsigapi = pyrsig.RsigApi(bdate='2022-03-01') | ||
print([k for k in rsigapi.keys() if 'ozone' in k]) | ||
# ['airnow.ozone', 'airnow2.ozone', 'aqs.ozone', 'aqs.ozone_8hour_average', 'aqs.ozone_daily_8hour_maximum', 'pandora.ozone'] | ||
df = rsigapi.to_dataframe('aqs.ozone') | ||
print(df.shape, *df.columns) | ||
# (26760, 6) Timestamp(UTC) LONGITUDE(deg) LATITUDE(deg) STATION(-) ozone(ppb) SITE_NAME |
43 changes: 43 additions & 0 deletions
43
_downloads/51a34c617be1f995d3fa70f4d9921c61/plot_shapefile.ipynb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"\n# GIS TropOMI Processing\n\nGet TropOMI from RSIG and save as GeoJSON and shapefiles.\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": { | ||
"collapsed": false | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"import matplotlib.pyplot as plt\nimport geopandas as gpd\nfrom shapely import polygons\nimport pyrsig\nimport pycno\n\n\ncoordkeys = [\n 'Longitude_SW(deg)', 'Latitude_SW(deg)',\n 'Longitude_SE(deg)', 'Latitude_SE(deg)',\n 'Longitude_NE(deg)', 'Latitude_NE(deg)',\n 'Longitude_NW(deg)', 'Latitude_NW(deg)',\n 'Longitude_SW(deg)', 'Latitude_SW(deg)',\n]\n\ncno = pycno.cno()\n\n# Retrieve data from RSIG (or cache)\ndatakey = \"tropomi.offl.no2.nitrogendioxide_tropospheric_column\"\nbdate = \"2023-07-23\"\nbbox = (-75, 40, -69, 46)\napi = pyrsig.RsigApi(bbox=bbox)\n# Either ascii or xdr backend works, xdr is faster\ntropdf = api.to_dataframe(datakey, bdate=bdate, backend='xdr')\ngeom = polygons(tropdf[coordkeys].values.reshape(-1, 5, 2))\ngtropdf = gpd.GeoDataFrame(\n tropdf.drop(columns=coordkeys), geometry=geom, crs=4326\n)\n\n# Make Plot\ncol = 'nitrogendioxide_tropospheric_column(molecules/cm2)'\nfig, ax = plt.subplots(figsize=(4, 4), dpi=300)\ngtropdf.plot(col, edgecolor=\"face\", linewidth=0.1, legend=True, ax=ax)\ncno.drawstates(ax=ax, resnum=1)\nfig.savefig(f'{datakey}_{bdate}.png')\n\n# Save as a GIS Format\ngtropdf.to_file(f'{datakey}_{bdate}.geojson')\n# Shapefiles prefer short names\ngtropdf.rename(columns={\n 'Timestamp(UTC)': 'time_utc',\n 'LATITUDE(deg)': 'lat_center',\n 'LONGITUDE(deg)': 'lon_center',\n col: 'no2_trop',\n}).to_file(f'{datakey}_{bdate}.shp')" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3", | ||
"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.12.3" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 0 | ||
} |
64 changes: 64 additions & 0 deletions
64
_downloads/55b848cb92e1312f56c1838bd20b5330/plot_hmssmoke.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
""" | ||
Plot Smoke Polygons | ||
=================== | ||
Get HMS Smoke from RSIG and create daily plots. | ||
""" | ||
import matplotlib.pyplot as plt | ||
import matplotlib.colors as mc | ||
import pandas as pd | ||
import pycno | ||
import pyrsig | ||
|
||
|
||
cno = pycno.cno() | ||
api = pyrsig.RsigApi() | ||
|
||
# %% | ||
# Retrieve data from RSIG (or cache) | ||
# ---------------------------------- | ||
hmsfs = [] | ||
dates = pd.date_range('2023-06-12', '2023-06-15') | ||
for bdate in dates: | ||
hmsf = api.to_dataframe("hms.smoke", bdate=bdate) | ||
hmsfs.append(hmsf) | ||
|
||
hmsf = pd.concat(hmsfs) | ||
|
||
# %% | ||
# Make Plot | ||
# --------- | ||
|
||
# set up colormap and normalization | ||
levels = [0, 7.5, 20, 35] | ||
colors = ['green', 'yellow', 'red'] | ||
cmap, norm = mc.from_levels_and_colors(levels, colors) | ||
|
||
# create multipanel figure | ||
gskw = dict(left=0.05, right=0.915, bottom=0.05, top=0.9) | ||
fig, axx = plt.subplots( | ||
2, 2, figsize=(11, 8), gridspec_kw=gskw, sharex=True, sharey=True | ||
) | ||
# add axes for colorbar | ||
cax = fig.add_axes([0.925, 0.1, 0.025, 0.8]) | ||
|
||
# add maps to each panel | ||
for di, date in enumerate(dates): | ||
jdate = date.strftime('%Y%j') | ||
ax = axx.ravel()[di] | ||
plotf = hmsf.query(f'YYYYDDD1 == {jdate}').sort_values(['DENS_UGM3']) | ||
plotf.plot('DENS_UGM3', cmap=cmap, norm=norm, ax=ax, aspect=None) | ||
topts = dict(size=16, transform=ax.transAxes, bbox=dict(facecolor='white')) | ||
ax.text(0.02, 0.04, date.strftime('%F'), **topts) | ||
cno.drawstates(ax=ax) | ||
|
||
# set extent to data extent | ||
ax.set(xlim=api.bbox[::2], ylim=api.bbox[1::2]) | ||
# add colorbar with categories | ||
cb = fig.colorbar(ax.collections[0], cax=cax, ticks=[3.25, 13.75, 27.5]) | ||
cb.ax.set_yticklabels( | ||
['Light', 'Medium', 'Heavy'], rotation=90, verticalalignment='center', | ||
size=16 | ||
) | ||
fig.suptitle('HMS Smoke Qualitative Categories from GOES', size=20) | ||
fig.savefig('hms_smoke.png') |
Binary file added
BIN
+30.8 KB
_downloads/6f1e7a639e0699d6164445b55e6c116d/auto_examples_jupyter.zip
Binary file not shown.
Oops, something went wrong.