seagrid.sources.static.longhurst#

Longhurst biogeographical provinces on any grid, in two versions.

"2007" (the default): the 57 provinces of Longhurst (2007) on a 1/6° grid (Longhurst_Regions_2007.nc). "1995": the 54 “initial static boundaries” (Longhurst 1995; 1998) as polygons, the Marine Regions v4 (2010) shapefile. Using it warns, because its provinces and numbers differ.

Module Attributes

BASINS

no province, i.e. land).

BIOMES

no province, i.e. land).

VERSIONS

Province versions; 2007 is the default.

PROVINCES

The 54 provinces of the 1995 version (the Marine Regions v4 (2010) shapefile): (code, name, biome, basin).

PROVINCES_2007

The 57 provinces of the 2007 version, (code, name, biome, basin), in the order of their numbers (from 1), as in the 2.x province table.

RAW_CODES_2007

Codes of the 2007 provinces in Longhurst_Regions_2007.nc, in table order.

Functions

check_version(version)

Return version as "2007" or "1995"; None is the default, 2007.

lookup(provinces, kind[, version])

Map province numbers to biome or basin codes (0 stays 0).

province_table([version])

Return the provinces with their numbers, biomes and basins.

regions_2007(raw)

Return 2007 province numbers from the codes of Longhurst_Regions_2007.nc.

shapefile_to_geojson(zip_path, dest)

Convert the zipped Longhurst shapefile (the SAERI copy) to GeoJSON.

warn_1995([stacklevel])

Warn that the 1995 provinces are used.

Classes

Longhurst([variant])

Longhurst biogeographical provinces, with biomes and basins.

seagrid.sources.static.longhurst.BASINS = {'Arctic': 1, 'Atlantic': 2, 'Indian': 3, 'Land': 0, 'Pacific': 4, 'Southern': 5}#

no province, i.e. land).

Type:

Basin codes of basins (0

seagrid.sources.static.longhurst.BIOMES = {'Coastal': 1, 'Land': 0, 'Polar': 2, 'Trades': 3, 'Westerlies': 4}#

no province, i.e. land).

Type:

