emod_api.weather.weather module¶
emod-api Weather module - Weather, Metadata, and WeatherNode objects along with IDREF and CLIMATE_UPDATE constants.
- class emod_api.weather.weather.WeatherNode(node_id: int, data)[source]¶
Bases:
object
Represents information for a single node: ID and timeseries data.
- property data¶
Time series data for this node.
- class emod_api.weather.weather.Metadata(node_ids: List[int], datavalue_count: int, author: Optional[str] = None, created: Optional[datetime.datetime] = None, frequency: Optional[str] = None, provenance: Optional[str] = None, reference: Optional[str] = None)[source]¶
Bases:
object
Metadata:
[DateCreated]
[Author]
[OriginalDataYears]
[StartDayOfYear]
[DataProvenance]
IdReference
NodeCount
DatavalueCount
UpdateResolution
NodeOffsets
- property creation_date: datetime.datetime¶
Creation date of this file.
- property id_reference: str¶
‘Schema’ for node IDs. Commonly Legacy, Gridded world grump2.5arcmin, and Gridded world grump30arcsec.
Legacy usually indicates a 0 or 1 based scheme with increasing ID numbers.
Gridded world grump2.5arcmin and Gridded world grump30arcsec encode latitude and longitude values in the node ID with the following formula:
latitude = (((nodeid - 1) & 0xFFFF) * resolution) - 90 longitude = ((nodeid >> 16) * resolution) - 180 # nodeid = 90967271 @ 2.5 arcmin resolution # longitude = -122.1667, latitude = 47.5833
- class emod_api.weather.weather.Weather(filename: Optional[str] = None, node_ids: Optional[List[int]] = None, datavalue_count: Optional[int] = None, author: Optional[str] = None, created: Optional[datetime.datetime] = None, frequency: Optional[str] = None, provenance: Optional[str] = None, reference: Optional[str] = None, data: Optional[numpy.array] = None)[source]¶
Bases:
object
- property data: numpy.array¶
Raw data as numpy array[node index, time step].
- property metadata: emod_api.weather.weather.Metadata¶
- property creation_date: datetime.datetime¶
- property nodes: Dict[int, emod_api.weather.weather.WeatherNode]¶
WeatherNodes indexed by node id.
- classmethod from_csv(filename: str, var_column: str = 'airtemp', id_column: str = 'node_id', step_column: str = 'step', author: Optional[str] = None, provenance: Optional[str] = None)[source]¶
Create weather from CSV file with specified variable column, node id column, and time step column.
Note
Column order in the CSV file is not significant, but columns names must match what is passed to this function.
Because a CSV might hold air temperature (may be negative and well outside 0-1 values), relative humidity (must _not_ be negative, must be in the interval [0-1]), or rainfall (must _not_ be negative, likely > 1), this function does not validate incoming data.