poets package — poets 0.3.2 documentation

# poets package

## Subpackages

- poets.grid package
  - Submodules
  - poets.grid.grids module
  - Module contents
- poets.image package
  - Submodules
  - poets.image.geotiff module
  - poets.image.hdf5 module
  - poets.image.imagefile module
  - poets.image.netcdf module
  - poets.image.resampling module
  - Module contents
- poets.io package
  - Submodules
  - poets.io.download module
  - poets.io.fileformats module
  - poets.io.source_base module
  - poets.io.unpack module
  - Module contents
- poets.shape package
  - Submodules
  - poets.shape.shapes module
  - Module contents
- poets.timedate package
  - Submodules
  - poets.timedate.dateindex module
  - poets.timedate.dekad module
  - Module contents
- poets.web package
  - Submodules
  - poets.web.app module
  - poets.web.overlays module
  - Module contents

## Submodules

## poets.poet module

This module includes the poets base class Poet.

class `poets.poet.` `Poet`(rootpath, regions=['global'], spatial_resolution=0.25, temporal_resolution='dekad', start_date=datetime.datetime(2000, 1, 1, 0, 0), nan_value=-99, shapefile=None, delete_rawdata=False)

  Bases: `object`

  POETS base class.

  Provides methods to download and resample data using parameters as defined in this class. Resampled outputfiles will be saved as NetCDF4 files.

  rootpath : str
    path to the directory where data should be stored
  regions : list of str, optional
    Identifier of the region in the shapefile. If the default shapefile is used, this would be the FIPS country code. Defaults to global.
  spatial_resolution : float, optional
    spatial resolution in degree, defaults to 0.25
  temporal_resolution : str, optional
    temporal resolution of the data, possible values: day, week, month, dekad; defaults to dekad
  start_date : datetime.datetime, optional
    first date of the dataset, defaults to 2000-01-01
  nan_value : int
    NaN value to use, defaults to -99
  shapefile : str, optional
    Path to shape file, uses “world country admin boundary shapefile” by default. Custom shapefile must use WGS84 as reference system.
  delete_rawdata : bool, optional
    Original files will be deleted from rawdata_path if set True. Defaults to False.
  rootpath : str
    path to the directory where data should be stored
  regions : list of str
    Identifier of the region in the shapefile.
  spatial_resolution : float
    Spatial resolution in degree.
  temporal_resolution : str
    Temporal resolution of the data.
  data_path : str
    Path where resampled NetCDF file is stored.
  rawdata_path : str
    Path where original files are stored and downloaded.
  tmp_path : str
    Path where temporary files are stored.
  nan_value : int
    NaN value to use, defaults to -99.
  start_date : datetime.datetime
    First date of the dataset.
  shapefile : str
    Path to shape file.
  sources : dict of poets.io.BasicSource objects
    Sources used by poets given as BasicSource class.
  delete_rawdata : bool
    Original files will be deleted from rawdata_path if True.
  `add_source`(name, filename, filedate, temp_res, host, protocol, username=None, password=None, port=22, directory=None, dirstruct=None, begin_date=None, variables=None, nan_value=None, valid_range=None, unit=None, ffilter=None, data_range=None, colorbar=None)

    Creates BasicSource class and adds it to Poet.sources.

    name : str
      Name of the data source.
    filename : str
      Structure/convention of the file name.
    filedate : dict
      Position of date fields in filename, given as tuple.
    temp_res : str
      Temporal resolution of the source.
    host : str
      Link to data host.
    protocol : str
      Protocol for data transfer.
    username : str, optional
      Username for data access.
    password : str, optional
      Password for data access.
    port : int, optional
      Port to data host, defaults to 22.
    directory : str, optional
      Path to data on host.
    dirstruct : list of strings
      Structure of source directory, each list item represents a subdirectory.
    begin_date : datetime.date, optional
      Date from which on data is available.
    variables : string or list of strings, optional
      Variables used from data source.
    nan_value : int, float, optional
      Nan value of the original data as given by the data provider.
    valid_range : tuple of int of float, optional
      Valid range of data, given as (minimum, maximum).
    data_range : tuple of int of float, optional
      Range of the values as data given in rawdata (minimum, maximum). Will be scaled to valid_range.
    ffilter : str, optional
      Pattern that apperas in filename. Can be used to select out not needed files if multiple files per date are provided.
    colorbar : str, optional
      Colorbar to use, use one from http://matplotlib.org/examples/color/colormaps_reference.html; defaults to jet.
    unit : str, optional
      Unit of dataset for displaying in legend. Does not have to be set if unit is specified in input file metadata. Defaults to None.
  `download`(begin=None, end=None)

    Starts download of input data for sources as added to Poets.sources.

    begin : datetime, optional
      Start date of data to download, defaults to start date as defined in poets class.
    end : datetime, optional
      End date of data to download, defaults to current datetime.
  `fetch_data`(begin=None, end=None, delete_rawdata=None)

    Starts download and resampling of input data for sources as added to Poets.sources.

    begin : datetime, optional
      Start date of data to download, defaults to start date as defined in poets class.
    end : datetime, optional
      End date of data to download, defaults to current datetime.
    delete_rawdata : bool, optional
      Original files will be deleted from rawdata_path if set True. Defaults to value of delete_rawdata attribute as set in Poet class.
  `get_gridpoints`()

    Returns gridpoints from NetCDF file.

    region : str
      Identifier of the region in the NetCDF file.
    gridpoints : dict of pandas.DataFrame
      Dict containing Dataframes with gridpoint index as index, longitutes and latitudes as columns for each region.
  `get_variables`()
  `read_image`(source, date, region=None, variable=None)

    Gets images from netCDF file for certain date

    date : datetime
      Date of the image.
    source : str
      Data source from which image should be read.
    region : str, optional
      Region of interest, set to first defined region if None.
    variable : str, optional
      Variable to display, set to first variable of source if None.
    img : numpy.ndarray
      Image of selected date.
    lon : numpy.array
      Array with longitudes.
    lat : numpy.array
      Array with latitudes.
    metadata : dict
      Dictionary containing metadata of the variable.
  `read_timeseries`(source, location, region=None, variable=None)

    Gets timeseries from netCDF file for a gridpoint.

    source : str
      Data source from which time series should be read.
    location : int or tuple of floats
      Either Grid point index as integer value or Longitude/Latitude given as tuple.
    region : str, optional
      Region of interest, set to first defined region if None.
    variable : str, optional
      Variable to display, set to first variable of source if None.
    ts : pd.DataFrame
      Timeseries for the selected data.
  `resample`(begin=None, end=None, delete_rawdata=None)

    Starts download of input data for sources as added to Poets.sources.

    begin : datetime, optional
      Start date of data to download, defaults to start date as defined in poets class.
    end : datetime, optional
      End date of data to download, defaults to current datetime.
  `start_app`(host='127.0.0.1', port=5000, debug=False)

    Starts web interface.

    host : str, optional
      Host that is used by the app, defaults to 127.0.0.1.
    port : int, optional
      Port where app runs on, defaults to 50000.
    debug : bool, optional
      Starts app in debug mode if set True, defaults to False.

## Module contents