Skip to main content

Se Level DBs

Project description

sealev

Allows to access various Sea Level Databases via python.

Installation

To install the package use the command:

pip install sealev

After the installation, it is possible to use the package in python:

python

List of available databases: getDB()

Once you are in python environment you can give the following collamnds

from sealev.sldb import seaLevelDB
sl=seaLevelDB()
#
# get the list of available database sources:
dbs=sl.getDBs()
#
for db in dbs:
   print(db)

You will get a list of all the database that you can query.

LIst the devices of a database: getDevs(<database>)

You can select one specific database, i.e. DART, and requst the list of available devices:

from sealev.sldb import seaLevelDB
sl=seaLevelDB()
darts=sl.getDevs('DART')
#
for dart in darts:
    print(dart['id'],dart['location'],format(dart['lat'])+'/'+format(dart['lon']))
#

The response will be:

21413 Station 21413 - SOUTHEAST TOKYO - 700NM ESE of Tokyo, JP 30.492/152.085
21414 Station 21414 - AMCHITKA - 170 NM South of Amchitka, AK 48.97/178.165
21415 Station 21415 - ATTU - 175 NM South of Attu, AK 50.12/171.867
21416 Station 21416 - KAMCHATKA PENINSULA - 240NM SE of Kamchatka Peninsula, RU 48.12/163.43
21418 Station 21418 - NORTHEAST TOKYO - 450 NM NE of Tokyo, JP 38.73/148.8
...
56003 Station 56003 - Indian Ocean 2     -     630km NNE of Dampier -15.019/118.073

The response if a list of devices; each device is a dictionary composed of:

  • id identifier of the device (will be used to retrieve data)
  • location place of the device
  • country country of the device
  • lat/lon coordinates of the device
  • [group] if it exists it represents a subclass of the database

the keyword 'id' contains the reference identifier to retrieve the level data.

Retrieve sea level of a device: getLevel(<database>,<device>, [<tmin>],[<tmax>])

Suppose you want to retrieve the level values of one specific device, such as 21414 (Station 21414 - AMCHITKA - 170 NM South of Amchitka), you can give the following command:

from sealev.sldb import seaLevelDB
sl=seaLevelDB()
values=sl.getLevel('DART','21414')
for j in range(len(values['x'])):
    print(values['x'][j],values['y'][j])

The response of the example above is a list of data if the device has recent recorded data:

2024-10-02 00:00:00 5442.868
2024-10-02 00:15:00 5442.874
2024-10-02 00:30:00 5442.882
2024-10-02 00:45:00 5442.891
2024-10-02 01:00:00 5442.897
...

You can retrieve data from the past adding the keyword tmin, tmax in the getLevel call. Example

from sealev.sldb import seaLevelDB
sl=seaLevelDB()
values=sl.getLevel('GLOSS @vliz','mnza','2022-09-19 00:00:00','2022-09-21 00:00:00')
for j in range(len(values['x'])):
    print(values['x'][j],values['y'][j])

The example above retrieves and print the data related to the Tsunami event in Mexico. mexico_mnza

The response is a dctionary containing the following keys:

  • x (list) containing a series of datatime values representing the time of the level
  • y (list) containing a series of sea level values of the device (m) each point of the x list will have a corresponding point in y In the example above, if you have setup the matplotlib package (pip install matplotlib), you can plot the quantities with the commands:
import matplotlib.pyplot as plt
plt.plot(values['x'],values['y'])
plt.xlabel('Date/Time')
plt.ylabel('Level (m)')
plt.title('M7.6 MEXICO, 2022-09-19 18:05:00')
plt.show()

The following plot would be generated: Figure_1

As another example, let's show the Hurricane Helene 2024 at Clearwater Beach (USA)

from sealev.sldb import seaLevelDB
import matplotlib.pyplot as plt

sl=seaLevelDB()
values=sl.getLevel('GLOSS @vliz','cwfl','2024-09-24 00:00:00','2024-09-29 00:00:00')

plt.plot(values['x'],values['y'])
plt.xlabel('Date/Time')
plt.ylabel('Level (m)')
plt.title('Clearwater Beach (FL), Cyclone Helene-24')
plt.show()

the output will be: helene

Export to csv file: to_csv(values,fnameout)

After having retrieved the values dictionary, you can export in a csv file. Example

from sealev.sldb import seaLevelDB
sl=seaLevelDB()
values=sl.getLevel('GLOSS @vliz','mnza','2022-09-19 00:00:00','2022-09-21 00:00:00')
sl.to_csv(values,'output.csv')

Extract other quantities

In some cases (i.e. JRC_TAD database), many other quantities are retrieved from the database in addition to the level. In these cases the available keys are many more thabn x and y, that however always eist. The other quantities can also be retrieved. The xample below collects the data of Cadiz (IDSL-06) from the JRC database and creates a plot of the battery voltage.

import matplotlib.pyplot as plt
from sealev.sldb import seaLevelDB
sl=seaLevelDB()
#
values=sl.getLevel('JRC_TAD','IDSL-06','2024-10-03 00:00:00','2024-10-08 00:00:00')
print('List of possible quantities to plot:',values.keys())
plt.plot(values['x'],values['anag3'])
plt.xlabel('Date/Time')
plt.ylabel('Battery voltage (volt)')
plt.title('Cadiz device IDSL-06')
plt.show()

The output plot is the folllowing: voltage

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

sealev-0.0.18.tar.gz (21.3 kB view details)

Uploaded Source

Built Distribution

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

sealev-0.0.18-py3-none-any.whl (19.6 kB view details)

Uploaded Python 3

File details

Details for the file sealev-0.0.18.tar.gz.

File metadata

  • Download URL: sealev-0.0.18.tar.gz
  • Upload date:
  • Size: 21.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.0

File hashes

Hashes for sealev-0.0.18.tar.gz
Algorithm Hash digest
SHA256 792486e48384e61d8ab4d6c055a638e995063d452701930ae0a3b63a1a0fbb5e
MD5 ec3bdb3f68329af720577196d3ddfe2b
BLAKE2b-256 87787c71bf86f19bf7e762d966f73add3a45be5a5f44e360f10d12fa9f47fe8d

See more details on using hashes here.

File details

Details for the file sealev-0.0.18-py3-none-any.whl.

File metadata

  • Download URL: sealev-0.0.18-py3-none-any.whl
  • Upload date:
  • Size: 19.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.0

File hashes

Hashes for sealev-0.0.18-py3-none-any.whl
Algorithm Hash digest
SHA256 92ae38fc2180ed5f5ffb825981dc6aae68a2742f248ed0c44b8e84db8ca8155b
MD5 e07439a32b74e248c439ae6d9afc45d3
BLAKE2b-256 f0cec0cd61354bbdf43eeb41246f117e8e1bc821a44c2ce2be74567bb83a3609

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