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: str | COMPSPlatform, site_file: str | Path, start_date: int, end_date: int | None = None, node_column: str = 'nodes', lat_column: str = 'lat', lon_column: str = 'lon', id_reference: str | None = None, request_name: str = '', local_dir: str | Path | None = None, data_source: str | None = None, force: bool = False) WeatherRequest[source]

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: str | Path | DataFrame, node_column: str = 'nodes', step_column: str = 'steps', weather_columns: Dict[WeatherVariable, str] | None = None, attributes: WeatherAttributes | None = None, weather_dir: str | Path | None = None, weather_file_names: Dict[WeatherVariable, str] | None = None) WeatherSet[source]

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: str | Path, weather_file_prefix: str = '', weather_file_names: Dict[WeatherVariable, str] | None = None, csv_file: str | Path | None = None, node_column: str = 'nodes', step_column: str = 'steps', weather_columns: Dict[WeatherVariable, str] | None = None) Tuple[DataFrame, WeatherAttributes][source]

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