Closed needham-michael closed 10 months ago
cmap = 'inferno'
levels = np.arange(0,91,10)
fig, [ax1,ax2] = plt.subplots(figsize=(6,6),nrows=2,layout='tight',dpi=200)
rsig_xr['ozone'].plot(
ax=ax1,
cmap=cmap,
levels=levels,
)
rsig_pd['ozone(ppb)'].plot(
ax=ax2,
cmap=cmap,
levels=levels,
)
ax1.set_title("using api.to_netcdf()")
ax2.set_title("using api.to_dataframe()")
I've tried to distill this to a very small test case. Below is a query to pyrsig via to_dataframe
and to_netcdf
for just two monitors. The monitors are extremely close to each other and one has missing more data.
import matplotlib.pyplot as plt
import pyrsig
api = pyrsig.RsigApi(
bdate='2018-08-01T00', edate='2018-08-05T23:59:59',
bbox=(-97.8, 27.6, -97.3, 28.),
)
fig, axx = plt.subplots(2, 1, figsize=(8, 8))
df = api.to_dataframe('aqs.ozone', parse_dates=True, unit_keys=False)
ds = api.to_netcdf('aqs.ozone')
tdf = df.set_index(['Timestamp', 'STATION'])['ozone'].unstack('STATION')
tdf.plot(ax=axx[0])
ds['ozone'][0].plot(ax=axx[1])
ds['ozone'][1].plot(ax=axx[1])
axx[0].set_xticks(range(0, 120, 24))
axx[0].set_xticklabels([t[5:10] for t in tdf.index.values[range(0, 120, 24)]], rotation=90)
Todd Plessel (Thanks Todd!!) updated the RSIG Web Coverage Service (WCS) to fix this. He changed the order of the dimensions of the variable. The order was ('station', 'time')
and is now ('time', 'station')
. pyrsig caches the files on disk, so your data won't be updated until you delete the *.nc
and *.nc.gz
files. After that, it will requery the system and get the new dimension order.
After your files are updated, the plots you made will be transposed (i.e., station on the x- instead of y-axis). If you want your plot to stay with station on the y-axis and time on the x-axis, transpose the variable in the plot line.
- rsig_xr['ozone'].plot(ax=ax1,cmap=cmap, levels=levels,)
+ rsig_xr['ozone'].T.plot(ax=ax1,cmap=cmap, levels=levels,)
Please confirm that this is fixed and close the issue.
I've confirmed that Todd Plessel's fix to RSIG Web Coverage Service has fixed my issue with to_netcdf()
(after clearing the old .nc
and .nc.gz
files, as you said).
Closing the issue - Thanks!
Description
pyrsig.RsigApi.to_netcdf()
pyrsig.RsigApi.to_dataframe()
For this use-case the temporary pyrsig -> pandas -> xarray work-around (shown in the example below) works fine, but the issue might apply to other situations too.
Version Info:
Minimum Example to Reproduce
Output from this example, which can be compared to EPA tile plots:
And attributes from the associated netcdf file: