plasticparcels.utils#

plasticparcels.utils.create_directory(directory)[source]#

Function to create a directory if it does not exist.

plasticparcels.utils.distance(lon1, lat1, lon2, lat2)[source]#

Function to calculate the great circle distance between two points on the earth (specified in decimal degrees).

plasticparcels.utils.download_plasticparcels_dataset(dataset: str, settings, data_home=None)[source]#

Function to load an example dataset from the parcels website.

This function provides quick access to a small number of example datasets that are useful in documentation and testing in parcels.

Parameters:
  • dataset (str) – Name of the dataset to load.

  • settings (dict) – Dictionary containing the settings for the models and simulation.

  • data_home (pathlike, optional) – The directory in which to cache data. If not specified, the value of the PLASTICPARCELS_DATA environment variable, if any, is used. Otherwise the default location is assigned by get_data_home().

Returns:

dataset_folder – Path to the folder containing the downloaded dataset files.

Return type:

Path

plasticparcels.utils.get_coords_from_polygon(shape)[source]#

Function to return a list of coordinate points on a Polygon (or MultiPolygon) shape.

Based on: https://stackoverflow.com/questions/58844463/how-to-get-a-list-of-every-point-inside-a-multipolygon-using-shapely

plasticparcels.utils.getclosest_ij(lats, lons, latpt, lonpt)[source]#

Function to find the index of the closest point to a certain lon/lat value.

plasticparcels.utils.load_settings(filename)[source]#

Function to load a settings file in json format.

plasticparcels.utils.select_files(dirread, string_, date_current, dt_sim, i_date_s=-13, i_date_e=-3, dt_margin=8)[source]#

Function to select files in a directory based on a current date and a simulation duration.