emodpy_malaria.weather package¶
weather is a module providing features for working with EMOD weather files.
Main Features¶
Here are main features:
Generate EMOD weather files locally from a csv file.
Generate EMOD weather files using COMPS SSMT weather service.
Convert existing EMOD weather files to csv file or dataframes.
Programmatic access to EMOD weather files via weather object model.
- emodpy_malaria.weather.generate_weather(platform: Union[str, idmtools_platform_comps.comps_platform.COMPSPlatform], site_file: Union[str, pathlib.Path], start_date: int, end_date: Optional[int] = None, node_column: str = 'nodes', lat_column: str = 'lat', lon_column: str = 'lon', id_reference: Optional[str] = None, request_name: str = '', local_dir: Optional[Union[str, pathlib.Path]] = None, data_source: Optional[str] = None, force: bool = False) emodpy_malaria.weather.weather_request.WeatherRequest ¶
Generate weather files by submitting a request and downloading generated weather files to a specified dir.
- Parameters
platform – Platform name (like “Bayesian”) or COMPSPlatform object, where the work item will run.
site_file – CSV (.csv) or demographics (.json) file containing a set of sites (points) defined with lat/lon. CSV file must contain columns for: EMOD node ids (node), latitude (lat) and longitude (lon). Demographics file must match EMOD demographics file schema.
start_date – Start date, in formats: year (2018), year and day-of-year (2018001) or date (20180101)
end_date – (Optional) End date, in formats: year (2018), year and day-of-year (2018365) or date (20181231)
node_column – (Optional) Name of a column containing EMOD node ids. The default is “nodes”.
lat_column – (Optional) Name of a column containing site (point) latitude. The default is “lat”.
lon_column – (Optional) Name of a column containing site (point) longitude. The default is “lon”.
id_reference – (Optional) Value of weather metadata IdReference attribute. The default is “Default”.
request_name – (Optional) Name to be used for the weather SSMT work item.
local_dir – (Optional) Local dir where files will be downloaded.
data_source – (Optional) SSMT data source to be used.
force –
(Optional) Flag ensuring a new weather request is submitted, even if weather files exist in “local_dir”.
Example:
wr: WeatherRequest = generate_weather(platform="Bayesian", site_file="path/to/sites.csv", start_date=2015, end_date=2016, node_column="id", local_dir="path/to/weather_dir")
- Returns
WeatherRequest object. Can be used to access asset collection id or a local dir (if not given as ) argument or a download report.
- emodpy_malaria.weather.csv_to_weather(csv_data: Union[str, pathlib.Path, pandas.core.frame.DataFrame], node_column: str = 'nodes', step_column: str = 'steps', weather_columns: Optional[Dict[emodpy_malaria.weather.weather_variable.WeatherVariable, str]] = None, attributes: Optional[emodpy_malaria.weather.weather_metadata.WeatherAttributes] = None, weather_dir: Optional[Union[str, pathlib.Path]] = None, weather_file_names: Optional[Dict[emodpy_malaria.weather.weather_variable.WeatherVariable, str]] = None) emodpy_malaria.weather.weather_set.WeatherSet ¶
Convert a dataframe or csv file, containing node, step and weather columns, into a weather set and corresponding weather files, if weather dir is specified.
- Parameters
csv_data – Dataframe or a csv file path, containing weather data.
node_column – (Optional) Column containing node ids. The default is “nodes”. The default is “nodes”.
step_column – (Optional) Column containing node index for weather time series values. The default is “steps”.
weather_columns – (Optional) Dictionary of weather variables (keys) and weather column names (values). Defaults are WeatherVariables values are used: “airtemp”, “humidity”, “rainfall”, “landtemp”.
attributes – (Optional) Weather attribute object containing metadata for WeatherMetadata object.
weather_dir – (Optional) Directory where weather files are stored. If not specified files are not created.
weather_file_names –
(Optional) Dictionary of weather variables (keys) and weather .bin file names (values).
Example:
wa = WeatherAttributes(start_year=2001, end_year=2010) ws = csv_to_weather(csv_data="path/to/data.csv", attributes=wa, weather_dir="path/to/weather_dir")
- Returns
WeatherSet object.
- emodpy_malaria.weather.weather_to_csv(weather_dir: Union[str, pathlib.Path], weather_file_prefix: str = '', weather_file_names: Optional[Dict[emodpy_malaria.weather.weather_variable.WeatherVariable, str]] = None, csv_file: Optional[Union[str, pathlib.Path]] = None, node_column: str = 'nodes', step_column: str = 'steps', weather_columns: Optional[Dict[emodpy_malaria.weather.weather_variable.WeatherVariable, str]] = None) Tuple[pandas.core.frame.DataFrame, emodpy_malaria.weather.weather_metadata.WeatherAttributes] ¶
Convert weather files into a dataframe and a .csv file, if csv file path is specified.
- Parameters
weather_dir – Local dir containing weather files.
weather_file_prefix – (Optional) Weather files prefix, e.g. “dtk_15arcmin_”
weather_file_names – (Optional) Dictionary of weather variables (keys) and weather .bin file names (values).
csv_file – (Optional) The path of a csv file to be generated. If not specified csv file is not created.
node_column – (Optional) Column containing node ids. The default is “nodes”.
step_column – (Optional) Column containing node index for weather time series values. The default is “steps”.
weather_columns –
- (Optional) Dictionary of weather variables (keys) and weather column names (values).
Defaults are WeatherVariables values are used: “airtemp”, “humidity”, “rainfall”, “landtemp”.
Example:
df, attributes = weather_to_csv(weather_dir="path/to/weather_dir")
- Returns
Dataframe and weather attributes objects.
Submodules¶
- emodpy_malaria.weather.data_sources module
- emodpy_malaria.weather.weather_data module
- emodpy_malaria.weather.weather_metadata module
- emodpy_malaria.weather.weather_request module
- emodpy_malaria.weather.weather_set module
- emodpy_malaria.weather.weather_utils module
- emodpy_malaria.weather.weather_variable module