`AvailablePotentialEnergyFramework.AvailablePotentialEnergyFramework`

— ModuleData filters: `filter_array`

, `filter_array_2`

, `filter_array_time`

, `getsmoothdata`

, `getsmoothdata_nospace`

Data structures: `ape_budget`

, `cat_ape_budget`

, `cutborders!`

, `surf_quantities`

, `cyclone_comp_timemean`

, `Composite_Cyclone`

, `Composite_Cyclone_v2`

, `Composite_Cyclone_v3`

Methods: `cyclonecompositer`

, `shifter`

, `smoothfilter`

, `cyclonecompositer_v2`

, `cyclonecompositer_v3`

, `timemean_nofalseframe`

, `removefalseframes`

, `getapebudget`

, `buoyancybudget`

`AvailablePotentialEnergyFramework.add_allcyclones!`

— Methodadd*allcyclones!(addition :: Array{T,2}, buf :: Array{T,2},array :: Array{T,2},radius*bins,array :: Array{T,3},segmentedcyclones,cyclonescenters,gridspacing)

Compute the azimuthal average of some quantity around a center. Repeats the process and averages about all the tropical cyclones detected on the array. It receives an array with the radius bins to use,the field to average, called `array`

, each cyclone as a SegmentedImage,the centers of the cyclones and the gridspacing.

`AvailablePotentialEnergyFramework.add_allcyclones`

— Methodadd*allcyclones(array :: Array{T,2},radius*bins,array :: Array{T,3},segmentedcyclones,cyclonescenters,gridspacing)

Compute the azimuthal average of some quantity around a center. Repeats the process and averages about all the tropical cyclones detected on the array. It receives an array with the radius bins to use,the field to average, called `array`

, each cyclone as a SegmentedImage,the centers of the cyclones and the gridspacing.

`AvailablePotentialEnergyFramework.average_precipitation_per_pw_bin`

— Method`average_precipitation_per_pw_bin(pw,precipitation,bins,binspacing)`

Computes the mean precipitation as a function of the binned precipitable water following Yang, D., 2018: Boundary Layer Height and Buoyancy Determine the Horizontal Scale of Convective Self-Aggregation. J. Atmos. Sci., 75, 469–478, https://doi.org/10.1175/JAS-D-17-0150.1. It will be happy if bins is quite large (example from 0 to 300 mm).

`AvailablePotentialEnergyFramework.average_precipitation_per_pw_bin_dayang`

— Method`AvailablePotentialEnergyFramework.averageallindistance!`

— Method`averageallindistance!(radiusbin,array :: Array{T,3},center,gridspacing = 1)`

Create an average of the quantity in array at all the points located between radiusbin[1] and radiusbin[2] from a center. The points should be masked by a boolean array. It assumes a uniform gridspacing.

`AvailablePotentialEnergyFramework.averageallindistance`

— Method`averageallindistance(radiusbin,array :: Array{T,3},mask,center,gridspacing = 1)`

Create an average of the quantity in array at all the points located between radiusbin[1] and radiusbin[2] from a center. The points should be masked by a boolean array. It assumes a uniform gridspacing.

`AvailablePotentialEnergyFramework.averageallindistance`

— Method`averageallindistance(radiusbin,array :: Array{T,2},mask,center,gridspacing = 1)`

Create an average of the quantity in array at all the points located between radiusbin[1] and radiusbin[2] from a center. The points should be masked by a boolean array. It assumes a uniform gridspacing.

`AvailablePotentialEnergyFramework.azimuthalaverage_allcyclones`

— Method`azimuthalaverage_allcyclones(radius_bins,array :: Array{T,3},segmentedcyclones,cyclonescenters,gridspacing)`

Compute the azimuthal average of some quantity around a center. Repeats the process and averages about all the tropical cyclones detected on the array. It receives an array with the radius bins to use,the field to average, called `array`

, each cyclone as a SegmentedImage,the centers of the cyclones and the gridspacing.

`AvailablePotentialEnergyFramework.azimuthalaverage_allcyclones`

