Skip to main content

Tools to specify the region of interest when analysing float, satellite or model data

Project description

Build status Build status Build status License

Basins

This project contains tools to specify regions of interest when analysing float, satellite or model data. They are managed through a C++ interface for maximum performance and contain data extracted from shapefiles.

The code has been optimized under AVX/AVX2 vectorization directives using the Intel(r) C++ compiler (icpc). Although this is the default compilation mode, it is not strictly required as the makefile will automatically default to GNU if the Intel compilers are not found.

The default optimization mode is fast although it can be changed using the variable OPTL, e.g.,

make OPTL=2

Deployment

A Makefile is provided within the tool to automate the installation for easiness of use for the user. To install the tool simply create a virtual environment as stated below or use the system Python. Once this is done simply type:

make

This will install all the requirements and install the package to your active python. To uninstall simply use

make uninstall

The previous operations can be done one step at a time using

make requirements

to install all the requirements;

make python

to compile and;

make install

to install the tool.

Virtual environment

The package can be installed in a Python virtual environement to avoid messing with the system Python installation. Next, we will use Conda for this purpose. Assuming that Conda is already installed, we can create a virtual environment with a specific python version and name (my_env) using

conda create -n my_env python=3.8

The environment is placed in ~/.conda/envs/my_env. Next we activate it be able to install packages using conda itself or another Python package manager in the environment directory:

conda activate my_env

Then just follow the instructions as stated above.

Python implementation

The basins module solves the 2D point in polygon problem in order to verify if a point is inside a geometry.

It defines the following basic entities:

  • Point
  • Vector (internal)
  • Ball
  • Polygon
  • Line
  • SimpleRectangle
  • Rectangle
  • Plane
  • SimpleCube
  • Cube

as well as the basin entity defined by an array of points. A number of predefined basins are included from different sources. The generic basins are:

  • med, Mediterranean Sea
  • wmed, Western Mediterranean
  • emed, Eastern Mediterranean
  • socean, Southern Ocean
  • kotor, Bay of Kotor

The methods isinside(Point) or areinside(np.array) can be used to check if a point or a set of points are inside (True) or outside (False) the region.

p1 = Basins.Point(0.5,0.5,0.5)
inside = Basins.med.isinside(p1)
inside = Basins.med > p1 # alternative to isinside

and the same works for numpy arrays using areinside

xyzp   = np.array([[.5,.5,0.1],[1.,.35,0.6],[0.2,0.5,1.2],[.35,.15,0.5]])
inside = Basins.med.areinside(xyzp)
inside = Basins.med > xyzp

Note that the operator > is more generic and is able to understand if the input data is a Point or a numpy array of points.

Basins information tool

The command line tool basins_info provides basic info about the available basins inside this tool. To list all the basins just run:

basins_info -l

Information on different basins can be obtained by the command:

basins_info -b <module>.<basin>

where module is the group where the basin belongs (eg., worldseas) and basin its name (eg. kotor). Using either -d or --display_ a plot of the basin will be generated. The polygon that forms the basin can be dumped to a text file as shown in this example:

basins_info -b worldseas.adr -p poly_adr.txt

which will store the polygon forming the Adriatic sea into the file poly_adr.txt.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

basins-1.6.6.tar.gz (22.4 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

basins-1.6.6-py3-none-any.whl (22.4 MB view details)

Uploaded Python 3

File details

Details for the file basins-1.6.6.tar.gz.

File metadata

  • Download URL: basins-1.6.6.tar.gz
  • Upload date:
  • Size: 22.4 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.24

File hashes

Hashes for basins-1.6.6.tar.gz
Algorithm Hash digest
SHA256 461b8014515ab82def7826fc5c1d258b74e8426f620d38d163f7a419f7978d06
MD5 ffd5fcf75fecbd04c857e129dad7d576
BLAKE2b-256 48e4b432479792f3a0afd313e7db9a8cccc24fdd09b7a9f020ca57693d276e7b

See more details on using hashes here.

File details

Details for the file basins-1.6.6-py3-none-any.whl.

File metadata

  • Download URL: basins-1.6.6-py3-none-any.whl
  • Upload date:
  • Size: 22.4 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.24

File hashes

Hashes for basins-1.6.6-py3-none-any.whl
Algorithm Hash digest
SHA256 2d417d1845162c6fd4e51a37ae574eab993f69c8c337d76aead3c8446093f6da
MD5 0a036bed1fe45133a79cfd4ac5ae75a7
BLAKE2b-256 5e04bb19d9832c3d48e7f8d16af18979a765e18a34df550fcc80f98ae69524ab

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page