Iowa Environmental Mesonet (IEM)
repository·main·Indexed 41 days ago
https://github.com/akrherz/iemA monolithic codebase for the Iowa Environmental Mesonet responsible for data ingestion, processing, product generation, and web presence. It manages large-scale environmental data workflows, including IEM Reanalysis (IEMRE) NetCDF files, NCEP MRMS Grib2 data, and PRISM grids. The system includes the iemjs JavaScript utility library and provides access to datasets such as the NWS Text Product Archive (AFOS) and IEM Climodat reports.
What's inside IEM
- The IEM repository is a monolith that manages the ingestion, processing, product generation, and web presence for the Iowa Environmental Mesonet. It is designed to handle large-scale environmental data workflows.
Access the NCEP MRMS Grib2 data cache
mainThe NCEP MRMS (Multi-Radar Multi-Sensor) Grib2 data is available via a cache hosted at the following locations:
- Primary Cache URL:
http://140.172.25.182/OPERATIONAL_NCEP_MRMS_GRIB2 - NCEP Source URL:
http://mrms.ncep.noaa.gov/data/
- Primary Cache URL:
Understand NWS Text Product Archive (AFOS) data quality and culling
mainThe AFOS archive undergoes specific processing and quality control to maintain data integrity:
Quality Control
- Format Validation: Ensures data is in ASCII format and free of unexpected control characters.
- Timestamp Validation: Checks that product timestamps are sane and close to real-time. For example, erroneous products from the NOAAPort SBN feed are filtered out.
Data Culling (Deletion)
To manage storage, certain high-frequency text products are culled.
- SHEF Products: These are significantly deleted to prevent overwhelming storage systems.
- RRM Products: These are generally SHEF products and were culled from the database. However, culling for
RRMstopped on 31 March 2023 due to user requests, meaning theRRMarchive only contains data up to that date.
For the exact list of AWIPS IDs used for daily database culling, refer to the clean_afos.py script.
Understand Climodat 'Statewide' and 'Climate District' observations
mainThe IEM produces gridded analyses of observed variables. To provide data for larger geographies like states or climate districts, the IEM performs GIS-style weighted spatial sampling from this grid.
Impact on Data: When viewing averaged values for a large area (like a state), expect:
- Lower rates compared to peak station rates (especially for precipitation).
- More frequent precipitation events than what would be seen at individual stations within that region.
Understand temperature units and precision issues
mainTemperature data in the METAR archive is subject to precision challenges due to the conversion between Celsius and Fahrenheit.
Core Behavior
ASOS stations internally store temperatures in whole degree Fahrenheit. However, data transmission often occurs in whole degree Celsius, which can lead to rounding errors during conversion (e.g., 78°F $\rightarrow$ 26°C $\rightarrow$ 78.8°F $\rightarrow$ 79°F).
Source-Specific Temperature Reliability
- NOAA Satellite Feed (NOAAPort): Transmits in whole degree Celsius. The IEM prioritizes METARs that include the
T-groupto ensure reliable conversion back to Fahrenheit. - MADIS 5-minute ASOS: Data transmitted from the FAA to the NWS is only in whole degree Celsius and cannot be reliably converted. The IEM database stores these values as missing and excludes them from standard data downloads. However, these values are preserved in the
IEM-encoded raw METAR stringavailable in the data downloads. - NCEI ISD: Currently considered reliable for whole degree Fahrenheit conversion.
- NOAA Satellite Feed (NOAAPort): Transmits in whole degree Celsius. The IEM prioritizes METARs that include the
Understand Climodat temporal definitions and observation timing
mainWhen working with Climodat data, be aware of the following temporal nuances:
Observation Timing
The date provided in the dataset typically represents the date on which the observation was taken, not necessarily a full local calendar day.
- Observations are typically taken around 7 AM.
- A single date entry usually represents the 24-hour period prior to 7 AM on that date.
- Some locations may have switched observation times over the years, or may observe 24-hour precipitation totals at different times than temperature values.
Solar Radiation Data
Since the NWS COOP Network does not provide daily solar radiation, the IEM provides point sampling from processed reanalysis datasets.
- Note: Because COOP observations are typically at 7 AM and gridded radiation data is extracted on a local calendar day basis, the 7 AM value is generally considered to be for the previous day.
Reference vendor assets using URI paths
mainWhen referencing common libraries (JS/CSS) in your project, use absolute URI paths starting with/vendor/. The webserver is configured via Apache to mount the centralized vendor repository at this path, ensuring assets are correctly resolved across the webfarm.Understand METAR precipitation data limitations
mainWhen using the METAR dataset, be aware of the following regarding precipitation data:
- Non-US Locations: Precipitation data is often missing or reported as zero for locations outside the United States. This is due to data distribution agreements regarding high-value agricultural commodity data.
- Daily Totals Calculation: Because ASOS stations operate on local standard time, calculating true calendar day totals is complex. The IEM uses three methods to determine these totals:
- Manual Totals: A script manually sums hourly precipitation reports to compute a local calendar day total.
- Daily Summary Message (DSM): Real-time ingestion of daily totals from stations that issue DSM products.
- Climate Report (CLI): Real-time ingestion of daily totals from Climate Reports issued by local NWS Forecast Offices.
Note that not all stations provide DSM or CLI products, so the manual totaling serves as the baseline accounting.
Understand IEM Reanalysis variable sourcing logic
mainThe
daily_analysis.pyscript is responsible for sourcing and gridding various variables. The logic depends on the specific variable and the time period being analyzed:Temperature and Snow (12z variables)
Variables:
high_tmpk_12z,low_tmpk_12z,snow_12z,snowd_12z- Years 2009+: Uses archived COOP data from IEM and performs simple gridding.
- Pre-2009: Uses all existing observations available in the COOP database for gridding.
Precipitation (12z)
Variable:
p01d_12z- Sums up hourly IEMRE precipitation data.
- Pre-1997: Grids available Climatolog Station observations for the specific date.
Temperature and Wind (Daily)
Variables:
high_tmpk,low_tmpk,avg_dwpk,wind_speed- Post-1927: Grids observations found in the IEM Access database.
Precipitation (Daily)
Variable:
p01d- Constructs a midnight CST/CDT analysis by looking at the hourly grids.
Surface Downward Radiation
Variable:
rsds- Derived from IFS forecast processing, which writes into IEMRE hourly NetCDF files, which are then totaled by
daily_analysis.py.
Understand PRISM grid metadata and coordinates
mainPRISM data grids can be inspected using
gdalinfoor by examining the.hdrheader file.GDAL Grid Information
gdalinfoprovides the bounding box coordinates (Upper Left, Lower Left, Upper Right, Lower Right) and the Center point in both decimal degrees and degrees/minutes/seconds.Header (.hdr) File Parameters
The
.hdrfile contains spatial mapping parameters. A key parameter isulxmap, which represents the x-axis map coordinate of the center of the upper-left pixel.Example
.hdrparameters:ULXMAP -125 ULYMAP 49.9166666666687 XDIM 0.04166666666667 YDIM 0.04166666666667gdalinfo says the grid is: Upper Left (-125.0208333, 49.9375000) (125d 1'15.00"W, 49d56'15.00"N) Lower Left (-125.0208333, 24.0625000) (125d 1'15.00"W, 24d 3'45.00"N) Upper Right ( -66.4791667, 49.9375000) ( 66d28'45.00"W, 49d56'15.00"N) Lower Right ( -66.4791667, 24.0625000) ( 66d28'45.00"W, 24d 3'45.00"N) Center ( -95.7500000, 37.0000000) ( 95d45' 0.00"W, 37d 0' 0.00"N)Differentiate between Snowfall and Snow Depth
mainWhen analyzing snow data in the Climodat dataset, distinguish between these two metrics:
- Snowfall: The amount of snow that fell from the sky over the previous 24-hour period.
- Snow depth: The amount of snow measured to be on the ground due to previous snowfalls.
Caution: These values may contradict (e.g., snowfall amounts being larger than snow depth) due to melting or snow compaction. Use care when performing comparative analysis.
Understand the VTEC event lifecycle and database snapshots
mainThe IEM database stores the last known state of a NWS Watch, Warning, or Advisory (WaWA) event. Because NWS events undergo a lifecycle (updates to times, spatial extents, or upgrades like a Watch becoming a Warning), the database does not store the full history of every change, but rather a snapshot of the most recent metadata.
Key Lifecycle Behavior:
- Updates: When the NWS updates an event, fields like
ISSUEDandEXPIREDare updated to reflect the new times. - Upgrades: If an event is upgraded (e.g., from a Watch to a Warning), the original event's
EXPIREDtime might be set to a time before itsISSUEDtime to denote its end. - Recommendation for Time Handling: To avoid issues where
EXPIRE<ISSUEdue to upgrades, it is recommended to use theINIT_ISS(initial issuance) andINIT_EXP(initial expiration) columns to represent the intended start and end of the event, as these are not updated during the lifecycle.
- Updates: When the NWS updates an event, fields like