— Method`azimuthalaverage_allcyclones(radius_bins,array :: Array{T,3},segmentedcyclones,cyclonescenters,gridspacing)`

`array`

, each cyclone as a SegmentedImage,the centers of the cyclones and the gridspacing.

`AvailablePotentialEnergyFramework.buoyancybudget_old`

— Method––––––-This function computes the buoyancy budget–––––––- Inputs: B (buoyancy) RAD_b the radiative heating, converted to units of buoyancy Fs the Surface fluxes U,V,W The three dimensional velocities N2 The Brunt Va"isala frequency squared dx,dy,dz,dt the steps in each coordinate x,y,z,t the coordinate vectors

`AvailablePotentialEnergyFramework.compute_N2`

— Method`compute_N2(xBar_Tv,z)`

Take a (1,1,size(z),size(t)) profile of temperature or virtual temperature and return the Brunt - Väisälä frequency at each z level and at each t.

`AvailablePotentialEnergyFramework.create_APE_netcdf`

— MethodCreate NetCDF for storing ape budget variables

`AvailablePotentialEnergyFramework.detect_cyclones!`

— Methodfunction detect*cyclones!(buf1, buf2,pressure*anomaly,pressure_threshold,resolution) receive 2 buffers and a pressure anomaly and returns a segmented image with the cyclones

`AvailablePotentialEnergyFramework.detect_cyclones`

— Methodfunction detect*cyclones!(buf1, buf2,pressure*anomaly,pressure_threshold,resolution) receive 2 buffers and a pressure anomaly and returns a segmented image with the cyclones

`AvailablePotentialEnergyFramework.distance`

— Function`distance(x1,x2,gridspacing :: Number)`

Compute the cartesian distance between two points given their indices and the gridspacing. It asummes uniform grid.

`AvailablePotentialEnergyFramework.filter_array!`

— Method`filter_array!(buffer,array,smooth_x,smooth_t,position)`

Filters the input array *in-place* using a moving mean. In the first two dimensions the window width is smooth*x and the border is treated as circular (for doubly periodic domains). In the space dimension the width is smooth*t and the border value is replicated.

This function calls under the hood the imfilter function of Images.jl

The first argument must be a buffer of the same size of array.

`AvailablePotentialEnergyFramework.filter_array`

— Methodfilter*array(array,smooth*x,smooth_t,position)

Filters the input arrayusing a moving mean. In the first two dimensions the window width is smooth*x and the border is treated as circular (for doubly periodic domains). In the space dimension the width is smooth*t and the border value is replicated.

This function calls under the hood the imfilter function of Images.jl

The first argument must be a buffer of the same size of array.

`AvailablePotentialEnergyFramework.filter_array`

— Methodfilter*array(array,smooth*x,smooth_t,position)

Filters the input arrayusing a moving mean. In the first two dimensions the window width is smooth*x and the border is treated as circular (for doubly periodic domains). In the space dimension the width is smooth*t and the border value is replicated.

This function calls under the hood the imfilter function of Images.jl

The first argument must be a buffer of the same size of array.

`AvailablePotentialEnergyFramework.filter_array_2!`

— Methodfilter*array*2!(array,smooth*x,smooth*t,position)

Filters the input array *in-place* using a moving mean.

In the first two dimensions the window width is smooth

This function calls under the hood the imfilter function of Images.jl

`AvailablePotentialEnergyFramework.filter_array_2!`

— Method`filter_array_2!(array,smooth_x,smooth_t,position)`

Filter the input array *in-place* using a moving mean.

In the first two dimensions the window width is smooth

This function calls under the hood the imfilter function of Images.jl

`AvailablePotentialEnergyFramework.filter_array_nospace`

— Methodfilter*array*nospace(array,smooth_t,position)

Filters the input array using a moving mean along the third dimension. In the 3th dimension the width is smooth_t and the border value is replicated except if position = 2, in which case it only takes the inner part of the smoothed array.

This function calls under the hood the imfilter function of Images.jl

`AvailablePotentialEnergyFramework.filter_array_nospace`

— Methodfilter*array*nospace(array,smooth_t,position)

