pyiem.iemre module#
Support library for the IEM Reanalysis code.
- pyiem.iemre.d2l(val)[source]#
Convert a domain label to a string used within filenames.
- Return type:
- pyiem.iemre.get_table(valid)[source]#
Figure out which table should be used for given valid.
- Parameters:
valid (datetime or date) – which time is of interest
- Returns:
str tablename
- pyiem.iemre.set_grids(valid, ds, table=None, domain='conus')[source]#
Update the database with a given
xarray.Dataset.- Parameters:
valid (datetime or date) – If datetime, save hourly, if date, save daily
ds (xarray.Dataset) – The xarray dataset to save
table (str,optional) – hard coded database table to use to set the data on. Usually dynamically computed.
domain (str,optional) – IEMRE domain to save data to
- pyiem.iemre.get_grids(valid, varnames=None, cursor=None, table=None, domain='conus')[source]#
Fetch grid(s) from the database, returning xarray.
- Parameters:
valid (datetime or date) – If datetime, load hourly, if date, load daily
varnames (str or list,optional) – Which variables to fetch from database, defaults to all available
cursor (database cursor,optional) – cursor to use for query
table (str,optional) – Hard coded table to fetch data from, useful in the case of forecast data.
domain (str,optional) – IEMRE domain to fetch data from
- Returns:
xarray.Dataset
- pyiem.iemre.get_dailyc_ncname(domain='conus')[source]#
Return the filename of the daily climatology netcdf file
- pyiem.iemre.get_daily_ncname(year, domain='conus')[source]#
Get the daily netcdf filename for the given year
- pyiem.iemre.get_daily_mrms_ncname(year)[source]#
Get the daily netcdf MRMS filename for the given year
- pyiem.iemre.get_hourly_ncname(year, domain='conus')[source]#
Get the daily netcdf filename for the given year
- pyiem.iemre.hourly_offset(dtobj)[source]#
Return time index for given timestamp
- Parameters:
dtobj (datetime) – datetime, if no tzinfo, we assume it is UTC
- Returns:
int time index in the netcdf file
- pyiem.iemre.find_ij(lon, lat, domain='conus')[source]#
Return the i, j grid indices (based 0) for given lat/lon.
- pyiem.iemre.grb2iemre(grb, resampling=None, domain='conus')[source]#
Reproject a grib message onto the IEMRE grid.
A helper frontend to
reproject2iemre.
- pyiem.iemre.reproject2iemre(grid, affine_in, crs_in, resampling=None, domain='conus')[source]#
Reproject the given grid to IEMRE grid, returning S to N oriented grid.
Note: If the affine_in is dy > 0 then the grid is assumed to be S to N.
- Parameters:
grid (numpy.array) – 2D grid to reproject
affine_in (affine.Affine) – affine transform of input grid
crs_in (pyproj.Proj) – projection of input grid
resampling (rasterio.warp.Resampling,optional) – defaults to nearest
domain (str) – IEMRE domain to reproject onto
- Returns:
numpy.ma.array of reprojected grid oriented S to N like IEMRE