natcap.invest.recreation.recmodel_server
InVEST Recreation Server.
- class natcap.invest.recreation.recmodel_server.RecModel(**kwargs)
Bases:
object
Class that manages RPCs for calculating photo user days.
- calc_photo_user_days_in_aoi(**kwargs)
General purpose try/except wrapper.
- fetch_workspace_aoi(**kwargs)
General purpose try/except wrapper.
- get_valid_year_range()
Return the min and max year queriable.
- Returns:
(min_year, max_year)
- get_version()
Return the rec model server version.
This string can be used to uniquely identify the PUD database and algorithm for publication in terms of reproducibility.
- natcap.invest.recreation.recmodel_server.build_quadtree_shape(quad_tree_shapefile_path, quadtree, spatial_reference)
Generate a vector of the quadtree geometry.
- Parameters:
quad_tree_shapefile_path (string) – path to save the vector
quadtree (out_of_core_quadtree.OutOfCoreQuadTree) – quadtree data structure
spatial_reference (osr.SpatialReference) – spatial reference for the output vector
- Returns:
None
- natcap.invest.recreation.recmodel_server.construct_userday_quadtree(initial_bounding_box, raw_photo_csv_table, cache_dir, max_points_per_node)
Construct a spatial quadtree for fast querying of userday points.
- Parameters:
initial_bounding_box (list of int)
() (raw_photo_csv_table)
cache_dir (string) – path to a directory that can be used to cache the quadtree files on disk
max_points_per_node (int) – maximum number of points to allow per node of the quadree. A larger amount will cause the quadtree to subdivide.
- Returns:
None
- natcap.invest.recreation.recmodel_server.execute(args)
Launch recreation server and parse/generate quadtree if necessary.
A call to this function registers a Pyro RPC RecModel entry point given the configuration input parameters described below.
There are many methods to launch a server, including at a Linux command line as shown:
nohup python -u -c “import natcap.invest.recreation.recmodel_server; args={
‘hostname’:’$LOCALIP’, ‘port’:$REC_SERVER_PORT, ‘raw_csv_point_data_path’: $POINT_DATA_PATH, ‘max_year’: $MAX_YEAR, ‘min_year’: $MIN_YEAR, ‘cache_workspace’: $CACHE_WORKSPACE_PATH’};
natcap.invest.recreation.recmodel_server.execute(args)”
- Parameters:
args['raw_csv_point_data_path'] (string) – path to a csv file of the format
args['hostname'] (string) – hostname to host Pyro server.
args['port'] (int/or string representation of int) – port number to host Pyro entry point.
args['max_year'] (int) – maximum year allowed to be queries by user
args['min_year'] (int) – minimum valid year allowed to be queried by user
- Returns:
Never returns