Biome codes of biomes (0

seagrid.sources.static.longhurst.PROVINCES: tuple[tuple[str, str, str, str], ...] = (('BPLR', 'Boreal Polar Province (POLR)', 'Polar', 'Arctic'), ('ARCT', 'Atlantic Arctic Province', 'Polar', 'Atlantic'), ('SARC', 'Atlantic Subarctic Province', 'Polar', 'Atlantic'), ('NADR', 'N. Atlantic Drift Province (WWDR)', 'Westerlies', 'Atlantic'), ('GFST', 'Gulf Stream Province', 'Westerlies', 'Atlantic'), ('NASW', 'N. Atlantic Subtropical Gyral Province (West) (STGW)', 'Westerlies', 'Atlantic'), ('NATR', 'N. Atlantic Tropical Gyral Province (TRPG)', 'Trades', 'Atlantic'), ('WTRA', 'Western Tropical Atlantic Province', 'Trades', 'Atlantic'), ('ETRA', 'Eastern Tropical Atlantic Province', 'Trades', 'Atlantic'), ('SATL', 'South Atlantic Gyral Province (SATG)', 'Trades', 'Atlantic'), ('NECS', 'NE Atlantic Shelves Province', 'Coastal', 'Atlantic'), ('CNRY', 'Canary Coastal Province (EACB)', 'Coastal', 'Atlantic'), ('GUIN', 'Guinea Current Coastal Province', 'Coastal', 'Atlantic'), ('GUIA', 'Guianas Coastal Province', 'Coastal', 'Atlantic'), ('NWCS', 'NW Atlantic Shelves Province', 'Coastal', 'Atlantic'), ('MEDI', 'Mediterranean Sea, Black Sea Province', 'Westerlies', 'Atlantic'), ('CARB', 'Caribbean Province', 'Trades', 'Atlantic'), ('NASE', 'N. Atlantic Subtropical Gyral Province (East) (STGE)', 'Westerlies', 'Atlantic'), ('BRAZ', 'Brazil Current Coastal Province', 'Coastal', 'Atlantic'), ('FKLD', 'SW Atlantic Shelves Province', 'Coastal', 'Atlantic'), ('BENG', 'Benguela Current Coastal Province', 'Coastal', 'Atlantic'), ('MONS', 'Indian Monsoon Gyres Province', 'Trades', 'Indian'), ('ISSG', 'Indian S. Subtropical Gyre Province', 'Trades', 'Indian'), ('EAFR', 'E. Africa Coastal Province', 'Coastal', 'Indian'), ('REDS', 'Red Sea, Persian Gulf Province', 'Coastal', 'Indian'), ('ARAB', 'NW Arabian Upwelling Province', 'Coastal', 'Indian'), ('INDE', 'E. India Coastal Province', 'Coastal', 'Indian'), ('INDW', 'W. India Coastal Province', 'Coastal', 'Indian'), ('AUSW', 'Australia-Indonesia Coastal Province', 'Coastal', 'Indian'), ('BERS', 'N. Pacific Epicontinental Province', 'Polar', 'Pacific'), ('PSAE', 'Pacific Subarctic Gyres Province (East)', 'Westerlies', 'Pacific'), ('PSAW', 'Pacific Subarctic Gyres Province (West)', 'Westerlies', 'Pacific'), ('KURO', 'Kuroshio Current Province', 'Westerlies', 'Pacific'), ('NPPF', 'N. Pacific Polar Front Province', 'Westerlies', 'Pacific'), ('NPSW', 'N. Pacific Subtropical Gyre Province (West)', 'Westerlies', 'Pacific'), ('TASM', 'Tasman Sea Province', 'Westerlies', 'Pacific'), ('SPSG', 'S. Pacific Subtropical Gyre Province', 'Westerlies', 'Pacific'), ('NPTG', 'N. Pacific Tropical Gyre Province', 'Trades', 'Pacific'), ('PNEC', 'N. Pacific Equatorial Countercurrent Province', 'Trades', 'Pacific'), ('PEQD', 'Pacific Equatorial Divergence Province', 'Trades', 'Pacific'), ('WARM', 'W. Pacific Warm Pool Province', 'Trades', 'Pacific'), ('ARCH', 'Archipelagic Deep Basins Province', 'Trades', 'Pacific'), ('ALSK', 'Alaska Downwelling Coastal Province', 'Coastal', 'Pacific'), ('CCAL', 'California Upwelling Coastal Province', 'Coastal', 'Pacific'), ('CAMR', 'Central American Coastal Province', 'Coastal', 'Pacific'), ('CHIL', 'Chile-Peru Current Coastal Province', 'Coastal', 'Pacific'), ('CHIN', 'China Sea Coastal Province', 'Coastal', 'Pacific'), ('SUND', 'Sunda-Arafura Shelves Province', 'Coastal', 'Pacific'), ('AUSE', 'East Australian Coastal Province', 'Coastal', 'Pacific'), ('NEWZ', 'New Zealand Coastal Province', 'Coastal', 'Pacific'), ('SSTC', 'S. Subtropical Convergence Province', 'Westerlies', 'Southern'), ('SANT', 'Subantarctic Province', 'Westerlies', 'Southern'), ('ANTA', 'Antarctic Province', 'Polar', 'Southern'), ('APLR', 'Austral Polar Province', 'Polar', 'Southern'))#

The 54 provinces of the 1995 version (the Marine Regions v4 (2010) shapefile): (code, name, biome, basin). Province numbers are the positions in this table, from 1, in Longhurst’s order. Names and biomes are those of the shapefile; basins are those of the 2007 table, whose codes BPRL, NAST E, NAST W and HUMB are BPLR, NASE, NASW and CHIL here.

seagrid.sources.static.longhurst.PROVINCES_2007: tuple[tuple[str, str, str, str], ...] = (('BPRL', 'Boreal Polar Province', 'Polar', 'Arctic'), ('ARCT', 'Atlantic Arctic Province', 'Polar', 'Atlantic'), ('SARC', 'Atlantic Subarctic Province', 'Polar', 'Atlantic'), ('NADR', 'N. Atlantic Drift Province', 'Westerlies', 'Atlantic'), ('GFST', 'Gulf Stream Province', 'Westerlies', 'Atlantic'), ('NAST W', 'N. Atlantic Subtropical Gyre Province (West)', 'Westerlies', 'Atlantic'), ('NATR', 'N. Atlantic Tropical Gyre Province', 'Trades', 'Atlantic'), ('WTRA', 'Western Tropical Atlantic Province', 'Trades', 'Atlantic'), ('ETRA', 'Eastern Tropical Atlantic Province', 'Trades', 'Atlantic'), ('SATL', 'South Atlantic Gyre Province', 'Trades', 'Atlantic'), ('NECS', 'NE Atlantic Shelves Province', 'Coastal', 'Atlantic'), ('CNRY', 'Canary Coastal Province', 'Coastal', 'Atlantic'), ('GUIN', 'Guinea Current Coastal Province', 'Coastal', 'Atlantic'), ('GUIA', 'Guianas Coastal Province', 'Coastal', 'Atlantic'), ('NWCS', 'NW Atlantic Shelves Province', 'Coastal', 'Atlantic'), ('MEDI', 'Mediterranean Sea', 'Westerlies', 'Atlantic'), ('CARB', 'Caribbean Province', 'Trades', 'Atlantic'), ('NAST E', 'N. Atlantic Subtropical Gyre Province (East)', 'Westerlies', 'Atlantic'), ('CHSB', 'Chesapeake Bay Province', 'Coastal', 'Atlantic'), ('BRAZ', 'Brazil Current Coastal Province', 'Coastal', 'Atlantic'), ('FKLD', 'SW Atlantic Shelves Province', 'Coastal', 'Atlantic'), ('BENG', 'Benguela Current Coastal Province', 'Coastal', 'Atlantic'), ('MONS', 'Indian Monsoon Gyres Province', 'Trades', 'Indian'), ('ISSG', 'Indian S. Subtropical Gyre Province', 'Trades', 'Indian'), ('EAFR', 'E. Africa Coastal Province', 'Coastal', 'Indian'), ('REDS', 'Red Sea, Persian Gulf Province', 'Coastal', 'Indian'), ('ARAB', 'NW Arabian Upwelling Province', 'Coastal', 'Indian'), ('INDE', 'E. India Coastal Province', 'Coastal', 'Indian'), ('INDW', 'W. India Coastal Province', 'Coastal', 'Indian'), ('AUSW', 'Australia-Indonesia Coastal Province', 'Coastal', 'Indian'), ('BERS', 'N. Pacific Epicontinental Province', 'Polar', 'Pacific'), ('PSAE', 'Pacific Subarctic Gyres Province (East)', 'Westerlies', 'Pacific'), ('PSAW', 'Pacific Subarctic Gyres Province (West)', 'Westerlies', 'Pacific'), ('KURO', 'Kuroshio Current Province', 'Westerlies', 'Pacific'), ('NPPF', 'N. Pacific Polar Front Province', 'Westerlies', 'Pacific'), ('NPSE', 'N. Pacific Subtropical Gyre Province (East)', 'Westerlies', 'Pacific'), ('NPSW', 'N. Pacific Subtropical Gyre Province (West)', 'Westerlies', 'Pacific'), ('OCAL', 'Offshore California Current Province', 'Westerlies', 'Pacific'), ('TASM', 'Tasman Sea Province', 'Westerlies', 'Pacific'), ('SPSG', 'South Pacific Gyre Province', 'Trades', 'Pacific'), ('NPTG', 'N. Pacific Tropical Gyre Province', 'Trades', 'Pacific'), ('PNEC', 'N. Pacific Equatorial Countercurrent Province', 'Trades', 'Pacific'), ('PEQD', 'Pacific Equatorial Divergence Province', 'Trades', 'Pacific'), ('WARM', 'W. Pacific Warm Pool Province', 'Trades', 'Pacific'), ('ARCH', 'Archipelagic Deep Basins Province', 'Trades', 'Pacific'), ('ALSK', 'Alaska Downwelling Coastal Province', 'Coastal', 'Pacific'), ('CCAL', 'California Upwelling Coastal Province', 'Coastal', 'Pacific'), ('CAMR', 'Central American Coastal Province', 'Coastal', 'Pacific'), ('HUMB', 'Chile-Peru Current Coastal Province', 'Coastal', 'Pacific'), ('CHIN', 'China Sea Coastal Province', 'Coastal', 'Pacific'), ('SUND', 'Sunda-Arafura Shelves Province', 'Coastal', 'Pacific'), ('AUSE', 'East Australian Coastal Province', 'Coastal', 'Pacific'), ('NEWZ', 'New Zealand Coastal Province', 'Coastal', 'Pacific'), ('SSTC', 'S. Subtropical Convergence Province', 'Westerlies', 'Southern'), ('SANT', 'Subantarctic Province', 'Westerlies', 'Southern'), ('ANTA', 'Antarctic Province', 'Polar', 'Southern'), ('APLR', 'Austral Polar Province', 'Polar', 'Southern'))#

The 57 provinces of the 2007 version, (code, name, biome, basin), in the order of their numbers (from 1), as in the 2.x province table. In Longhurst_Regions_2007.nc they are the codes 1-22, 30-37, 50-72 and 80-83 in this order; 0 and 99 are land.

seagrid.sources.static.longhurst.VERSIONS = ('2007', '1995')#

Province versions; 2007 is the default.

class seagrid.sources.static.longhurst.Longhurst(variant=None, **overrides)[source]#

Bases: HTTPSource

Longhurst biogeographical provinces, with biomes and basins.

Two versions, chosen as variants:

  • get_source("longhurst"): the 2007 version, 57 provinces on a 1/6° grid, from Longhurst_Regions_2007.nc in datadir. Its last known server (url) is gone and no other is known, so the file must be copied there by hand.

  • get_source("longhurst", variant="1995"): the 54 initial static boundaries as polygons, downloaded once as GeoJSON from the Marine Regions WFS (url) or, if that fails, as the same shapefile from SAERI (mirror). Using it warns.

open_dataset() returns regions (province number, see province_table(); 0 on land), biomes and basins (see BIOMES, BASINS) on the 1/6° grid, and regions_on() puts the provinces on any grid. Every source has longhurst_provinces(), longhurst_biomes() and longhurst_basins() on its own grid. Static.

Settings section [longhurst]: version, url, mirror, filename, grid, and [longhurst.variants.1995].

Examples

>>> import seagrid
>>> seagrid.get_source("longhurst").filename()
'Longhurst_Regions_2007.nc'
>>> seagrid.get_source("longhurst", variant="1995").filename()
'longhurst_v4_2010.geojson'
Parameters:
  • variant (str | None)

  • overrides (Any)

property version: str#

"2007" or "1995", from the version setting.

table()[source]#

Return province_table() of this version.

Return type:

DataFrame

read_definitions()[source]#

Return the province table (the 2.x name of table()).

Return type:

DataFrame

polygons()[source]#

Return the 54 polygons of the 1995 version, in PROVINCES order.

Downloads the GeoJSON on first use.

Returns:

list of shapely geometries

Raises:

ValueError – For the 2007 version, which is a grid.

Return type:

list[Any]

regions_on(grid)[source]#

Return the province number of every cell of grid (0 outside them).

1995: the polygon that contains the cell centre. 2007: the 1/6° cell nearest to the cell centre. No warning, no filling of coastal cells (see DataSource.longhurst_provinces).

Parameters:

grid (Grid or anything :func:`seagrid.grids.as_grid accepts`)

Returns:

numpy.ndarray – int16 on grid.

Return type:

ndarray

seagrid.sources.static.longhurst.check_version(version)[source]#

Return version as "2007" or "1995"; None is the default, 2007.

Raises:

ValueError – For any other version.

Parameters:

version (str | None)

Return type:

str

Examples

>>> check_version(None), check_version(1995)
('2007', '1995')
seagrid.sources.static.longhurst.lookup(provinces, kind, version=None)[source]#

Map province numbers to biome or basin codes (0 stays 0).

Parameters:
  • provinces (numpy.ndarray) – Province numbers (0 for none).

  • kind ({"biome", "basin"})

  • version ({"2007", "1995"}, optional) – Version of the province numbers. Default "2007".

Returns:

numpy.ndarray – int16, the shape of provinces.

Return type:

ndarray

seagrid.sources.static.longhurst.province_table(version=None)[source]#

Return the provinces with their numbers, biomes and basins.

Parameters:

version ({"2007", "1995"}, optional) – Default "2007".

Returns:

pandas.DataFrame – Columns ID (province number, as in regions), Code, Province, Biome, Basin, biome_id and basin_id (the codes in BIOMES and BASINS).

Return type:

DataFrame

Examples

>>> table = province_table()
>>> len(table), table.loc[table.Code == "NADR", "ID"].item()
(57, 4)
>>> len(province_table("1995"))
54