View on GitHub


Alarconpy is a tools collection in Python programming language that offers many functions and algorithms for several meteorological applications as well as for a quickly processing weather data

Alarconpy: A Python Package for Meteorologists



Note: If you use Alarconpy in a research article, please cite as: Pérez-Alarcón, A. and Fernández-Alvarez, J.C. (2021). Alarconpy: A Python Package for Meteorologists (Version 1.0.4). Zenodo. doi: 10.5281/zenodo.4493257 </br> ……………………………………………………………………

Alarconpy v1.0.4 includes, among other, functions for calculating some atmospheric variables such as saturation vapor pressure and relative humidity, units converting, maps creation, predefined color palettes for plotting meteorological variables and some tropical cyclones applications such as radial wind profiles. It also contains in a same function the facilities of other Python packages benefiting existing and future users.

Alarconpy requirements

python status
Python2 no tested
Python3 tested

Alarconpy is developed for Python 3.x and there are some python libraries required for use it:


We recommend using the Alarconpy package in the Anaconda environment. Just clone the Alarconpy repository

You can use

conda install -c apa_py alarconpy


git clone

and copy the alarconpy folder into alarconpy (cloned folder) to anaconda installation


Please check that you have installed all dependencies nedeed for Alarconpy.


Alarconpy examples

Plotting maps

Figure shows the use of the Alarconpy to create a geographic map with Cartopy. As can be seen in practically one line of code (without count the lines to import required packages), a geographic map was created, while making this same map using directly Cartopy package it is required at least of 10 lines of code. Screenshot

The get_map(arguments*) function contains the possibility to use new backgrounds for the maps, as shown in the Figure 2 on the bottom map, where the Blue Marble (https://neo.sci.gsfc.nasa.govview.php?datasetId=BlueMarbleNG-TB) background was used. It also allows to change the resolution of the map background, the font size and the interval to draw the parallels and meridians.

Operations with time

Many meteorological data files contain the date in Unix Time format (number of seconds elapsed since the start of the Unix epoch at 1 January 1970 00:00:00 UTC). The Alarconpy package provides a function to convert the date in Unix Time to Julian date. The following code shows the use of the time calc(arguments*) function:

import alarconpy as al

Out[2]: str(al.time_calc("1970-01-01 00:00:00",1592094920.964/3600.))
Out[3]: '2020-06-14 00:35:20.964000'

It also includes a function to calculate the total hours elapsed between two dates:

Out[3] al.time_dif("20200610000000","20200612000000")
Out[3]: 48

Interpolation methods

As mentioned above, Alarconpy includes the Scipy and Metpy interpolation methods in the same function, which facilitates the implementation of any of them easily and quickly. Available interpolation methods are “linear”, “nearest”, “cubic” and “rbf” from Scipy and “natural_neighbor”,”barnes” and “cressman” from Metpy. Below is an example of the use of some of them.

import alarconpy as al

In [2]: print(points)
[[-99.875   5.125]
 [-99.625   5.125]
 [-99.375   5.125]
 [-15.375  35.125]
 [-15.125  35.125]
 [-14.875  35.125]]
In [3]:  print(ipoints)
[[-50.  22.]] 

In [4]: print(sst)
[[28.27 28.31 28.40 ...
  28.85 28.70 28.63]
 [28.61 28.61 28.63 ...
  28.84 28.68 28.61]
 [28.77 28.76 28.76 ...
  28.89 28.73 28.65]
 [--  19.60 19.61 19.60]
 [--  19.53 19.56 19.55]
 [--  19.52 19.55 19.56]]

In[5]: al.points_interpolation(points,sst.flatten(),ipoints,interp_type="linear")
Out[5]: array([26.3949995])

In[6]: al.points_interpolation(points,sst.flatten(),ipoints,interp_type="natural_neighbor")
Out[6]: array([26.39])

In[7]: al.points_interpolation(points,sst.flatten(),ipoints,interp_type="nearest")
Out[7]: array([26.44999885559082])

In[8]: al.points_interpolation(points,sst.flatten(), ipoints,interp_type="cubic")
Out[8]: array([26.37522029])

Units conversion

This python package presented in this article includes a function that allows unit conversion. Supports conversion of units, among others, in acceleration, angle, area, moment of inertia, density, length, mass, temperature and velocity. Below is shown an example:

import alarconpy as al

In[2]:al.units_conversion( 1,"knots", "m/s" )
Out[2]: 0.514444

In[3]:al.units_conversion( 1,"km", "m" )
Out[3]: 1000

In[4]: al.units_conversion( 300,"degK", "degC" )
Out[4]: 26.850000000000023

Color palettes

Alarconpy includes several color palettes for representing different meteorological variables. Figure shows an example of their use. The color palettes developed in Alarconpy are in agreement with the color palettes used for plotting the corresponding meteorological variables at the Cuban Institute of Meteorology.


Tropical cyclones modules

The radial wind profiles of tropical cyclones are a powerful tool for describing the radial wind structure of these storms. Alarconpy incorporates a module with the implementation of several radial wind profiles: Holland (1980), DeMaria (1987), Emanuel (2004), Willoughby et al. (2006), Emanuel and Rotunno (2011), Frisius and Scgönemann (2013) and Chavas et al. (2015). Figure shows an example of using the profiles module to obtain the TC radial wind structure from Holland (1980) and Emanuel and Rotunno (2011) radial wind profiles.


For the study of the risk associated with the impact of TCs on a certain geographic area, it is important to make a mask of the area occupied by the TC that allows it to be distinguished from the environment undisturbed by cyclonic circulation. Therefore, the function create TCmask(arguments*) was incorporated into Alarconpy package, which allows to be performed quickly this mask, as shown in the following figure.


In several occasions, in order to provide an evaluation of the TCs track forecast, it is necessary to calculate the distance between two geographic locations. The python package presented in this article includes the implementation of the Haversine function for calculating the distance between two geographic coordinates. The code segment below shows the simplicity of its use.

import alarconpy as al





Out[7]: 919.627811821197

Text files

One of the most important aspects of Alarconpy is the incorporation of the index_row(arguments*) function, which allows to quickly determine the indexes in which a certain character string is found in a list of string. The code presented below shows the use of this function to determine the position of Hurricane Irma (AL112017) entries in the HURDAT2 database of the National Hurricane Center (NHC). The HURDAT2 database have a text format with contain information every six hours about the location, maximum winds, minimum central pressure of all known tropical and subtropical cyclones.

import alarconpy as al






Out[9]: 'AL112017,       IRMA,     66,\n'

Plotting of meteorological variables

Finally, Alarconpy has several functions for plotting some meteorological variables. These functions were developed to plot the outputs of the Numerical Tools for Weather Forecast system (NTWF) and the Numerical Tools for Hurricane Forecast system (NTHF), which are based on the NMM (Nonhydrostatic Mesoscale Model)) dynamic core of the WRF (Weather Research and Forecasting) model. Both were developed in the Department of Meteorology of the Higher of Tecnologies and Applied Sciences, University of Havana. NTWF and NTHF outputs are available at Figure shows an example of the use of this plotting functions.


The Alarconpy’s plotting functions could be used to plot the outputs of any numerical weather forecast model or any meteorological data matrix which contains information of some meteorological variable included in this package.