Filters the input array using a moving mean along the fourth dimension. In the 4th dimension the width is smooth_t and the border value is replicated except if position = 2, in which case it only takes the inner part of the smoothed array.

This function calls under the hood the imfilter function of Images.jl

`AvailablePotentialEnergyFramework.filter_array_time`

— Methodfilter*array*nospace(array,smooth_t,position=1)

Filters the input, 1-d array. The border value is replicated except if position = 2, in which case it only takes the inner part of the smoothed array.

This function calls under the hood the imfilter function of Images.jl

`AvailablePotentialEnergyFramework.findcyclonecenters!`

— Methodfindcyclonecenters*aspressureminima!(buf1,buf2,surf*pres*anomaly,detection*threshold)

Takes a surface pressure anomaly array surf*pres*anomaly[x,y] = surf*pres[x,y] .- mean(surf*pres,dims(1,2)) a detection threshold for the anomaly, and return an array of tuples (x,y) where each tuple represents the centers of cyclones identified as the minima of the anomaly.

`AvailablePotentialEnergyFramework.findcyclonecenters!`

— Methodfindcyclonecenters*aspressureminima!(buf1,buf2,surf*pres*anomaly,detection*threshold)

Takes a surface pressure anomaly array surf*pres*anomaly[x,y] = surf*pres[x,y] .- mean(surf*pres,dims(1,2)) a detection threshold for the anomaly, and return an array of tuples (x,y) where each tuple represents the centers of cyclones identified as the minima of the anomaly.

`AvailablePotentialEnergyFramework.findcyclonecenters`

— Methodfindcyclonecenters*aspressureminima(surf*pres*anomaly,detection*threshold)

Takes a surface pressure anomaly array surf*pres*anomaly[x,y] = surf*pres[x,y] .- mean(surf*pres,dims(1,2)) a detection threshold for the anomaly, and return an array of tuples (x,y) where each tuple represents the centers of cyclones identified as the minima of the anomaly.

`AvailablePotentialEnergyFramework.get_buoyancy`

— Methodget*buoyancy(temperature*anomaly,mean_temperature) Compute buoyancy from a temperature anomaly and a temperature profile as in RamirezReyes and Yang 2021

`AvailablePotentialEnergyFramework.get_buoyancy_of_lifted_parcel`

— Function`get_buoyancy_of_lifted_parcel(tparcel,rparcel,pparcel,t,r,p,ptop=50)`

`AvailablePotentialEnergyFramework.get_density_ideal_gas`

— Methodget*density*ideal_gas(pressure, temperature) Compute density of dry air from pressure and temperature using the Ideal gas law.

`AvailablePotentialEnergyFramework.get_lifted_condensation_level`

— Method`get_lifted_condensation_level(temperature,relative_humidity,pressure)`

Receive temperature in Kelvin, relative humidity (unitless) and pressure (hPa) and compute the lifted condensation level based on Emanuel's E94 "calcsound.f" code at http://texmex.mit.edu/pub/emanuel/BOOK/

`AvailablePotentialEnergyFramework.get_mixing_ratio`

— Method`get_mixing_ratio(water_vapor_partial_pressure,env_pressure)`

Receive a water vapor mixing ratio (unitless g/g) and environmental pressure and compute the partial pressure of water vapor in the same units as the incoming pressure.

`AvailablePotentialEnergyFramework.get_partial_vapor_pressure`

— Method`get_partial_vapor_pressure(mixing_ratio,pressure)`

Receive a water vapor mixing ratio (unitless g/g) and environmental pressure and compute the partial pressure of water vapor in the same units as the input pressure.

`AvailablePotentialEnergyFramework.get_potential_temperature`

— Method`get_potential_temperature(temperature, pressure, reference_pressure)`

Compute potential temperature from temperature and pressure.

`AvailablePotentialEnergyFramework.get_saturation_vapor_pressure`

— Method`get_saturation_vapor_pressure(T)`

Receive temperature T in Kelvin and compute the saturation vapor pressure in hPa from the August-Roche-Magnus formula that approximates the solution to the Clausius-Clapeyron relationship (Wikipedia contributors. (2020, December 19). Clausius–Clapeyron relation. In Wikipedia, The Free Encyclopedia. Retrieved 06:57, December 20, 2020, from https://en.wikipedia.org/w/index.php?title=Clausius%E2%80%93Clapeyron_relation&oldid=995159175)

`AvailablePotentialEnergyFramework.get_specific_entropy`

— Method`get_specific_entropy(temperature,mixing_ratio,pressure)`

Receive temperature in Kelvin, water vapor mixing ratio (unitless g/g) and pressure (hPa) and compute the specific entropy of a parcel using equation in Emmanuel's (E94, EQN. 4.5.9)

`AvailablePotentialEnergyFramework.get_virtual_temperature`

— Method`get_virtual_temperature(temperature,mixing_ratio_total_water,mixing_ratio_water_vapor)`

Receive temperature (K) and mixing ratios of total water and water vapor (unitless g/g) and compute the virtual temperature

`AvailablePotentialEnergyFramework.get_virtual_temperature`

— Method`get_virtual_temperature(temperature, specific_humidity)`

Compute virtual temperature from temperature and specific humidity.

`AvailablePotentialEnergyFramework.isindexindistancebin`

— Function`isindexindistancebin(binlimits,index,center = (0,0),gridspacing=1) = (binlimits[1] < distance(index,center,gridspacing) <= binlimits[2]) ? true : false`

computes the distance of one index to the origin and returns true if that distance is inside a bin

`AvailablePotentialEnergyFramework.isinteracting`

— Method`isinteracting(cyclones :: SegmentedImage,regionnumber)`

Computes the adjacency of identified cyclones and returns true if the cylone-number is adjacent to a region other than the background.

`AvailablePotentialEnergyFramework.isinteracting`

— Method`isinteracting(adjacencyMatrix :: SparseMatrixCSC,regionnumber)`

Computes the adjacency of identified cyclones and returns true if the cylone-number is adjacent to a region other than the background.

`AvailablePotentialEnergyFramework.kernel_1d`

— Method`kernel_1d(window)`

Create a kernel to perform a moving average filtering of a 1-d array. It will use window as windows size unless the given vaule is even, in which case it will add one to the given value before creating the kernel. This kernel has to be passed into imfilter or imfilter!

`AvailablePotentialEnergyFramework.kernel_2d`

— Functionkernel*2d(window*h,T :: Type :: Float64) Create a kernel to perform a moving average filtering of a 2-d array along the dimensions 1,2. It will use window_h as windows size unless the given vaule is even, in which case it will add one to the given value before creating the kernel. This kernel has to be passed into imfilter or imfilter!

`AvailablePotentialEnergyFramework.kernel_3d`

— Functionkernel*3d(window*h,window*t,T :: Type :: Float64) Create a kernel to perform a moving average filtering of a 3-d array along the dimensions 1,2 and 3. It will use window*h (dimensions 1 and 2) and window_t (dimension 3) as windows sizes unless the given vaules are even, in which case it will add one to the given value before creating the kernel. This kernel has to be passed into imfilter or imfilter!

`AvailablePotentialEnergyFramework.kernel_3d_t`

— Functionkernel*3d*t(window*t,T :: Type :: Float64) Create a kernel to perform a moving average filtering of a 3-d array along the dimension 3. It will use window*t as windows size unless the given vaule is even, in which case it will add one to the given value before creating the kernel. This kernel has to be passed into imfilter or imfilter!

`AvailablePotentialEnergyFramework.kernel_4d`

— Function`kernel_4d(window_h,window_t,T :: Type :: Float64)`

Create a kernel to perform a moving average filtering of a 4-d array along the dimensions 1,2 and 4. It will use window*h (dimensions 1 and 2) and window*t (dimension 4) as windows sizes unless the given vaules are even, in which case it will add one to the given value before creating the kernel. This kernel has to be passed into imfilter or imfilter!

`AvailablePotentialEnergyFramework.kernel_4d_t`

— Functionkernel*4d*t(window*t,T :: Type :: Float64) Create a kernel to perform a moving average filtering of a 4-d array along the dimension 4. It will use window*t as windows size unless the given vaule is even, in which case it will add one to the given value before creating the kernel. This kernel has to be passed into imfilter or imfilter!

`AvailablePotentialEnergyFramework.mixing_ratio_to_specific_humidity`

— Method`mixing_ratio_to_specific_humidity(mixing_ratio)`

Take a mixing ratio (unitless g/g) and return a specific humidity

`AvailablePotentialEnergyFramework.neighbours_2d`

— Methodneighbours_2d(arraysize,indicesCartesian) Compute de neighboring points of an index in a 2-d array considering periodic boundaries

`AvailablePotentialEnergyFramework.radiative_heating_rate_to_buoyancy`

— Methodradiative*heating*rate*to*buoyancy(mean*temperature,radiative*heating_rate) Convert radiative heating rate in K/s to buoyancy production rate in m/s^2 using the a mean sounding as reference profile

`AvailablePotentialEnergyFramework.set_netcdf_var!`

— MethodCreate NetCDF for storing ape budget variables

`AvailablePotentialEnergyFramework.shifter!`

— Method`shifter!(dest,array,time,domain_center,peak)`

Stores in `dest`

an array in which a pressure perturbation center is displaced to the center of the domain using circshift. Using it may assume periodic domain. Receives and SAM 3D+time or 2D+time array and two tuples, the (x,y) indices of the domain center, and the (x,y) indices of the location of the pressure perturbation peak.

`AvailablePotentialEnergyFramework.shifter`

— Method`shifter(array,domain_center,peak)`

Returns an array in which a pressure perturbation center is displaced to the center of the domain using circshift. Using it may assume periodic domain. Receives and SAM 3D+time or 2D+time array and two tuples, the (x,y) indices of the domain center, and the (x,y) indices of the location of the pressure perturbation peak.

`AvailablePotentialEnergyFramework.smooth_and_mask`

— Functionsmooth*and*mask(surf*pres*anomaly, threshold = -9)

Takes a 2d array and smooths it using a rolling median filter. It then returns the elements of the filtered array whose values are less than the threshold.

`AvailablePotentialEnergyFramework.smooth_and_mask!`

— Functionsmooth*and*mask!(buf,surf*pres*anomaly, threshold = -9)

Takes a 2d array and smooths it using a rolling median filter. It then returns the elements of the filtered array whose values are less than the threshold.

`AvailablePotentialEnergyFramework.smooth_vars_and_write_to_netcdf!`

— Method`smooth_vars_and_write_to_netcdf!(output_file,input_file,vars_to_smooth,window_h,window_t)`

Take a netcdf file, a list of variables and two integers and performs a moving mean smoothing of these variables. Write the smoothed fields into a netcdf file called output_file

`AvailablePotentialEnergyFramework.specific_humidity_to_mixing_ratio`

— Method`specific_humidity_to_mixing_ratio(specific_humidity)`

Take a specific humidity (unitless g/g) and return a mixing ratio

`AvailablePotentialEnergyFramework.surface_latent_heat_flux_to_buoyancy`

— Methodfunction surface*latent*heat*flux*to*buoyancy(SST , sensible*heat_flux ; rho = 1) Convert surface energy fluxes in units of W/m^2 to units of buoyancy m^2/s^3).

`AvailablePotentialEnergyFramework.surface_sensible_heat_flux_to_buoyancy`

— Methodfunction surface*sensible*heat*flux*to*buoyancy(SST , sensible*heat_flux ; rho = 1) Convert surface energy fluxes in units of W/m^2 to units of buoyancy m^2/s^3).

`AvailablePotentialEnergyFramework.timemean_nofalseframe`

— Method`timemean_nofalseframe(input)`

Takes a 3-d or 3-d array and computes the average along the third or fourth dimension, skipping the slices input[:,:,:,i] for which the maxiumum value is 0.0

`AvailablePotentialEnergyFramework.velocity_topolar`

— Method`velocity_topolar(u,v,index,center)`

Take a velocity vector, an origin of said vector and a center and return the tangential and azimuthal velocities with respect to that center.